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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 bool use_paint_properties = paint_properties_.source_frame_number == | 738 bool use_paint_properties = paint_properties_.source_frame_number == |
736 layer_tree_host_->source_frame_number(); | 739 layer_tree_host_->source_frame_number(); |
737 | 740 |
738 layer->SetAnchorPoint(anchor_point_); | 741 layer->SetAnchorPoint(anchor_point_); |
739 layer->SetAnchorPointZ(anchor_point_z_); | 742 layer->SetAnchorPointZ(anchor_point_z_); |
740 layer->SetBackgroundColor(background_color_); | 743 layer->SetBackgroundColor(background_color_); |
741 layer->SetBounds(use_paint_properties ? paint_properties_.bounds | 744 layer->SetBounds(use_paint_properties ? paint_properties_.bounds |
742 : bounds_); | 745 : bounds_); |
743 layer->SetContentBounds(content_bounds()); | 746 layer->SetContentBounds(content_bounds()); |
744 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 747 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
745 layer->SetDebugName(debug_name_); | 748 |
| 749 bool is_tracing; |
| 750 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 751 &is_tracing); |
| 752 if (is_tracing) |
| 753 layer->SetDebugName(DebugName()); |
| 754 else |
| 755 layer->SetDebugName(std::string()); |
| 756 |
746 layer->SetCompositingReasons(compositing_reasons_); | 757 layer->SetCompositingReasons(compositing_reasons_); |
747 layer->SetDoubleSided(double_sided_); | 758 layer->SetDoubleSided(double_sided_); |
748 layer->SetDrawCheckerboardForMissingTiles( | 759 layer->SetDrawCheckerboardForMissingTiles( |
749 draw_checkerboard_for_missing_tiles_); | 760 draw_checkerboard_for_missing_tiles_); |
750 layer->SetForceRenderSurface(force_render_surface_); | 761 layer->SetForceRenderSurface(force_render_surface_); |
751 layer->SetDrawsContent(DrawsContent()); | 762 layer->SetDrawsContent(DrawsContent()); |
752 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 763 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
753 layer->SetFilters(filters()); | 764 layer->SetFilters(filters()); |
754 layer->SetFilter(filter()); | 765 layer->SetFilter(filter()); |
755 layer->SetBackgroundFilters(background_filters()); | 766 layer->SetBackgroundFilters(background_filters()); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 DCHECK_EQ(layer_tree_host_->source_frame_number(), | 872 DCHECK_EQ(layer_tree_host_->source_frame_number(), |
862 paint_properties_.source_frame_number) << | 873 paint_properties_.source_frame_number) << |
863 "SavePaintProperties must be called for any layer that is painted."; | 874 "SavePaintProperties must be called for any layer that is painted."; |
864 return false; | 875 return false; |
865 } | 876 } |
866 | 877 |
867 bool Layer::NeedMoreUpdates() { | 878 bool Layer::NeedMoreUpdates() { |
868 return false; | 879 return false; |
869 } | 880 } |
870 | 881 |
871 void Layer::SetDebugName(const std::string& debug_name) { | 882 std::string Layer::DebugName() { |
872 debug_name_ = debug_name; | 883 return client_ ? client_->DebugName() : std::string(); |
873 SetNeedsCommit(); | |
874 } | 884 } |
875 | 885 |
876 void Layer::SetCompositingReasons(CompositingReasons reasons) { | 886 void Layer::SetCompositingReasons(CompositingReasons reasons) { |
877 compositing_reasons_ = reasons; | 887 compositing_reasons_ = reasons; |
878 } | 888 } |
879 | 889 |
880 void Layer::CreateRenderSurface() { | 890 void Layer::CreateRenderSurface() { |
881 DCHECK(!draw_properties_.render_surface); | 891 DCHECK(!draw_properties_.render_surface); |
882 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); | 892 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); |
883 draw_properties_.render_target = this; | 893 draw_properties_.render_target = this; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 983 |
974 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 984 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
975 return layer_tree_host_->rendering_stats_instrumentation(); | 985 return layer_tree_host_->rendering_stats_instrumentation(); |
976 } | 986 } |
977 | 987 |
978 bool Layer::SupportsLCDText() const { | 988 bool Layer::SupportsLCDText() const { |
979 return false; | 989 return false; |
980 } | 990 } |
981 | 991 |
982 } // namespace cc | 992 } // namespace cc |
OLD | NEW |