Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: cc/gl_renderer.cc

Issue 12393053: Re-land: cc: Added antialiasing support for solid color layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-land: cc: Added antialiasing support for solid color layers Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 setShaderOpacity(quad->opacity(), shaderAlphaLocation); 715 setShaderOpacity(quad->opacity(), shaderAlphaLocation);
716 setShaderQuadF(surfaceQuad, shaderQuadLocation); 716 setShaderQuadF(surfaceQuad, shaderQuadLocation);
717 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, shaderMatrixLocat ion); 717 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, shaderMatrixLocat ion);
718 718
719 // Flush the compositor context before the filter bitmap goes out of 719 // Flush the compositor context before the filter bitmap goes out of
720 // scope, so the draw gets processed before the filter texture gets deleted. 720 // scope, so the draw gets processed before the filter texture gets deleted.
721 if (filterBitmap.getTexture()) 721 if (filterBitmap.getTexture())
722 m_context->flush(); 722 m_context->flush();
723 } 723 }
724 724
725 struct SolidColorProgramUniforms {
726 unsigned program;
727 unsigned matrixLocation;
728 unsigned colorLocation;
729 unsigned pointLocation;
730 unsigned texScaleLocation;
731 unsigned edgeLocation;
732 };
733
734 template<class T>
735 static void solidColorUniformLocation(T program, SolidColorProgramUniforms& unif orms)
736 {
737 uniforms.program = program->program();
738 uniforms.matrixLocation = program->vertexShader().matrixLocation();
739 uniforms.colorLocation = program->fragmentShader().colorLocation();
740 uniforms.pointLocation = program->vertexShader().pointLocation();
741 uniforms.texScaleLocation = program->vertexShader().texScaleLocation();
742 uniforms.edgeLocation = program->fragmentShader().edgeLocation();
743 }
744
745 bool GLRenderer::setupQuadForAntialiasing(const gfx::Transform& deviceTransform, const DrawQuad* quad,
746 gfx::QuadF* localQuad, float edge[24]) const
747 {
748 gfx::Rect tileRect = quad->visible_rect;
749
750 bool clipped = false;
751 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q uad->visibleContentRect()), clipped);
752 DCHECK(!clipped);
753
754 // TODO(reveman): Axis-aligned is not enough to avoid anti-aliasing.
755 // Bounding rectangle for quad also needs to be expressible as
756 // an integer rectangle. crbug.com/169374
757 bool isAxisAlignedInTarget = deviceLayerQuad.IsRectilinear();
758 bool useAA = !clipped && !isAxisAlignedInTarget && quad->IsEdge();
759
760 if (!useAA)
761 return false;
762
763 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.BoundingB ox()));
764 deviceLayerBounds.inflateAntiAliasingDistance();
765
766 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad);
767 deviceLayerEdges.inflateAntiAliasingDistance();
768
769 deviceLayerEdges.toFloatArray(edge);
770 deviceLayerBounds.toFloatArray(&edge[12]);
771
772 gfx::PointF bottomRight = tileRect.bottom_right();
773 gfx::PointF bottomLeft = tileRect.bottom_left();
774 gfx::PointF topLeft = tileRect.origin();
775 gfx::PointF topRight = tileRect.top_right();
776
777 // Map points to device space.
778 bottomRight = MathUtil::mapPoint(deviceTransform, bottomRight, clipped);
779 DCHECK(!clipped);
780 bottomLeft = MathUtil::mapPoint(deviceTransform, bottomLeft, clipped);
781 DCHECK(!clipped);
782 topLeft = MathUtil::mapPoint(deviceTransform, topLeft, clipped);
783 DCHECK(!clipped);
784 topRight = MathUtil::mapPoint(deviceTransform, topRight, clipped);
785 DCHECK(!clipped);
786
787 LayerQuad::Edge bottomEdge(bottomRight, bottomLeft);
788 LayerQuad::Edge leftEdge(bottomLeft, topLeft);
789 LayerQuad::Edge topEdge(topLeft, topRight);
790 LayerQuad::Edge rightEdge(topRight, bottomRight);
791
792 // Only apply anti-aliasing to edges not clipped by culling or scissoring.
793 if (quad->IsTopEdge() && tileRect.y() == quad->rect.y())
794 topEdge = deviceLayerEdges.top();
795 if (quad->IsLeftEdge() && tileRect.x() == quad->rect.x())
796 leftEdge = deviceLayerEdges.left();
797 if (quad->IsRightEdge() && tileRect.right() == quad->rect.right())
798 rightEdge = deviceLayerEdges.right();
799 if (quad->IsBottomEdge() && tileRect.bottom() == quad->rect.bottom())
800 bottomEdge = deviceLayerEdges.bottom();
801
802 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1;
803 bottomEdge.scale(sign);
804 leftEdge.scale(sign);
805 topEdge.scale(sign);
806 rightEdge.scale(sign);
807
808 // Create device space quad.
809 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge);
810
811 // Map device space quad to local space. deviceTransform has no 3d component since it was flattened, so we don't need to project.
812 // We should have already checked that the transform was uninvertible above.
813 gfx::Transform inverseDeviceTransform(gfx::Transform::kSkipInitialization);
814 bool didInvert = deviceTransform.GetInverse(&inverseDeviceTransform);
815 DCHECK(didInvert);
816 *localQuad = MathUtil::mapQuad(inverseDeviceTransform, deviceQuad.ToQuadF(), clipped);
817 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become
818 // clipped. To our knowledge this scenario does not need to be handled diffe rently than the unclipped case.
819
820 return true;
821 }
822
725 void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorD rawQuad* quad) 823 void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorD rawQuad* quad)
726 { 824 {
727 setBlendEnabled(quad->ShouldDrawWithBlending()); 825 gfx::Rect tileRect = quad->visible_rect;
728 826
729 const SolidColorProgram* program = solidColorProgram(); 827 gfx::Transform deviceTransform = frame.windowMatrix * frame.projectionMatrix * quad->quadTransform();
730 setUseProgram(program->program()); 828 deviceTransform.FlattenTo2d();
829 if (!deviceTransform.IsInvertible())
830 return;
831
832 gfx::QuadF localQuad = gfx::QuadF(gfx::RectF(tileRect));
833 float edge[24];
834 bool useAA = setupQuadForAntialiasing(deviceTransform, quad, &localQuad, edg e);
835
836 SolidColorProgramUniforms uniforms;
837 if (useAA)
838 solidColorUniformLocation(solidColorProgramAA(), uniforms);
839 else
840 solidColorUniformLocation(solidColorProgram(), uniforms);
841 setUseProgram(uniforms.program);
731 842
732 SkColor color = quad->color; 843 SkColor color = quad->color;
733 float opacity = quad->opacity(); 844 float opacity = quad->opacity();
734 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; 845 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
735 846
736 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, alpha)); 847 GLC(context(), context()->uniform4f(uniforms.colorLocation,
848 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
849 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
850 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
851 alpha));
737 852
738 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh ader().matrixLocation()); 853 GLC(context(), context()->uniform2f(uniforms.texScaleLocation, 1.0f, 1.0f));
854
855 if (useAA) {
856 GLC(context(), context()->uniform3fv(uniforms.edgeLocation, 8, edge));
857 }
858
859 // Enable blending when the quad properties require it or if we decided
860 // to use antialiasing.
861 setBlendEnabled(quad->ShouldDrawWithBlending() || useAA);
862
863 // Normalize to tileRect.
864 localQuad.Scale(1.0f / tileRect.width(), 1.0f / tileRect.height());
865
866 setShaderQuadF(localQuad, uniforms.pointLocation);
867
868 // The transform and vertex data are used to figure out the extents that the
869 // un-antialiased quad should have and which vertex this is and the float
870 // quad passed in via uniform is the actual geometry that gets used to draw
871 // it. This is why this centered rect is used and not the original quadRect.
872 gfx::RectF centeredRect(gfx::PointF(-0.5 * tileRect.width(), -0.5 * tileRect .height()), tileRect.size());
873 drawQuadGeometry(frame, quad->quadTransform(), centeredRect, uniforms.matrix Location);
739 } 874 }
740 875
741 struct TileProgramUniforms { 876 struct TileProgramUniforms {
742 unsigned program; 877 unsigned program;
743 unsigned samplerLocation; 878 unsigned samplerLocation;
744 unsigned vertexTexTransformLocation; 879 unsigned vertexTexTransformLocation;
745 unsigned fragmentTexTransformLocation; 880 unsigned fragmentTexTransformLocation;
746 unsigned edgeLocation; 881 unsigned edgeLocation;
747 unsigned matrixLocation; 882 unsigned matrixLocation;
748 unsigned alphaLocation; 883 unsigned alphaLocation;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 float vertexTexScaleX = tileRect.width() / clampGeomRect.width(); 941 float vertexTexScaleX = tileRect.width() / clampGeomRect.width();
807 float vertexTexScaleY = tileRect.height() / clampGeomRect.height(); 942 float vertexTexScaleY = tileRect.height() / clampGeomRect.height();
808 943
809 // Map to normalized texture coordinates. 944 // Map to normalized texture coordinates.
810 const gfx::Size& textureSize = quad->texture_size; 945 const gfx::Size& textureSize = quad->texture_size;
811 float fragmentTexTranslateX = clampTexRect.x() / textureSize.width(); 946 float fragmentTexTranslateX = clampTexRect.x() / textureSize.width();
812 float fragmentTexTranslateY = clampTexRect.y() / textureSize.height(); 947 float fragmentTexTranslateY = clampTexRect.y() / textureSize.height();
813 float fragmentTexScaleX = clampTexRect.width() / textureSize.width(); 948 float fragmentTexScaleX = clampTexRect.width() / textureSize.width();
814 float fragmentTexScaleY = clampTexRect.height() / textureSize.height(); 949 float fragmentTexScaleY = clampTexRect.height() / textureSize.height();
815 950
816 gfx::QuadF localQuad;
817 gfx::Transform deviceTransform = frame.windowMatrix * frame.projectionMatrix * quad->quadTransform(); 951 gfx::Transform deviceTransform = frame.windowMatrix * frame.projectionMatrix * quad->quadTransform();
818 deviceTransform.FlattenTo2d(); 952 deviceTransform.FlattenTo2d();
819 if (!deviceTransform.IsInvertible()) 953 if (!deviceTransform.IsInvertible())
820 return; 954 return;
821 955
822 bool clipped = false; 956 gfx::QuadF localQuad = gfx::QuadF(gfx::RectF(tileRect));
823 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q uad->visibleContentRect()), clipped); 957 float edge[24];
824 DCHECK(!clipped); 958 bool useAA = setupQuadForAntialiasing(deviceTransform, quad, &localQuad, edg e);
825
826 // TODO(reveman): Axis-aligned is not enough to avoid anti-aliasing.
827 // Bounding rectangle for quad also needs to be expressible as
828 // an integer rectangle. crbug.com/169374
829 bool isAxisAlignedInTarget = deviceLayerQuad.IsRectilinear();
830 bool useAA = !clipped && !isAxisAlignedInTarget && quad->IsEdge();
831 959
832 TileProgramUniforms uniforms; 960 TileProgramUniforms uniforms;
833 if (useAA) { 961 if (useAA) {
834 if (quad->swizzle_contents) 962 if (quad->swizzle_contents)
835 tileUniformLocation(tileProgramSwizzleAA(), uniforms); 963 tileUniformLocation(tileProgramSwizzleAA(), uniforms);
836 else 964 else
837 tileUniformLocation(tileProgramAA(), uniforms); 965 tileUniformLocation(tileProgramAA(), uniforms);
838 } else { 966 } else {
839 if (quad->ShouldDrawWithBlending()) { 967 if (quad->ShouldDrawWithBlending()) {
840 if (quad->swizzle_contents) 968 if (quad->swizzle_contents)
841 tileUniformLocation(tileProgramSwizzle(), uniforms); 969 tileUniformLocation(tileProgramSwizzle(), uniforms);
842 else 970 else
843 tileUniformLocation(tileProgram(), uniforms); 971 tileUniformLocation(tileProgram(), uniforms);
844 } else { 972 } else {
845 if (quad->swizzle_contents) 973 if (quad->swizzle_contents)
846 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); 974 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms);
847 else 975 else
848 tileUniformLocation(tileProgramOpaque(), uniforms); 976 tileUniformLocation(tileProgramOpaque(), uniforms);
849 } 977 }
850 } 978 }
851 979
852 setUseProgram(uniforms.program); 980 setUseProgram(uniforms.program);
853 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); 981 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0));
854 bool scaled = (texToGeomScaleX != 1 || texToGeomScaleY != 1); 982 bool scaled = (texToGeomScaleX != 1 || texToGeomScaleY != 1);
855 GLenum filter = (useAA || scaled || !quad->quadTransform().IsIdentityOrInteg erTranslation()) ? GL_LINEAR : GL_NEAREST; 983 GLenum filter = (useAA || scaled || !quad->quadTransform().IsIdentityOrInteg erTranslation()) ? GL_LINEAR : GL_NEAREST;
856 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad- >resource_id, GL_TEXTURE_2D, filter); 984 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad- >resource_id, GL_TEXTURE_2D, filter);
857 985
858 if (useAA) { 986 if (useAA) {
859 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound ingBox()));
860 deviceLayerBounds.inflateAntiAliasingDistance();
861
862 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad);
863 deviceLayerEdges.inflateAntiAliasingDistance();
864
865 float edge[24];
866 deviceLayerEdges.toFloatArray(edge);
867 deviceLayerBounds.toFloatArray(&edge[12]);
868 GLC(context(), context()->uniform3fv(uniforms.edgeLocation, 8, edge)); 987 GLC(context(), context()->uniform3fv(uniforms.edgeLocation, 8, edge));
869
870 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation, vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); 988 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation, vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY));
871 GLC(context(), context()->uniform4f(uniforms.fragmentTexTransformLocatio n, fragmentTexTranslateX, fragmentTexTranslateY, fragmentTexScaleX, fragmentTexS caleY)); 989 GLC(context(), context()->uniform4f(uniforms.fragmentTexTransformLocatio n, fragmentTexTranslateX, fragmentTexTranslateY, fragmentTexScaleX, fragmentTexS caleY));
872
873 gfx::PointF bottomRight = tileRect.bottom_right();
874 gfx::PointF bottomLeft = tileRect.bottom_left();
875 gfx::PointF topLeft = tileRect.origin();
876 gfx::PointF topRight = tileRect.top_right();
877
878 // Map points to device space.
879 bottomRight = MathUtil::mapPoint(deviceTransform, bottomRight, clipped);
880 DCHECK(!clipped);
881 bottomLeft = MathUtil::mapPoint(deviceTransform, bottomLeft, clipped);
882 DCHECK(!clipped);
883 topLeft = MathUtil::mapPoint(deviceTransform, topLeft, clipped);
884 DCHECK(!clipped);
885 topRight = MathUtil::mapPoint(deviceTransform, topRight, clipped);
886 DCHECK(!clipped);
887
888 LayerQuad::Edge bottomEdge(bottomRight, bottomLeft);
889 LayerQuad::Edge leftEdge(bottomLeft, topLeft);
890 LayerQuad::Edge topEdge(topLeft, topRight);
891 LayerQuad::Edge rightEdge(topRight, bottomRight);
892
893 // Only apply anti-aliasing to edges not clipped by culling or scissorin g.
894 if (quad->IsTopEdge() && tileRect.y() == quad->rect.y())
895 topEdge = deviceLayerEdges.top();
896 if (quad->IsLeftEdge() && tileRect.x() == quad->rect.x())
897 leftEdge = deviceLayerEdges.left();
898 if (quad->IsRightEdge() && tileRect.right() == quad->rect.right())
899 rightEdge = deviceLayerEdges.right();
900 if (quad->IsBottomEdge() && tileRect.bottom() == quad->rect.bottom())
901 bottomEdge = deviceLayerEdges.bottom();
902
903 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1;
904 bottomEdge.scale(sign);
905 leftEdge.scale(sign);
906 topEdge.scale(sign);
907 rightEdge.scale(sign);
908
909 // Create device space quad.
910 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge);
911
912 // Map device space quad to local space. deviceTransform has no 3d compo nent since it was flattened, so we don't need to project.
913 // We should have already checked that the transform was uninvertible ab ove.
914 gfx::Transform inverseDeviceTransform(gfx::Transform::kSkipInitializatio n);
915 bool didInvert = deviceTransform.GetInverse(&inverseDeviceTransform);
916 DCHECK(didInvert);
917 localQuad = MathUtil::mapQuad(inverseDeviceTransform, deviceQuad.ToQuadF (), clipped);
918
919 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become
920 // clipped. To our knowledge this scenario does not need to be handled d ifferently than the unclipped case.
921 } else { 990 } else {
922 // Move fragment shader transform to vertex shader. We can do this while 991 // Move fragment shader transform to vertex shader. We can do this while
923 // still producing correct results as fragmentTexTransformLocation 992 // still producing correct results as fragmentTexTransformLocation
924 // should always be non-negative when tiles are transformed in a way 993 // should always be non-negative when tiles are transformed in a way
925 // that could result in sampling outside the layer. 994 // that could result in sampling outside the layer.
926 vertexTexScaleX *= fragmentTexScaleX; 995 vertexTexScaleX *= fragmentTexScaleX;
927 vertexTexScaleY *= fragmentTexScaleY; 996 vertexTexScaleY *= fragmentTexScaleY;
928 vertexTexTranslateX *= fragmentTexScaleX; 997 vertexTexTranslateX *= fragmentTexScaleX;
929 vertexTexTranslateY *= fragmentTexScaleY; 998 vertexTexTranslateY *= fragmentTexScaleY;
930 vertexTexTranslateX += fragmentTexTranslateX; 999 vertexTexTranslateX += fragmentTexTranslateX;
931 vertexTexTranslateY += fragmentTexTranslateY; 1000 vertexTexTranslateY += fragmentTexTranslateY;
932 1001
933 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation, vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); 1002 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation, vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY));
934
935 localQuad = gfx::RectF(tileRect);
936 } 1003 }
937 1004
938 // Enable blending when the quad properties require it or if we decided 1005 // Enable blending when the quad properties require it or if we decided
939 // to use antialiasing. 1006 // to use antialiasing.
940 setBlendEnabled(quad->ShouldDrawWithBlending() || useAA); 1007 setBlendEnabled(quad->ShouldDrawWithBlending() || useAA);
941 1008
942 // Normalize to tileRect. 1009 // Normalize to tileRect.
943 localQuad.Scale(1.0f / tileRect.width(), 1.0f / tileRect.height()); 1010 localQuad.Scale(1.0f / tileRect.width(), 1.0f / tileRect.height());
944 1011
945 setShaderOpacity(quad->opacity(), uniforms.alphaLocation); 1012 setShaderOpacity(quad->opacity(), uniforms.alphaLocation);
946 setShaderQuadF(localQuad, uniforms.pointLocation); 1013 setShaderQuadF(localQuad, uniforms.pointLocation);
947 1014
948 // The tile quad shader behaves differently compared to all other shaders.
949 // The transform and vertex data are used to figure out the extents that the 1015 // The transform and vertex data are used to figure out the extents that the
950 // un-antialiased quad should have and which vertex this is and the float 1016 // un-antialiased quad should have and which vertex this is and the float
951 // quad passed in via uniform is the actual geometry that gets used to draw 1017 // quad passed in via uniform is the actual geometry that gets used to draw
952 // it. This is why this centered rect is used and not the original quadRect. 1018 // it. This is why this centered rect is used and not the original quadRect.
953 gfx::RectF centeredRect(gfx::PointF(-0.5f * tileRect.width(), -0.5f * tileRe ct.height()), tileRect.size()); 1019 gfx::RectF centeredRect(gfx::PointF(-0.5f * tileRect.width(), -0.5f * tileRe ct.height()), tileRect.size());
954 drawQuadGeometry(frame, quad->quadTransform(), centeredRect, uniforms.matrix Location); 1020 drawQuadGeometry(frame, quad->quadTransform(), centeredRect, uniforms.matrix Location);
955 } 1021 }
956 1022
957 void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQ uad* quad) 1023 void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQ uad* quad)
958 { 1024 {
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 { 1706 {
1641 if (!m_solidColorProgram) 1707 if (!m_solidColorProgram)
1642 m_solidColorProgram = make_scoped_ptr(new SolidColorProgram(m_context)); 1708 m_solidColorProgram = make_scoped_ptr(new SolidColorProgram(m_context));
1643 if (!m_solidColorProgram->initialized()) { 1709 if (!m_solidColorProgram->initialized()) {
1644 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); 1710 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize");
1645 m_solidColorProgram->initialize(m_context, m_isUsingBindUniform); 1711 m_solidColorProgram->initialize(m_context, m_isUsingBindUniform);
1646 } 1712 }
1647 return m_solidColorProgram.get(); 1713 return m_solidColorProgram.get();
1648 } 1714 }
1649 1715
1716 const GLRenderer::SolidColorProgramAA* GLRenderer::solidColorProgramAA()
1717 {
1718 if (!m_solidColorProgramAA)
1719 m_solidColorProgramAA = make_scoped_ptr(new SolidColorProgramAA(m_conte xt));
1720 if (!m_solidColorProgramAA->initialized()) {
1721 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize");
1722 m_solidColorProgramAA->initialize(m_context, m_isUsingBindUniform);
1723 }
1724 return m_solidColorProgramAA.get();
1725 }
1726
1650 const GLRenderer::RenderPassProgram* GLRenderer::renderPassProgram() 1727 const GLRenderer::RenderPassProgram* GLRenderer::renderPassProgram()
1651 { 1728 {
1652 DCHECK(m_renderPassProgram); 1729 DCHECK(m_renderPassProgram);
1653 if (!m_renderPassProgram->initialized()) { 1730 if (!m_renderPassProgram->initialized()) {
1654 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); 1731 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize");
1655 m_renderPassProgram->initialize(m_context, m_isUsingBindUniform); 1732 m_renderPassProgram->initialize(m_context, m_isUsingBindUniform);
1656 } 1733 }
1657 return m_renderPassProgram.get(); 1734 return m_renderPassProgram.get();
1658 } 1735 }
1659 1736
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 if (m_textureIOSurfaceProgram) 1923 if (m_textureIOSurfaceProgram)
1847 m_textureIOSurfaceProgram->cleanup(m_context); 1924 m_textureIOSurfaceProgram->cleanup(m_context);
1848 1925
1849 if (m_videoYUVProgram) 1926 if (m_videoYUVProgram)
1850 m_videoYUVProgram->cleanup(m_context); 1927 m_videoYUVProgram->cleanup(m_context);
1851 if (m_videoStreamTextureProgram) 1928 if (m_videoStreamTextureProgram)
1852 m_videoStreamTextureProgram->cleanup(m_context); 1929 m_videoStreamTextureProgram->cleanup(m_context);
1853 1930
1854 if (m_solidColorProgram) 1931 if (m_solidColorProgram)
1855 m_solidColorProgram->cleanup(m_context); 1932 m_solidColorProgram->cleanup(m_context);
1933 if (m_solidColorProgramAA)
1934 m_solidColorProgramAA->cleanup(m_context);
1856 1935
1857 if (m_offscreenFramebufferId) 1936 if (m_offscreenFramebufferId)
1858 GLC(m_context, m_context->deleteFramebuffer(m_offscreenFramebufferId)); 1937 GLC(m_context, m_context->deleteFramebuffer(m_offscreenFramebufferId));
1859 1938
1860 releaseRenderPassTextures(); 1939 releaseRenderPassTextures();
1861 } 1940 }
1862 1941
1863 bool GLRenderer::isContextLost() 1942 bool GLRenderer::isContextLost()
1864 { 1943 {
1865 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1944 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1866 } 1945 }
1867 1946
1868 } // namespace cc 1947 } // namespace cc
OLDNEW
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_pixeltest.cc » ('j') | cc/gl_renderer_pixeltest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698