Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1378)

Side by Side Diff: cc/scrollbar_layer.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "cc/scrollbar_layer.h" 7 #include "cc/scrollbar_layer.h"
8 8
9 #include "CCLayerTreeHost.h" 9 #include "CCLayerTreeHost.h"
10 #include "CCScrollbarLayerImpl.h" 10 #include "CCScrollbarLayerImpl.h"
11 #include "CCTextureUpdateQueue.h" 11 #include "CCTextureUpdateQueue.h"
12 #include "TraceEvent.h" 12 #include "TraceEvent.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "cc/layer_painter.h" 14 #include "cc/layer_painter.h"
15 #include <public/WebRect.h> 15 #include <public/WebRect.h>
16 16
17 using WebKit::WebRect; 17 using WebKit::WebRect;
18 18
19 namespace cc { 19 namespace cc {
20 20
21 scoped_ptr<CCLayerImpl> ScrollbarLayerChromium::createCCLayerImpl() 21 scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl()
22 { 22 {
23 return CCScrollbarLayerImpl::create(id()).PassAs<CCLayerImpl>(); 23 return ScrollbarLayerImpl::create(id()).PassAs<LayerImpl>();
24 } 24 }
25 25
26 scoped_refptr<ScrollbarLayerChromium> ScrollbarLayerChromium::create(scoped_ptr< WebKit::WebScrollbar> scrollbar, WebKit::WebScrollbarThemePainter painter, scope d_ptr<WebKit::WebScrollbarThemeGeometry> geometry, int scrollLayerId) 26 scoped_refptr<ScrollbarLayer> ScrollbarLayer::create(scoped_ptr<WebKit::WebScrol lbar> scrollbar, WebKit::WebScrollbarThemePainter painter, scoped_ptr<WebKit::We bScrollbarThemeGeometry> geometry, int scrollLayerId)
27 { 27 {
28 return make_scoped_refptr(new ScrollbarLayerChromium(scrollbar.Pass(), paint er, geometry.Pass(), scrollLayerId)); 28 return make_scoped_refptr(new ScrollbarLayer(scrollbar.Pass(), painter, geom etry.Pass(), scrollLayerId));
29 } 29 }
30 30
31 ScrollbarLayerChromium::ScrollbarLayerChromium(scoped_ptr<WebKit::WebScrollbar> scrollbar, WebKit::WebScrollbarThemePainter painter, scoped_ptr<WebKit::WebScrol lbarThemeGeometry> geometry, int scrollLayerId) 31 ScrollbarLayer::ScrollbarLayer(scoped_ptr<WebKit::WebScrollbar> scrollbar, WebKi t::WebScrollbarThemePainter painter, scoped_ptr<WebKit::WebScrollbarThemeGeometr y> geometry, int scrollLayerId)
32 : m_scrollbar(scrollbar.Pass()) 32 : m_scrollbar(scrollbar.Pass())
33 , m_painter(painter) 33 , m_painter(painter)
34 , m_geometry(geometry.Pass()) 34 , m_geometry(geometry.Pass())
35 , m_scrollLayerId(scrollLayerId) 35 , m_scrollLayerId(scrollLayerId)
36 , m_textureFormat(GraphicsContext3D::INVALID_ENUM) 36 , m_textureFormat(GraphicsContext3D::INVALID_ENUM)
37 { 37 {
38 } 38 }
39 39
40 ScrollbarLayerChromium::~ScrollbarLayerChromium() 40 ScrollbarLayer::~ScrollbarLayer()
41 { 41 {
42 } 42 }
43 43
44 void ScrollbarLayerChromium::pushPropertiesTo(CCLayerImpl* layer) 44 void ScrollbarLayer::pushPropertiesTo(LayerImpl* layer)
45 { 45 {
46 LayerChromium::pushPropertiesTo(layer); 46 Layer::pushPropertiesTo(layer);
47 47
48 CCScrollbarLayerImpl* scrollbarLayer = static_cast<CCScrollbarLayerImpl*>(la yer); 48 ScrollbarLayerImpl* scrollbarLayer = static_cast<ScrollbarLayerImpl*>(layer) ;
49 49
50 if (!scrollbarLayer->scrollbarGeometry()) 50 if (!scrollbarLayer->scrollbarGeometry())
51 scrollbarLayer->setScrollbarGeometry(CCScrollbarGeometryFixedThumb::crea te(make_scoped_ptr(m_geometry->clone()))); 51 scrollbarLayer->setScrollbarGeometry(ScrollbarGeometryFixedThumb::create (make_scoped_ptr(m_geometry->clone())));
52 52
53 scrollbarLayer->setScrollbarData(m_scrollbar.get()); 53 scrollbarLayer->setScrollbarData(m_scrollbar.get());
54 54
55 if (m_backTrack && m_backTrack->texture()->haveBackingTexture()) 55 if (m_backTrack && m_backTrack->texture()->haveBackingTexture())
56 scrollbarLayer->setBackTrackResourceId(m_backTrack->texture()->resourceI d()); 56 scrollbarLayer->setBackTrackResourceId(m_backTrack->texture()->resourceI d());
57 else 57 else
58 scrollbarLayer->setBackTrackResourceId(0); 58 scrollbarLayer->setBackTrackResourceId(0);
59 59
60 if (m_foreTrack && m_foreTrack->texture()->haveBackingTexture()) 60 if (m_foreTrack && m_foreTrack->texture()->haveBackingTexture())
61 scrollbarLayer->setForeTrackResourceId(m_foreTrack->texture()->resourceI d()); 61 scrollbarLayer->setForeTrackResourceId(m_foreTrack->texture()->resourceI d());
62 else 62 else
63 scrollbarLayer->setForeTrackResourceId(0); 63 scrollbarLayer->setForeTrackResourceId(0);
64 64
65 if (m_thumb && m_thumb->texture()->haveBackingTexture()) 65 if (m_thumb && m_thumb->texture()->haveBackingTexture())
66 scrollbarLayer->setThumbResourceId(m_thumb->texture()->resourceId()); 66 scrollbarLayer->setThumbResourceId(m_thumb->texture()->resourceId());
67 else 67 else
68 scrollbarLayer->setThumbResourceId(0); 68 scrollbarLayer->setThumbResourceId(0);
69 } 69 }
70 70
71 ScrollbarLayerChromium* ScrollbarLayerChromium::toScrollbarLayerChromium() 71 ScrollbarLayer* ScrollbarLayer::toScrollbarLayer()
72 { 72 {
73 return this; 73 return this;
74 } 74 }
75 75
76 class ScrollbarBackgroundPainter : public LayerPainterChromium { 76 class ScrollbarBackgroundPainter : public LayerPainter {
77 public: 77 public:
78 static scoped_ptr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s crollbar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeo metry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart) 78 static scoped_ptr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s crollbar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeo metry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart)
79 { 79 {
80 return make_scoped_ptr(new ScrollbarBackgroundPainter(scrollbar, painter , geometry, trackPart)); 80 return make_scoped_ptr(new ScrollbarBackgroundPainter(scrollbar, painter , geometry, trackPart));
81 } 81 }
82 82
83 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect &) OVERRIDE 83 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect &) OVERRIDE
84 { 84 {
85 WebKit::WebCanvas* canvas = skCanvas; 85 WebKit::WebCanvas* canvas = skCanvas;
86 // The following is a simplification of ScrollbarThemeComposite::paint. 86 // The following is a simplification of ScrollbarThemeComposite::paint.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 WebKit::WebScrollbar* m_scrollbar; 126 WebKit::WebScrollbar* m_scrollbar;
127 WebKit::WebScrollbarThemePainter m_painter; 127 WebKit::WebScrollbarThemePainter m_painter;
128 WebKit::WebScrollbarThemeGeometry* m_geometry; 128 WebKit::WebScrollbarThemeGeometry* m_geometry;
129 WebKit::WebScrollbar::ScrollbarPart m_trackPart; 129 WebKit::WebScrollbar::ScrollbarPart m_trackPart;
130 130
131 DISALLOW_COPY_AND_ASSIGN(ScrollbarBackgroundPainter); 131 DISALLOW_COPY_AND_ASSIGN(ScrollbarBackgroundPainter);
132 }; 132 };
133 133
134 bool ScrollbarLayerChromium::needsContentsScale() const 134 bool ScrollbarLayer::needsContentsScale() const
135 { 135 {
136 return true; 136 return true;
137 } 137 }
138 138
139 IntSize ScrollbarLayerChromium::contentBounds() const 139 IntSize ScrollbarLayer::contentBounds() const
140 { 140 {
141 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds() .height() * contentsScale())); 141 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds() .height() * contentsScale()));
142 } 142 }
143 143
144 class ScrollbarThumbPainter : public LayerPainterChromium { 144 class ScrollbarThumbPainter : public LayerPainter {
145 public: 145 public:
146 static scoped_ptr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry * geometry) 146 static scoped_ptr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry * geometry)
147 { 147 {
148 return make_scoped_ptr(new ScrollbarThumbPainter(scrollbar, painter, geo metry)); 148 return make_scoped_ptr(new ScrollbarThumbPainter(scrollbar, painter, geo metry));
149 } 149 }
150 150
151 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect & opaque) OVERRIDE 151 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect & opaque) OVERRIDE
152 { 152 {
153 WebKit::WebCanvas* canvas = skCanvas; 153 WebKit::WebCanvas* canvas = skCanvas;
154 154
(...skipping 12 matching lines...) Expand all
167 { 167 {
168 } 168 }
169 169
170 WebKit::WebScrollbar* m_scrollbar; 170 WebKit::WebScrollbar* m_scrollbar;
171 WebKit::WebScrollbarThemePainter m_painter; 171 WebKit::WebScrollbarThemePainter m_painter;
172 WebKit::WebScrollbarThemeGeometry* m_geometry; 172 WebKit::WebScrollbarThemeGeometry* m_geometry;
173 173
174 DISALLOW_COPY_AND_ASSIGN(ScrollbarThumbPainter); 174 DISALLOW_COPY_AND_ASSIGN(ScrollbarThumbPainter);
175 }; 175 };
176 176
177 void ScrollbarLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) 177 void ScrollbarLayer::setLayerTreeHost(LayerTreeHost* host)
178 { 178 {
179 if (!host || host != layerTreeHost()) { 179 if (!host || host != layerTreeHost()) {
180 m_backTrackUpdater = NULL; 180 m_backTrackUpdater = NULL;
181 m_backTrack.reset(); 181 m_backTrack.reset();
182 m_thumbUpdater = NULL; 182 m_thumbUpdater = NULL;
183 m_thumb.reset(); 183 m_thumb.reset();
184 } 184 }
185 185
186 LayerChromium::setLayerTreeHost(host); 186 Layer::setLayerTreeHost(host);
187 } 187 }
188 188
189 void ScrollbarLayerChromium::createTextureUpdaterIfNeeded() 189 void ScrollbarLayer::createTextureUpdaterIfNeeded()
190 { 190 {
191 m_textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat; 191 m_textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat;
192 192
193 if (!m_backTrackUpdater) 193 if (!m_backTrackUpdater)
194 m_backTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(Scro llbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), W ebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainterChromium>()); 194 m_backTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(Scro llbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), W ebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>());
195 if (!m_backTrack) 195 if (!m_backTrack)
196 m_backTrack = m_backTrackUpdater->createTexture(layerTreeHost()->content sTextureManager()); 196 m_backTrack = m_backTrackUpdater->createTexture(layerTreeHost()->content sTextureManager());
197 197
198 // Only create two-part track if we think the two parts could be different i n appearance. 198 // Only create two-part track if we think the two parts could be different i n appearance.
199 if (m_scrollbar->isCustomScrollbar()) { 199 if (m_scrollbar->isCustomScrollbar()) {
200 if (!m_foreTrackUpdater) 200 if (!m_foreTrackUpdater)
201 m_foreTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create( ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get( ), WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainterChromium>()); 201 m_foreTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create( ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get( ), WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>());
202 if (!m_foreTrack) 202 if (!m_foreTrack)
203 m_foreTrack = m_foreTrackUpdater->createTexture(layerTreeHost()->con tentsTextureManager()); 203 m_foreTrack = m_foreTrackUpdater->createTexture(layerTreeHost()->con tentsTextureManager());
204 } 204 }
205 205
206 if (!m_thumbUpdater) 206 if (!m_thumbUpdater)
207 m_thumbUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(Scrollba rThumbPainter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs<Lay erPainterChromium>()); 207 m_thumbUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(Scrollba rThumbPainter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs<Lay erPainter>());
208 if (!m_thumb) 208 if (!m_thumb)
209 m_thumb = m_thumbUpdater->createTexture(layerTreeHost()->contentsTexture Manager()); 209 m_thumb = m_thumbUpdater->createTexture(layerTreeHost()->contentsTexture Manager());
210 } 210 }
211 211
212 void ScrollbarLayerChromium::updatePart(CachingBitmapCanvasLayerTextureUpdater* painter, LayerTextureUpdater::Texture* texture, const IntRect& rect, CCTextureUp dateQueue& queue, CCRenderingStats& stats) 212 void ScrollbarLayer::updatePart(CachingBitmapCanvasLayerTextureUpdater* painter, LayerTextureUpdater::Texture* texture, const IntRect& rect, TextureUpdateQueue& queue, RenderingStats& stats)
213 { 213 {
214 // Skip painting and uploading if there are no invalidations and 214 // Skip painting and uploading if there are no invalidations and
215 // we already have valid texture data. 215 // we already have valid texture data.
216 if (texture->texture()->haveBackingTexture() 216 if (texture->texture()->haveBackingTexture()
217 && texture->texture()->size() == rect.size() 217 && texture->texture()->size() == rect.size()
218 && m_updateRect.isEmpty()) 218 && m_updateRect.isEmpty())
219 return; 219 return;
220 220
221 // We should always have enough memory for UI. 221 // We should always have enough memory for UI.
222 ASSERT(texture->texture()->canAcquireBackingTexture()); 222 ASSERT(texture->texture()->canAcquireBackingTexture());
223 if (!texture->texture()->canAcquireBackingTexture()) 223 if (!texture->texture()->canAcquireBackingTexture())
224 return; 224 return;
225 225
226 // Paint and upload the entire part. 226 // Paint and upload the entire part.
227 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth(); 227 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth();
228 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height(); 228 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height();
229 IntRect paintedOpaqueRect; 229 IntRect paintedOpaqueRect;
230 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted OpaqueRect, stats); 230 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted OpaqueRect, stats);
231 if (!painter->pixelsDidChange() && texture->texture()->haveBackingTexture()) { 231 if (!painter->pixelsDidChange() && texture->texture()->haveBackingTexture()) {
232 TRACE_EVENT_INSTANT0("cc","ScrollbarLayerChromium::updatePart no texture upload needed"); 232 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload needed");
233 return; 233 return;
234 } 234 }
235 235
236 IntSize destOffset(0, 0); 236 IntSize destOffset(0, 0);
237 texture->update(queue, rect, destOffset, false, stats); 237 texture->update(queue, rect, destOffset, false, stats);
238 } 238 }
239 239
240 240
241 void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&) 241 void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&)
242 { 242 {
243 if (contentBounds().isEmpty()) 243 if (contentBounds().isEmpty())
244 return; 244 return;
245 245
246 createTextureUpdaterIfNeeded(); 246 createTextureUpdaterIfNeeded();
247 247
248 bool drawsToRoot = !renderTarget()->parent(); 248 bool drawsToRoot = !renderTarget()->parent();
249 if (m_backTrack) { 249 if (m_backTrack) {
250 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat); 250 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
251 m_backTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior ity(drawsToRoot)); 251 m_backTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit y(drawsToRoot));
252 } 252 }
253 if (m_foreTrack) { 253 if (m_foreTrack) {
254 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat); 254 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
255 m_foreTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior ity(drawsToRoot)); 255 m_foreTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit y(drawsToRoot));
256 } 256 }
257 if (m_thumb) { 257 if (m_thumb) {
258 IntSize thumbSize = layerRectToContentRect(m_geometry->thumbRect(m_scrol lbar.get())).size(); 258 IntSize thumbSize = layerRectToContentRect(m_geometry->thumbRect(m_scrol lbar.get())).size();
259 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); 259 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat);
260 m_thumb->texture()->setRequestPriority(CCPriorityCalculator::uiPriority( drawsToRoot)); 260 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr awsToRoot));
261 } 261 }
262 } 262 }
263 263
264 void ScrollbarLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusi onTracker*, CCRenderingStats& stats) 264 void ScrollbarLayer::update(TextureUpdateQueue& queue, const OcclusionTracker*, RenderingStats& stats)
265 { 265 {
266 if (contentBounds().isEmpty()) 266 if (contentBounds().isEmpty())
267 return; 267 return;
268 268
269 createTextureUpdaterIfNeeded(); 269 createTextureUpdaterIfNeeded();
270 270
271 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location(). y); 271 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location(). y);
272 IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin .x(), scrollbarOrigin.y(), bounds().width(), bounds().height())); 272 IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin .x(), scrollbarOrigin.y(), bounds().width(), bounds().height()));
273 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats); 273 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats);
274 if (m_foreTrack && m_foreTrackUpdater) 274 if (m_foreTrack && m_foreTrackUpdater)
275 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats); 275 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats);
276 276
277 // Consider the thumb to be at the origin when painting. 277 // Consider the thumb to be at the origin when painting.
278 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); 278 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get());
279 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));
280 if (!originThumbRect.isEmpty()) 280 if (!originThumbRect.isEmpty())
281 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats); 281 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats);
282 } 282 }
283 283
284 } 284 }
OLDNEW
« cc/active_animation.h ('K') | « cc/scrollbar_layer.h ('k') | cc/scrollbar_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698