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/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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace cc { | 34 namespace cc { |
35 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) | 35 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) |
36 : parent_(NULL), | 36 : parent_(NULL), |
37 scroll_parent_(NULL), | 37 scroll_parent_(NULL), |
38 clip_parent_(NULL), | 38 clip_parent_(NULL), |
39 mask_layer_id_(-1), | 39 mask_layer_id_(-1), |
40 replica_layer_id_(-1), | 40 replica_layer_id_(-1), |
41 layer_id_(id), | 41 layer_id_(id), |
42 layer_tree_impl_(tree_impl), | 42 layer_tree_impl_(tree_impl), |
43 anchor_point_(0.5f, 0.5f), | |
44 anchor_point_z_(0.f), | |
45 scroll_offset_delegate_(NULL), | 43 scroll_offset_delegate_(NULL), |
46 scroll_clip_layer_(NULL), | 44 scroll_clip_layer_(NULL), |
47 should_scroll_on_main_thread_(false), | 45 should_scroll_on_main_thread_(false), |
48 have_wheel_event_handlers_(false), | 46 have_wheel_event_handlers_(false), |
49 have_scroll_event_handlers_(false), | 47 have_scroll_event_handlers_(false), |
50 user_scrollable_horizontal_(true), | 48 user_scrollable_horizontal_(true), |
51 user_scrollable_vertical_(true), | 49 user_scrollable_vertical_(true), |
52 stacking_order_changed_(false), | 50 stacking_order_changed_(false), |
53 double_sided_(true), | 51 double_sided_(true), |
54 should_flatten_transform_(true), | 52 should_flatten_transform_(true), |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 481 |
484 bool LayerImpl::AreVisibleResourcesReady() const { | 482 bool LayerImpl::AreVisibleResourcesReady() const { |
485 return true; | 483 return true; |
486 } | 484 } |
487 | 485 |
488 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 486 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
489 return LayerImpl::Create(tree_impl, layer_id_); | 487 return LayerImpl::Create(tree_impl, layer_id_); |
490 } | 488 } |
491 | 489 |
492 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 490 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
493 layer->SetAnchorPoint(anchor_point_); | 491 layer->SetTransformOrigin(transform_origin_); |
494 layer->SetAnchorPointZ(anchor_point_z_); | |
495 layer->SetBackgroundColor(background_color_); | 492 layer->SetBackgroundColor(background_color_); |
496 layer->SetBounds(bounds_); | 493 layer->SetBounds(bounds_); |
497 layer->SetContentBounds(content_bounds()); | 494 layer->SetContentBounds(content_bounds()); |
498 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 495 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
499 layer->SetDoubleSided(double_sided_); | 496 layer->SetDoubleSided(double_sided_); |
500 layer->SetDrawCheckerboardForMissingTiles( | 497 layer->SetDrawCheckerboardForMissingTiles( |
501 draw_checkerboard_for_missing_tiles_); | 498 draw_checkerboard_for_missing_tiles_); |
502 layer->SetForceRenderSurface(force_render_surface_); | 499 layer->SetForceRenderSurface(force_render_surface_); |
503 layer->SetDrawsContent(DrawsContent()); | 500 layer->SetDrawsContent(DrawsContent()); |
504 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 501 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 } | 843 } |
847 | 844 |
848 void LayerImpl::SetHideLayerAndSubtree(bool hide) { | 845 void LayerImpl::SetHideLayerAndSubtree(bool hide) { |
849 if (hide_layer_and_subtree_ == hide) | 846 if (hide_layer_and_subtree_ == hide) |
850 return; | 847 return; |
851 | 848 |
852 hide_layer_and_subtree_ = hide; | 849 hide_layer_and_subtree_ = hide; |
853 NoteLayerPropertyChangedForSubtree(); | 850 NoteLayerPropertyChangedForSubtree(); |
854 } | 851 } |
855 | 852 |
856 void LayerImpl::SetAnchorPoint(const gfx::PointF& anchor_point) { | 853 void LayerImpl::SetTransformOrigin(const gfx::Point3F& transform_origin) { |
857 if (anchor_point_ == anchor_point) | 854 if (transform_origin_ == transform_origin) |
858 return; | 855 return; |
859 | 856 transform_origin_ = transform_origin; |
860 anchor_point_ = anchor_point; | |
861 NoteLayerPropertyChangedForSubtree(); | 857 NoteLayerPropertyChangedForSubtree(); |
862 } | 858 } |
863 | 859 |
864 void LayerImpl::SetAnchorPointZ(float anchor_point_z) { | |
865 if (anchor_point_z_ == anchor_point_z) | |
866 return; | |
867 | |
868 anchor_point_z_ = anchor_point_z; | |
869 NoteLayerPropertyChangedForSubtree(); | |
870 } | |
871 | |
872 void LayerImpl::SetBackgroundColor(SkColor background_color) { | 860 void LayerImpl::SetBackgroundColor(SkColor background_color) { |
873 if (background_color_ == background_color) | 861 if (background_color_ == background_color) |
874 return; | 862 return; |
875 | 863 |
876 background_color_ = background_color; | 864 background_color_ = background_color; |
877 NoteLayerPropertyChanged(); | 865 NoteLayerPropertyChanged(); |
878 } | 866 } |
879 | 867 |
880 SkColor LayerImpl::SafeOpaqueBackgroundColor() const { | 868 SkColor LayerImpl::SafeOpaqueBackgroundColor() const { |
881 SkColor color = background_color(); | 869 SkColor color = background_color(); |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 state, | 1408 state, |
1421 "cc::LayerImpl", | 1409 "cc::LayerImpl", |
1422 LayerTypeAsString(), | 1410 LayerTypeAsString(), |
1423 this); | 1411 this); |
1424 state->SetInteger("layer_id", id()); | 1412 state->SetInteger("layer_id", id()); |
1425 state->Set("bounds", MathUtil::AsValue(bounds_).release()); | 1413 state->Set("bounds", MathUtil::AsValue(bounds_).release()); |
1426 state->Set("position", MathUtil::AsValue(position_).release()); | 1414 state->Set("position", MathUtil::AsValue(position_).release()); |
1427 state->SetInteger("draws_content", DrawsContent()); | 1415 state->SetInteger("draws_content", DrawsContent()); |
1428 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); | 1416 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); |
1429 state->Set("scroll_offset", MathUtil::AsValue(scroll_offset_).release()); | 1417 state->Set("scroll_offset", MathUtil::AsValue(scroll_offset_).release()); |
| 1418 state->Set("transform_origin", |
| 1419 MathUtil::AsValue(transform_origin_).release()); |
1430 | 1420 |
1431 bool clipped; | 1421 bool clipped; |
1432 gfx::QuadF layer_quad = MathUtil::MapQuad( | 1422 gfx::QuadF layer_quad = MathUtil::MapQuad( |
1433 screen_space_transform(), | 1423 screen_space_transform(), |
1434 gfx::QuadF(gfx::Rect(content_bounds())), | 1424 gfx::QuadF(gfx::Rect(content_bounds())), |
1435 &clipped); | 1425 &clipped); |
1436 state->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); | 1426 state->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); |
1437 | 1427 |
1438 if (!touch_event_handler_region_.IsEmpty()) { | 1428 if (!touch_event_handler_region_.IsEmpty()) { |
1439 state->Set("touch_event_handler_region", | 1429 state->Set("touch_event_handler_region", |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1500 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1511 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1501 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1512 AsValueInto(state.get()); | 1502 AsValueInto(state.get()); |
1513 return state.PassAs<base::Value>(); | 1503 return state.PassAs<base::Value>(); |
1514 } | 1504 } |
1515 | 1505 |
1516 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1506 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1517 benchmark->RunOnLayer(this); | 1507 benchmark->RunOnLayer(this); |
1518 } | 1508 } |
1519 } // namespace cc | 1509 } // namespace cc |
OLD | NEW |