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/render_surface_impl.h" | 5 #include "cc/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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 maskLayer = 0; | 217 maskLayer = 0; |
| 218 | 218 |
| 219 if (!maskLayer && forReplica) { | 219 if (!maskLayer && forReplica) { |
| 220 maskLayer = m_owningLayer->replicaLayer()->maskLayer(); | 220 maskLayer = m_owningLayer->replicaLayer()->maskLayer(); |
| 221 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEm pty())) | 221 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEm pty())) |
| 222 maskLayer = 0; | 222 maskLayer = 0; |
| 223 } | 223 } |
| 224 | 224 |
| 225 gfx::RectF maskUVRect(0.0f, 0.0f, 1.0f, 1.0f); | 225 gfx::RectF maskUVRect(0.0f, 0.0f, 1.0f, 1.0f); |
| 226 if (maskLayer) { | 226 if (maskLayer) { |
| 227 float scaleX = contentRect().width() / maskLayer->contentsScaleX() / mas kLayer->bounds().width(); | 227 // Because the RenderSurface is sized base on the screen footprint, |
| 228 float scaleY = contentRect().height() / maskLayer->contentsScaleY() / ma skLayer->bounds().height(); | 228 // there can be a scale between the RenderSurface and the owning layer, |
| 229 // as well as the mask. While the mask doesn't have a drawTransform, the | |
| 230 // owning layer has it (and should be pure scaling), so use that to | |
| 231 // scale the mask to the right size. | |
| 232 gfx::Vector2dF maskDrawScale = MathUtil::computeTransform2dScaleComponen ts(m_owningLayer->drawTransform(), 1.f); | |
|
enne (OOO)
2013/01/15 04:12:43
This will work given the current implementation of
danakj
2013/01/15 16:31:11
I'm not sure I agree. My POV is that the mask is a
danakj
2013/01/15 17:11:53
Ok I take this back. I had developed an impression
| |
| 233 float scaleX = contentRect().width() / maskLayer->contentsScaleX() / mas kLayer->bounds().width() / maskDrawScale.x(); | |
| 234 float scaleY = contentRect().height() / maskLayer->contentsScaleY() / ma skLayer->bounds().height() / maskDrawScale.y(); | |
| 229 | 235 |
| 230 maskUVRect = gfx::RectF(static_cast<float>(contentRect().x()) / contentR ect().width() * scaleX, | 236 maskUVRect = gfx::RectF(static_cast<float>(contentRect().x()) / contentR ect().width() * scaleX, |
| 231 static_cast<float>(contentRect().y()) / contentR ect().height() * scaleY, | 237 static_cast<float>(contentRect().y()) / contentR ect().height() * scaleY, |
| 232 scaleX, | 238 scaleX, |
| 233 scaleY); | 239 scaleY); |
| 234 } | 240 } |
| 235 | 241 |
| 236 ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->content sResourceId() : 0; | 242 ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->content sResourceId() : 0; |
| 237 gfx::Rect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : gfx::Rect(); | 243 gfx::Rect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : gfx::Rect(); |
| 238 | 244 |
| 239 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); | 245 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
| 240 quad->SetNew(sharedQuadState, contentRect(), renderPassId, forReplica, maskR esourceId, contentsChangedSinceLastFrame, maskUVRect, m_owningLayer->filters(), m_owningLayer->filter(), m_owningLayer->backgroundFilters()); | 246 quad->SetNew(sharedQuadState, contentRect(), renderPassId, forReplica, maskR esourceId, contentsChangedSinceLastFrame, maskUVRect, m_owningLayer->filters(), m_owningLayer->filter(), m_owningLayer->backgroundFilters()); |
| 241 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 247 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 242 } | 248 } |
| 243 | 249 |
| 244 } // namespace cc | 250 } // namespace cc |
| OLD | NEW |