OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | |
9 #include "base/location.h" | 10 #include "base/location.h" |
10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "cc/animation/animation.h" | 13 #include "cc/animation/animation.h" |
13 #include "cc/animation/animation_events.h" | 14 #include "cc/animation/animation_events.h" |
14 #include "cc/animation/layer_animation_controller.h" | 15 #include "cc/animation/layer_animation_controller.h" |
16 #include "cc/layers/layer_client.h" | |
15 #include "cc/layers/layer_impl.h" | 17 #include "cc/layers/layer_impl.h" |
16 #include "cc/output/copy_output_request.h" | 18 #include "cc/output/copy_output_request.h" |
17 #include "cc/output/copy_output_result.h" | 19 #include "cc/output/copy_output_result.h" |
18 #include "cc/trees/layer_tree_host.h" | 20 #include "cc/trees/layer_tree_host.h" |
19 #include "cc/trees/layer_tree_impl.h" | 21 #include "cc/trees/layer_tree_impl.h" |
20 #include "third_party/skia/include/core/SkImageFilter.h" | 22 #include "third_party/skia/include/core/SkImageFilter.h" |
21 #include "ui/gfx/rect_conversions.h" | 23 #include "ui/gfx/rect_conversions.h" |
22 | 24 |
23 namespace cc { | 25 namespace cc { |
24 | 26 |
(...skipping 23 matching lines...) Expand all Loading... | |
48 is_drawable_(false), | 50 is_drawable_(false), |
49 hide_layer_and_subtree_(false), | 51 hide_layer_and_subtree_(false), |
50 masks_to_bounds_(false), | 52 masks_to_bounds_(false), |
51 contents_opaque_(false), | 53 contents_opaque_(false), |
52 double_sided_(true), | 54 double_sided_(true), |
53 preserves_3d_(false), | 55 preserves_3d_(false), |
54 use_parent_backface_visibility_(false), | 56 use_parent_backface_visibility_(false), |
55 draw_checkerboard_for_missing_tiles_(false), | 57 draw_checkerboard_for_missing_tiles_(false), |
56 force_render_surface_(false), | 58 force_render_surface_(false), |
57 replica_layer_(NULL), | 59 replica_layer_(NULL), |
58 raster_scale_(0.f) { | 60 raster_scale_(0.f), |
61 client_(NULL) { | |
59 if (layer_id_ < 0) { | 62 if (layer_id_ < 0) { |
60 s_next_layer_id = 1; | 63 s_next_layer_id = 1; |
61 layer_id_ = s_next_layer_id++; | 64 layer_id_ = s_next_layer_id++; |
62 } | 65 } |
63 | 66 |
64 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 67 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
65 layer_animation_controller_->AddValueObserver(this); | 68 layer_animation_controller_->AddValueObserver(this); |
66 } | 69 } |
67 | 70 |
68 Layer::~Layer() { | 71 Layer::~Layer() { |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 base::Passed(&result))); | 728 base::Passed(&result))); |
726 } | 729 } |
727 | 730 |
728 void Layer::PushPropertiesTo(LayerImpl* layer) { | 731 void Layer::PushPropertiesTo(LayerImpl* layer) { |
729 layer->SetAnchorPoint(anchor_point_); | 732 layer->SetAnchorPoint(anchor_point_); |
730 layer->SetAnchorPointZ(anchor_point_z_); | 733 layer->SetAnchorPointZ(anchor_point_z_); |
731 layer->SetBackgroundColor(background_color_); | 734 layer->SetBackgroundColor(background_color_); |
732 layer->SetBounds(paint_properties_.bounds); | 735 layer->SetBounds(paint_properties_.bounds); |
733 layer->SetContentBounds(content_bounds()); | 736 layer->SetContentBounds(content_bounds()); |
734 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 737 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
735 layer->SetDebugName(debug_name_); | 738 |
739 bool is_tracing; | |
740 TRACE_EVENT_CATEGORY_GROUP_ENABLED("cc", &is_tracing); | |
enne (OOO)
2013/08/02 17:58:17
I think "cc" should instead be TRACE_DISABLED_BY_D
qiankun
2013/08/05 06:54:15
Done.
| |
741 if (is_tracing) | |
742 layer->SetDebugName(DebugName()); | |
743 else | |
744 layer->SetDebugName(std::string()); | |
745 | |
736 layer->SetCompositingReasons(compositing_reasons_); | 746 layer->SetCompositingReasons(compositing_reasons_); |
737 layer->SetDoubleSided(double_sided_); | 747 layer->SetDoubleSided(double_sided_); |
738 layer->SetDrawCheckerboardForMissingTiles( | 748 layer->SetDrawCheckerboardForMissingTiles( |
739 draw_checkerboard_for_missing_tiles_); | 749 draw_checkerboard_for_missing_tiles_); |
740 layer->SetForceRenderSurface(force_render_surface_); | 750 layer->SetForceRenderSurface(force_render_surface_); |
741 layer->SetDrawsContent(DrawsContent()); | 751 layer->SetDrawsContent(DrawsContent()); |
742 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 752 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
743 layer->SetFilters(filters()); | 753 layer->SetFilters(filters()); |
744 layer->SetFilter(filter()); | 754 layer->SetFilter(filter()); |
745 layer->SetBackgroundFilters(background_filters()); | 755 layer->SetBackgroundFilters(background_filters()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 | 858 |
849 bool Layer::NeedMoreUpdates() { | 859 bool Layer::NeedMoreUpdates() { |
850 return false; | 860 return false; |
851 } | 861 } |
852 | 862 |
853 void Layer::SetDebugName(const std::string& debug_name) { | 863 void Layer::SetDebugName(const std::string& debug_name) { |
854 debug_name_ = debug_name; | 864 debug_name_ = debug_name; |
855 SetNeedsCommit(); | 865 SetNeedsCommit(); |
856 } | 866 } |
857 | 867 |
868 std::string Layer::DebugName() { | |
869 return client_ ? client_->DebugName() : std::string(); | |
870 } | |
871 | |
858 void Layer::SetCompositingReasons(CompositingReasons reasons) { | 872 void Layer::SetCompositingReasons(CompositingReasons reasons) { |
859 compositing_reasons_ = reasons; | 873 compositing_reasons_ = reasons; |
860 } | 874 } |
861 | 875 |
862 void Layer::CreateRenderSurface() { | 876 void Layer::CreateRenderSurface() { |
863 DCHECK(!draw_properties_.render_surface); | 877 DCHECK(!draw_properties_.render_surface); |
864 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); | 878 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); |
865 draw_properties_.render_target = this; | 879 draw_properties_.render_target = this; |
866 } | 880 } |
867 | 881 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
955 | 969 |
956 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 970 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
957 return layer_tree_host_->rendering_stats_instrumentation(); | 971 return layer_tree_host_->rendering_stats_instrumentation(); |
958 } | 972 } |
959 | 973 |
960 bool Layer::SupportsLCDText() const { | 974 bool Layer::SupportsLCDText() const { |
961 return false; | 975 return false; |
962 } | 976 } |
963 | 977 |
964 } // namespace cc | 978 } // namespace cc |
OLD | NEW |