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 "base/trace_event/trace_event_argument.h" | 7 #include "base/trace_event/trace_event_argument.h" |
8 #include "cc/debug/debug_colors.h" | 8 #include "cc/debug/debug_colors.h" |
9 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
| 11 #include "cc/trees/layer_tree_impl.h" |
11 #include "cc/trees/occlusion.h" | 12 #include "cc/trees/occlusion.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 | 15 |
15 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) | 16 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) |
16 : LayerImpl(tree_impl, id), surface_scale_(0.f) { | 17 : LayerImpl(tree_impl, id), surface_scale_(0.f) { |
| 18 layer_tree_impl()->AddSurfaceLayer(this); |
17 } | 19 } |
18 | 20 |
19 SurfaceLayerImpl::~SurfaceLayerImpl() {} | 21 SurfaceLayerImpl::~SurfaceLayerImpl() { |
| 22 layer_tree_impl()->RemoveSurfaceLayer(this); |
| 23 } |
20 | 24 |
21 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( | 25 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( |
22 LayerTreeImpl* tree_impl) { | 26 LayerTreeImpl* tree_impl) { |
23 return SurfaceLayerImpl::Create(tree_impl, id()); | 27 return SurfaceLayerImpl::Create(tree_impl, id()); |
24 } | 28 } |
25 | 29 |
26 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) { | 30 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) { |
27 if (surface_id_ == surface_id) | 31 if (surface_id_ == surface_id) |
28 return; | 32 return; |
29 | 33 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 73 |
70 gfx::Rect quad_rect(surface_size_); | 74 gfx::Rect quad_rect(surface_size_); |
71 gfx::Rect visible_quad_rect = | 75 gfx::Rect visible_quad_rect = |
72 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( | 76 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
73 quad_rect); | 77 quad_rect); |
74 if (visible_quad_rect.IsEmpty()) | 78 if (visible_quad_rect.IsEmpty()) |
75 return; | 79 return; |
76 SurfaceDrawQuad* quad = | 80 SurfaceDrawQuad* quad = |
77 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 81 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
78 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); | 82 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); |
79 render_pass->referenced_surfaces.push_back(surface_id_); | |
80 } | 83 } |
81 | 84 |
82 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, | 85 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, |
83 float* width) const { | 86 float* width) const { |
84 *color = DebugColors::SurfaceLayerBorderColor(); | 87 *color = DebugColors::SurfaceLayerBorderColor(); |
85 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); | 88 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); |
86 } | 89 } |
87 | 90 |
88 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) { | 91 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) { |
89 if (!ShowDebugBorders()) | 92 if (!ShowDebugBorders()) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { | 178 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { |
176 LayerImpl::AsValueInto(dict); | 179 LayerImpl::AsValueInto(dict); |
177 dict->SetInteger("surface_id", surface_id_.id); | 180 dict->SetInteger("surface_id", surface_id_.id); |
178 } | 181 } |
179 | 182 |
180 const char* SurfaceLayerImpl::LayerTypeAsString() const { | 183 const char* SurfaceLayerImpl::LayerTypeAsString() const { |
181 return "cc::SurfaceLayerImpl"; | 184 return "cc::SurfaceLayerImpl"; |
182 } | 185 } |
183 | 186 |
184 } // namespace cc | 187 } // namespace cc |
OLD | NEW |