OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui_resource_layer_impl.h" | 5 #include "cc/layers/ui_resource_layer_impl.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/layers/quad_sink.h" | |
11 #include "cc/quads/texture_draw_quad.h" | 10 #include "cc/quads/texture_draw_quad.h" |
12 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
| 12 #include "cc/trees/occlusion_tracker.h" |
13 #include "ui/gfx/rect_f.h" | 13 #include "ui/gfx/rect_f.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 UIResourceLayerImpl::UIResourceLayerImpl(LayerTreeImpl* tree_impl, int id) | 17 UIResourceLayerImpl::UIResourceLayerImpl(LayerTreeImpl* tree_impl, int id) |
18 : LayerImpl(tree_impl, id), | 18 : LayerImpl(tree_impl, id), |
19 ui_resource_id_(0), | 19 ui_resource_id_(0), |
20 uv_top_left_(0.f, 0.f), | 20 uv_top_left_(0.f, 0.f), |
21 uv_bottom_right_(1.f, 1.f) { | 21 uv_bottom_right_(1.f, 1.f) { |
22 vertex_opacity_[0] = 1.0f; | 22 vertex_opacity_[0] = 1.0f; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 NoteLayerPropertyChanged(); | 84 NoteLayerPropertyChanged(); |
85 } | 85 } |
86 | 86 |
87 bool UIResourceLayerImpl::WillDraw(DrawMode draw_mode, | 87 bool UIResourceLayerImpl::WillDraw(DrawMode draw_mode, |
88 ResourceProvider* resource_provider) { | 88 ResourceProvider* resource_provider) { |
89 if (!ui_resource_id_ || draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 89 if (!ui_resource_id_ || draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
90 return false; | 90 return false; |
91 return LayerImpl::WillDraw(draw_mode, resource_provider); | 91 return LayerImpl::WillDraw(draw_mode, resource_provider); |
92 } | 92 } |
93 | 93 |
94 void UIResourceLayerImpl::AppendQuads(QuadSink* quad_sink, | 94 void UIResourceLayerImpl::AppendQuads( |
95 AppendQuadsData* append_quads_data) { | 95 RenderPass* render_pass, |
96 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 96 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 97 AppendQuadsData* append_quads_data) { |
| 98 SharedQuadState* shared_quad_state = |
| 99 render_pass->CreateAndAppendSharedQuadState(); |
97 PopulateSharedQuadState(shared_quad_state); | 100 PopulateSharedQuadState(shared_quad_state); |
98 | 101 |
99 AppendDebugBorderQuad( | 102 AppendDebugBorderQuad( |
100 quad_sink, content_bounds(), shared_quad_state, append_quads_data); | 103 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
101 | 104 |
102 if (!ui_resource_id_) | 105 if (!ui_resource_id_) |
103 return; | 106 return; |
104 | 107 |
105 ResourceProvider::ResourceId resource = | 108 ResourceProvider::ResourceId resource = |
106 layer_tree_impl()->ResourceIdForUIResource(ui_resource_id_); | 109 layer_tree_impl()->ResourceIdForUIResource(ui_resource_id_); |
107 | 110 |
108 if (!resource) | 111 if (!resource) |
109 return; | 112 return; |
110 | 113 |
111 static const bool flipped = false; | 114 static const bool flipped = false; |
112 static const bool premultiplied_alpha = true; | 115 static const bool premultiplied_alpha = true; |
113 | 116 |
114 DCHECK(!bounds().IsEmpty()); | 117 DCHECK(!bounds().IsEmpty()); |
115 | 118 |
116 bool opaque = layer_tree_impl()->IsUIResourceOpaque(ui_resource_id_) || | 119 bool opaque = layer_tree_impl()->IsUIResourceOpaque(ui_resource_id_) || |
117 contents_opaque(); | 120 contents_opaque(); |
118 | 121 |
119 gfx::Rect quad_rect(bounds()); | 122 gfx::Rect quad_rect(bounds()); |
120 gfx::Rect opaque_rect(opaque ? quad_rect : gfx::Rect()); | 123 gfx::Rect opaque_rect(opaque ? quad_rect : gfx::Rect()); |
121 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( | 124 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( |
122 quad_rect, draw_properties().target_space_transform); | 125 quad_rect, draw_properties().target_space_transform); |
123 if (visible_quad_rect.IsEmpty()) | 126 if (visible_quad_rect.IsEmpty()) |
124 return; | 127 return; |
125 | 128 |
126 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 129 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
127 quad->SetNew(shared_quad_state, | 130 quad->SetNew(shared_quad_state, |
128 quad_rect, | 131 quad_rect, |
129 opaque_rect, | 132 opaque_rect, |
130 visible_quad_rect, | 133 visible_quad_rect, |
131 resource, | 134 resource, |
132 premultiplied_alpha, | 135 premultiplied_alpha, |
133 uv_top_left_, | 136 uv_top_left_, |
134 uv_bottom_right_, | 137 uv_bottom_right_, |
135 SK_ColorTRANSPARENT, | 138 SK_ColorTRANSPARENT, |
136 vertex_opacity_, | 139 vertex_opacity_, |
137 flipped); | 140 flipped); |
138 quad_sink->Append(quad.PassAs<DrawQuad>()); | 141 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
139 } | 142 } |
140 | 143 |
141 const char* UIResourceLayerImpl::LayerTypeAsString() const { | 144 const char* UIResourceLayerImpl::LayerTypeAsString() const { |
142 return "cc::UIResourceLayerImpl"; | 145 return "cc::UIResourceLayerImpl"; |
143 } | 146 } |
144 | 147 |
145 base::DictionaryValue* UIResourceLayerImpl::LayerTreeAsJson() const { | 148 base::DictionaryValue* UIResourceLayerImpl::LayerTreeAsJson() const { |
146 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); | 149 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); |
147 | 150 |
148 result->Set("ImageBounds", MathUtil::AsValue(image_bounds_).release()); | 151 result->Set("ImageBounds", MathUtil::AsValue(image_bounds_).release()); |
149 | 152 |
150 base::ListValue* list = new base::ListValue; | 153 base::ListValue* list = new base::ListValue; |
151 list->AppendDouble(vertex_opacity_[0]); | 154 list->AppendDouble(vertex_opacity_[0]); |
152 list->AppendDouble(vertex_opacity_[1]); | 155 list->AppendDouble(vertex_opacity_[1]); |
153 list->AppendDouble(vertex_opacity_[2]); | 156 list->AppendDouble(vertex_opacity_[2]); |
154 list->AppendDouble(vertex_opacity_[3]); | 157 list->AppendDouble(vertex_opacity_[3]); |
155 result->Set("VertexOpacity", list); | 158 result->Set("VertexOpacity", list); |
156 | 159 |
157 result->Set("UVTopLeft", MathUtil::AsValue(uv_top_left_).release()); | 160 result->Set("UVTopLeft", MathUtil::AsValue(uv_top_left_).release()); |
158 result->Set("UVBottomRight", MathUtil::AsValue(uv_bottom_right_).release()); | 161 result->Set("UVBottomRight", MathUtil::AsValue(uv_bottom_right_).release()); |
159 | 162 |
160 return result; | 163 return result; |
161 } | 164 } |
162 | 165 |
163 } // namespace cc | 166 } // namespace cc |
OLD | NEW |