OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "cc/layers/surface_layer.h" | 22 #include "cc/layers/surface_layer.h" |
23 #include "cc/layers/texture_layer.h" | 23 #include "cc/layers/texture_layer.h" |
24 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
25 #include "cc/output/delegated_frame_data.h" | 25 #include "cc/output/delegated_frame_data.h" |
26 #include "cc/output/filter_operation.h" | 26 #include "cc/output/filter_operation.h" |
27 #include "cc/output/filter_operations.h" | 27 #include "cc/output/filter_operations.h" |
28 #include "cc/resources/transferable_resource.h" | 28 #include "cc/resources/transferable_resource.h" |
29 #include "ui/compositor/compositor_switches.h" | 29 #include "ui/compositor/compositor_switches.h" |
30 #include "ui/compositor/dip_util.h" | 30 #include "ui/compositor/dip_util.h" |
31 #include "ui/compositor/layer_animator.h" | 31 #include "ui/compositor/layer_animator.h" |
| 32 #include "ui/compositor/paint_context.h" |
32 #include "ui/gfx/animation/animation.h" | 33 #include "ui/gfx/animation/animation.h" |
33 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
34 #include "ui/gfx/display.h" | 35 #include "ui/gfx/display.h" |
35 #include "ui/gfx/geometry/point3_f.h" | 36 #include "ui/gfx/geometry/point3_f.h" |
36 #include "ui/gfx/geometry/point_conversions.h" | 37 #include "ui/gfx/geometry/point_conversions.h" |
37 #include "ui/gfx/geometry/size_conversions.h" | 38 #include "ui/gfx/geometry/size_conversions.h" |
38 #include "ui/gfx/interpolated_transform.h" | 39 #include "ui/gfx/interpolated_transform.h" |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
(...skipping 29 matching lines...) Expand all Loading... |
71 layer_brightness_(0.0f), | 72 layer_brightness_(0.0f), |
72 layer_grayscale_(0.0f), | 73 layer_grayscale_(0.0f), |
73 layer_inverted_(false), | 74 layer_inverted_(false), |
74 layer_mask_(NULL), | 75 layer_mask_(NULL), |
75 layer_mask_back_link_(NULL), | 76 layer_mask_back_link_(NULL), |
76 zoom_(1), | 77 zoom_(1), |
77 zoom_inset_(0), | 78 zoom_inset_(0), |
78 delegate_(NULL), | 79 delegate_(NULL), |
79 owner_(NULL), | 80 owner_(NULL), |
80 cc_layer_(NULL), | 81 cc_layer_(NULL), |
81 device_scale_factor_(1.0f), | 82 device_scale_factor_(1.0f) { |
82 inside_paint_(false) { | |
83 CreateCcLayer(); | 83 CreateCcLayer(); |
84 } | 84 } |
85 | 85 |
86 Layer::Layer(LayerType type) | 86 Layer::Layer(LayerType type) |
87 : type_(type), | 87 : type_(type), |
88 compositor_(NULL), | 88 compositor_(NULL), |
89 parent_(NULL), | 89 parent_(NULL), |
90 visible_(true), | 90 visible_(true), |
91 force_render_surface_(false), | 91 force_render_surface_(false), |
92 fills_bounds_opaquely_(true), | 92 fills_bounds_opaquely_(true), |
93 fills_bounds_completely_(false), | 93 fills_bounds_completely_(false), |
94 background_blur_radius_(0), | 94 background_blur_radius_(0), |
95 layer_saturation_(0.0f), | 95 layer_saturation_(0.0f), |
96 layer_brightness_(0.0f), | 96 layer_brightness_(0.0f), |
97 layer_grayscale_(0.0f), | 97 layer_grayscale_(0.0f), |
98 layer_inverted_(false), | 98 layer_inverted_(false), |
99 layer_mask_(NULL), | 99 layer_mask_(NULL), |
100 layer_mask_back_link_(NULL), | 100 layer_mask_back_link_(NULL), |
101 zoom_(1), | 101 zoom_(1), |
102 zoom_inset_(0), | 102 zoom_inset_(0), |
103 delegate_(NULL), | 103 delegate_(NULL), |
104 owner_(NULL), | 104 owner_(NULL), |
105 cc_layer_(NULL), | 105 cc_layer_(NULL), |
106 device_scale_factor_(1.0f), | 106 device_scale_factor_(1.0f) { |
107 inside_paint_(false) { | |
108 CreateCcLayer(); | 107 CreateCcLayer(); |
109 } | 108 } |
110 | 109 |
111 Layer::~Layer() { | 110 Layer::~Layer() { |
112 // Destroying the animator may cause observers to use the layer (and | 111 // Destroying the animator may cause observers to use the layer (and |
113 // indirectly the WebLayer). Destroy the animator first so that the WebLayer | 112 // indirectly the WebLayer). Destroy the animator first so that the WebLayer |
114 // is still around. | 113 // is still around. |
115 if (animator_.get()) | 114 if (animator_.get()) |
116 animator_->SetDelegate(NULL); | 115 animator_->SetDelegate(NULL); |
117 animator_ = NULL; | 116 animator_ = NULL; |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 cc_layer_->RequestCopyOfOutput(request.Pass()); | 740 cc_layer_->RequestCopyOfOutput(request.Pass()); |
742 } | 741 } |
743 | 742 |
744 void Layer::PaintContents( | 743 void Layer::PaintContents( |
745 SkCanvas* sk_canvas, | 744 SkCanvas* sk_canvas, |
746 const gfx::Rect& clip, | 745 const gfx::Rect& clip, |
747 ContentLayerClient::PaintingControlSetting painting_control) { | 746 ContentLayerClient::PaintingControlSetting painting_control) { |
748 TRACE_EVENT1("ui", "Layer::PaintContents", "name", name_); | 747 TRACE_EVENT1("ui", "Layer::PaintContents", "name", name_); |
749 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( | 748 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( |
750 sk_canvas, device_scale_factor_)); | 749 sk_canvas, device_scale_factor_)); |
751 if (delegate_) { | 750 if (delegate_) |
752 base::AutoReset<bool> inside_paint(&inside_paint_, true); | 751 delegate_->OnPaintLayer(PaintContext(canvas.get(), clip)); |
753 paint_rect_ = clip; | |
754 delegate_->OnPaintLayer(canvas.get()); | |
755 } | |
756 } | 752 } |
757 | 753 |
758 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( | 754 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( |
759 const gfx::Rect& clip, | 755 const gfx::Rect& clip, |
760 ContentLayerClient::PaintingControlSetting painting_control) { | 756 ContentLayerClient::PaintingControlSetting painting_control) { |
761 NOTIMPLEMENTED(); | 757 NOTIMPLEMENTED(); |
762 return cc::DisplayItemList::Create(); | 758 return cc::DisplayItemList::Create(); |
763 } | 759 } |
764 | 760 |
765 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } | 761 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } |
(...skipping 10 matching lines...) Expand all Loading... |
776 } | 772 } |
777 | 773 |
778 void Layer::SetForceRenderSurface(bool force) { | 774 void Layer::SetForceRenderSurface(bool force) { |
779 if (force_render_surface_ == force) | 775 if (force_render_surface_ == force) |
780 return; | 776 return; |
781 | 777 |
782 force_render_surface_ = force; | 778 force_render_surface_ = force; |
783 cc_layer_->SetForceRenderSurface(force_render_surface_); | 779 cc_layer_->SetForceRenderSurface(force_render_surface_); |
784 } | 780 } |
785 | 781 |
786 gfx::Rect Layer::PaintRect() const { | |
787 DCHECK(inside_paint_); | |
788 return paint_rect_; | |
789 } | |
790 | |
791 class LayerDebugInfo : public base::trace_event::ConvertableToTraceFormat { | 782 class LayerDebugInfo : public base::trace_event::ConvertableToTraceFormat { |
792 public: | 783 public: |
793 explicit LayerDebugInfo(std::string name) : name_(name) { } | 784 explicit LayerDebugInfo(std::string name) : name_(name) { } |
794 void AppendAsTraceFormat(std::string* out) const override { | 785 void AppendAsTraceFormat(std::string* out) const override { |
795 base::DictionaryValue dictionary; | 786 base::DictionaryValue dictionary; |
796 dictionary.SetString("layer_name", name_); | 787 dictionary.SetString("layer_name", name_); |
797 base::JSONWriter::Write(&dictionary, out); | 788 base::JSONWriter::Write(&dictionary, out); |
798 } | 789 } |
799 | 790 |
800 private: | 791 private: |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 children_.end(), | 1082 children_.end(), |
1092 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), | 1083 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), |
1093 collection)); | 1084 collection)); |
1094 } | 1085 } |
1095 | 1086 |
1096 bool Layer::IsAnimating() const { | 1087 bool Layer::IsAnimating() const { |
1097 return animator_.get() && animator_->is_animating(); | 1088 return animator_.get() && animator_->is_animating(); |
1098 } | 1089 } |
1099 | 1090 |
1100 } // namespace ui | 1091 } // namespace ui |
OLD | NEW |