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->UnoccludedContributingSurfaceContentRect(content_rect_, |
| 148 draw_transform); |
| 149 if (visible_content_rect.IsEmpty()) |
| 150 return; |
| 151 |
146 SharedQuadState* shared_quad_state = | 152 SharedQuadState* shared_quad_state = |
147 quad_sink->UseSharedQuadState(SharedQuadState::Create()); | 153 quad_sink->UseSharedQuadState(SharedQuadState::Create()); |
148 shared_quad_state->SetAll(draw_transform, | 154 shared_quad_state->SetAll(draw_transform, |
149 content_rect_.size(), | 155 content_rect_.size(), |
150 content_rect_, | 156 content_rect_, |
151 clip_rect_, | 157 clip_rect_, |
152 is_clipped_, | 158 is_clipped_, |
153 draw_opacity_, | 159 draw_opacity_, |
154 owning_layer_->blend_mode()); | 160 owning_layer_->blend_mode()); |
155 | 161 |
156 if (owning_layer_->ShowDebugBorders()) { | 162 if (owning_layer_->ShowDebugBorders()) { |
157 gfx::Rect quad_rect = content_rect_; | |
158 gfx::Rect visible_quad_rect = quad_rect; | |
159 SkColor color = for_replica ? | 163 SkColor color = for_replica ? |
160 DebugColors::SurfaceReplicaBorderColor() : | 164 DebugColors::SurfaceReplicaBorderColor() : |
161 DebugColors::SurfaceBorderColor(); | 165 DebugColors::SurfaceBorderColor(); |
162 float width = for_replica ? | 166 float width = for_replica ? |
163 DebugColors::SurfaceReplicaBorderWidth( | 167 DebugColors::SurfaceReplicaBorderWidth( |
164 owning_layer_->layer_tree_impl()) : | 168 owning_layer_->layer_tree_impl()) : |
165 DebugColors::SurfaceBorderWidth( | 169 DebugColors::SurfaceBorderWidth( |
166 owning_layer_->layer_tree_impl()); | 170 owning_layer_->layer_tree_impl()); |
167 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = | 171 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
168 DebugBorderDrawQuad::Create(); | 172 DebugBorderDrawQuad::Create(); |
169 debug_border_quad->SetNew( | 173 debug_border_quad->SetNew( |
170 shared_quad_state, quad_rect, visible_quad_rect, color, width); | 174 shared_quad_state, content_rect_, visible_content_rect, color, width); |
171 quad_sink->MaybeAppend(debug_border_quad.PassAs<DrawQuad>()); | 175 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); |
172 } | 176 } |
173 | 177 |
174 // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content | 178 // 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 | 179 // 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 | 180 // the reflection layer or correctly handle opacity in reflections (opacity |
177 // must be applied after drawing both the layer and its reflection). The | 181 // must be applied after drawing both the layer and its reflection). The |
178 // solution is to introduce yet another RenderSurfaceImpl to draw the layer | 182 // 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 | 183 // 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. | 184 // the contents don't have a mask of their own. |
181 LayerImpl* mask_layer = owning_layer_->mask_layer(); | 185 LayerImpl* mask_layer = owning_layer_->mask_layer(); |
(...skipping 23 matching lines...) Expand all Loading... |
205 float uv_scale_y = | 209 float uv_scale_y = |
206 content_rect_.height() / unclipped_mask_target_size.height(); | 210 content_rect_.height() / unclipped_mask_target_size.height(); |
207 | 211 |
208 mask_uv_rect = gfx::RectF( | 212 mask_uv_rect = gfx::RectF( |
209 uv_scale_x * content_rect_.x() / content_rect_.width(), | 213 uv_scale_x * content_rect_.x() / content_rect_.width(), |
210 uv_scale_y * content_rect_.y() / content_rect_.height(), | 214 uv_scale_y * content_rect_.y() / content_rect_.height(), |
211 uv_scale_x, | 215 uv_scale_x, |
212 uv_scale_y); | 216 uv_scale_y); |
213 } | 217 } |
214 | 218 |
215 gfx::Rect visible_content_rect(content_rect_); | |
216 ResourceProvider::ResourceId mask_resource_id = | 219 ResourceProvider::ResourceId mask_resource_id = |
217 mask_layer ? mask_layer->ContentsResourceId() : 0; | 220 mask_layer ? mask_layer->ContentsResourceId() : 0; |
218 gfx::Rect contents_changed_since_last_frame = | 221 gfx::Rect contents_changed_since_last_frame = |
219 ContentsChanged() ? content_rect_ : gfx::Rect(); | 222 ContentsChanged() ? content_rect_ : gfx::Rect(); |
220 | 223 |
221 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); | 224 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
222 quad->SetNew(shared_quad_state, | 225 quad->SetNew(shared_quad_state, |
223 content_rect_, | 226 content_rect_, |
224 visible_content_rect, | 227 visible_content_rect, |
225 render_pass_id, | 228 render_pass_id, |
226 for_replica, | 229 for_replica, |
227 mask_resource_id, | 230 mask_resource_id, |
228 contents_changed_since_last_frame, | 231 contents_changed_since_last_frame, |
229 mask_uv_rect, | 232 mask_uv_rect, |
230 owning_layer_->filters(), | 233 owning_layer_->filters(), |
231 owning_layer_->background_filters()); | 234 owning_layer_->background_filters()); |
232 quad_sink->MaybeAppend(quad.PassAs<DrawQuad>()); | 235 quad_sink->Append(quad.PassAs<DrawQuad>()); |
233 } | 236 } |
234 | 237 |
235 } // namespace cc | 238 } // namespace cc |
OLD | NEW |