Chromium Code Reviews| Index: cc/layers/scrollbar_layer_impl.cc |
| =================================================================== |
| --- cc/layers/scrollbar_layer_impl.cc (revision 210393) |
| +++ cc/layers/scrollbar_layer_impl.cc (working copy) |
| @@ -9,6 +9,7 @@ |
| #include "cc/layers/quad_sink.h" |
| #include "cc/quads/solid_color_draw_quad.h" |
| #include "cc/quads/texture_draw_quad.h" |
| +#include "cc/quads/tile_draw_quad.h" |
| #include "cc/trees/layer_tree_impl.h" |
| #include "cc/trees/layer_tree_settings.h" |
| #include "ui/gfx/rect_conversions.h" |
| @@ -29,8 +30,6 @@ |
| int id, |
| ScrollbarOrientation orientation) |
| : LayerImpl(tree_impl, id), |
| - track_resource_id_(0), |
| - thumb_resource_id_(0), |
| current_pos_(0.f), |
| maximum_(0), |
| thumb_thickness_(0), |
| @@ -41,6 +40,8 @@ |
| vertical_adjust_(0.f), |
| visible_to_total_length_ratio_(1.f), |
| scroll_layer_id_(Layer::INVALID_ID), |
| + track_ui_resource_id_(0), |
| + thumb_ui_resource_id_(0), |
| is_scrollable_area_active_(false), |
| is_scroll_view_scrollbar_(false), |
| enabled_(false), |
| @@ -70,8 +71,11 @@ |
| scrollbar_layer->set_track_start(track_start_); |
| scrollbar_layer->set_track_length(track_length_); |
| - scrollbar_layer->set_track_resource_id(track_resource_id_); |
| - scrollbar_layer->set_thumb_resource_id(thumb_resource_id_); |
| + if (scrollbar_layer->track_ui_resource_id_ != track_ui_resource_id_ || |
|
enne (OOO)
2013/07/22 23:09:15
No need for this to be conditional.
powei
2013/07/24 02:28:29
Done.
|
| + scrollbar_layer->thumb_ui_resource_id_ != thumb_ui_resource_id_) { |
| + scrollbar_layer->set_track_ui_resource_id(track_ui_resource_id_); |
| + scrollbar_layer->set_thumb_ui_resource_id(thumb_ui_resource_id_); |
| + } |
| } |
| bool ScrollbarLayerImpl::WillDraw(DrawMode draw_mode, |
| @@ -107,14 +111,21 @@ |
| return; |
| } |
| - if (thumb_resource_id_ && !thumb_quad_rect.IsEmpty()) { |
| + gfx::Rect track_quad_rect = content_bounds_rect; |
| + |
| + ResourceProvider::ResourceId thumb_resource_id = |
| + layer_tree_impl()->ResourceIdForUIResource(thumb_ui_resource_id_); |
| + ResourceProvider::ResourceId track_resource_id = |
| + layer_tree_impl()->ResourceIdForUIResource(track_ui_resource_id_); |
| + |
| + if (thumb_resource_id && !thumb_quad_rect.IsEmpty()) { |
| gfx::Rect opaque_rect; |
| const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
| quad->SetNew(shared_quad_state, |
| thumb_quad_rect, |
| opaque_rect, |
| - thumb_resource_id_, |
| + thumb_resource_id, |
| premultipled_alpha, |
| uv_top_left, |
| uv_bottom_right, |
| @@ -123,21 +134,14 @@ |
| quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| } |
| - if (!track_resource_id_) |
| - return; |
| - |
| - // Order matters here: since the back track texture is being drawn to the |
| - // entire contents rect, we must append it after the thumb and fore track |
| - // quads. The back track texture contains (and displays) the buttons. |
| - if (!content_bounds_rect.IsEmpty()) { |
| - gfx::Rect quad_rect(content_bounds_rect); |
| - gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
| + if (track_resource_id && !track_quad_rect.IsEmpty()) { |
| + gfx::Rect opaque_rect(contents_opaque() ? track_quad_rect : gfx::Rect()); |
| const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
| quad->SetNew(shared_quad_state, |
| - quad_rect, |
| + track_quad_rect, |
| opaque_rect, |
| - track_resource_id_, |
| + track_resource_id, |
| premultipled_alpha, |
| uv_top_left, |
| uv_bottom_right, |
| @@ -258,13 +262,18 @@ |
| return ScrollbarLayerRectToContentRect(thumb_rect); |
| } |
| -void ScrollbarLayerImpl::DidLoseOutputSurface() { |
| - track_resource_id_ = 0; |
| - thumb_resource_id_ = 0; |
| -} |
| +void ScrollbarLayerImpl::DidLoseOutputSurface() {} |
|
enne (OOO)
2013/07/22 23:09:15
This can be removed entirely.
powei
2013/07/24 02:28:29
Done.
|
| const char* ScrollbarLayerImpl::LayerTypeAsString() const { |
| return "cc::ScrollbarLayerImpl"; |
| } |
| +void ScrollbarLayerImpl::set_track_ui_resource_id(UIResourceId uid) { |
| + track_ui_resource_id_ = uid; |
| +} |
| + |
| +void ScrollbarLayerImpl::set_thumb_ui_resource_id(UIResourceId uid) { |
| + thumb_ui_resource_id_ = uid; |
| +} |
| + |
| } // namespace cc |