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