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