OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 771 |
772 gfx::QuadF localQuad; | 772 gfx::QuadF localQuad; |
773 gfx::Transform deviceTransform = MathUtil::to2dTransform(frame.windowMatrix
* frame.projectionMatrix * quad->quadTransform()); | 773 gfx::Transform deviceTransform = MathUtil::to2dTransform(frame.windowMatrix
* frame.projectionMatrix * quad->quadTransform()); |
774 if (!deviceTransform.IsInvertible()) | 774 if (!deviceTransform.IsInvertible()) |
775 return; | 775 return; |
776 | 776 |
777 bool clipped = false; | 777 bool clipped = false; |
778 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q
uad->visibleContentRect()), clipped); | 778 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q
uad->visibleContentRect()), clipped); |
779 DCHECK(!clipped); | 779 DCHECK(!clipped); |
780 | 780 |
| 781 // TODO(reveman): Axis-aligned is not enough to avoid anti-aliasing. |
| 782 // Bounding rectangle for quad also needs to be expressible as |
| 783 // an integer rectangle. crbug.com/169374 |
| 784 bool isAxisAlignedInTarget = deviceLayerQuad.IsRectilinear(); |
| 785 bool useAA = !clipped && !isAxisAlignedInTarget && quad->IsAntialiased(); |
| 786 |
781 TileProgramUniforms uniforms; | 787 TileProgramUniforms uniforms; |
782 // For now, we simply skip anti-aliasing with the quad is clipped. This only
happens | 788 if (useAA) { |
783 // on perspective transformed layers that go partially behind the camera. | |
784 if (quad->IsAntialiased() && !clipped) { | |
785 if (quad->swizzle_contents) | 789 if (quad->swizzle_contents) |
786 tileUniformLocation(tileProgramSwizzleAA(), uniforms); | 790 tileUniformLocation(tileProgramSwizzleAA(), uniforms); |
787 else | 791 else |
788 tileUniformLocation(tileProgramAA(), uniforms); | 792 tileUniformLocation(tileProgramAA(), uniforms); |
789 } else { | 793 } else { |
790 if (quad->ShouldDrawWithBlending()) { | 794 if (quad->ShouldDrawWithBlending()) { |
791 if (quad->swizzle_contents) | 795 if (quad->swizzle_contents) |
792 tileUniformLocation(tileProgramSwizzle(), uniforms); | 796 tileUniformLocation(tileProgramSwizzle(), uniforms); |
793 else | 797 else |
794 tileUniformLocation(tileProgram(), uniforms); | 798 tileUniformLocation(tileProgram(), uniforms); |
795 } else { | 799 } else { |
796 if (quad->swizzle_contents) | 800 if (quad->swizzle_contents) |
797 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); | 801 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); |
798 else | 802 else |
799 tileUniformLocation(tileProgramOpaque(), uniforms); | 803 tileUniformLocation(tileProgramOpaque(), uniforms); |
800 } | 804 } |
801 } | 805 } |
802 | 806 |
803 setUseProgram(uniforms.program); | 807 setUseProgram(uniforms.program); |
804 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); | 808 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); |
805 bool scaled = (texToGeomScaleX != 1 || texToGeomScaleY != 1); | 809 bool scaled = (texToGeomScaleX != 1 || texToGeomScaleY != 1); |
806 GLenum filter = (quad->IsAntialiased() || scaled || !quad->quadTransform().I
sIdentityOrIntegerTranslation()) ? GL_LINEAR : GL_NEAREST; | 810 GLenum filter = (quad->IsAntialiased() || scaled || !quad->quadTransform().I
sIdentityOrIntegerTranslation()) ? GL_LINEAR : GL_NEAREST; |
807 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad-
>resource_id, GL_TEXTURE_2D, filter); | 811 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad-
>resource_id, GL_TEXTURE_2D, filter); |
808 | 812 |
809 bool useAA = !clipped && quad->IsAntialiased(); | |
810 if (useAA) { | 813 if (useAA) { |
811 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound
ingBox())); | 814 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound
ingBox())); |
812 deviceLayerBounds.inflateAntiAliasingDistance(); | 815 deviceLayerBounds.inflateAntiAliasingDistance(); |
813 | 816 |
814 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); | 817 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); |
815 deviceLayerEdges.inflateAntiAliasingDistance(); | 818 deviceLayerEdges.inflateAntiAliasingDistance(); |
816 | 819 |
817 float edge[24]; | 820 float edge[24]; |
818 deviceLayerEdges.toFloatArray(edge); | 821 deviceLayerEdges.toFloatArray(edge); |
819 deviceLayerBounds.toFloatArray(&edge[12]); | 822 deviceLayerBounds.toFloatArray(&edge[12]); |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 | 1798 |
1796 releaseRenderPassTextures(); | 1799 releaseRenderPassTextures(); |
1797 } | 1800 } |
1798 | 1801 |
1799 bool GLRenderer::isContextLost() | 1802 bool GLRenderer::isContextLost() |
1800 { | 1803 { |
1801 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1804 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1802 } | 1805 } |
1803 | 1806 |
1804 } // namespace cc | 1807 } // namespace cc |
OLD | NEW |