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/debug/trace_event_argument.h" | 7 #include "base/debug/trace_event_argument.h" |
8 #include "cc/debug/debug_colors.h" | 8 #include "cc/debug/debug_colors.h" |
9 #include "cc/quads/surface_draw_quad.h" | 9 #include "cc/quads/surface_draw_quad.h" |
10 #include "cc/trees/occlusion_tracker.h" | 10 #include "cc/trees/occlusion.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) | 14 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) |
15 : LayerImpl(tree_impl, id) { | 15 : LayerImpl(tree_impl, id) { |
16 } | 16 } |
17 | 17 |
18 SurfaceLayerImpl::~SurfaceLayerImpl() {} | 18 SurfaceLayerImpl::~SurfaceLayerImpl() {} |
19 | 19 |
20 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( | 20 scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( |
21 LayerTreeImpl* tree_impl) { | 21 LayerTreeImpl* tree_impl) { |
22 return SurfaceLayerImpl::Create(tree_impl, id()); | 22 return SurfaceLayerImpl::Create(tree_impl, id()); |
23 } | 23 } |
24 | 24 |
25 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) { | 25 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) { |
26 if (surface_id_ == surface_id) | 26 if (surface_id_ == surface_id) |
27 return; | 27 return; |
28 | 28 |
29 surface_id_ = surface_id; | 29 surface_id_ = surface_id; |
30 NoteLayerPropertyChanged(); | 30 NoteLayerPropertyChanged(); |
31 } | 31 } |
32 | 32 |
33 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 33 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
34 LayerImpl::PushPropertiesTo(layer); | 34 LayerImpl::PushPropertiesTo(layer); |
35 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 35 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
36 | 36 |
37 layer_impl->SetSurfaceId(surface_id_); | 37 layer_impl->SetSurfaceId(surface_id_); |
38 } | 38 } |
39 | 39 |
40 void SurfaceLayerImpl::AppendQuads( | 40 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, |
41 RenderPass* render_pass, | 41 const Occlusion& occlusion_in_content_space, |
42 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 42 AppendQuadsData* append_quads_data) { |
43 AppendQuadsData* append_quads_data) { | |
44 SharedQuadState* shared_quad_state = | 43 SharedQuadState* shared_quad_state = |
45 render_pass->CreateAndAppendSharedQuadState(); | 44 render_pass->CreateAndAppendSharedQuadState(); |
46 PopulateSharedQuadState(shared_quad_state); | 45 PopulateSharedQuadState(shared_quad_state); |
47 | 46 |
48 AppendDebugBorderQuad( | 47 AppendDebugBorderQuad( |
49 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 48 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
50 | 49 |
51 if (surface_id_.is_null()) | 50 if (surface_id_.is_null()) |
52 return; | 51 return; |
53 | 52 |
54 gfx::Rect quad_rect(content_bounds()); | 53 gfx::Rect quad_rect(content_bounds()); |
55 gfx::Rect visible_quad_rect = | 54 gfx::Rect visible_quad_rect = |
56 occlusion_tracker.GetCurrentOcclusionForLayer( | 55 occlusion_in_content_space.GetUnoccludedContentRect(quad_rect); |
57 draw_properties().target_space_transform) | |
58 .GetUnoccludedContentRect(quad_rect); | |
59 if (visible_quad_rect.IsEmpty()) | 56 if (visible_quad_rect.IsEmpty()) |
60 return; | 57 return; |
61 SurfaceDrawQuad* quad = | 58 SurfaceDrawQuad* quad = |
62 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 59 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
63 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); | 60 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); |
64 } | 61 } |
65 | 62 |
66 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, | 63 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, |
67 float* width) const { | 64 float* width) const { |
68 *color = DebugColors::SurfaceLayerBorderColor(); | 65 *color = DebugColors::SurfaceLayerBorderColor(); |
69 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); | 66 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); |
70 } | 67 } |
71 | 68 |
72 void SurfaceLayerImpl::AsValueInto(base::debug::TracedValue* dict) const { | 69 void SurfaceLayerImpl::AsValueInto(base::debug::TracedValue* dict) const { |
73 LayerImpl::AsValueInto(dict); | 70 LayerImpl::AsValueInto(dict); |
74 dict->SetInteger("surface_id", surface_id_.id); | 71 dict->SetInteger("surface_id", surface_id_.id); |
75 } | 72 } |
76 | 73 |
77 const char* SurfaceLayerImpl::LayerTypeAsString() const { | 74 const char* SurfaceLayerImpl::LayerTypeAsString() const { |
78 return "cc::SurfaceLayerImpl"; | 75 return "cc::SurfaceLayerImpl"; |
79 } | 76 } |
80 | 77 |
81 } // namespace cc | 78 } // namespace cc |
OLD | NEW |