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/layers/scrollbar_layer_impl.h" | 5 #include "cc/layers/scrollbar_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "cc/animation/scrollbar_animation_controller.h" | 9 #include "cc/animation/scrollbar_animation_controller.h" |
10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
11 #include "cc/layers/quad_sink.h" | 11 #include "cc/layers/quad_sink.h" |
12 #include "cc/quads/solid_color_draw_quad.h" | 12 #include "cc/quads/solid_color_draw_quad.h" |
13 #include "cc/quads/texture_draw_quad.h" | 13 #include "cc/quads/texture_draw_quad.h" |
14 #include "cc/quads/tile_draw_quad.h" | |
aelias_OOO_until_Jul13
2013/07/31 21:00:30
remove this include
powei
2013/07/31 21:29:39
Done.
| |
14 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
15 #include "cc/trees/layer_tree_settings.h" | 16 #include "cc/trees/layer_tree_settings.h" |
16 #include "ui/gfx/rect_conversions.h" | 17 #include "ui/gfx/rect_conversions.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 | 20 |
20 scoped_ptr<ScrollbarLayerImpl> ScrollbarLayerImpl::Create( | 21 scoped_ptr<ScrollbarLayerImpl> ScrollbarLayerImpl::Create( |
21 LayerTreeImpl* tree_impl, | 22 LayerTreeImpl* tree_impl, |
22 int id, | 23 int id, |
23 ScrollbarOrientation orientation) { | 24 ScrollbarOrientation orientation) { |
24 return make_scoped_ptr(new ScrollbarLayerImpl(tree_impl, | 25 return make_scoped_ptr(new ScrollbarLayerImpl(tree_impl, |
25 id, | 26 id, |
26 orientation)); | 27 orientation)); |
27 } | 28 } |
28 | 29 |
29 ScrollbarLayerImpl::ScrollbarLayerImpl( | 30 ScrollbarLayerImpl::ScrollbarLayerImpl( |
30 LayerTreeImpl* tree_impl, | 31 LayerTreeImpl* tree_impl, |
31 int id, | 32 int id, |
32 ScrollbarOrientation orientation) | 33 ScrollbarOrientation orientation) |
33 : LayerImpl(tree_impl, id), | 34 : LayerImpl(tree_impl, id), |
34 track_resource_id_(0), | 35 track_ui_resource_id_(0), |
35 thumb_resource_id_(0), | 36 thumb_ui_resource_id_(0), |
36 current_pos_(0.f), | 37 current_pos_(0.f), |
37 maximum_(0), | 38 maximum_(0), |
38 thumb_thickness_(0), | 39 thumb_thickness_(0), |
39 thumb_length_(0), | 40 thumb_length_(0), |
40 track_start_(0), | 41 track_start_(0), |
41 track_length_(0), | 42 track_length_(0), |
42 orientation_(orientation), | 43 orientation_(orientation), |
43 vertical_adjust_(0.f), | 44 vertical_adjust_(0.f), |
44 visible_to_total_length_ratio_(1.f), | 45 visible_to_total_length_ratio_(1.f), |
45 scroll_layer_id_(Layer::INVALID_ID), | 46 scroll_layer_id_(Layer::INVALID_ID), |
(...skipping 16 matching lines...) Expand all Loading... | |
62 LayerImpl::PushPropertiesTo(layer); | 63 LayerImpl::PushPropertiesTo(layer); |
63 | 64 |
64 ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer); | 65 ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer); |
65 | 66 |
66 scrollbar_layer->set_thumb_thickness(thumb_thickness_); | 67 scrollbar_layer->set_thumb_thickness(thumb_thickness_); |
67 scrollbar_layer->set_thumb_length(thumb_length_); | 68 scrollbar_layer->set_thumb_length(thumb_length_); |
68 scrollbar_layer->set_track_start(track_start_); | 69 scrollbar_layer->set_track_start(track_start_); |
69 scrollbar_layer->set_track_length(track_length_); | 70 scrollbar_layer->set_track_length(track_length_); |
70 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_scrollbar_); | 71 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_scrollbar_); |
71 | 72 |
72 scrollbar_layer->set_track_resource_id(track_resource_id_); | 73 scrollbar_layer->set_track_ui_resource_id(track_ui_resource_id_); |
73 scrollbar_layer->set_thumb_resource_id(thumb_resource_id_); | 74 scrollbar_layer->set_thumb_ui_resource_id(thumb_ui_resource_id_); |
74 } | 75 } |
75 | 76 |
76 bool ScrollbarLayerImpl::WillDraw(DrawMode draw_mode, | 77 bool ScrollbarLayerImpl::WillDraw(DrawMode draw_mode, |
77 ResourceProvider* resource_provider) { | 78 ResourceProvider* resource_provider) { |
78 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE && | 79 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE && |
79 !layer_tree_impl()->settings().solid_color_scrollbars) | 80 !layer_tree_impl()->settings().solid_color_scrollbars) |
80 return false; | 81 return false; |
81 return LayerImpl::WillDraw(draw_mode, resource_provider); | 82 return LayerImpl::WillDraw(draw_mode, resource_provider); |
82 } | 83 } |
83 | 84 |
(...skipping 15 matching lines...) Expand all Loading... | |
99 if (layer_tree_impl()->settings().solid_color_scrollbars) { | 100 if (layer_tree_impl()->settings().solid_color_scrollbars) { |
100 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 101 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
101 quad->SetNew(shared_quad_state, | 102 quad->SetNew(shared_quad_state, |
102 thumb_quad_rect, | 103 thumb_quad_rect, |
103 layer_tree_impl()->settings().solid_color_scrollbar_color, | 104 layer_tree_impl()->settings().solid_color_scrollbar_color, |
104 false); | 105 false); |
105 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 106 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
106 return; | 107 return; |
107 } | 108 } |
108 | 109 |
109 if (thumb_resource_id_ && !thumb_quad_rect.IsEmpty()) { | 110 gfx::Rect track_quad_rect = content_bounds_rect; |
enne (OOO)
2013/07/31 22:02:40
This temporary variable isn't used for anything.
powei
2013/08/01 00:05:10
Done. It is, but placed too far away from its use
| |
111 | |
112 ResourceProvider::ResourceId thumb_resource_id = | |
113 layer_tree_impl()->ResourceIdForUIResource(thumb_ui_resource_id_); | |
114 ResourceProvider::ResourceId track_resource_id = | |
115 layer_tree_impl()->ResourceIdForUIResource(track_ui_resource_id_); | |
116 | |
117 if (thumb_resource_id && !thumb_quad_rect.IsEmpty()) { | |
110 gfx::Rect opaque_rect; | 118 gfx::Rect opaque_rect; |
111 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 119 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
112 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 120 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
113 quad->SetNew(shared_quad_state, | 121 quad->SetNew(shared_quad_state, |
114 thumb_quad_rect, | 122 thumb_quad_rect, |
115 opaque_rect, | 123 opaque_rect, |
116 thumb_resource_id_, | 124 thumb_resource_id, |
117 premultipled_alpha, | 125 premultipled_alpha, |
118 uv_top_left, | 126 uv_top_left, |
119 uv_bottom_right, | 127 uv_bottom_right, |
120 SK_ColorTRANSPARENT, | 128 SK_ColorTRANSPARENT, |
121 opacity, | 129 opacity, |
122 flipped); | 130 flipped); |
123 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 131 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
124 } | 132 } |
125 | 133 |
126 if (!track_resource_id_) | 134 if (track_resource_id && !track_quad_rect.IsEmpty()) { |
127 return; | 135 gfx::Rect opaque_rect(contents_opaque() ? track_quad_rect : gfx::Rect()); |
128 | |
129 // Order matters here: since the back track texture is being drawn to the | |
130 // entire contents rect, we must append it after the thumb and fore track | |
131 // quads. The back track texture contains (and displays) the buttons. | |
132 if (!content_bounds_rect.IsEmpty()) { | |
133 gfx::Rect quad_rect(content_bounds_rect); | |
134 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | |
135 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 136 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
136 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 137 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
137 quad->SetNew(shared_quad_state, | 138 quad->SetNew(shared_quad_state, |
138 quad_rect, | 139 track_quad_rect, |
139 opaque_rect, | 140 opaque_rect, |
140 track_resource_id_, | 141 track_resource_id, |
141 premultipled_alpha, | 142 premultipled_alpha, |
142 uv_top_left, | 143 uv_top_left, |
143 uv_bottom_right, | 144 uv_bottom_right, |
144 SK_ColorTRANSPARENT, | 145 SK_ColorTRANSPARENT, |
145 opacity, | 146 opacity, |
146 flipped); | 147 flipped); |
147 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 148 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
148 } | 149 } |
149 } | 150 } |
150 | 151 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 thumb_rect = gfx::RectF(thumb_offset, vertical_adjust_, | 255 thumb_rect = gfx::RectF(thumb_offset, vertical_adjust_, |
255 thumb_length, thumb_thickness_); | 256 thumb_length, thumb_thickness_); |
256 } else { | 257 } else { |
257 thumb_rect = gfx::RectF(0.f, thumb_offset, | 258 thumb_rect = gfx::RectF(0.f, thumb_offset, |
258 thumb_thickness_, thumb_length); | 259 thumb_thickness_, thumb_length); |
259 } | 260 } |
260 | 261 |
261 return ScrollbarLayerRectToContentRect(thumb_rect); | 262 return ScrollbarLayerRectToContentRect(thumb_rect); |
262 } | 263 } |
263 | 264 |
264 void ScrollbarLayerImpl::DidLoseOutputSurface() { | |
265 track_resource_id_ = 0; | |
266 thumb_resource_id_ = 0; | |
267 } | |
268 | |
269 const char* ScrollbarLayerImpl::LayerTypeAsString() const { | 265 const char* ScrollbarLayerImpl::LayerTypeAsString() const { |
270 return "cc::ScrollbarLayerImpl"; | 266 return "cc::ScrollbarLayerImpl"; |
271 } | 267 } |
272 | 268 |
273 } // namespace cc | 269 } // namespace cc |
OLD | NEW |