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 "base/basictypes.h" |
12 #include "BitmapCanvasLayerTextureUpdater.h" | |
13 #include "CCLayerTreeHost.h" | 12 #include "CCLayerTreeHost.h" |
14 #include "CCScrollbarLayerImpl.h" | 13 #include "CCScrollbarLayerImpl.h" |
15 #include "CCTextureUpdateQueue.h" | 14 #include "CCTextureUpdateQueue.h" |
16 #include "LayerPainterChromium.h" | 15 #include "LayerPainterChromium.h" |
17 #include <public/WebRect.h> | 16 #include <public/WebRect.h> |
18 | 17 |
19 using WebKit::WebRect; | 18 using WebKit::WebRect; |
20 | 19 |
21 namespace cc { | 20 namespace cc { |
22 | 21 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 } | 185 } |
187 | 186 |
188 LayerChromium::setLayerTreeHost(host); | 187 LayerChromium::setLayerTreeHost(host); |
189 } | 188 } |
190 | 189 |
191 void ScrollbarLayerChromium::createTextureUpdaterIfNeeded() | 190 void ScrollbarLayerChromium::createTextureUpdaterIfNeeded() |
192 { | 191 { |
193 m_textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat; | 192 m_textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat; |
194 | 193 |
195 if (!m_backTrackUpdater) | 194 if (!m_backTrackUpdater) |
196 m_backTrackUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarBa ckgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), WebKit:: WebScrollbar::BackTrackPart)); | 195 m_backTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(Scro llbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), W ebKit::WebScrollbar::BackTrackPart)); |
197 if (!m_backTrack) | 196 if (!m_backTrack) |
198 m_backTrack = m_backTrackUpdater->createTexture(layerTreeHost()->content sTextureManager()); | 197 m_backTrack = m_backTrackUpdater->createTexture(layerTreeHost()->content sTextureManager()); |
199 | 198 |
200 // Only create two-part track if we think the two parts could be different i n appearance. | 199 // Only create two-part track if we think the two parts could be different i n appearance. |
201 if (m_scrollbar->isCustomScrollbar()) { | 200 if (m_scrollbar->isCustomScrollbar()) { |
202 if (!m_foreTrackUpdater) | 201 if (!m_foreTrackUpdater) |
203 m_foreTrackUpdater = BitmapCanvasLayerTextureUpdater::create(Scrollb arBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), WebK it::WebScrollbar::ForwardTrackPart)); | 202 m_foreTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create( ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get( ), WebKit::WebScrollbar::ForwardTrackPart)); |
204 if (!m_foreTrack) | 203 if (!m_foreTrack) |
205 m_foreTrack = m_foreTrackUpdater->createTexture(layerTreeHost()->con tentsTextureManager()); | 204 m_foreTrack = m_foreTrackUpdater->createTexture(layerTreeHost()->con tentsTextureManager()); |
206 } | 205 } |
207 | 206 |
208 if (!m_thumbUpdater) | 207 if (!m_thumbUpdater) |
209 m_thumbUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarThumbP ainter::create(m_scrollbar.get(), m_painter, m_geometry.get())); | 208 m_thumbUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(Scrollba rThumbPainter::create(m_scrollbar.get(), m_painter, m_geometry.get())); |
210 if (!m_thumb) | 209 if (!m_thumb) |
211 m_thumb = m_thumbUpdater->createTexture(layerTreeHost()->contentsTexture Manager()); | 210 m_thumb = m_thumbUpdater->createTexture(layerTreeHost()->contentsTexture Manager()); |
212 } | 211 } |
213 | 212 |
214 void ScrollbarLayerChromium::updatePart(LayerTextureUpdater* painter, LayerTextu reUpdater::Texture* texture, const IntRect& rect, CCTextureUpdateQueue& queue, C CRenderingStats& stats) | 213 void ScrollbarLayerChromium::updatePart(CachingBitmapCanvasLayerTextureUpdater* painter, LayerTextureUpdater::Texture* texture, const IntRect& rect, CCTextureUp dateQueue& queue, CCRenderingStats& stats) |
215 { | 214 { |
216 // Skip painting and uploading if there are no invalidations and | 215 // Skip painting and uploading if there are no invalidations and |
217 // we already have valid texture data. | 216 // we already have valid texture data. |
218 if (texture->texture()->haveBackingTexture() | 217 if (texture->texture()->haveBackingTexture() |
219 && texture->texture()->size() == rect.size() | 218 && texture->texture()->size() == rect.size() |
220 && m_updateRect.isEmpty()) | 219 && m_updateRect.isEmpty()) |
221 return; | 220 return; |
222 | 221 |
223 // We should always have enough memory for UI. | 222 // We should always have enough memory for UI. |
224 ASSERT(texture->texture()->canAcquireBackingTexture()); | 223 ASSERT(texture->texture()->canAcquireBackingTexture()); |
225 if (!texture->texture()->canAcquireBackingTexture()) | 224 if (!texture->texture()->canAcquireBackingTexture()) |
226 return; | 225 return; |
227 | 226 |
228 // Paint and upload the entire part. | 227 // Paint and upload the entire part. |
229 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth(); | 228 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth(); |
230 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height(); | 229 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height(); |
231 IntRect paintedOpaqueRect; | 230 IntRect paintedOpaqueRect; |
232 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted OpaqueRect, stats); | 231 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted OpaqueRect, stats); |
232 if (!painter->pixelsDidChange() && texture->texture()->haveBackingTexture()) | |
233 return; | |
jamesr
2012/10/03 20:22:33
place add a TRACE_INSTANT0("cc", ...) here so we c
wjmaclean
2012/10/03 21:30:53
Good plan - done!
| |
234 | |
233 texture->prepareRect(rect, stats); | 235 texture->prepareRect(rect, stats); |
234 | 236 |
235 IntSize destOffset(0, 0); | 237 IntSize destOffset(0, 0); |
236 TextureUploader::Parameters upload = { texture, rect, destOffset }; | 238 TextureUploader::Parameters upload = { texture, rect, destOffset }; |
237 queue.appendFullUpload(upload); | 239 queue.appendFullUpload(upload); |
238 } | 240 } |
239 | 241 |
240 | 242 |
241 void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&) | 243 void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&) |
242 { | 244 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 278 |
277 // Consider the thumb to be at the origin when painting. | 279 // Consider the thumb to be at the origin when painting. |
278 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 280 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
279 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb Rect.width, thumbRect.height)); | 281 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb Rect.width, thumbRect.height)); |
280 if (!originThumbRect.isEmpty()) | 282 if (!originThumbRect.isEmpty()) |
281 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats); | 283 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats); |
282 } | 284 } |
283 | 285 |
284 } | 286 } |
285 #endif // USE(ACCELERATED_COMPOSITING) | 287 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |