OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surface_layer_impl.h" | 5 #include "cc/layers/surface_layer_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/trace_event/trace_event_argument.h" | 9 #include "base/trace_event/trace_event_argument.h" |
10 #include "cc/debug/debug_colors.h" | 10 #include "cc/debug/debug_colors.h" |
11 #include "cc/quads/solid_color_draw_quad.h" | 11 #include "cc/quads/solid_color_draw_quad.h" |
12 #include "cc/quads/surface_draw_quad.h" | 12 #include "cc/quads/surface_draw_quad.h" |
13 #include "cc/trees/layer_tree_impl.h" | 13 #include "cc/trees/layer_tree_impl.h" |
14 #include "cc/trees/occlusion.h" | 14 #include "cc/trees/occlusion.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) | 18 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) |
19 : LayerImpl(tree_impl, id), surface_scale_(0.f) { | 19 : LayerImpl(tree_impl, id) { |
| 20 surface_info_.scale = 0; |
20 layer_tree_impl()->AddSurfaceLayer(this); | 21 layer_tree_impl()->AddSurfaceLayer(this); |
21 } | 22 } |
22 | 23 |
23 SurfaceLayerImpl::~SurfaceLayerImpl() { | 24 SurfaceLayerImpl::~SurfaceLayerImpl() { |
24 layer_tree_impl()->RemoveSurfaceLayer(this); | 25 layer_tree_impl()->RemoveSurfaceLayer(this); |
25 } | 26 } |
26 | 27 |
27 std::unique_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( | 28 std::unique_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( |
28 LayerTreeImpl* tree_impl) { | 29 LayerTreeImpl* tree_impl) { |
29 return SurfaceLayerImpl::Create(tree_impl, id()); | 30 return SurfaceLayerImpl::Create(tree_impl, id()); |
30 } | 31 } |
31 | 32 |
32 void SurfaceLayerImpl::SetSurfaceId(const SurfaceId& surface_id) { | 33 void SurfaceLayerImpl::SetSurfaceInfo(const SurfaceInfo& surface_info) { |
33 if (surface_id_ == surface_id) | 34 if (surface_info_ == surface_info) |
34 return; | 35 return; |
35 | 36 |
36 surface_id_ = surface_id; | 37 surface_info_ = surface_info; |
37 NoteLayerPropertyChanged(); | |
38 } | |
39 | |
40 void SurfaceLayerImpl::SetSurfaceScale(float scale) { | |
41 if (surface_scale_ == scale) | |
42 return; | |
43 | |
44 surface_scale_ = scale; | |
45 NoteLayerPropertyChanged(); | |
46 } | |
47 | |
48 void SurfaceLayerImpl::SetSurfaceSize(const gfx::Size& size) { | |
49 if (surface_size_ == size) | |
50 return; | |
51 | |
52 surface_size_ = size; | |
53 NoteLayerPropertyChanged(); | 38 NoteLayerPropertyChanged(); |
54 } | 39 } |
55 | 40 |
56 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 41 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
57 LayerImpl::PushPropertiesTo(layer); | 42 LayerImpl::PushPropertiesTo(layer); |
58 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 43 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
59 | 44 layer_impl->SetSurfaceInfo(surface_info_); |
60 layer_impl->SetSurfaceId(surface_id_); | |
61 layer_impl->SetSurfaceSize(surface_size_); | |
62 layer_impl->SetSurfaceScale(surface_scale_); | |
63 } | 45 } |
64 | 46 |
65 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, | 47 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, |
66 AppendQuadsData* append_quads_data) { | 48 AppendQuadsData* append_quads_data) { |
67 AppendRainbowDebugBorder(render_pass); | 49 AppendRainbowDebugBorder(render_pass); |
68 | 50 |
69 SharedQuadState* shared_quad_state = | 51 SharedQuadState* shared_quad_state = |
70 render_pass->CreateAndAppendSharedQuadState(); | 52 render_pass->CreateAndAppendSharedQuadState(); |
71 PopulateScaledSharedQuadState(shared_quad_state, surface_scale_); | 53 PopulateScaledSharedQuadState(shared_quad_state, surface_info_.scale); |
72 | 54 |
73 if (!surface_id_.is_valid()) | 55 if (!surface_id().is_valid()) |
74 return; | 56 return; |
75 | 57 |
76 gfx::Rect quad_rect(surface_size_); | 58 gfx::Rect quad_rect(surface_info_.size); |
77 gfx::Rect visible_quad_rect = | 59 gfx::Rect visible_quad_rect = |
78 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( | 60 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
79 quad_rect); | 61 quad_rect); |
80 if (visible_quad_rect.IsEmpty()) | 62 if (visible_quad_rect.IsEmpty()) |
81 return; | 63 return; |
82 SurfaceDrawQuad* quad = | 64 SurfaceDrawQuad* quad = |
83 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 65 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
84 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); | 66 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id()); |
85 } | 67 } |
86 | 68 |
87 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, | 69 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, |
88 float* width) const { | 70 float* width) const { |
89 *color = DebugColors::SurfaceLayerBorderColor(); | 71 *color = DebugColors::SurfaceLayerBorderColor(); |
90 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); | 72 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); |
91 } | 73 } |
92 | 74 |
93 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) { | 75 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) { |
94 if (!ShowDebugBorders()) | 76 if (!ShowDebugBorders()) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 SolidColorDrawQuad* right_quad = | 154 SolidColorDrawQuad* right_quad = |
173 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 155 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
174 right_quad->SetNew(shared_quad_state, right, right, | 156 right_quad->SetNew(shared_quad_state, right, right, |
175 colors[i % kNumColors], force_anti_aliasing_off); | 157 colors[i % kNumColors], force_anti_aliasing_off); |
176 } | 158 } |
177 } | 159 } |
178 } | 160 } |
179 | 161 |
180 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { | 162 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { |
181 LayerImpl::AsValueInto(dict); | 163 LayerImpl::AsValueInto(dict); |
182 dict->SetString("surface_id", surface_id_.ToString()); | 164 dict->SetString("surface_id", surface_id().ToString()); |
183 } | 165 } |
184 | 166 |
185 const char* SurfaceLayerImpl::LayerTypeAsString() const { | 167 const char* SurfaceLayerImpl::LayerTypeAsString() const { |
186 return "cc::SurfaceLayerImpl"; | 168 return "cc::SurfaceLayerImpl"; |
187 } | 169 } |
188 | 170 |
189 } // namespace cc | 171 } // namespace cc |
OLD | NEW |