| 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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 } | 1337 } |
| 1338 return; | 1338 return; |
| 1339 } | 1339 } |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 // See fall through note above | 1342 // See fall through note above |
| 1343 this->disableScissor(); | 1343 this->disableScissor(); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 bool GrGLGpu::flushGLState(const GrOptDrawState& optState) { | 1346 bool GrGLGpu::flushGLState(const GrOptDrawState& optState) { |
| 1347 GrXferProcessor::BlendInfo blendInfo; |
| 1348 optState.getXferProcessor()->getBlendInfo(&blendInfo); |
| 1349 |
| 1347 this->flushDither(optState.isDitherState()); | 1350 this->flushDither(optState.isDitherState()); |
| 1348 this->flushColorWriteDisable(optState.isColorWriteDisabled()); | 1351 this->flushColorWrite(blendInfo.fWriteColor); |
| 1349 this->flushDrawFace(optState.getDrawFace()); | 1352 this->flushDrawFace(optState.getDrawFace()); |
| 1350 | 1353 |
| 1351 fCurrentProgram.reset(fProgramCache->getProgram(optState)); | 1354 fCurrentProgram.reset(fProgramCache->getProgram(optState)); |
| 1352 if (NULL == fCurrentProgram.get()) { | 1355 if (NULL == fCurrentProgram.get()) { |
| 1353 SkDEBUGFAIL("Failed to create program!"); | 1356 SkDEBUGFAIL("Failed to create program!"); |
| 1354 return false; | 1357 return false; |
| 1355 } | 1358 } |
| 1356 | 1359 |
| 1357 fCurrentProgram.get()->ref(); | 1360 fCurrentProgram.get()->ref(); |
| 1358 | 1361 |
| 1359 GrGLuint programID = fCurrentProgram->programID(); | 1362 GrGLuint programID = fCurrentProgram->programID(); |
| 1360 if (fHWProgramID != programID) { | 1363 if (fHWProgramID != programID) { |
| 1361 GL_CALL(UseProgram(programID)); | 1364 GL_CALL(UseProgram(programID)); |
| 1362 fHWProgramID = programID; | 1365 fHWProgramID = programID; |
| 1363 } | 1366 } |
| 1364 | 1367 |
| 1365 this->flushBlend(optState); | 1368 if (blendInfo.fWriteColor) { |
| 1369 this->flushBlend(blendInfo); |
| 1370 } |
| 1366 | 1371 |
| 1367 fCurrentProgram->setData(optState); | 1372 fCurrentProgram->setData(optState); |
| 1368 | 1373 |
| 1369 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTa
rget()); | 1374 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTa
rget()); |
| 1370 this->flushStencil(optState.getStencil()); | 1375 this->flushStencil(optState.getStencil()); |
| 1371 this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->or
igin()); | 1376 this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->or
igin()); |
| 1372 this->flushHWAAState(glRT, optState.isHWAntialiasState(), | 1377 this->flushHWAAState(glRT, optState.isHWAntialiasState(), |
| 1373 kDrawLines_DrawType == optState.drawType()); | 1378 kDrawLines_DrawType == optState.drawType()); |
| 1374 | 1379 |
| 1375 // This must come after textures are flushed because a texture may need | 1380 // This must come after textures are flushed because a texture may need |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 aglSwapBuffers(aglGetCurrentContext()); | 1862 aglSwapBuffers(aglGetCurrentContext()); |
| 1858 #elif defined(SK_BUILD_FOR_WIN32) | 1863 #elif defined(SK_BUILD_FOR_WIN32) |
| 1859 SwapBuf(); | 1864 SwapBuf(); |
| 1860 int set_a_break_pt_here = 9; | 1865 int set_a_break_pt_here = 9; |
| 1861 SwapBuf(); | 1866 SwapBuf(); |
| 1862 #endif | 1867 #endif |
| 1863 #endif | 1868 #endif |
| 1864 } | 1869 } |
| 1865 | 1870 |
| 1866 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { | 1871 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { |
| 1867 this->flushColorWriteDisable(true); | 1872 this->flushColorWrite(false); |
| 1868 this->flushDrawFace(GrDrawState::kBoth_DrawFace); | 1873 this->flushDrawFace(GrDrawState::kBoth_DrawFace); |
| 1869 | 1874 |
| 1870 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget); | 1875 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget); |
| 1871 SkISize size = SkISize::Make(rt->width(), rt->height()); | 1876 SkISize size = SkISize::Make(rt->width(), rt->height()); |
| 1872 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o
rigin()); | 1877 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o
rigin()); |
| 1873 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); | 1878 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); |
| 1874 this->flushHWAAState(rt, state.fUseHWAA, false); | 1879 this->flushHWAAState(rt, state.fUseHWAA, false); |
| 1875 this->flushRenderTarget(rt, NULL); | 1880 this->flushRenderTarget(rt, NULL); |
| 1876 | 1881 |
| 1877 fPathRendering->stencilPath(path, *state.fStencil); | 1882 fPathRendering->stencilPath(path, *state.fStencil); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 } else { | 2053 } else { |
| 2049 if (kNo_TriState != fMSAAEnabled) { | 2054 if (kNo_TriState != fMSAAEnabled) { |
| 2050 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2055 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
| 2051 fMSAAEnabled = kNo_TriState; | 2056 fMSAAEnabled = kNo_TriState; |
| 2052 } | 2057 } |
| 2053 } | 2058 } |
| 2054 } | 2059 } |
| 2055 } | 2060 } |
| 2056 } | 2061 } |
| 2057 | 2062 |
| 2058 void GrGLGpu::flushBlend(const GrOptDrawState& optState) { | 2063 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |
| 2059 // Any optimization to disable blending should have already been applied and | 2064 // Any optimization to disable blending should have already been applied and |
| 2060 // tweaked the coeffs to (1, 0). | 2065 // tweaked the coeffs to (1, 0). |
| 2061 | 2066 |
| 2062 GrXferProcessor::BlendInfo blendInfo; | |
| 2063 optState.getXferProcessor()->getBlendInfo(&blendInfo); | |
| 2064 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; | 2067 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
| 2065 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; | 2068 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; |
| 2066 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; | 2069 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; |
| 2067 if (blendOff) { | 2070 if (blendOff) { |
| 2068 if (kNo_TriState != fHWBlendState.fEnabled) { | 2071 if (kNo_TriState != fHWBlendState.fEnabled) { |
| 2069 GL_CALL(Disable(GR_GL_BLEND)); | 2072 GL_CALL(Disable(GR_GL_BLEND)); |
| 2070 fHWBlendState.fEnabled = kNo_TriState; | 2073 fHWBlendState.fEnabled = kNo_TriState; |
| 2071 } | 2074 } |
| 2072 } else { | 2075 } else { |
| 2073 if (kYes_TriState != fHWBlendState.fEnabled) { | 2076 if (kYes_TriState != fHWBlendState.fEnabled) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2215 fHWDitherEnabled = kYes_TriState; | 2218 fHWDitherEnabled = kYes_TriState; |
| 2216 } | 2219 } |
| 2217 } else { | 2220 } else { |
| 2218 if (kNo_TriState != fHWDitherEnabled) { | 2221 if (kNo_TriState != fHWDitherEnabled) { |
| 2219 GL_CALL(Disable(GR_GL_DITHER)); | 2222 GL_CALL(Disable(GR_GL_DITHER)); |
| 2220 fHWDitherEnabled = kNo_TriState; | 2223 fHWDitherEnabled = kNo_TriState; |
| 2221 } | 2224 } |
| 2222 } | 2225 } |
| 2223 } | 2226 } |
| 2224 | 2227 |
| 2225 void GrGLGpu::flushColorWriteDisable(bool disableColorWrites) { | 2228 void GrGLGpu::flushColorWrite(bool writeColor) { |
| 2226 if (disableColorWrites) { | 2229 if (!writeColor) { |
| 2227 if (kNo_TriState != fHWWriteToColor) { | 2230 if (kNo_TriState != fHWWriteToColor) { |
| 2228 GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE, | 2231 GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE, |
| 2229 GR_GL_FALSE, GR_GL_FALSE)); | 2232 GR_GL_FALSE, GR_GL_FALSE)); |
| 2230 fHWWriteToColor = kNo_TriState; | 2233 fHWWriteToColor = kNo_TriState; |
| 2231 } | 2234 } |
| 2232 } else { | 2235 } else { |
| 2233 if (kYes_TriState != fHWWriteToColor) { | 2236 if (kYes_TriState != fHWWriteToColor) { |
| 2234 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); | 2237 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); |
| 2235 fHWWriteToColor = kYes_TriState; | 2238 fHWWriteToColor = kYes_TriState; |
| 2236 } | 2239 } |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 this->setVertexArrayID(gpu, 0); | 2739 this->setVertexArrayID(gpu, 0); |
| 2737 } | 2740 } |
| 2738 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2741 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2739 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2742 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2740 fDefaultVertexArrayAttribState.resize(attrCount); | 2743 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2741 } | 2744 } |
| 2742 attribState = &fDefaultVertexArrayAttribState; | 2745 attribState = &fDefaultVertexArrayAttribState; |
| 2743 } | 2746 } |
| 2744 return attribState; | 2747 return attribState; |
| 2745 } | 2748 } |
| OLD | NEW |