Chromium Code Reviews| Index: cc/gl_renderer.cc |
| diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc |
| index 241bcfe246709b8d72ae27e9233dd55eaab4ac8e..89bdb05e5d401a7a70c0529dd708125c101aa462 100644 |
| --- a/cc/gl_renderer.cc |
| +++ b/cc/gl_renderer.cc |
| @@ -403,7 +403,7 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc |
| SkBitmap source; |
| source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(), sourceTexture->size().height()); |
| source.setPixelRef(new SkGrPixelRef(texture.get()))->unref(); |
| - |
| + |
| // Create a scratch texture for backing store. |
| GrTextureDesc desc; |
| desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
| @@ -428,7 +428,11 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc |
| return device.accessBitmap(false); |
| } |
| -scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(DrawingFrame& frame, const RenderPassDrawQuad* quad, const WebKit::WebFilterOperations& filters, const WebTransformationMatrix& contentsDeviceTransform) |
| +scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters( |
| + DrawingFrame& frame, const RenderPassDrawQuad* quad, |
| + const WebKit::WebFilterOperations& filters, |
| + const WebTransformationMatrix& deviceMatrix, |
| + const WebTransformationMatrix& deviceMatrixInv) |
| { |
| // This method draws a background filter, which applies a filter to any pixels behind the quad and seen through its background. |
| // The algorithm works as follows: |
| @@ -456,7 +460,7 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(DrawingFrame& frame, |
| DCHECK(!frame.currentTexture); |
| // FIXME: Do a single readback for both the surface and replica and cache the filtered results (once filter textures are not reused). |
| - gfx::Rect deviceRect = gfx::ToEnclosingRect(MathUtil::mapClippedRect(contentsDeviceTransform, sharedGeometryQuad().BoundingBox())); |
| + gfx::Rect deviceRect = gfx::ToEnclosingRect(MathUtil::mapClippedRect(deviceMatrix, sharedGeometryQuad().BoundingBox())); |
| int top, right, bottom, left; |
| filters.getOutsets(top, right, bottom, left); |
| @@ -487,7 +491,7 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(DrawingFrame& frame, |
| WebTransformationMatrix deviceToFramebufferTransform; |
| deviceToFramebufferTransform.translate(quad->quadRect().width() / 2.0, quad->quadRect().height() / 2.0); |
| deviceToFramebufferTransform.scale3d(quad->quadRect().width(), quad->quadRect().height(), 1); |
| - deviceToFramebufferTransform.multiply(contentsDeviceTransform.inverse()); |
| + deviceToFramebufferTransform.multiply(deviceMatrixInv); |
| copyTextureToFramebuffer(frame, filteredDeviceBackgroundTextureId, deviceRect, deviceToFramebufferTransform); |
| } |
| @@ -511,13 +515,16 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua |
| WebTransformationMatrix quadRectMatrix; |
| quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->quadRect()); |
| - WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * frame.projectionMatrix * quadRectMatrix).to2dTransform(); |
| + WebTransformationMatrix deviceMatrix = (frame.windowMatrix * frame.projectionMatrix * quadRectMatrix).to2dTransform(); |
|
jamesr
2012/11/06 23:53:43
what's the reason for the rename?
|
| // Can only draw surface if device matrix is invertible. |
| - if (!contentsDeviceTransform.isInvertible()) |
| + if (!deviceMatrix.isInvertible()) |
| return; |
| - scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters(frame, quad, renderPass->backgroundFilters(), contentsDeviceTransform); |
| + WebTransformationMatrix deviceMatrixInv = deviceMatrix.inverse(); |
| + scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters( |
| + frame, quad, renderPass->backgroundFilters(), |
| + deviceMatrix, deviceMatrixInv); |
| // FIXME: Cache this value so that we don't have to do it for both the surface and its replica. |
| // Apply filters to the contents texture. |
| @@ -545,7 +552,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua |
| } |
| bool clipped = false; |
| - gfx::QuadF deviceQuad = MathUtil::mapQuad(contentsDeviceTransform, sharedGeometryQuad(), clipped); |
| + gfx::QuadF deviceQuad = MathUtil::mapQuad(deviceMatrix, sharedGeometryQuad(), clipped); |
| DCHECK(!clipped); |
| LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceQuad.BoundingBox())); |
| LayerQuad deviceLayerEdges = LayerQuad(deviceQuad); |
| @@ -634,8 +641,8 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua |
| GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge)); |
| } |
| - // Map device space quad to surface space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to project. |
| - gfx::QuadF surfaceQuad = MathUtil::mapQuad(contentsDeviceTransform.inverse(), deviceLayerEdges.ToQuadF(), clipped); |
| + // Map device space quad to surface space. deviceMatrix has no 3d component since it was generated with to2dTransform() so we don't need to project. |
| + gfx::QuadF surfaceQuad = MathUtil::mapQuad(deviceMatrixInv, deviceLayerEdges.ToQuadF(), clipped); |
| DCHECK(!clipped); |
| setShaderOpacity(quad->opacity(), shaderAlphaLocation); |
| @@ -715,12 +722,12 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| gfx::QuadF localQuad; |
| - WebTransformationMatrix deviceTransform = WebTransformationMatrix(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform()).to2dTransform(); |
| - if (!deviceTransform.isInvertible()) |
| + WebTransformationMatrix deviceMatrix = WebTransformationMatrix(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform()).to2dTransform(); |
|
jamesr
2012/11/06 23:53:43
this rename seems somewhat arbitrary
|
| + if (!deviceMatrix.isInvertible()) |
| return; |
| bool clipped = false; |
| - gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(quad->visibleContentRect()), clipped); |
| + gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceMatrix, gfx::QuadF(quad->visibleContentRect()), clipped); |
| DCHECK(!clipped); |
| TileProgramUniforms uniforms; |
| @@ -775,13 +782,13 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| gfx::PointF topRight(tileRect.right(), tileRect.y()); |
| // Map points to device space. |
| - bottomRight = MathUtil::mapPoint(deviceTransform, bottomRight, clipped); |
| + bottomRight = MathUtil::mapPoint(deviceMatrix, bottomRight, clipped); |
| DCHECK(!clipped); |
| - bottomLeft = MathUtil::mapPoint(deviceTransform, bottomLeft, clipped); |
| + bottomLeft = MathUtil::mapPoint(deviceMatrix, bottomLeft, clipped); |
| DCHECK(!clipped); |
| - topLeft = MathUtil::mapPoint(deviceTransform, topLeft, clipped); |
| + topLeft = MathUtil::mapPoint(deviceMatrix, topLeft, clipped); |
| DCHECK(!clipped); |
| - topRight = MathUtil::mapPoint(deviceTransform, topRight, clipped); |
| + topRight = MathUtil::mapPoint(deviceMatrix, topRight, clipped); |
| DCHECK(!clipped); |
| LayerQuad::Edge bottomEdge(bottomRight, bottomLeft); |
| @@ -808,9 +815,9 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| // Create device space quad. |
| LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); |
| - // Map device space quad to local space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to project. |
| - WebTransformationMatrix inverseDeviceTransform = deviceTransform.inverse(); |
| - localQuad = MathUtil::mapQuad(inverseDeviceTransform, deviceQuad.ToQuadF(), clipped); |
| + // Map device space quad to local space. deviceMatrix has no 3d component since it was generated with to2dTransform() so we don't need to project. |
| + WebTransformationMatrix deviceMatrixInv = deviceMatrix.inverse(); |
| + localQuad = MathUtil::mapQuad(deviceMatrixInv, deviceQuad.ToQuadF(), clipped); |
| // We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become |
| // clipped. To our knowledge this scenario does not need to be handled differently than the unclipped case. |