Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: cc/layers/render_surface_impl.cc

Issue 2828353003: Determine mask UVs based on texture size (Closed)
Patch Set: small fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // The software renderer applies mask layer and blending in the wrong 409 // The software renderer applies mask layer and blending in the wrong
410 // order but kDstIn doesn't commute with masking. It is okay to not 410 // order but kDstIn doesn't commute with masking. It is okay to not
411 // support this configuration because kDstIn was introduced to replace 411 // support this configuration because kDstIn was introduced to replace
412 // mask layers. 412 // mask layers.
413 DCHECK(BlendMode() != SkBlendMode::kDstIn) 413 DCHECK(BlendMode() != SkBlendMode::kDstIn)
414 << "kDstIn blend mode with mask layer is unsupported."; 414 << "kDstIn blend mode with mask layer is unsupported.";
415 if (mask_layer->mask_type() == Layer::LayerMaskType::MULTI_TEXTURE_MASK) { 415 if (mask_layer->mask_type() == Layer::LayerMaskType::MULTI_TEXTURE_MASK) {
416 TileMaskLayer(render_pass, shared_quad_state, visible_layer_rect); 416 TileMaskLayer(render_pass, shared_quad_state, visible_layer_rect);
417 return; 417 return;
418 } 418 }
419 mask_layer->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 419 gfx::SizeF mask_uv_size;
420 mask_layer->GetContentsResourceId(&mask_resource_id, &mask_texture_size,
421 &mask_uv_size);
420 gfx::SizeF unclipped_mask_target_size = gfx::ScaleSize( 422 gfx::SizeF unclipped_mask_target_size = gfx::ScaleSize(
421 gfx::SizeF(OwningEffectNode()->unscaled_mask_target_size), 423 gfx::SizeF(OwningEffectNode()->unscaled_mask_target_size),
422 surface_contents_scale.x(), surface_contents_scale.y()); 424 surface_contents_scale.x(), surface_contents_scale.y());
423 // Convert content_rect from target space to normalized space. 425 // Convert content_rect from target space to normalized mask UV space.
424 // Where unclipped_mask_target_size maps to gfx::Size(1, 1). 426 // Where |unclipped_mask_target_size| maps to |mask_uv_size|.
425 mask_uv_rect = gfx::ScaleRect(gfx::RectF(content_rect()), 427 mask_uv_rect = gfx::ScaleRect(
426 1.0f / unclipped_mask_target_size.width(), 428 gfx::RectF(content_rect()),
427 1.0f / unclipped_mask_target_size.height()); 429 mask_uv_size.width() / unclipped_mask_target_size.width(),
430 mask_uv_size.height() / unclipped_mask_target_size.height());
428 } 431 }
429 432
430 gfx::RectF tex_coord_rect(gfx::Rect(content_rect().size())); 433 gfx::RectF tex_coord_rect(gfx::Rect(content_rect().size()));
431 RenderPassDrawQuad* quad = 434 RenderPassDrawQuad* quad =
432 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); 435 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
433 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, 436 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect,
434 GetRenderPassId(), mask_resource_id, mask_uv_rect, 437 GetRenderPassId(), mask_resource_id, mask_uv_rect,
435 mask_texture_size, surface_contents_scale, FiltersOrigin(), 438 mask_texture_size, surface_contents_scale, FiltersOrigin(),
436 tex_coord_rect); 439 tex_coord_rect);
437 } 440 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 NOTIMPLEMENTED(); 544 NOTIMPLEMENTED();
542 break; 545 break;
543 default: 546 default:
544 NOTREACHED(); 547 NOTREACHED();
545 break; 548 break;
546 } 549 }
547 } 550 }
548 } 551 }
549 552
550 } // namespace cc 553 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698