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 "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 fHWScissorSettings.fEnabled = kYes_TriState; | 1329 fHWScissorSettings.fEnabled = kYes_TriState; |
1330 } | 1330 } |
1331 return; | 1331 return; |
1332 } | 1332 } |
1333 } | 1333 } |
1334 | 1334 |
1335 // See fall through note above | 1335 // See fall through note above |
1336 this->disableScissor(); | 1336 this->disableScissor(); |
1337 } | 1337 } |
1338 | 1338 |
1339 bool GrGLGpu::flushGLState(const DrawArgs& args) { | 1339 bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) { |
1340 GrXferProcessor::BlendInfo blendInfo; | 1340 GrXferProcessor::BlendInfo blendInfo; |
1341 const GrOptDrawState& optState = *args.fOptState; | 1341 const GrOptDrawState& optState = *args.fOptState; |
1342 args.fOptState->getXferProcessor()->getBlendInfo(&blendInfo); | 1342 args.fOptState->getXferProcessor()->getBlendInfo(&blendInfo); |
1343 | 1343 |
1344 this->flushDither(optState.isDitherState()); | 1344 this->flushDither(optState.isDitherState()); |
1345 this->flushColorWrite(blendInfo.fWriteColor); | 1345 this->flushColorWrite(blendInfo.fWriteColor); |
1346 this->flushDrawFace(optState.getDrawFace()); | 1346 this->flushDrawFace(optState.getDrawFace()); |
1347 | 1347 |
1348 fCurrentProgram.reset(fProgramCache->getProgram(args)); | 1348 fCurrentProgram.reset(fProgramCache->getProgram(args)); |
1349 if (NULL == fCurrentProgram.get()) { | 1349 if (NULL == fCurrentProgram.get()) { |
(...skipping 11 matching lines...) Expand all Loading... |
1361 | 1361 |
1362 if (blendInfo.fWriteColor) { | 1362 if (blendInfo.fWriteColor) { |
1363 this->flushBlend(blendInfo); | 1363 this->flushBlend(blendInfo); |
1364 } | 1364 } |
1365 | 1365 |
1366 fCurrentProgram->setData(*args.fPrimitiveProcessor, optState, *args.fBatchTr
acker); | 1366 fCurrentProgram->setData(*args.fPrimitiveProcessor, optState, *args.fBatchTr
acker); |
1367 | 1367 |
1368 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTa
rget()); | 1368 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTa
rget()); |
1369 this->flushStencil(optState.getStencil()); | 1369 this->flushStencil(optState.getStencil()); |
1370 this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->or
igin()); | 1370 this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->or
igin()); |
1371 this->flushHWAAState(glRT, optState.isHWAntialiasState(), | 1371 this->flushHWAAState(glRT, optState.isHWAntialiasState(), isLineDraw); |
1372 kDrawLines_DrawType == args.fDrawType); | |
1373 | 1372 |
1374 // This must come after textures are flushed because a texture may need | 1373 // This must come after textures are flushed because a texture may need |
1375 // to be msaa-resolved (which will modify bound FBO state). | 1374 // to be msaa-resolved (which will modify bound FBO state). |
1376 this->flushRenderTarget(glRT, NULL); | 1375 this->flushRenderTarget(glRT, NULL); |
1377 | 1376 |
1378 return true; | 1377 return true; |
1379 } | 1378 } |
1380 | 1379 |
1381 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, | 1380 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
1382 const GrDrawTarget::DrawInfo& info, | 1381 const GrDrawTarget::DrawInfo& info, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 offset += attrib.fOffset; | 1427 offset += attrib.fOffset; |
1429 } | 1428 } |
1430 attribState->disableUnusedArrays(this, usedAttribArraysMask); | 1429 attribState->disableUnusedArrays(this, usedAttribArraysMask); |
1431 } | 1430 } |
1432 } | 1431 } |
1433 | 1432 |
1434 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, | 1433 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, |
1435 const GrPrimitiveProcessor& primProc, | 1434 const GrPrimitiveProcessor& primProc, |
1436 const GrOptDrawState& optState, | 1435 const GrOptDrawState& optState, |
1437 const GrProgramDesc::DescInfo& descInfo, | 1436 const GrProgramDesc::DescInfo& descInfo, |
1438 GrGpu::DrawType drawType, | |
1439 const GrBatchTracker& batchTracker) const { | 1437 const GrBatchTracker& batchTracker) const { |
1440 if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, drawT
ype, this, | 1438 if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, this, |
1441 batchTracker)) { | 1439 batchTracker)) { |
1442 SkDEBUGFAIL("Failed to generate GL program descriptor"); | 1440 SkDEBUGFAIL("Failed to generate GL program descriptor"); |
1443 } | 1441 } |
1444 } | 1442 } |
1445 | 1443 |
1446 void GrGLGpu::disableScissor() { | 1444 void GrGLGpu::disableScissor() { |
1447 if (kNo_TriState != fHWScissorSettings.fEnabled) { | 1445 if (kNo_TriState != fHWScissorSettings.fEnabled) { |
1448 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); | 1446 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); |
1449 fHWScissorSettings.fEnabled = kNo_TriState; | 1447 fHWScissorSettings.fEnabled = kNo_TriState; |
1450 return; | 1448 return; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 if(wndProcID == procID) { | 1818 if(wndProcID == procID) { |
1821 SwapBuffers(GetDC(hwnd)); | 1819 SwapBuffers(GetDC(hwnd)); |
1822 } | 1820 } |
1823 hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); | 1821 hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); |
1824 } | 1822 } |
1825 } | 1823 } |
1826 #endif | 1824 #endif |
1827 #endif | 1825 #endif |
1828 | 1826 |
1829 void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) { | 1827 void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) { |
1830 if (!this->flushGLState(args)) { | 1828 if (!this->flushGLState(args, GrIsPrimTypeLines(info.primitiveType()))) { |
1831 return; | 1829 return; |
1832 } | 1830 } |
1833 | 1831 |
1834 size_t indexOffsetInBytes = 0; | 1832 size_t indexOffsetInBytes = 0; |
1835 this->setupGeometry(*args.fPrimitiveProcessor, info, &indexOffsetInBytes); | 1833 this->setupGeometry(*args.fPrimitiveProcessor, info, &indexOffsetInBytes); |
1836 | 1834 |
1837 SkASSERT((size_t)info.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GLMode
)); | 1835 SkASSERT((size_t)info.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GLMode
)); |
1838 | 1836 |
1839 if (info.isIndexed()) { | 1837 if (info.isIndexed()) { |
1840 GrGLvoid* indices = | 1838 GrGLvoid* indices = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o
rigin()); | 1871 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o
rigin()); |
1874 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); | 1872 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); |
1875 this->flushHWAAState(rt, state.fUseHWAA, false); | 1873 this->flushHWAAState(rt, state.fUseHWAA, false); |
1876 this->flushRenderTarget(rt, NULL); | 1874 this->flushRenderTarget(rt, NULL); |
1877 | 1875 |
1878 fPathRendering->stencilPath(path, *state.fStencil); | 1876 fPathRendering->stencilPath(path, *state.fStencil); |
1879 } | 1877 } |
1880 | 1878 |
1881 void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path, | 1879 void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path, |
1882 const GrStencilSettings& stencil) { | 1880 const GrStencilSettings& stencil) { |
1883 if (!this->flushGLState(args)) { | 1881 if (!this->flushGLState(args, false)) { |
1884 return; | 1882 return; |
1885 } | 1883 } |
1886 fPathRendering->drawPath(path, stencil); | 1884 fPathRendering->drawPath(path, stencil); |
1887 } | 1885 } |
1888 | 1886 |
1889 void GrGLGpu::onDrawPaths(const DrawArgs& args, | 1887 void GrGLGpu::onDrawPaths(const DrawArgs& args, |
1890 const GrPathRange* pathRange, | 1888 const GrPathRange* pathRange, |
1891 const void* indices, | 1889 const void* indices, |
1892 GrDrawTarget::PathIndexType indexType, | 1890 GrDrawTarget::PathIndexType indexType, |
1893 const float transformValues[], | 1891 const float transformValues[], |
1894 GrDrawTarget::PathTransformType transformType, | 1892 GrDrawTarget::PathTransformType transformType, |
1895 int count, | 1893 int count, |
1896 const GrStencilSettings& stencil) { | 1894 const GrStencilSettings& stencil) { |
1897 if (!this->flushGLState(args)) { | 1895 if (!this->flushGLState(args, false)) { |
1898 return; | 1896 return; |
1899 } | 1897 } |
1900 fPathRendering->drawPaths(pathRange, indices, indexType, transformValues, | 1898 fPathRendering->drawPaths(pathRange, indices, indexType, transformValues, |
1901 transformType, count, stencil); | 1899 transformType, count, stencil); |
1902 } | 1900 } |
1903 | 1901 |
1904 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { | 1902 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { |
1905 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); | 1903 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); |
1906 if (rt->needsResolve()) { | 1904 if (rt->needsResolve()) { |
1907 // Some extensions automatically resolves the texture when it is read. | 1905 // Some extensions automatically resolves the texture when it is read. |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 this->setVertexArrayID(gpu, 0); | 2743 this->setVertexArrayID(gpu, 0); |
2746 } | 2744 } |
2747 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2745 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2748 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2746 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2749 fDefaultVertexArrayAttribState.resize(attrCount); | 2747 fDefaultVertexArrayAttribState.resize(attrCount); |
2750 } | 2748 } |
2751 attribState = &fDefaultVertexArrayAttribState; | 2749 attribState = &fDefaultVertexArrayAttribState; |
2752 } | 2750 } |
2753 return attribState; | 2751 return attribState; |
2754 } | 2752 } |
OLD | NEW |