| 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 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 | 1493 |
| 1494 int numTextureAccesses = textureAccesses.count(); | 1494 int numTextureAccesses = textureAccesses.count(); |
| 1495 for (int i = 0; i < numTextureAccesses; i++) { | 1495 for (int i = 0; i < numTextureAccesses; i++) { |
| 1496 this->bindTexture(i, textureAccesses[i]->getParams(), | 1496 this->bindTexture(i, textureAccesses[i]->getParams(), |
| 1497 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu
re())); | 1497 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu
re())); |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); | 1500 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); |
| 1501 this->flushStencil(pipeline.getStencil()); | 1501 this->flushStencil(pipeline.getStencil()); |
| 1502 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); | 1502 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); |
| 1503 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc
il().isDisabled()); | 1503 this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); |
| 1504 | 1504 |
| 1505 // This must come after textures are flushed because a texture may need | 1505 // This must come after textures are flushed because a texture may need |
| 1506 // to be msaa-resolved (which will modify bound FBO state). | 1506 // to be msaa-resolved (which will modify bound FBO state). |
| 1507 this->flushRenderTarget(glRT, nullptr); | 1507 this->flushRenderTarget(glRT, nullptr); |
| 1508 | 1508 |
| 1509 return true; | 1509 return true; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, | 1512 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
| 1513 const GrNonInstancedVertices& vertices, | 1513 const GrNonInstancedVertices& vertices, |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 if (!flipY) { | 2027 if (!flipY) { |
| 2028 dst += rowBytes; | 2028 dst += rowBytes; |
| 2029 } else { | 2029 } else { |
| 2030 dst -= rowBytes; | 2030 dst -= rowBytes; |
| 2031 } | 2031 } |
| 2032 } | 2032 } |
| 2033 } | 2033 } |
| 2034 return true; | 2034 return true; |
| 2035 } | 2035 } |
| 2036 | 2036 |
| 2037 void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedS
ampleLocations) { | |
| 2038 GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget
()); | |
| 2039 SkASSERT(0 != target->renderFBOID()); | |
| 2040 | |
| 2041 if (!rt->isStencilBufferMultisampled() || | |
| 2042 useColocatedSampleLocations == target->usesColocatedSampleLocations()) { | |
| 2043 return; | |
| 2044 } | |
| 2045 | |
| 2046 GL_CALL(NamedFramebufferParameteri(target->renderFBOID(), | |
| 2047 GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOC
ATIONS, | |
| 2048 useColocatedSampleLocations)); | |
| 2049 | |
| 2050 target->flagAsUsingColocatedSampleLocations(useColocatedSampleLocations); | |
| 2051 } | |
| 2052 | |
| 2053 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ | 2037 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ |
| 2054 | 2038 |
| 2055 SkASSERT(target); | 2039 SkASSERT(target); |
| 2056 | 2040 |
| 2057 uint32_t rtID = target->getUniqueID(); | 2041 uint32_t rtID = target->getUniqueID(); |
| 2058 if (fHWBoundRenderTargetUniqueID != rtID) { | 2042 if (fHWBoundRenderTargetUniqueID != rtID) { |
| 2059 fStats.incRenderTargetBinds(); | 2043 fStats.incRenderTargetBinds(); |
| 2060 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 2044 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
| 2061 #ifdef SK_DEBUG | 2045 #ifdef SK_DEBUG |
| 2062 // don't do this check in Chromium -- this is causing | 2046 // don't do this check in Chromium -- this is causing |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 set_gl_stencil(this->glInterface(), | 2274 set_gl_stencil(this->glInterface(), |
| 2291 stencilSettings, | 2275 stencilSettings, |
| 2292 GR_GL_FRONT_AND_BACK, | 2276 GR_GL_FRONT_AND_BACK, |
| 2293 GrStencilSettings::kFront_Face); | 2277 GrStencilSettings::kFront_Face); |
| 2294 } | 2278 } |
| 2295 } | 2279 } |
| 2296 fHWStencilSettings = stencilSettings; | 2280 fHWStencilSettings = stencilSettings; |
| 2297 } | 2281 } |
| 2298 } | 2282 } |
| 2299 | 2283 |
| 2300 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { | 2284 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
| 2301 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2285 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
| 2302 | 2286 |
| 2303 if (rt->hasMixedSamples() && stencilEnabled && | |
| 2304 this->glCaps().glslCaps()->programmableSampleLocationsSupport()) { | |
| 2305 if (useHWAA) { | |
| 2306 this->setColocatedSampleLocations(rt, false); | |
| 2307 } else { | |
| 2308 this->setColocatedSampleLocations(rt, true); | |
| 2309 } | |
| 2310 useHWAA = true; | |
| 2311 } | |
| 2312 | |
| 2313 if (this->glCaps().multisampleDisableSupport()) { | 2287 if (this->glCaps().multisampleDisableSupport()) { |
| 2314 if (useHWAA) { | 2288 if (useHWAA) { |
| 2315 if (kYes_TriState != fMSAAEnabled) { | 2289 if (kYes_TriState != fMSAAEnabled) { |
| 2316 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2290 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
| 2317 fMSAAEnabled = kYes_TriState; | 2291 fMSAAEnabled = kYes_TriState; |
| 2318 } | 2292 } |
| 2319 } else { | 2293 } else { |
| 2320 if (kNo_TriState != fMSAAEnabled) { | 2294 if (kNo_TriState != fMSAAEnabled) { |
| 2321 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2295 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
| 2322 fMSAAEnabled = kNo_TriState; | 2296 fMSAAEnabled = kNo_TriState; |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3104 | 3078 |
| 3105 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); | 3079 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); |
| 3106 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); | 3080 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); |
| 3107 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); | 3081 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); |
| 3108 | 3082 |
| 3109 GrXferProcessor::BlendInfo blendInfo; | 3083 GrXferProcessor::BlendInfo blendInfo; |
| 3110 blendInfo.reset(); | 3084 blendInfo.reset(); |
| 3111 this->flushBlend(blendInfo); | 3085 this->flushBlend(blendInfo); |
| 3112 this->flushColorWrite(true); | 3086 this->flushColorWrite(true); |
| 3113 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 3087 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 3114 this->flushHWAAState(dstRT, false, false); | 3088 this->flushHWAAState(dstRT, false); |
| 3115 this->disableScissor(); | 3089 this->disableScissor(); |
| 3116 GrStencilSettings stencil; | 3090 GrStencilSettings stencil; |
| 3117 stencil.setDisabled(); | 3091 stencil.setDisabled(); |
| 3118 this->flushStencil(stencil); | 3092 this->flushStencil(stencil); |
| 3119 | 3093 |
| 3120 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | 3094 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
| 3121 } | 3095 } |
| 3122 | 3096 |
| 3123 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, | 3097 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, |
| 3124 GrSurface* src, | 3098 GrSurface* src, |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3349 this->setVertexArrayID(gpu, 0); | 3323 this->setVertexArrayID(gpu, 0); |
| 3350 } | 3324 } |
| 3351 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3325 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3352 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3326 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3353 fDefaultVertexArrayAttribState.resize(attrCount); | 3327 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3354 } | 3328 } |
| 3355 attribState = &fDefaultVertexArrayAttribState; | 3329 attribState = &fDefaultVertexArrayAttribState; |
| 3356 } | 3330 } |
| 3357 return attribState; | 3331 return attribState; |
| 3358 } | 3332 } |
| OLD | NEW |