Chromium Code Reviews| 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/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 if (mask_layer && | 243 if (mask_layer && |
| 244 (!mask_layer->DrawsContent() || mask_layer->bounds().IsEmpty())) | 244 (!mask_layer->DrawsContent() || mask_layer->bounds().IsEmpty())) |
| 245 mask_layer = NULL; | 245 mask_layer = NULL; |
| 246 } | 246 } |
| 247 | 247 |
| 248 gfx::RectF mask_uv_rect(0.f, 0.f, 1.f, 1.f); | 248 gfx::RectF mask_uv_rect(0.f, 0.f, 1.f, 1.f); |
| 249 if (mask_layer) { | 249 if (mask_layer) { |
| 250 gfx::Vector2dF owning_layer_draw_scale = | 250 gfx::Vector2dF owning_layer_draw_scale = |
| 251 MathUtil::ComputeTransform2dScaleComponents( | 251 MathUtil::ComputeTransform2dScaleComponents( |
| 252 owning_layer_->draw_transform(), 1.f); | 252 owning_layer_->draw_transform(), 1.f); |
| 253 gfx::SizeF unclipped_surface_size = gfx::ScaleSize( | 253 gfx::SizeF unclipped_mask_target_size = gfx::ScaleSize( |
| 254 owning_layer_->content_bounds(), | 254 owning_layer_->content_bounds(), |
| 255 owning_layer_draw_scale.x(), | 255 owning_layer_draw_scale.x(), |
| 256 owning_layer_draw_scale.y()); | 256 owning_layer_draw_scale.y()); |
| 257 // This assumes that the owning layer clips its subtree when a mask is | 257 gfx::SizeF clipped_mask_target_size = gfx::IntersectRects( |
|
enne (OOO)
2013/04/16 21:06:44
I'm a little confused about this intersection. Do
danakj
2013/04/16 21:21:01
This is the old behaviour minus assumptions that t
shawnsingh
2013/04/16 23:08:26
I don't understand this - if the surface has a mas
danakj
2013/04/16 23:13:55
if the replica has a mask, the layer does not mask
| |
| 258 // present. | 258 gfx::RectF(unclipped_mask_target_size), content_rect_).size(); |
| 259 DCHECK(gfx::RectF(unclipped_surface_size).Contains(content_rect_)); | |
| 260 | 259 |
| 261 float uv_scale_x = content_rect_.width() / unclipped_surface_size.width(); | 260 gfx::Vector2dF unclipped_to_clipped_mask_target_size( |
| 262 float uv_scale_y = content_rect_.height() / unclipped_surface_size.height(); | 261 clipped_mask_target_size.width() / |
| 262 unclipped_mask_target_size.width(), | |
| 263 clipped_mask_target_size.height() / | |
| 264 unclipped_mask_target_size.height()); | |
| 265 | |
| 266 gfx::Vector2dF owning_layer_to_mask_layer_bounds_ratio( | |
|
enne (OOO)
2013/04/16 21:06:44
This whole function needs a lot more comments abou
danakj
2013/04/16 21:21:01
ok, will add.
| |
| 267 (static_cast<float>(mask_layer->content_bounds().width()) / | |
| 268 mask_layer->bounds().width()) / | |
| 269 (static_cast<float>(owning_layer_->content_bounds().width()) / | |
| 270 owning_layer_->bounds().width()), | |
| 271 (static_cast<float>(mask_layer->content_bounds().height()) / | |
| 272 mask_layer->bounds().height()) / | |
| 273 (static_cast<float>(owning_layer_->content_bounds().height()) / | |
| 274 owning_layer_->bounds().height())); | |
| 275 | |
| 276 float uv_scale_x = unclipped_to_clipped_mask_target_size.x() * | |
| 277 owning_layer_to_mask_layer_bounds_ratio.x(); | |
| 278 float uv_scale_y = unclipped_to_clipped_mask_target_size.y() * | |
| 279 owning_layer_to_mask_layer_bounds_ratio.y(); | |
| 263 | 280 |
| 264 mask_uv_rect = gfx::RectF( | 281 mask_uv_rect = gfx::RectF( |
| 265 uv_scale_x * content_rect_.x() / content_rect_.width(), | 282 uv_scale_x * content_rect_.x() / content_rect_.width(), |
| 266 uv_scale_y * content_rect_.y() / content_rect_.height(), | 283 uv_scale_y * content_rect_.y() / content_rect_.height(), |
| 267 uv_scale_x, | 284 uv_scale_x, |
| 268 uv_scale_y); | 285 uv_scale_y); |
| 269 } | 286 } |
| 270 | 287 |
| 271 ResourceProvider::ResourceId mask_resource_id = | 288 ResourceProvider::ResourceId mask_resource_id = |
| 272 mask_layer ? mask_layer->ContentsResourceId() : 0; | 289 mask_layer ? mask_layer->ContentsResourceId() : 0; |
| 273 gfx::Rect contents_changed_since_last_frame = | 290 gfx::Rect contents_changed_since_last_frame = |
| 274 ContentsChanged() ? content_rect_ : gfx::Rect(); | 291 ContentsChanged() ? content_rect_ : gfx::Rect(); |
| 275 | 292 |
| 276 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); | 293 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
| 277 quad->SetNew(shared_quad_state, | 294 quad->SetNew(shared_quad_state, |
| 278 content_rect_, | 295 content_rect_, |
| 279 render_pass_id, | 296 render_pass_id, |
| 280 for_replica, | 297 for_replica, |
| 281 mask_resource_id, | 298 mask_resource_id, |
| 282 contents_changed_since_last_frame, | 299 contents_changed_since_last_frame, |
| 283 mask_uv_rect, | 300 mask_uv_rect, |
| 284 owning_layer_->filters(), | 301 owning_layer_->filters(), |
| 285 owning_layer_->filter(), | 302 owning_layer_->filter(), |
| 286 owning_layer_->background_filters()); | 303 owning_layer_->background_filters()); |
| 287 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 304 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 288 } | 305 } |
| 289 | 306 |
| 290 } // namespace cc | 307 } // namespace cc |
| OLD | NEW |