OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 draw_properties_.content_bounds, | 116 draw_properties_.content_bounds, |
117 draw_properties_.visible_content_rect, | 117 draw_properties_.visible_content_rect, |
118 draw_properties_.clip_rect, | 118 draw_properties_.clip_rect, |
119 draw_properties_.is_clipped, | 119 draw_properties_.is_clipped, |
120 draw_properties_.opacity); | 120 draw_properties_.opacity); |
121 return state.Pass(); | 121 return state.Pass(); |
122 } | 122 } |
123 | 123 |
124 void LayerImpl::WillDraw(ResourceProvider* resource_provider) { | 124 void LayerImpl::WillDraw(ResourceProvider* resource_provider) { |
125 #ifndef NDEBUG | 125 #ifndef NDEBUG |
126 // willDraw/didDraw must be matched. | 126 // WillDraw/DidDraw must be matched. |
127 DCHECK(!between_will_draw_and_did_draw_); | 127 DCHECK(!between_will_draw_and_did_draw_); |
128 between_will_draw_and_did_draw_ = true; | 128 between_will_draw_and_did_draw_ = true; |
129 #endif | 129 #endif |
130 } | 130 } |
131 | 131 |
132 void LayerImpl::DidDraw(ResourceProvider* resource_provider) { | 132 void LayerImpl::DidDraw(ResourceProvider* resource_provider) { |
133 #ifndef NDEBUG | 133 #ifndef NDEBUG |
134 DCHECK(between_will_draw_and_did_draw_); | 134 DCHECK(between_will_draw_and_did_draw_); |
135 between_will_draw_and_did_draw_ = false; | 135 between_will_draw_and_did_draw_ = false; |
136 #endif | 136 #endif |
(...skipping 25 matching lines...) Expand all Loading... |
162 const SharedQuadState* shared_quad_state, | 162 const SharedQuadState* shared_quad_state, |
163 AppendQuadsData* append_quads_data) const { | 163 AppendQuadsData* append_quads_data) const { |
164 if (!ShowDebugBorders()) | 164 if (!ShowDebugBorders()) |
165 return; | 165 return; |
166 | 166 |
167 SkColor color; | 167 SkColor color; |
168 float width; | 168 float width; |
169 GetDebugBorderProperties(&color, &width); | 169 GetDebugBorderProperties(&color, &width); |
170 | 170 |
171 gfx::Rect content_rect(content_bounds()); | 171 gfx::Rect content_rect(content_bounds()); |
172 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = | 172 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
173 DebugBorderDrawQuad::Create(); | 173 DebugBorderDrawQuad::Create(); |
174 debugBorderQuad->SetNew(shared_quad_state, content_rect, color, width); | 174 debug_border_quad->SetNew(shared_quad_state, content_rect, color, width); |
175 quad_sink->Append(debugBorderQuad.PassAs<DrawQuad>(), append_quads_data); | 175 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>(), append_quads_data); |
176 } | 176 } |
177 | 177 |
178 bool LayerImpl::HasDelegatedContent() const { | 178 bool LayerImpl::HasDelegatedContent() const { |
179 return false; | 179 return false; |
180 } | 180 } |
181 | 181 |
182 bool LayerImpl::HasContributingDelegatedRenderPasses() const { | 182 bool LayerImpl::HasContributingDelegatedRenderPasses() const { |
183 return false; | 183 return false; |
184 } | 184 } |
185 | 185 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 gfx::Vector2dF unscrolled = scroll_delta_ + scroll - new_delta; | 217 gfx::Vector2dF unscrolled = scroll_delta_ + scroll - new_delta; |
218 | 218 |
219 SetScrollDelta(new_delta); | 219 SetScrollDelta(new_delta); |
220 return unscrolled; | 220 return unscrolled; |
221 } | 221 } |
222 | 222 |
223 InputHandlerClient::ScrollStatus LayerImpl::TryScroll( | 223 InputHandlerClient::ScrollStatus LayerImpl::TryScroll( |
224 gfx::PointF screen_space_point, | 224 gfx::PointF screen_space_point, |
225 InputHandlerClient::ScrollInputType type) const { | 225 InputHandlerClient::ScrollInputType type) const { |
226 if (should_scroll_on_main_thread()) { | 226 if (should_scroll_on_main_thread()) { |
227 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed shouldScrollOnMainThread"); | 227 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); |
228 return InputHandlerClient::ScrollOnMainThread; | 228 return InputHandlerClient::ScrollOnMainThread; |
229 } | 229 } |
230 | 230 |
231 if (!screen_space_transform().IsInvertible()) { | 231 if (!screen_space_transform().IsInvertible()) { |
232 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform"); | 232 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); |
233 return InputHandlerClient::ScrollIgnored; | 233 return InputHandlerClient::ScrollIgnored; |
234 } | 234 } |
235 | 235 |
236 if (!non_fast_scrollable_region().IsEmpty()) { | 236 if (!non_fast_scrollable_region().IsEmpty()) { |
237 bool clipped = false; | 237 bool clipped = false; |
238 gfx::Transform inverse_screen_space_transform( | 238 gfx::Transform inverse_screen_space_transform( |
239 gfx::Transform::kSkipInitialization); | 239 gfx::Transform::kSkipInitialization); |
240 if (!screen_space_transform().GetInverse(&inverse_screen_space_transform)) { | 240 if (!screen_space_transform().GetInverse(&inverse_screen_space_transform)) { |
241 // TODO(shawnsingh): We shouldn't be applying a projection if screen space | 241 // TODO(shawnsingh): We shouldn't be applying a projection if screen space |
242 // transform is uninvertible here. Perhaps we should be returning | 242 // transform is uninvertible here. Perhaps we should be returning |
243 // ScrollOnMainThread in this case? | 243 // ScrollOnMainThread in this case? |
244 } | 244 } |
245 | 245 |
246 gfx::PointF hit_test_point_in_content_space = | 246 gfx::PointF hit_test_point_in_content_space = |
247 MathUtil::ProjectPoint(inverse_screen_space_transform, | 247 MathUtil::ProjectPoint(inverse_screen_space_transform, |
248 screen_space_point, | 248 screen_space_point, |
249 &clipped); | 249 &clipped); |
250 gfx::PointF hit_test_point_in_layer_space = | 250 gfx::PointF hit_test_point_in_layer_space = |
251 gfx::ScalePoint(hit_test_point_in_content_space, | 251 gfx::ScalePoint(hit_test_point_in_content_space, |
252 1.f / contents_scale_x(), | 252 1.f / contents_scale_x(), |
253 1.f / contents_scale_y()); | 253 1.f / contents_scale_y()); |
254 if (!clipped && | 254 if (!clipped && |
255 non_fast_scrollable_region().Contains( | 255 non_fast_scrollable_region().Contains( |
256 gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { | 256 gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { |
257 TRACE_EVENT0("cc", | 257 TRACE_EVENT0("cc", |
258 "LayerImpl::tryScroll: Failed nonFastScrollableRegion"); | 258 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); |
259 return InputHandlerClient::ScrollOnMainThread; | 259 return InputHandlerClient::ScrollOnMainThread; |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 if (type == InputHandlerClient::Wheel && have_wheel_event_handlers()) { | 263 if (type == InputHandlerClient::Wheel && have_wheel_event_handlers()) { |
264 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed wheelEventHandlers"); | 264 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers"); |
265 return InputHandlerClient::ScrollOnMainThread; | 265 return InputHandlerClient::ScrollOnMainThread; |
266 } | 266 } |
267 | 267 |
268 if (!scrollable()) { | 268 if (!scrollable()) { |
269 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); | 269 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); |
270 return InputHandlerClient::ScrollIgnored; | 270 return InputHandlerClient::ScrollIgnored; |
271 } | 271 } |
272 | 272 |
273 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { | 273 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { |
274 TRACE_EVENT0("cc", | 274 TRACE_EVENT0("cc", |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 342 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
343 layer->SetSublayerTransform(sublayer_transform_); | 343 layer->SetSublayerTransform(sublayer_transform_); |
344 layer->SetTransform(transform_); | 344 layer->SetTransform(transform_); |
345 | 345 |
346 layer->SetScrollable(scrollable_); | 346 layer->SetScrollable(scrollable_); |
347 layer->SetScrollOffset(scroll_offset_); | 347 layer->SetScrollOffset(scroll_offset_); |
348 layer->SetMaxScrollOffset(max_scroll_offset_); | 348 layer->SetMaxScrollOffset(max_scroll_offset_); |
349 | 349 |
350 // If the main thread commits multiple times before the impl thread actually | 350 // If the main thread commits multiple times before the impl thread actually |
351 // draws, then damage tracking will become incorrect if we simply clobber the | 351 // draws, then damage tracking will become incorrect if we simply clobber the |
352 // updateRect here. The LayerImpl's updateRect needs to accumulate (i.e. | 352 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
353 // union) any update changes that have occurred on the main thread. | 353 // union) any update changes that have occurred on the main thread. |
354 update_rect_.Union(layer->update_rect()); | 354 update_rect_.Union(layer->update_rect()); |
355 layer->set_update_rect(update_rect_); | 355 layer->set_update_rect(update_rect_); |
356 | 356 |
357 layer->SetScrollDelta(layer->scroll_delta() - layer->sent_scroll_delta()); | 357 layer->SetScrollDelta(layer->scroll_delta() - layer->sent_scroll_delta()); |
358 layer->SetSentScrollDelta(gfx::Vector2d()); | 358 layer->SetSentScrollDelta(gfx::Vector2d()); |
359 | 359 |
360 layer->SetStackingOrderChanged(stacking_order_changed_); | 360 layer->SetStackingOrderChanged(stacking_order_changed_); |
361 | 361 |
362 layer_animation_controller_->PushAnimationUpdatesTo( | 362 layer_animation_controller_->PushAnimationUpdatesTo( |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 | 957 |
958 } | 958 } |
959 | 959 |
960 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 960 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
961 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 961 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
962 AsValueInto(state.get()); | 962 AsValueInto(state.get()); |
963 return state.PassAs<base::Value>(); | 963 return state.PassAs<base::Value>(); |
964 } | 964 } |
965 | 965 |
966 } // namespace cc | 966 } // namespace cc |
OLD | NEW |