| 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<LayerImpl> ScrollbarLayer::createLayerImpl( | 20 scoped_ptr<LayerImpl> ScrollbarLayer::CreateLayerImpl( |
| 21 LayerTreeImpl* tree_impl) { | 21 LayerTreeImpl* tree_impl) { |
| 22 return ScrollbarLayerImpl::Create( | 22 return ScrollbarLayerImpl::Create( |
| 23 tree_impl, | 23 tree_impl, |
| 24 id(), | 24 id(), |
| 25 ScrollbarGeometryFixedThumb::create(make_scoped_ptr(geometry_->clone()))) | 25 ScrollbarGeometryFixedThumb::create(make_scoped_ptr(geometry_->clone()))) |
| 26 .PassAs<LayerImpl>(); | 26 .PassAs<LayerImpl>(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 scoped_refptr<ScrollbarLayer> ScrollbarLayer::Create( | 29 scoped_refptr<ScrollbarLayer> ScrollbarLayer::Create( |
| 30 scoped_ptr<WebKit::WebScrollbar> scrollbar, | 30 scoped_ptr<WebKit::WebScrollbar> scrollbar, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 scoped_ptr<WebKit::WebScrollbar> scrollbar, | 41 scoped_ptr<WebKit::WebScrollbar> scrollbar, |
| 42 scoped_ptr<ScrollbarThemePainter> painter, | 42 scoped_ptr<ScrollbarThemePainter> painter, |
| 43 scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry, | 43 scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry, |
| 44 int scrollLayerId) | 44 int scrollLayerId) |
| 45 : scrollbar_(scrollbar.Pass()), | 45 : scrollbar_(scrollbar.Pass()), |
| 46 painter_(painter.Pass()), | 46 painter_(painter.Pass()), |
| 47 geometry_(geometry.Pass()), | 47 geometry_(geometry.Pass()), |
| 48 scroll_layer_id_(scrollLayerId), | 48 scroll_layer_id_(scrollLayerId), |
| 49 texture_format_(GL_INVALID_ENUM) { | 49 texture_format_(GL_INVALID_ENUM) { |
| 50 if (!scrollbar_->isOverlay()) | 50 if (!scrollbar_->isOverlay()) |
| 51 setShouldScrollOnMainThread(true); | 51 SetShouldScrollOnMainThread(true); |
| 52 } | 52 } |
| 53 | 53 |
| 54 ScrollbarLayer::~ScrollbarLayer() {} | 54 ScrollbarLayer::~ScrollbarLayer() {} |
| 55 | 55 |
| 56 void ScrollbarLayer::SetScrollLayerId(int id) { | 56 void ScrollbarLayer::SetScrollLayerId(int id) { |
| 57 if (id == scroll_layer_id_) | 57 if (id == scroll_layer_id_) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 scroll_layer_id_ = id; | 60 scroll_layer_id_ = id; |
| 61 setNeedsFullTreeSync(); | 61 SetNeedsFullTreeSync(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 WebKit::WebScrollbar::Orientation ScrollbarLayer::Orientation() const { | 64 WebKit::WebScrollbar::Orientation ScrollbarLayer::Orientation() const { |
| 65 return scrollbar_->orientation(); | 65 return scrollbar_->orientation(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 int ScrollbarLayer::MaxTextureSize() { | 68 int ScrollbarLayer::MaxTextureSize() { |
| 69 DCHECK(layerTreeHost()); | 69 DCHECK(layer_tree_host()); |
| 70 return layerTreeHost()->rendererCapabilities().maxTextureSize; | 70 return layer_tree_host()->rendererCapabilities().maxTextureSize; |
| 71 } | 71 } |
| 72 | 72 |
| 73 float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) { | 73 float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) { |
| 74 if (layerTreeHost()->settings().solidColorScrollbars) | 74 if (layer_tree_host()->settings().solidColorScrollbars) |
| 75 return scale; | 75 return scale; |
| 76 | 76 |
| 77 // If the scaled contentBounds() is bigger than the max texture size of the | 77 // If the scaled content_bounds() is bigger than the max texture size of the |
| 78 // device, we need to clamp it by rescaling, since contentBounds() is used | 78 // device, we need to clamp it by rescaling, since content_bounds() is used |
| 79 // below to set the texture size. | 79 // below to set the texture size. |
| 80 gfx::Size scaled_bounds = computeContentBoundsForScale(scale, scale); | 80 gfx::Size scaled_bounds = computeContentBoundsForScale(scale, scale); |
| 81 if (scaled_bounds.width() > MaxTextureSize() || | 81 if (scaled_bounds.width() > MaxTextureSize() || |
| 82 scaled_bounds.height() > MaxTextureSize()) { | 82 scaled_bounds.height() > MaxTextureSize()) { |
| 83 if (scaled_bounds.width() > scaled_bounds.height()) | 83 if (scaled_bounds.width() > scaled_bounds.height()) |
| 84 return (MaxTextureSize() - 1) / static_cast<float>(bounds().width()); | 84 return (MaxTextureSize() - 1) / static_cast<float>(bounds().width()); |
| 85 else | 85 else |
| 86 return (MaxTextureSize() - 1) / static_cast<float>(bounds().height()); | 86 return (MaxTextureSize() - 1) / static_cast<float>(bounds().height()); |
| 87 } | 87 } |
| 88 return scale; | 88 return scale; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void ScrollbarLayer::calculateContentsScale(float ideal_contents_scale, | 91 void ScrollbarLayer::CalculateContentsScale(float ideal_contents_scale, |
| 92 bool animating_transform_to_screen, | 92 bool animating_transform_to_screen, |
| 93 float* contents_scale_x, | 93 float* contents_scale_x, |
| 94 float* contents_scale_y, | 94 float* contents_scale_y, |
| 95 gfx::Size* contentBounds) { | 95 gfx::Size* contentBounds) { |
| 96 ContentsScalingLayer::calculateContentsScale( | 96 ContentsScalingLayer::CalculateContentsScale( |
| 97 ClampScaleToMaxTextureSize(ideal_contents_scale), | 97 ClampScaleToMaxTextureSize(ideal_contents_scale), |
| 98 animating_transform_to_screen, | 98 animating_transform_to_screen, |
| 99 contents_scale_x, | 99 contents_scale_x, |
| 100 contents_scale_y, | 100 contents_scale_y, |
| 101 contentBounds); | 101 contentBounds); |
| 102 DCHECK_LE(contentBounds->width(), MaxTextureSize()); | 102 DCHECK_LE(contentBounds->width(), MaxTextureSize()); |
| 103 DCHECK_LE(contentBounds->height(), MaxTextureSize()); | 103 DCHECK_LE(contentBounds->height(), MaxTextureSize()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ScrollbarLayer::pushPropertiesTo(LayerImpl* layer) { | 106 void ScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
| 107 ContentsScalingLayer::pushPropertiesTo(layer); | 107 ContentsScalingLayer::PushPropertiesTo(layer); |
| 108 | 108 |
| 109 ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer); | 109 ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer); |
| 110 | 110 |
| 111 scrollbar_layer->SetScrollbarData(scrollbar_.get()); | 111 scrollbar_layer->SetScrollbarData(scrollbar_.get()); |
| 112 scrollbar_layer->SetThumbSize(thumb_size_); | 112 scrollbar_layer->SetThumbSize(thumb_size_); |
| 113 | 113 |
| 114 if (back_track_ && back_track_->texture()->haveBackingTexture()) { | 114 if (back_track_ && back_track_->texture()->haveBackingTexture()) { |
| 115 scrollbar_layer->set_back_track_resource_id( | 115 scrollbar_layer->set_back_track_resource_id( |
| 116 back_track_->texture()->resourceId()); | 116 back_track_->texture()->resourceId()); |
| 117 } else { | 117 } else { |
| 118 scrollbar_layer->set_back_track_resource_id(0); | 118 scrollbar_layer->set_back_track_resource_id(0); |
| 119 } | 119 } |
| 120 | 120 |
| 121 if (fore_track_ && fore_track_->texture()->haveBackingTexture()) { | 121 if (fore_track_ && fore_track_->texture()->haveBackingTexture()) { |
| 122 scrollbar_layer->set_fore_track_resource_id( | 122 scrollbar_layer->set_fore_track_resource_id( |
| 123 fore_track_->texture()->resourceId()); | 123 fore_track_->texture()->resourceId()); |
| 124 } else { | 124 } else { |
| 125 scrollbar_layer->set_fore_track_resource_id(0); | 125 scrollbar_layer->set_fore_track_resource_id(0); |
| 126 } | 126 } |
| 127 | 127 |
| 128 if (thumb_ && thumb_->texture()->haveBackingTexture()) | 128 if (thumb_ && thumb_->texture()->haveBackingTexture()) |
| 129 scrollbar_layer->set_thumb_resource_id(thumb_->texture()->resourceId()); | 129 scrollbar_layer->set_thumb_resource_id(thumb_->texture()->resourceId()); |
| 130 else | 130 else |
| 131 scrollbar_layer->set_thumb_resource_id(0); | 131 scrollbar_layer->set_thumb_resource_id(0); |
| 132 } | 132 } |
| 133 | 133 |
| 134 ScrollbarLayer* ScrollbarLayer::toScrollbarLayer() { | 134 ScrollbarLayer* ScrollbarLayer::ToScrollbarLayer() { |
| 135 return this; | 135 return this; |
| 136 } | 136 } |
| 137 | 137 |
| 138 class ScrollbarBackgroundPainter : public LayerPainter { | 138 class ScrollbarBackgroundPainter : public LayerPainter { |
| 139 public: | 139 public: |
| 140 static scoped_ptr<ScrollbarBackgroundPainter> Create( | 140 static scoped_ptr<ScrollbarBackgroundPainter> Create( |
| 141 WebKit::WebScrollbar* scrollbar, | 141 WebKit::WebScrollbar* scrollbar, |
| 142 ScrollbarThemePainter *painter, | 142 ScrollbarThemePainter *painter, |
| 143 WebKit::WebScrollbarThemeGeometry* geometry, | 143 WebKit::WebScrollbarThemeGeometry* geometry, |
| 144 WebKit::WebScrollbar::ScrollbarPart trackPart) { | 144 WebKit::WebScrollbar::ScrollbarPart trackPart) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 painter_(painter), | 231 painter_(painter), |
| 232 geometry_(geometry) {} | 232 geometry_(geometry) {} |
| 233 | 233 |
| 234 WebKit::WebScrollbar* scrollbar_; | 234 WebKit::WebScrollbar* scrollbar_; |
| 235 ScrollbarThemePainter* painter_; | 235 ScrollbarThemePainter* painter_; |
| 236 WebKit::WebScrollbarThemeGeometry* geometry_; | 236 WebKit::WebScrollbarThemeGeometry* geometry_; |
| 237 | 237 |
| 238 DISALLOW_COPY_AND_ASSIGN(ScrollbarThumbPainter); | 238 DISALLOW_COPY_AND_ASSIGN(ScrollbarThumbPainter); |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 void ScrollbarLayer::setLayerTreeHost(LayerTreeHost* host) { | 241 void ScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 242 if (!host || host != layerTreeHost()) { | 242 if (!host || host != layer_tree_host()) { |
| 243 back_track_updater_ = NULL; | 243 back_track_updater_ = NULL; |
| 244 back_track_.reset(); | 244 back_track_.reset(); |
| 245 thumb_updater_ = NULL; | 245 thumb_updater_ = NULL; |
| 246 thumb_.reset(); | 246 thumb_.reset(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 ContentsScalingLayer::setLayerTreeHost(host); | 249 ContentsScalingLayer::SetLayerTreeHost(host); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void ScrollbarLayer::CreateUpdaterIfNeeded() { | 252 void ScrollbarLayer::CreateUpdaterIfNeeded() { |
| 253 if (layerTreeHost()->settings().solidColorScrollbars) | 253 if (layer_tree_host()->settings().solidColorScrollbars) |
| 254 return; | 254 return; |
| 255 | 255 |
| 256 texture_format_ = layerTreeHost()->rendererCapabilities().bestTextureFormat; | 256 texture_format_ = layer_tree_host()->rendererCapabilities().bestTextureFormat; |
| 257 | 257 |
| 258 if (!back_track_updater_) { | 258 if (!back_track_updater_) { |
| 259 back_track_updater_ = CachingBitmapContentLayerUpdater::Create( | 259 back_track_updater_ = CachingBitmapContentLayerUpdater::Create( |
| 260 ScrollbarBackgroundPainter::Create( | 260 ScrollbarBackgroundPainter::Create( |
| 261 scrollbar_.get(), | 261 scrollbar_.get(), |
| 262 painter_.get(), | 262 painter_.get(), |
| 263 geometry_.get(), | 263 geometry_.get(), |
| 264 WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>()); | 264 WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>()); |
| 265 } | 265 } |
| 266 if (!back_track_) { | 266 if (!back_track_) { |
| 267 back_track_ = back_track_updater_->createResource( | 267 back_track_ = back_track_updater_->createResource( |
| 268 layerTreeHost()->contentsTextureManager()); | 268 layer_tree_host()->contentsTextureManager()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Only create two-part track if we think the two parts could be different in | 271 // Only create two-part track if we think the two parts could be different in |
| 272 // appearance. | 272 // appearance. |
| 273 if (scrollbar_->isCustomScrollbar()) { | 273 if (scrollbar_->isCustomScrollbar()) { |
| 274 if (!fore_track_updater_) { | 274 if (!fore_track_updater_) { |
| 275 fore_track_updater_ = CachingBitmapContentLayerUpdater::Create( | 275 fore_track_updater_ = CachingBitmapContentLayerUpdater::Create( |
| 276 ScrollbarBackgroundPainter::Create( | 276 ScrollbarBackgroundPainter::Create( |
| 277 scrollbar_.get(), | 277 scrollbar_.get(), |
| 278 painter_.get(), | 278 painter_.get(), |
| 279 geometry_.get(), | 279 geometry_.get(), |
| 280 WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>()); | 280 WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>()); |
| 281 } | 281 } |
| 282 if (!fore_track_) { | 282 if (!fore_track_) { |
| 283 fore_track_ = fore_track_updater_->createResource( | 283 fore_track_ = fore_track_updater_->createResource( |
| 284 layerTreeHost()->contentsTextureManager()); | 284 layer_tree_host()->contentsTextureManager()); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 if (!thumb_updater_) { | 288 if (!thumb_updater_) { |
| 289 thumb_updater_ = CachingBitmapContentLayerUpdater::Create( | 289 thumb_updater_ = CachingBitmapContentLayerUpdater::Create( |
| 290 ScrollbarThumbPainter::Create(scrollbar_.get(), | 290 ScrollbarThumbPainter::Create(scrollbar_.get(), |
| 291 painter_.get(), | 291 painter_.get(), |
| 292 geometry_.get()).PassAs<LayerPainter>()); | 292 geometry_.get()).PassAs<LayerPainter>()); |
| 293 } | 293 } |
| 294 if (!thumb_) { | 294 if (!thumb_) { |
| 295 thumb_ = thumb_updater_->createResource( | 295 thumb_ = thumb_updater_->createResource( |
| 296 layerTreeHost()->contentsTextureManager()); | 296 layer_tree_host()->contentsTextureManager()); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, | 300 void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, |
| 301 LayerUpdater::Resource* resource, | 301 LayerUpdater::Resource* resource, |
| 302 gfx::Rect rect, | 302 gfx::Rect rect, |
| 303 ResourceUpdateQueue* queue, | 303 ResourceUpdateQueue* queue, |
| 304 RenderingStats* stats) { | 304 RenderingStats* stats) { |
| 305 if (layerTreeHost()->settings().solidColorScrollbars) | 305 if (layer_tree_host()->settings().solidColorScrollbars) |
| 306 return; | 306 return; |
| 307 | 307 |
| 308 // Skip painting and uploading if there are no invalidations and | 308 // Skip painting and uploading if there are no invalidations and |
| 309 // we already have valid texture data. | 309 // we already have valid texture data. |
| 310 if (resource->texture()->haveBackingTexture() && | 310 if (resource->texture()->haveBackingTexture() && |
| 311 resource->texture()->size() == rect.size() && | 311 resource->texture()->size() == rect.size() && |
| 312 !is_dirty()) | 312 !is_dirty()) |
| 313 return; | 313 return; |
| 314 | 314 |
| 315 // We should always have enough memory for UI. | 315 // We should always have enough memory for UI. |
| 316 DCHECK(resource->texture()->canAcquireBackingTexture()); | 316 DCHECK(resource->texture()->canAcquireBackingTexture()); |
| 317 if (!resource->texture()->canAcquireBackingTexture()) | 317 if (!resource->texture()->canAcquireBackingTexture()) |
| 318 return; | 318 return; |
| 319 | 319 |
| 320 // Paint and upload the entire part. | 320 // Paint and upload the entire part. |
| 321 gfx::Rect painted_opaque_rect; | 321 gfx::Rect painted_opaque_rect; |
| 322 painter->prepareToUpdate(rect, | 322 painter->prepareToUpdate(rect, |
| 323 rect.size(), | 323 rect.size(), |
| 324 contentsScaleX(), | 324 contents_scale_x(), |
| 325 contentsScaleY(), | 325 contents_scale_y(), |
| 326 painted_opaque_rect, | 326 painted_opaque_rect, |
| 327 stats); | 327 stats); |
| 328 if (!painter->pixelsDidChange() && | 328 if (!painter->pixelsDidChange() && |
| 329 resource->texture()->haveBackingTexture()) { | 329 resource->texture()->haveBackingTexture()) { |
| 330 TRACE_EVENT_INSTANT0("cc", | 330 TRACE_EVENT_INSTANT0("cc", |
| 331 "ScrollbarLayer::updatePart no texture upload needed"); | 331 "ScrollbarLayer::updatePart no texture upload needed"); |
| 332 return; | 332 return; |
| 333 } | 333 } |
| 334 | 334 |
| 335 bool partial_updates_allowed = | 335 bool partial_updates_allowed = |
| 336 layerTreeHost()->settings().maxPartialTextureUpdates > 0; | 336 layer_tree_host()->settings().maxPartialTextureUpdates > 0; |
| 337 if (!partial_updates_allowed) | 337 if (!partial_updates_allowed) |
| 338 resource->texture()->returnBackingTexture(); | 338 resource->texture()->returnBackingTexture(); |
| 339 | 339 |
| 340 gfx::Vector2d dest_offset(0, 0); | 340 gfx::Vector2d dest_offset(0, 0); |
| 341 resource->update(*queue, rect, dest_offset, partial_updates_allowed, stats); | 341 resource->update(*queue, rect, dest_offset, partial_updates_allowed, stats); |
| 342 } | 342 } |
| 343 | 343 |
| 344 gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect( | 344 gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect( |
| 345 gfx::Rect layer_rect) const { | 345 gfx::Rect layer_rect) const { |
| 346 // Don't intersect with the bounds as in layerRectToContentRect() because | 346 // Don't intersect with the bounds as in LayerRectToContentRect() because |
| 347 // layer_rect here might be in coordinates of the containing layer. | 347 // layer_rect here might be in coordinates of the containing layer. |
| 348 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, | 348 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, |
| 349 contentsScaleY(), | 349 contents_scale_y(), |
| 350 contentsScaleY()); | 350 contents_scale_y()); |
| 351 return gfx::ToEnclosingRect(content_rect); | 351 return gfx::ToEnclosingRect(content_rect); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void ScrollbarLayer::setTexturePriorities( | 354 void ScrollbarLayer::SetTexturePriorities( |
| 355 const PriorityCalculator& priority_calc) { | 355 const PriorityCalculator& priority_calc) { |
| 356 if (layerTreeHost()->settings().solidColorScrollbars) | 356 if (layer_tree_host()->settings().solidColorScrollbars) |
| 357 return; | 357 return; |
| 358 | 358 |
| 359 if (contentBounds().IsEmpty()) | 359 if (content_bounds().IsEmpty()) |
| 360 return; | 360 return; |
| 361 DCHECK_LE(contentBounds().width(), MaxTextureSize()); | 361 DCHECK_LE(content_bounds().width(), MaxTextureSize()); |
| 362 DCHECK_LE(contentBounds().height(), MaxTextureSize()); | 362 DCHECK_LE(content_bounds().height(), MaxTextureSize()); |
| 363 | 363 |
| 364 CreateUpdaterIfNeeded(); | 364 CreateUpdaterIfNeeded(); |
| 365 | 365 |
| 366 bool draws_to_root = !renderTarget()->parent(); | 366 bool draws_to_root = !render_target()->parent(); |
| 367 if (back_track_) { | 367 if (back_track_) { |
| 368 back_track_->texture()->setDimensions(contentBounds(), texture_format_); | 368 back_track_->texture()->setDimensions(content_bounds(), texture_format_); |
| 369 back_track_->texture()->setRequestPriority( | 369 back_track_->texture()->setRequestPriority( |
| 370 PriorityCalculator::uiPriority(draws_to_root)); | 370 PriorityCalculator::uiPriority(draws_to_root)); |
| 371 } | 371 } |
| 372 if (fore_track_) { | 372 if (fore_track_) { |
| 373 fore_track_->texture()->setDimensions(contentBounds(), texture_format_); | 373 fore_track_->texture()->setDimensions(content_bounds(), texture_format_); |
| 374 fore_track_->texture()->setRequestPriority( | 374 fore_track_->texture()->setRequestPriority( |
| 375 PriorityCalculator::uiPriority(draws_to_root)); | 375 PriorityCalculator::uiPriority(draws_to_root)); |
| 376 } | 376 } |
| 377 if (thumb_) { | 377 if (thumb_) { |
| 378 gfx::Rect thumb_layer_rect = geometry_->thumbRect(scrollbar_.get()); | 378 gfx::Rect thumb_layer_rect = geometry_->thumbRect(scrollbar_.get()); |
| 379 gfx::Size thumb_size = | 379 gfx::Size thumb_size = |
| 380 ScrollbarLayerRectToContentRect(thumb_layer_rect).size(); | 380 ScrollbarLayerRectToContentRect(thumb_layer_rect).size(); |
| 381 thumb_->texture()->setDimensions(thumb_size, texture_format_); | 381 thumb_->texture()->setDimensions(thumb_size, texture_format_); |
| 382 thumb_->texture()->setRequestPriority( | 382 thumb_->texture()->setRequestPriority( |
| 383 PriorityCalculator::uiPriority(draws_to_root)); | 383 PriorityCalculator::uiPriority(draws_to_root)); |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 void ScrollbarLayer::update(ResourceUpdateQueue& queue, | 387 void ScrollbarLayer::Update(ResourceUpdateQueue* queue, |
| 388 const OcclusionTracker* occlusion, | 388 const OcclusionTracker* occlusion, |
| 389 RenderingStats* stats) { | 389 RenderingStats* stats) { |
| 390 ContentsScalingLayer::update(queue, occlusion, stats); | 390 ContentsScalingLayer::Update(queue, occlusion, stats); |
| 391 | 391 |
| 392 dirty_rect_.Union(m_updateRect); | 392 dirty_rect_.Union(update_rect_); |
| 393 if (contentBounds().IsEmpty()) | 393 if (content_bounds().IsEmpty()) |
| 394 return; | 394 return; |
| 395 if (visibleContentRect().IsEmpty()) | 395 if (visible_content_rect().IsEmpty()) |
| 396 return; | 396 return; |
| 397 | 397 |
| 398 CreateUpdaterIfNeeded(); | 398 CreateUpdaterIfNeeded(); |
| 399 | 399 |
| 400 gfx::Rect content_rect = ScrollbarLayerRectToContentRect( | 400 gfx::Rect content_rect = ScrollbarLayerRectToContentRect( |
| 401 gfx::Rect(scrollbar_->location(), bounds())); | 401 gfx::Rect(scrollbar_->location(), bounds())); |
| 402 UpdatePart(back_track_updater_.get(), | 402 UpdatePart(back_track_updater_.get(), |
| 403 back_track_.get(), | 403 back_track_.get(), |
| 404 content_rect, | 404 content_rect, |
| 405 &queue, | 405 queue, |
| 406 stats); | 406 stats); |
| 407 if (fore_track_ && fore_track_updater_) { | 407 if (fore_track_ && fore_track_updater_) { |
| 408 UpdatePart(fore_track_updater_.get(), | 408 UpdatePart(fore_track_updater_.get(), |
| 409 fore_track_.get(), | 409 fore_track_.get(), |
| 410 content_rect, | 410 content_rect, |
| 411 &queue, | 411 queue, |
| 412 stats); | 412 stats); |
| 413 } | 413 } |
| 414 | 414 |
| 415 // Consider the thumb to be at the origin when painting. | 415 // Consider the thumb to be at the origin when painting. |
| 416 gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get()); | 416 gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get()); |
| 417 thumb_size_ = thumb_rect.size(); | 417 thumb_size_ = thumb_rect.size(); |
| 418 gfx::Rect origin_thumb_rect = | 418 gfx::Rect origin_thumb_rect = |
| 419 ScrollbarLayerRectToContentRect(gfx::Rect(thumb_rect.size())); | 419 ScrollbarLayerRectToContentRect(gfx::Rect(thumb_rect.size())); |
| 420 if (!origin_thumb_rect.IsEmpty()) { | 420 if (!origin_thumb_rect.IsEmpty()) { |
| 421 UpdatePart(thumb_updater_.get(), | 421 UpdatePart(thumb_updater_.get(), |
| 422 thumb_.get(), | 422 thumb_.get(), |
| 423 origin_thumb_rect, | 423 origin_thumb_rect, |
| 424 &queue, | 424 queue, |
| 425 stats); | 425 stats); |
| 426 } | 426 } |
| 427 | 427 |
| 428 dirty_rect_ = gfx::RectF(); | 428 dirty_rect_ = gfx::RectF(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 } // namespace cc | 431 } // namespace cc |
| OLD | NEW |