OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/render_surface_impl.h" | 5 #include "cc/layers/render_surface_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 } | 136 } |
137 | 137 |
138 void RenderSurfaceImpl::AppendQuads(QuadSink* quad_sink, | 138 void RenderSurfaceImpl::AppendQuads(QuadSink* quad_sink, |
139 AppendQuadsData* append_quads_data, | 139 AppendQuadsData* append_quads_data, |
140 bool for_replica, | 140 bool for_replica, |
141 RenderPass::Id render_pass_id) { | 141 RenderPass::Id render_pass_id) { |
142 DCHECK(!for_replica || owning_layer_->has_replica()); | 142 DCHECK(!for_replica || owning_layer_->has_replica()); |
143 | 143 |
144 const gfx::Transform& draw_transform = | 144 const gfx::Transform& draw_transform = |
145 for_replica ? replica_draw_transform_ : draw_transform_; | 145 for_replica ? replica_draw_transform_ : draw_transform_; |
146 gfx::Rect visible_content_rect = | |
147 quad_sink->UnoccludedContentRect(content_rect_, draw_transform); | |
enne (OOO)
2014/03/19 23:05:32
Why does this not use UnoccludedContributingSurfac
danakj
2014/03/19 23:12:33
Cuz copy/paste, woops. Maybe I should add a separa
enne (OOO)
2014/03/19 23:18:36
Yah. Having a test that would have caught this sg
danakj
2014/03/19 23:22:22
Done.
| |
148 if (visible_content_rect.IsEmpty()) | |
149 return; | |
150 | |
146 SharedQuadState* shared_quad_state = | 151 SharedQuadState* shared_quad_state = |
147 quad_sink->UseSharedQuadState(SharedQuadState::Create()); | 152 quad_sink->UseSharedQuadState(SharedQuadState::Create()); |
148 shared_quad_state->SetAll(draw_transform, | 153 shared_quad_state->SetAll(draw_transform, |
149 content_rect_.size(), | 154 content_rect_.size(), |
150 content_rect_, | 155 content_rect_, |
151 clip_rect_, | 156 clip_rect_, |
152 is_clipped_, | 157 is_clipped_, |
153 draw_opacity_, | 158 draw_opacity_, |
154 owning_layer_->blend_mode()); | 159 owning_layer_->blend_mode()); |
155 | 160 |
156 if (owning_layer_->ShowDebugBorders()) { | 161 if (owning_layer_->ShowDebugBorders()) { |
157 gfx::Rect quad_rect = content_rect_; | |
158 gfx::Rect visible_quad_rect = quad_rect; | |
159 SkColor color = for_replica ? | 162 SkColor color = for_replica ? |
160 DebugColors::SurfaceReplicaBorderColor() : | 163 DebugColors::SurfaceReplicaBorderColor() : |
161 DebugColors::SurfaceBorderColor(); | 164 DebugColors::SurfaceBorderColor(); |
162 float width = for_replica ? | 165 float width = for_replica ? |
163 DebugColors::SurfaceReplicaBorderWidth( | 166 DebugColors::SurfaceReplicaBorderWidth( |
164 owning_layer_->layer_tree_impl()) : | 167 owning_layer_->layer_tree_impl()) : |
165 DebugColors::SurfaceBorderWidth( | 168 DebugColors::SurfaceBorderWidth( |
166 owning_layer_->layer_tree_impl()); | 169 owning_layer_->layer_tree_impl()); |
167 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = | 170 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
168 DebugBorderDrawQuad::Create(); | 171 DebugBorderDrawQuad::Create(); |
169 debug_border_quad->SetNew( | 172 debug_border_quad->SetNew( |
170 shared_quad_state, quad_rect, visible_quad_rect, color, width); | 173 shared_quad_state, content_rect_, visible_content_rect, color, width); |
171 quad_sink->MaybeAppend(debug_border_quad.PassAs<DrawQuad>()); | 174 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); |
172 } | 175 } |
173 | 176 |
174 // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content | 177 // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content |
175 // and its reflection, it's currently not possible to apply a separate mask to | 178 // and its reflection, it's currently not possible to apply a separate mask to |
176 // the reflection layer or correctly handle opacity in reflections (opacity | 179 // the reflection layer or correctly handle opacity in reflections (opacity |
177 // must be applied after drawing both the layer and its reflection). The | 180 // must be applied after drawing both the layer and its reflection). The |
178 // solution is to introduce yet another RenderSurfaceImpl to draw the layer | 181 // solution is to introduce yet another RenderSurfaceImpl to draw the layer |
179 // and its reflection in. For now we only apply a separate reflection mask if | 182 // and its reflection in. For now we only apply a separate reflection mask if |
180 // the contents don't have a mask of their own. | 183 // the contents don't have a mask of their own. |
181 LayerImpl* mask_layer = owning_layer_->mask_layer(); | 184 LayerImpl* mask_layer = owning_layer_->mask_layer(); |
(...skipping 23 matching lines...) Expand all Loading... | |
205 float uv_scale_y = | 208 float uv_scale_y = |
206 content_rect_.height() / unclipped_mask_target_size.height(); | 209 content_rect_.height() / unclipped_mask_target_size.height(); |
207 | 210 |
208 mask_uv_rect = gfx::RectF( | 211 mask_uv_rect = gfx::RectF( |
209 uv_scale_x * content_rect_.x() / content_rect_.width(), | 212 uv_scale_x * content_rect_.x() / content_rect_.width(), |
210 uv_scale_y * content_rect_.y() / content_rect_.height(), | 213 uv_scale_y * content_rect_.y() / content_rect_.height(), |
211 uv_scale_x, | 214 uv_scale_x, |
212 uv_scale_y); | 215 uv_scale_y); |
213 } | 216 } |
214 | 217 |
215 gfx::Rect visible_content_rect(content_rect_); | |
216 ResourceProvider::ResourceId mask_resource_id = | 218 ResourceProvider::ResourceId mask_resource_id = |
217 mask_layer ? mask_layer->ContentsResourceId() : 0; | 219 mask_layer ? mask_layer->ContentsResourceId() : 0; |
218 gfx::Rect contents_changed_since_last_frame = | 220 gfx::Rect contents_changed_since_last_frame = |
219 ContentsChanged() ? content_rect_ : gfx::Rect(); | 221 ContentsChanged() ? content_rect_ : gfx::Rect(); |
220 | 222 |
221 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); | 223 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
222 quad->SetNew(shared_quad_state, | 224 quad->SetNew(shared_quad_state, |
223 content_rect_, | 225 content_rect_, |
224 visible_content_rect, | 226 visible_content_rect, |
225 render_pass_id, | 227 render_pass_id, |
226 for_replica, | 228 for_replica, |
227 mask_resource_id, | 229 mask_resource_id, |
228 contents_changed_since_last_frame, | 230 contents_changed_since_last_frame, |
229 mask_uv_rect, | 231 mask_uv_rect, |
230 owning_layer_->filters(), | 232 owning_layer_->filters(), |
231 owning_layer_->background_filters()); | 233 owning_layer_->background_filters()); |
232 quad_sink->MaybeAppend(quad.PassAs<DrawQuad>()); | 234 quad_sink->Append(quad.PassAs<DrawQuad>()); |
233 } | 235 } |
234 | 236 |
235 } // namespace cc | 237 } // namespace cc |
OLD | NEW |