Chromium Code Reviews| Index: cc/gl_renderer.cc |
| diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc |
| index 6a4413d1383695ea849c3a213d54711011dc55f9..2022ccc48a73b516a64714c789d2bf86e613185d 100644 |
| --- a/cc/gl_renderer.cc |
| +++ b/cc/gl_renderer.cc |
| @@ -283,10 +283,6 @@ void GLRenderer::doNoOp() |
| void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) |
| { |
| DCHECK(quad->rect.Contains(quad->visible_rect)); |
| - if (quad->material != DrawQuad::TEXTURE_CONTENT) { |
| - flushTextureQuadCache(); |
|
reveman
2013/02/26 01:49:28
I think we should keep this flushTextureQuadCache(
ernstm
2013/02/26 18:10:57
Done.
|
| - setBlendEnabled(quad->ShouldDrawWithBlending()); |
| - } |
| switch (quad->material) { |
| case DrawQuad::INVALID: |
| @@ -324,6 +320,9 @@ void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) |
| void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const CheckerboardDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + setBlendEnabled(quad->ShouldDrawWithBlending()); |
| + |
| const TileCheckerboardProgram* program = tileCheckerboardProgram(); |
| DCHECK(program && (program->initialized() || isContextLost())); |
| setUseProgram(program->program()); |
| @@ -349,6 +348,9 @@ void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const Checkerbo |
| void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorderDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + setBlendEnabled(quad->ShouldDrawWithBlending()); |
| + |
| static float glMatrix[16]; |
| const SolidColorProgram* program = solidColorProgram(); |
| DCHECK(program && (program->initialized() || isContextLost())); |
| @@ -552,6 +554,9 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters( |
| void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + setBlendEnabled(quad->ShouldDrawWithBlending()); |
| + |
| CachedResource* contentsTexture = m_renderPassTextures.get(quad->render_pass_id); |
| if (!contentsTexture || !contentsTexture->id()) |
| return; |
| @@ -721,6 +726,9 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua |
| void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + setBlendEnabled(quad->ShouldDrawWithBlending()); |
| + |
| const SolidColorProgram* program = solidColorProgram(); |
| setUseProgram(program->program()); |
| @@ -760,6 +768,8 @@ static void tileUniformLocation(T program, TileProgramUniforms& uniforms) |
| void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + |
| gfx::Rect tileRect = quad->visible_rect; |
| gfx::RectF texCoordRect = quad->tex_coord_rect; |
| @@ -808,7 +818,6 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| float fragmentTexScaleX = clampTexRect.width() / textureSize.width(); |
| float fragmentTexScaleY = clampTexRect.height() / textureSize.height(); |
| - |
| gfx::QuadF localQuad; |
| gfx::Transform deviceTransform = frame.windowMatrix * frame.projectionMatrix * quad->quadTransform(); |
| deviceTransform.FlattenTo2d(); |
| @@ -819,10 +828,14 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(quad->visibleContentRect()), clipped); |
| DCHECK(!clipped); |
| + // TODO(reveman): Axis-aligned is not enough to avoid anti-aliasing. |
| + // Bounding rectangle for quad also needs to be expressible as |
| + // an integer rectangle. crbug.com/169374 |
| + bool isAxisAlignedInTarget = deviceLayerQuad.IsRectilinear(); |
| + bool useAA = !clipped && !isAxisAlignedInTarget && quad->IsEdge(); |
| + |
| TileProgramUniforms uniforms; |
| - // For now, we simply skip anti-aliasing with the quad is clipped. This only happens |
| - // on perspective transformed layers that go partially behind the camera. |
| - if (quad->IsAntialiased() && !clipped) { |
| + if (useAA) { |
| if (quad->swizzle_contents) |
| tileUniformLocation(tileProgramSwizzleAA(), uniforms); |
| else |
| @@ -840,15 +853,17 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| tileUniformLocation(tileProgramOpaque(), uniforms); |
| } |
| } |
| - |
| + |
|
reveman
2013/02/26 01:49:28
nit: remove this whitespace change.
ernstm
2013/02/26 18:10:57
Done.
ernstm
2013/02/26 18:10:57
Done.
|
| setUseProgram(uniforms.program); |
| GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); |
| bool scaled = (texToGeomScaleX != 1 || texToGeomScaleY != 1); |
| - GLenum filter = (quad->IsAntialiased() || scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) ? GL_LINEAR : GL_NEAREST; |
| + GLenum filter = (useAA || scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) ? GL_LINEAR : GL_NEAREST; |
| ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad->resource_id, GL_TEXTURE_2D, filter); |
| - bool useAA = !clipped && quad->IsAntialiased(); |
| if (useAA) { |
| + // always enable blending when using antialiasing |
| + setBlendEnabled(true); |
|
reveman
2013/02/26 01:49:28
is the setBlendEnabled(quad->ShouldDrawWithBlendin
ernstm
2013/02/26 18:10:57
The line below is enough. This one is a leftover f
|
| + |
| LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.BoundingBox())); |
| deviceLayerBounds.inflateAntiAliasingDistance(); |
| @@ -884,13 +899,13 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| LayerQuad::Edge rightEdge(topRight, bottomRight); |
| // Only apply anti-aliasing to edges not clipped by culling or scissoring. |
| - if (quad->top_edge_aa && tileRect.y() == quad->rect.y()) |
| + if (quad->IsTopEdge() && tileRect.y() == quad->rect.y()) |
| topEdge = deviceLayerEdges.top(); |
| - if (quad->left_edge_aa && tileRect.x() == quad->rect.x()) |
| + if (quad->IsLeftEdge() && tileRect.x() == quad->rect.x()) |
| leftEdge = deviceLayerEdges.left(); |
| - if (quad->right_edge_aa && tileRect.right() == quad->rect.right()) |
| + if (quad->IsRightEdge() && tileRect.right() == quad->rect.right()) |
| rightEdge = deviceLayerEdges.right(); |
| - if (quad->bottom_edge_aa && tileRect.bottom() == quad->rect.bottom()) |
| + if (quad->IsBottomEdge() && tileRect.bottom() == quad->rect.bottom()) |
| bottomEdge = deviceLayerEdges.bottom(); |
| float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; |
| @@ -928,6 +943,10 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| localQuad = gfx::RectF(tileRect); |
| } |
| + // Enable blending when the quad properties require it or if we decided |
|
reveman
2013/02/26 01:49:28
nit: remove whitespace at end of line.
ernstm
2013/02/26 18:10:57
Done.
|
| + // to use antialiasing. |
| + setBlendEnabled(quad->ShouldDrawWithBlending() || useAA); |
| + |
| // Normalize to tileRect. |
| localQuad.Scale(1.0f / tileRect.width(), 1.0f / tileRect.height()); |
| @@ -945,6 +964,9 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua |
| void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + setBlendEnabled(quad->ShouldDrawWithBlending()); |
|
reveman
2013/02/26 01:49:28
nit: remove whitespace at end of line.
ernstm
2013/02/26 18:10:57
Done.
|
| + |
| const VideoYUVProgram* program = videoYUVProgram(); |
| DCHECK(program && (program->initialized() || isContextLost())); |
| @@ -997,6 +1019,9 @@ void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQ |
| void GLRenderer::drawStreamVideoQuad(const DrawingFrame& frame, const StreamVideoDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + setBlendEnabled(quad->ShouldDrawWithBlending()); |
| + |
| static float glMatrix[16]; |
| DCHECK(m_capabilities.usingEglImage); |
| @@ -1185,6 +1210,9 @@ void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua |
| void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDrawQuad* quad) |
| { |
| + flushTextureQuadCache(); |
| + setBlendEnabled(quad->ShouldDrawWithBlending()); |
| + |
| TexTransformTextureProgramBinding binding; |
| binding.set(textureIOSurfaceProgram(), context()); |