summaryrefslogtreecommitdiffstats
path: root/cc/render_surface_impl.cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-17 03:44:55 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-17 03:44:55 +0000
commit8611f01f36a713d0260e11670f24403be7294b7c (patch)
treee1c56b09d08dcf2d48a8f1bc7081811d7d4ef92c /cc/render_surface_impl.cc
parent6646043896e02173e61c1d20df278d56577cce08 (diff)
downloadchromium_src-8611f01f36a713d0260e11670f24403be7294b7c.zip
chromium_src-8611f01f36a713d0260e11670f24403be7294b7c.tar.gz
chromium_src-8611f01f36a713d0260e11670f24403be7294b7c.tar.bz2
cc: Clarify the uvRect used for RenderSurfaces and support masks with different bounds.
The texture coords for the mask layer go from 0.0 to 1.0, so there is no need to scale between the size of the mask texture and the render surface texture. The uv rect is there to scale between the unclipped render surface coordinates and the clipped render surface texture. So make this explicit in the code. This remove the mask layer's content size completely from the equations. Tests: cc_unittests:LayerTreeHostImplTest.maskLayerWithDifferentBounds R=piman BUG=170076 Review URL: https://chromiumcodereview.appspot.com/11968007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177337 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/render_surface_impl.cc')
-rw-r--r--cc/render_surface_impl.cc30
1 files changed, 17 insertions, 13 deletions
diff --git a/cc/render_surface_impl.cc b/cc/render_surface_impl.cc
index 8023da6..84758da0 100644
--- a/cc/render_surface_impl.cc
+++ b/cc/render_surface_impl.cc
@@ -224,19 +224,23 @@ void RenderSurfaceImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQ
gfx::RectF maskUVRect(0.0f, 0.0f, 1.0f, 1.0f);
if (maskLayer) {
- // Because the RenderSurface is sized base on the screen footprint,
- // there can be a scale between the RenderSurface and the owning layer,
- // as well as the mask. While the mask doesn't have a drawTransform, the
- // owning layer has it (and should be pure scaling), so use that to
- // scale the mask to the right size.
- gfx::Vector2dF maskDrawScale = MathUtil::computeTransform2dScaleComponents(m_owningLayer->drawTransform(), 1.f);
- float scaleX = contentRect().width() / maskLayer->contentsScaleX() / maskLayer->bounds().width() / maskDrawScale.x();
- float scaleY = contentRect().height() / maskLayer->contentsScaleY() / maskLayer->bounds().height() / maskDrawScale.y();
-
- maskUVRect = gfx::RectF(static_cast<float>(contentRect().x()) / contentRect().width() * scaleX,
- static_cast<float>(contentRect().y()) / contentRect().height() * scaleY,
- scaleX,
- scaleY);
+ gfx::Vector2dF owningLayerDrawScale = MathUtil::computeTransform2dScaleComponents(m_owningLayer->drawTransform(), 1.f);
+ gfx::SizeF unclippedSurfaceSize = gfx::ScaleSize(
+ m_owningLayer->contentBounds(),
+ owningLayerDrawScale.x(),
+ owningLayerDrawScale.y());
+ // This assumes that the owning layer clips its subtree when a mask is
+ // present.
+ DCHECK(gfx::RectF(unclippedSurfaceSize).Contains(contentRect()));
+
+ float uvScaleX = contentRect().width() / unclippedSurfaceSize.width();
+ float uvScaleY = contentRect().height() / unclippedSurfaceSize.height();
+
+ maskUVRect = gfx::RectF(
+ static_cast<float>(contentRect().x()) / contentRect().width() * uvScaleX,
+ static_cast<float>(contentRect().y()) / contentRect().height() * uvScaleY,
+ uvScaleX,
+ uvScaleY);
}
ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->contentsResourceId() : 0;