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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #if USE(ACCELERATED_COMPOSITING) | 7 #if USE(ACCELERATED_COMPOSITING) |
8 | 8 |
9 #include "ScrollbarLayerChromium.h" | 9 #include "ScrollbarLayerChromium.h" |
10 | 10 |
| 11 #include "base/basictypes.h" |
11 #include "BitmapCanvasLayerTextureUpdater.h" | 12 #include "BitmapCanvasLayerTextureUpdater.h" |
12 #include "CCLayerTreeHost.h" | 13 #include "CCLayerTreeHost.h" |
13 #include "CCScrollbarLayerImpl.h" | 14 #include "CCScrollbarLayerImpl.h" |
14 #include "CCTextureUpdateQueue.h" | 15 #include "CCTextureUpdateQueue.h" |
15 #include "LayerPainterChromium.h" | 16 #include "LayerPainterChromium.h" |
16 #include <public/WebRect.h> | 17 #include <public/WebRect.h> |
17 | 18 |
18 using WebKit::WebRect; | 19 using WebKit::WebRect; |
19 | 20 |
20 namespace cc { | 21 namespace cc { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 else | 69 else |
69 scrollbarLayer->setThumbResourceId(0); | 70 scrollbarLayer->setThumbResourceId(0); |
70 } | 71 } |
71 | 72 |
72 ScrollbarLayerChromium* ScrollbarLayerChromium::toScrollbarLayerChromium() | 73 ScrollbarLayerChromium* ScrollbarLayerChromium::toScrollbarLayerChromium() |
73 { | 74 { |
74 return this; | 75 return this; |
75 } | 76 } |
76 | 77 |
77 class ScrollbarBackgroundPainter : public LayerPainterChromium { | 78 class ScrollbarBackgroundPainter : public LayerPainterChromium { |
78 WTF_MAKE_NONCOPYABLE(ScrollbarBackgroundPainter); | |
79 public: | 79 public: |
80 static PassOwnPtr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s
crollbar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeo
metry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart) | 80 static PassOwnPtr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s
crollbar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeo
metry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart) |
81 { | 81 { |
82 return adoptPtr(new ScrollbarBackgroundPainter(scrollbar, painter, geome
try, trackPart)); | 82 return adoptPtr(new ScrollbarBackgroundPainter(scrollbar, painter, geome
try, trackPart)); |
83 } | 83 } |
84 | 84 |
85 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
&) OVERRIDE | 85 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
&) OVERRIDE |
86 { | 86 { |
87 WebKit::WebCanvas* canvas = skCanvas; | 87 WebKit::WebCanvas* canvas = skCanvas; |
88 // The following is a simplification of ScrollbarThemeComposite::paint. | 88 // The following is a simplification of ScrollbarThemeComposite::paint. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 , m_painter(painter) | 122 , m_painter(painter) |
123 , m_geometry(geometry) | 123 , m_geometry(geometry) |
124 , m_trackPart(trackPart) | 124 , m_trackPart(trackPart) |
125 { | 125 { |
126 } | 126 } |
127 | 127 |
128 WebKit::WebScrollbar* m_scrollbar; | 128 WebKit::WebScrollbar* m_scrollbar; |
129 WebKit::WebScrollbarThemePainter m_painter; | 129 WebKit::WebScrollbarThemePainter m_painter; |
130 WebKit::WebScrollbarThemeGeometry* m_geometry; | 130 WebKit::WebScrollbarThemeGeometry* m_geometry; |
131 WebKit::WebScrollbar::ScrollbarPart m_trackPart; | 131 WebKit::WebScrollbar::ScrollbarPart m_trackPart; |
| 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(ScrollbarBackgroundPainter); |
132 }; | 134 }; |
133 | 135 |
134 bool ScrollbarLayerChromium::needsContentsScale() const | 136 bool ScrollbarLayerChromium::needsContentsScale() const |
135 { | 137 { |
136 return true; | 138 return true; |
137 } | 139 } |
138 | 140 |
139 IntSize ScrollbarLayerChromium::contentBounds() const | 141 IntSize ScrollbarLayerChromium::contentBounds() const |
140 { | 142 { |
141 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds()
.height() * contentsScale())); | 143 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds()
.height() * contentsScale())); |
142 } | 144 } |
143 | 145 |
144 class ScrollbarThumbPainter : public LayerPainterChromium { | 146 class ScrollbarThumbPainter : public LayerPainterChromium { |
145 WTF_MAKE_NONCOPYABLE(ScrollbarThumbPainter); | |
146 public: | 147 public: |
147 static PassOwnPtr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll
bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry
* geometry) | 148 static PassOwnPtr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll
bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry
* geometry) |
148 { | 149 { |
149 return adoptPtr(new ScrollbarThumbPainter(scrollbar, painter, geometry))
; | 150 return adoptPtr(new ScrollbarThumbPainter(scrollbar, painter, geometry))
; |
150 } | 151 } |
151 | 152 |
152 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
& opaque) OVERRIDE | 153 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
& opaque) OVERRIDE |
153 { | 154 { |
154 WebKit::WebCanvas* canvas = skCanvas; | 155 WebKit::WebCanvas* canvas = skCanvas; |
155 | 156 |
156 // Consider the thumb to be at the origin when painting. | 157 // Consider the thumb to be at the origin when painting. |
157 WebRect thumbRect = m_geometry->thumbRect(m_scrollbar); | 158 WebRect thumbRect = m_geometry->thumbRect(m_scrollbar); |
158 thumbRect.x = 0; | 159 thumbRect.x = 0; |
159 thumbRect.y = 0; | 160 thumbRect.y = 0; |
160 m_painter.paintThumb(canvas, thumbRect); | 161 m_painter.paintThumb(canvas, thumbRect); |
161 } | 162 } |
162 | 163 |
163 private: | 164 private: |
164 ScrollbarThumbPainter(WebKit::WebScrollbar* scrollbar, WebKit::WebScrollbarT
hemePainter painter, WebKit::WebScrollbarThemeGeometry* geometry) | 165 ScrollbarThumbPainter(WebKit::WebScrollbar* scrollbar, WebKit::WebScrollbarT
hemePainter painter, WebKit::WebScrollbarThemeGeometry* geometry) |
165 : m_scrollbar(scrollbar) | 166 : m_scrollbar(scrollbar) |
166 , m_painter(painter) | 167 , m_painter(painter) |
167 , m_geometry(geometry) | 168 , m_geometry(geometry) |
168 { | 169 { |
169 } | 170 } |
170 | 171 |
171 WebKit::WebScrollbar* m_scrollbar; | 172 WebKit::WebScrollbar* m_scrollbar; |
172 WebKit::WebScrollbarThemePainter m_painter; | 173 WebKit::WebScrollbarThemePainter m_painter; |
173 WebKit::WebScrollbarThemeGeometry* m_geometry; | 174 WebKit::WebScrollbarThemeGeometry* m_geometry; |
| 175 |
| 176 DISALLOW_COPY_AND_ASSIGN(ScrollbarThumbPainter); |
174 }; | 177 }; |
175 | 178 |
176 void ScrollbarLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) | 179 void ScrollbarLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) |
177 { | 180 { |
178 if (!host || host != layerTreeHost()) { | 181 if (!host || host != layerTreeHost()) { |
179 m_backTrackUpdater.clear(); | 182 m_backTrackUpdater.clear(); |
180 m_backTrack.clear(); | 183 m_backTrack.clear(); |
181 m_thumbUpdater.clear(); | 184 m_thumbUpdater.clear(); |
182 m_thumb.clear(); | 185 m_thumb.clear(); |
183 } | 186 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 276 |
274 // Consider the thumb to be at the origin when painting. | 277 // Consider the thumb to be at the origin when painting. |
275 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 278 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
276 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb
Rect.width, thumbRect.height)); | 279 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb
Rect.width, thumbRect.height)); |
277 if (!originThumbRect.isEmpty()) | 280 if (!originThumbRect.isEmpty()) |
278 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); | 281 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); |
279 } | 282 } |
280 | 283 |
281 } | 284 } |
282 #endif // USE(ACCELERATED_COMPOSITING) | 285 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |