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