| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
| (...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 | 1469 |
| 1470 int numTextureAccesses = textureAccesses.count(); | 1470 int numTextureAccesses = textureAccesses.count(); |
| 1471 for (int i = 0; i < numTextureAccesses; i++) { | 1471 for (int i = 0; i < numTextureAccesses; i++) { |
| 1472 this->bindTexture(i, textureAccesses[i]->getParams(), | 1472 this->bindTexture(i, textureAccesses[i]->getParams(), |
| 1473 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu
re())); | 1473 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu
re())); |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); | 1476 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); |
| 1477 this->flushStencil(pipeline.getStencil()); | 1477 this->flushStencil(pipeline.getStencil()); |
| 1478 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); | 1478 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); |
| 1479 this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); | 1479 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc
il().isDisabled()); |
| 1480 | 1480 |
| 1481 // This must come after textures are flushed because a texture may need | 1481 // This must come after textures are flushed because a texture may need |
| 1482 // to be msaa-resolved (which will modify bound FBO state). | 1482 // to be msaa-resolved (which will modify bound FBO state). |
| 1483 this->flushRenderTarget(glRT, nullptr); | 1483 this->flushRenderTarget(glRT, nullptr); |
| 1484 | 1484 |
| 1485 return true; | 1485 return true; |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, | 1488 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
| 1489 const GrNonInstancedVertices& vertices, | 1489 const GrNonInstancedVertices& vertices, |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 if (!flipY) { | 1892 if (!flipY) { |
| 1893 dst += rowBytes; | 1893 dst += rowBytes; |
| 1894 } else { | 1894 } else { |
| 1895 dst -= rowBytes; | 1895 dst -= rowBytes; |
| 1896 } | 1896 } |
| 1897 } | 1897 } |
| 1898 } | 1898 } |
| 1899 return true; | 1899 return true; |
| 1900 } | 1900 } |
| 1901 | 1901 |
| 1902 void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedS
ampleLocations) { |
| 1903 GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget
()); |
| 1904 SkASSERT(0 != target->renderFBOID()); |
| 1905 |
| 1906 if (!rt->isStencilBufferMultisampled() || |
| 1907 useColocatedSampleLocations == target->usesColocatedSampleLocations()) { |
| 1908 return; |
| 1909 } |
| 1910 |
| 1911 GL_CALL(NamedFramebufferParameteri(target->renderFBOID(), |
| 1912 GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOC
ATIONS, |
| 1913 useColocatedSampleLocations)); |
| 1914 |
| 1915 target->flagAsUsingColocatedSampleLocations(useColocatedSampleLocations); |
| 1916 } |
| 1917 |
| 1902 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ | 1918 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ |
| 1903 | 1919 |
| 1904 SkASSERT(target); | 1920 SkASSERT(target); |
| 1905 | 1921 |
| 1906 uint32_t rtID = target->getUniqueID(); | 1922 uint32_t rtID = target->getUniqueID(); |
| 1907 if (fHWBoundRenderTargetUniqueID != rtID) { | 1923 if (fHWBoundRenderTargetUniqueID != rtID) { |
| 1908 fStats.incRenderTargetBinds(); | 1924 fStats.incRenderTargetBinds(); |
| 1909 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 1925 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
| 1910 #ifdef SK_DEBUG | 1926 #ifdef SK_DEBUG |
| 1911 // don't do this check in Chromium -- this is causing | 1927 // don't do this check in Chromium -- this is causing |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 set_gl_stencil(this->glInterface(), | 2155 set_gl_stencil(this->glInterface(), |
| 2140 stencilSettings, | 2156 stencilSettings, |
| 2141 GR_GL_FRONT_AND_BACK, | 2157 GR_GL_FRONT_AND_BACK, |
| 2142 GrStencilSettings::kFront_Face); | 2158 GrStencilSettings::kFront_Face); |
| 2143 } | 2159 } |
| 2144 } | 2160 } |
| 2145 fHWStencilSettings = stencilSettings; | 2161 fHWStencilSettings = stencilSettings; |
| 2146 } | 2162 } |
| 2147 } | 2163 } |
| 2148 | 2164 |
| 2149 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2165 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { |
| 2150 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2166 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
| 2151 | 2167 |
| 2168 if (rt->hasMixedSamples() && stencilEnabled && |
| 2169 this->glCaps().glslCaps()->programmableSampleLocationsSupport()) { |
| 2170 if (useHWAA) { |
| 2171 this->setColocatedSampleLocations(rt, false); |
| 2172 } else { |
| 2173 this->setColocatedSampleLocations(rt, true); |
| 2174 } |
| 2175 useHWAA = true; |
| 2176 } |
| 2177 |
| 2152 if (this->glCaps().multisampleDisableSupport()) { | 2178 if (this->glCaps().multisampleDisableSupport()) { |
| 2153 if (useHWAA) { | 2179 if (useHWAA) { |
| 2154 if (kYes_TriState != fMSAAEnabled) { | 2180 if (kYes_TriState != fMSAAEnabled) { |
| 2155 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2181 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
| 2156 fMSAAEnabled = kYes_TriState; | 2182 fMSAAEnabled = kYes_TriState; |
| 2157 } | 2183 } |
| 2158 } else { | 2184 } else { |
| 2159 if (kNo_TriState != fMSAAEnabled) { | 2185 if (kNo_TriState != fMSAAEnabled) { |
| 2160 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2186 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
| 2161 fMSAAEnabled = kNo_TriState; | 2187 fMSAAEnabled = kNo_TriState; |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2909 | 2935 |
| 2910 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); | 2936 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); |
| 2911 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); | 2937 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); |
| 2912 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); | 2938 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); |
| 2913 | 2939 |
| 2914 GrXferProcessor::BlendInfo blendInfo; | 2940 GrXferProcessor::BlendInfo blendInfo; |
| 2915 blendInfo.reset(); | 2941 blendInfo.reset(); |
| 2916 this->flushBlend(blendInfo); | 2942 this->flushBlend(blendInfo); |
| 2917 this->flushColorWrite(true); | 2943 this->flushColorWrite(true); |
| 2918 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 2944 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 2919 this->flushHWAAState(dstRT, false); | 2945 this->flushHWAAState(dstRT, false, false); |
| 2920 this->disableScissor(); | 2946 this->disableScissor(); |
| 2921 GrStencilSettings stencil; | 2947 GrStencilSettings stencil; |
| 2922 stencil.setDisabled(); | 2948 stencil.setDisabled(); |
| 2923 this->flushStencil(stencil); | 2949 this->flushStencil(stencil); |
| 2924 | 2950 |
| 2925 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | 2951 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
| 2926 } | 2952 } |
| 2927 | 2953 |
| 2928 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, | 2954 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, |
| 2929 GrSurface* src, | 2955 GrSurface* src, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3144 this->setVertexArrayID(gpu, 0); | 3170 this->setVertexArrayID(gpu, 0); |
| 3145 } | 3171 } |
| 3146 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3172 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3147 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3173 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3148 fDefaultVertexArrayAttribState.resize(attrCount); | 3174 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3149 } | 3175 } |
| 3150 attribState = &fDefaultVertexArrayAttribState; | 3176 attribState = &fDefaultVertexArrayAttribState; |
| 3151 } | 3177 } |
| 3152 return attribState; | 3178 return attribState; |
| 3153 } | 3179 } |
| OLD | NEW |