Chromium Code Reviews| Index: cc/layers/scrollbar_layer.cc |
| diff --git a/cc/layers/scrollbar_layer.cc b/cc/layers/scrollbar_layer.cc |
| index 4a6383504fc5750bb706b694764e664fff59309a..14eacc1511d6dba0fcf352dcb0f47ef5fa229d76 100644 |
| --- a/cc/layers/scrollbar_layer.cc |
| +++ b/cc/layers/scrollbar_layer.cc |
| @@ -34,8 +34,8 @@ scoped_refptr<ScrollbarLayer> ScrollbarLayer::Create( |
| ScrollbarLayer::ScrollbarLayer( |
| scoped_ptr<Scrollbar> scrollbar, |
| int scroll_layer_id) |
| - : scrollbar_(scrollbar.Pass()), |
| - scroll_layer_id_(scroll_layer_id), |
| + : ScrollbarLayerBase(scroll_layer_id, scrollbar->Orientation()), |
| + scrollbar_(scrollbar.Pass()), |
| texture_format_(GL_INVALID_ENUM) { |
| if (!scrollbar_->IsOverlay()) |
| SetShouldScrollOnMainThread(true); |
| @@ -43,31 +43,26 @@ ScrollbarLayer::ScrollbarLayer( |
| ScrollbarLayer::~ScrollbarLayer() {} |
| -void ScrollbarLayer::SetScrollLayerId(int id) { |
| - if (id == scroll_layer_id_) |
| - return; |
| - |
| - scroll_layer_id_ = id; |
| - SetNeedsFullTreeSync(); |
| -} |
| - |
| bool ScrollbarLayer::OpacityCanAnimateOnImplThread() const { |
| return scrollbar_->IsOverlay(); |
| } |
| -ScrollbarOrientation ScrollbarLayer::Orientation() const { |
| - return scrollbar_->Orientation(); |
| -} |
| +ScrollbarLayerBase* ScrollbarLayer::ToScrollbarLayerBase() { return this; } |
| int ScrollbarLayer::MaxTextureSize() { |
| DCHECK(layer_tree_host()); |
| return layer_tree_host()->GetRendererCapabilities().max_texture_size; |
| } |
| -float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) { |
| - if (layer_tree_host()->settings().solid_color_scrollbars) |
| - return scale; |
| +void ScrollbarLayer::SetScrollLayerId(int id) { |
| + if (id == scroll_layer_id_) |
| + return; |
| + scroll_layer_id_ = id; |
| + SetNeedsFullTreeSync(); |
| +} |
| + |
| +float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) { |
| // If the scaled content_bounds() is bigger than the max texture size of the |
| // device, we need to clamp it by rescaling, since content_bounds() is used |
| // below to set the texture size. |
| @@ -104,23 +99,9 @@ void ScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
| ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer); |
| - if (layer_tree_host() && |
| - layer_tree_host()->settings().solid_color_scrollbars) { |
| - int thickness_override = |
| - layer_tree_host()->settings().solid_color_scrollbar_thickness_dip; |
| - if (thickness_override != -1) { |
| - scrollbar_layer->set_thumb_thickness(thickness_override); |
| - } else { |
| - if (Orientation() == HORIZONTAL) |
| - scrollbar_layer->set_thumb_thickness(bounds().height()); |
| - else |
| - scrollbar_layer->set_thumb_thickness(bounds().width()); |
| - } |
| - } else { |
| - scrollbar_layer->set_thumb_thickness(thumb_thickness_); |
| - } |
| + scrollbar_layer->set_thumb_thickness(thumb_thickness_); |
| scrollbar_layer->set_thumb_length(thumb_length_); |
| - if (Orientation() == HORIZONTAL) { |
| + if (orientation() == HORIZONTAL) { |
| scrollbar_layer->set_track_start(track_rect_.x()); |
| scrollbar_layer->set_track_length(track_rect_.width()); |
| } else { |
| @@ -138,16 +119,13 @@ void ScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
| else |
| scrollbar_layer->set_thumb_resource_id(0); |
| - scrollbar_layer->set_is_overlay_scrollbar(scrollbar_->IsOverlay()); |
| + // wjm: remove this? |
|
enne (OOO)
2013/08/12 23:15:01
No. Mac can have overlay scrollbars that are not
wjmaclean
2013/08/14 18:19:44
Done.
|
| +// scrollbar_layer->set_is_overlay_scrollbar(scrollbar_->IsOverlay()); |
| // ScrollbarLayer must push properties every frame. crbug.com/259095 |
| needs_push_properties_ = true; |
| } |
| -ScrollbarLayer* ScrollbarLayer::ToScrollbarLayer() { |
| - return this; |
| -} |
| - |
| void ScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| if (!host || host != layer_tree_host()) { |
| track_updater_ = NULL; |
| @@ -179,9 +157,6 @@ class ScrollbarPartPainter : public LayerPainter { |
| }; |
| void ScrollbarLayer::CreateUpdaterIfNeeded() { |
| - if (layer_tree_host()->settings().solid_color_scrollbars) |
| - return; |
| - |
| texture_format_ = |
| layer_tree_host()->GetRendererCapabilities().best_texture_format; |
| @@ -216,9 +191,6 @@ bool ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, |
| LayerUpdater::Resource* resource, |
| gfx::Rect rect, |
| ResourceUpdateQueue* queue) { |
| - if (layer_tree_host()->settings().solid_color_scrollbars) |
| - return false; |
| - |
| // Skip painting and uploading if there are no invalidations and |
| // we already have valid texture data. |
| if (resource->texture()->have_backing_texture() && |
| @@ -271,9 +243,6 @@ gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect( |
| void ScrollbarLayer::SetTexturePriorities( |
| const PriorityCalculator& priority_calc) { |
| - if (layer_tree_host()->settings().solid_color_scrollbars) |
| - return; |
| - |
| if (content_bounds().IsEmpty()) |
| return; |
| DCHECK_LE(content_bounds().width(), MaxTextureSize()); |
| @@ -299,9 +268,7 @@ bool ScrollbarLayer::Update(ResourceUpdateQueue* queue, |
| const OcclusionTracker* occlusion) { |
| track_rect_ = scrollbar_->TrackRect(); |
| - if (layer_tree_host()->settings().solid_color_scrollbars) |
| - return false; |
| - |
| + // WJM: is this specific to solid color scrollbars? probably!! |
| bool updated = false; |
| { |
| @@ -339,7 +306,7 @@ bool ScrollbarLayer::Update(ResourceUpdateQueue* queue, |
| gfx::Rect ScrollbarLayer::OriginThumbRect() const { |
| gfx::Size thumb_size; |
| - if (Orientation() == HORIZONTAL) { |
| + if (orientation() == HORIZONTAL) { |
| thumb_size = gfx::Size(scrollbar_->ThumbLength(), |
| scrollbar_->ThumbThickness()); |
| } else { |