OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/scrollbar_layer.h" | 5 #include "cc/scrollbar_layer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/caching_bitmap_content_layer_updater.h" | 9 #include "cc/caching_bitmap_content_layer_updater.h" |
10 #include "cc/layer_painter.h" | 10 #include "cc/layer_painter.h" |
11 #include "cc/layer_tree_host.h" | 11 #include "cc/layer_tree_host.h" |
12 #include "cc/prioritized_resource.h" | 12 #include "cc/prioritized_resource.h" |
13 #include "cc/resource_update_queue.h" | 13 #include "cc/resource_update_queue.h" |
14 #include "cc/scrollbar_layer_impl.h" | 14 #include "cc/scrollbar_layer_impl.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
16 #include "ui/gfx/rect_conversions.h" | 16 #include "ui/gfx/rect_conversions.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
| 20 scoped_ptr<WebKit::WebScrollbarThemeGeometry> ScrollbarLayer::s_defaultGeometry; |
| 21 bool ScrollbarLayer::s_usesOverlayScrollbars = false; |
| 22 |
20 scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl(LayerTreeImpl* treeImpl) | 23 scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl(LayerTreeImpl* treeImpl) |
21 { | 24 { |
22 return ScrollbarLayerImpl::create(treeImpl, id(), ScrollbarGeometryFixedThum
b::create(make_scoped_ptr(m_geometry->clone()))).PassAs<LayerImpl>(); | 25 return ScrollbarLayerImpl::create(treeImpl, id(), ScrollbarGeometryFixedThum
b::create(make_scoped_ptr(m_geometry->clone()))).PassAs<LayerImpl>(); |
23 } | 26 } |
24 | 27 |
25 scoped_refptr<ScrollbarLayer> ScrollbarLayer::create( | 28 scoped_refptr<ScrollbarLayer> ScrollbarLayer::create( |
26 scoped_ptr<WebKit::WebScrollbar> scrollbar, | 29 scoped_ptr<WebKit::WebScrollbar> scrollbar, |
27 scoped_ptr<ScrollbarThemePainter> painter, | 30 scoped_ptr<ScrollbarThemePainter> painter, |
28 scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry, | 31 scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry, |
| 32 int scrollLayerId, bool isPinchZoomScrollbar) |
| 33 { |
| 34 return make_scoped_refptr(new ScrollbarLayer(scrollbar.Pass(), painter.Pass(
), geometry.Pass(), scrollLayerId, isPinchZoomScrollbar)); |
| 35 } |
| 36 |
| 37 scoped_refptr<ScrollbarLayer> ScrollbarLayer::create( |
| 38 scoped_ptr<WebKit::WebScrollbar> scrollbar, |
| 39 scoped_ptr<ScrollbarThemePainter> painter, |
29 int scrollLayerId) | 40 int scrollLayerId) |
30 { | 41 { |
31 return make_scoped_refptr(new ScrollbarLayer(scrollbar.Pass(), painter.Pass(
), geometry.Pass(), scrollLayerId)); | 42 if (!s_defaultGeometry) |
| 43 return make_scoped_refptr(static_cast<ScrollbarLayer*>(0)); |
| 44 return create(scrollbar.Pass(), painter.Pass(), |
| 45 make_scoped_ptr(s_defaultGeometry->clone()).Pass(), |
| 46 scrollLayerId, true); |
| 47 } |
| 48 |
| 49 void ScrollbarLayer::setDefaultGeometry( |
| 50 WebKit::WebScrollbarThemeGeometry* themeGeometry) |
| 51 { |
| 52 // We assume themeGeometry is ours to own. |
| 53 if (themeGeometry) |
| 54 s_defaultGeometry = make_scoped_ptr(themeGeometry); |
| 55 } |
| 56 |
| 57 WebKit::WebScrollbarThemeGeometry* ScrollbarLayer::cloneDefaultGeometry() |
| 58 { |
| 59 if (s_defaultGeometry) |
| 60 return s_defaultGeometry->clone(); |
| 61 return 0; |
| 62 } |
| 63 |
| 64 void ScrollbarLayer::setDefaultUsesOverlayScrollbars(bool usesOverlayScrollbars) |
| 65 { |
| 66 s_usesOverlayScrollbars = usesOverlayScrollbars; |
32 } | 67 } |
33 | 68 |
34 ScrollbarLayer::ScrollbarLayer( | 69 ScrollbarLayer::ScrollbarLayer( |
35 scoped_ptr<WebKit::WebScrollbar> scrollbar, | 70 scoped_ptr<WebKit::WebScrollbar> scrollbar, |
36 scoped_ptr<ScrollbarThemePainter> painter, | 71 scoped_ptr<ScrollbarThemePainter> painter, |
37 scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry, | 72 scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry, |
38 int scrollLayerId) | 73 int scrollLayerId, bool isPinchZoomScrollbar) |
39 : m_scrollbar(scrollbar.Pass()) | 74 : m_scrollbar(scrollbar.Pass()) |
40 , m_painter(painter.Pass()) | 75 , m_painter(painter.Pass()) |
41 , m_geometry(geometry.Pass()) | 76 , m_geometry(geometry.Pass()) |
42 , m_scrollLayerId(scrollLayerId) | 77 , m_scrollLayerId(scrollLayerId) |
43 , m_textureFormat(GL_INVALID_ENUM) | 78 , m_textureFormat(GL_INVALID_ENUM) |
| 79 , m_isPinchZoomScrollbar(isPinchZoomScrollbar) |
44 { | 80 { |
45 if (!m_scrollbar->isOverlay()) | 81 if (!m_scrollbar->isOverlay()) |
46 setShouldScrollOnMainThread(true); | 82 setShouldScrollOnMainThread(true); |
47 } | 83 } |
48 | 84 |
49 ScrollbarLayer::~ScrollbarLayer() | 85 ScrollbarLayer::~ScrollbarLayer() |
50 { | 86 { |
51 } | 87 } |
52 | 88 |
53 void ScrollbarLayer::setScrollLayerId(int id) | 89 void ScrollbarLayer::setScrollLayerId(int id) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 152 |
117 if (m_foreTrack && m_foreTrack->texture()->haveBackingTexture()) | 153 if (m_foreTrack && m_foreTrack->texture()->haveBackingTexture()) |
118 scrollbarLayer->setForeTrackResourceId(m_foreTrack->texture()->resourceI
d()); | 154 scrollbarLayer->setForeTrackResourceId(m_foreTrack->texture()->resourceI
d()); |
119 else | 155 else |
120 scrollbarLayer->setForeTrackResourceId(0); | 156 scrollbarLayer->setForeTrackResourceId(0); |
121 | 157 |
122 if (m_thumb && m_thumb->texture()->haveBackingTexture()) | 158 if (m_thumb && m_thumb->texture()->haveBackingTexture()) |
123 scrollbarLayer->setThumbResourceId(m_thumb->texture()->resourceId()); | 159 scrollbarLayer->setThumbResourceId(m_thumb->texture()->resourceId()); |
124 else | 160 else |
125 scrollbarLayer->setThumbResourceId(0); | 161 scrollbarLayer->setThumbResourceId(0); |
| 162 |
| 163 scrollbarLayer->setIsPinchZoomScrollbar(m_isPinchZoomScrollbar); |
126 } | 164 } |
127 | 165 |
128 ScrollbarLayer* ScrollbarLayer::toScrollbarLayer() | 166 ScrollbarLayer* ScrollbarLayer::toScrollbarLayer() |
129 { | 167 { |
130 return this; | 168 return this; |
131 } | 169 } |
132 | 170 |
133 class ScrollbarBackgroundPainter : public LayerPainter { | 171 class ScrollbarBackgroundPainter : public LayerPainter { |
134 public: | 172 public: |
135 static scoped_ptr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s
crollbar, ScrollbarThemePainter *painter, WebKit::WebScrollbarThemeGeometry* geo
metry, WebKit::WebScrollbar::ScrollbarPart trackPart) | 173 static scoped_ptr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s
crollbar, ScrollbarThemePainter *painter, WebKit::WebScrollbarThemeGeometry* geo
metry, WebKit::WebScrollbar::ScrollbarPart trackPart) |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 gfx::Rect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 372 gfx::Rect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
335 m_thumbSize = thumbRect.size(); | 373 m_thumbSize = thumbRect.size(); |
336 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(thumbR
ect.size())); | 374 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(thumbR
ect.size())); |
337 if (!originThumbRect.IsEmpty()) | 375 if (!originThumbRect.IsEmpty()) |
338 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); | 376 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); |
339 | 377 |
340 m_dirtyRect = gfx::RectF(); | 378 m_dirtyRect = gfx::RectF(); |
341 } | 379 } |
342 | 380 |
343 } // namespace cc | 381 } // namespace cc |
OLD | NEW |