| 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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 fHWScissorSettings.fEnabled = kYes_TriState; | 1380 fHWScissorSettings.fEnabled = kYes_TriState; |
| 1381 } | 1381 } |
| 1382 return; | 1382 return; |
| 1383 } | 1383 } |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 // See fall through note above | 1386 // See fall through note above |
| 1387 this->disableScissor(); | 1387 this->disableScissor(); |
| 1388 } | 1388 } |
| 1389 | 1389 |
| 1390 bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) { | 1390 bool GrGLGpu::flushGLState(const DrawArgs& args) { |
| 1391 GrXferProcessor::BlendInfo blendInfo; | 1391 GrXferProcessor::BlendInfo blendInfo; |
| 1392 const GrPipeline& pipeline = *args.fPipeline; | 1392 const GrPipeline& pipeline = *args.fPipeline; |
| 1393 args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); | 1393 args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); |
| 1394 | 1394 |
| 1395 this->flushDither(pipeline.isDitherState()); | 1395 this->flushDither(pipeline.isDitherState()); |
| 1396 this->flushColorWrite(blendInfo.fWriteColor); | 1396 this->flushColorWrite(blendInfo.fWriteColor); |
| 1397 this->flushDrawFace(pipeline.getDrawFace()); | 1397 this->flushDrawFace(pipeline.getDrawFace()); |
| 1398 | 1398 |
| 1399 fCurrentProgram.reset(fProgramCache->getProgram(args)); | 1399 fCurrentProgram.reset(fProgramCache->getProgram(args)); |
| 1400 if (NULL == fCurrentProgram.get()) { | 1400 if (NULL == fCurrentProgram.get()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1412 | 1412 |
| 1413 if (blendInfo.fWriteColor) { | 1413 if (blendInfo.fWriteColor) { |
| 1414 this->flushBlend(blendInfo); | 1414 this->flushBlend(blendInfo); |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 fCurrentProgram->setData(*args.fPrimitiveProcessor, pipeline, *args.fBatchTr
acker); | 1417 fCurrentProgram->setData(*args.fPrimitiveProcessor, pipeline, *args.fBatchTr
acker); |
| 1418 | 1418 |
| 1419 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); | 1419 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); |
| 1420 this->flushStencil(pipeline.getStencil()); | 1420 this->flushStencil(pipeline.getStencil()); |
| 1421 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); | 1421 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); |
| 1422 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), isLineDraw); | 1422 this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); |
| 1423 | 1423 |
| 1424 // This must come after textures are flushed because a texture may need | 1424 // This must come after textures are flushed because a texture may need |
| 1425 // to be msaa-resolved (which will modify bound FBO state). | 1425 // to be msaa-resolved (which will modify bound FBO state). |
| 1426 this->flushRenderTarget(glRT, NULL); | 1426 this->flushRenderTarget(glRT, NULL); |
| 1427 | 1427 |
| 1428 return true; | 1428 return true; |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, | 1431 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
| 1432 const GrDrawTarget::DrawInfo& info, | 1432 const GrDrawTarget::DrawInfo& info, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 if(wndProcID == procID) { | 1866 if(wndProcID == procID) { |
| 1867 SwapBuffers(GetDC(hwnd)); | 1867 SwapBuffers(GetDC(hwnd)); |
| 1868 } | 1868 } |
| 1869 hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); | 1869 hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); |
| 1870 } | 1870 } |
| 1871 } | 1871 } |
| 1872 #endif | 1872 #endif |
| 1873 #endif | 1873 #endif |
| 1874 | 1874 |
| 1875 void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) { | 1875 void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) { |
| 1876 if (!this->flushGLState(args, GrIsPrimTypeLines(info.primitiveType()))) { | 1876 if (!this->flushGLState(args)) { |
| 1877 return; | 1877 return; |
| 1878 } | 1878 } |
| 1879 | 1879 |
| 1880 size_t indexOffsetInBytes = 0; | 1880 size_t indexOffsetInBytes = 0; |
| 1881 this->setupGeometry(*args.fPrimitiveProcessor, info, &indexOffsetInBytes); | 1881 this->setupGeometry(*args.fPrimitiveProcessor, info, &indexOffsetInBytes); |
| 1882 | 1882 |
| 1883 SkASSERT((size_t)info.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GLMode
)); | 1883 SkASSERT((size_t)info.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GLMode
)); |
| 1884 | 1884 |
| 1885 if (info.isIndexed()) { | 1885 if (info.isIndexed()) { |
| 1886 GrGLvoid* indices = | 1886 GrGLvoid* indices = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1911 } | 1911 } |
| 1912 | 1912 |
| 1913 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { | 1913 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { |
| 1914 this->flushColorWrite(false); | 1914 this->flushColorWrite(false); |
| 1915 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 1915 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 1916 | 1916 |
| 1917 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget); | 1917 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget); |
| 1918 SkISize size = SkISize::Make(rt->width(), rt->height()); | 1918 SkISize size = SkISize::Make(rt->width(), rt->height()); |
| 1919 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o
rigin()); | 1919 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o
rigin()); |
| 1920 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); | 1920 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); |
| 1921 this->flushHWAAState(rt, state.fUseHWAA, false); | 1921 this->flushHWAAState(rt, state.fUseHWAA); |
| 1922 this->flushRenderTarget(rt, NULL); | 1922 this->flushRenderTarget(rt, NULL); |
| 1923 | 1923 |
| 1924 fPathRendering->stencilPath(path, *state.fStencil); | 1924 fPathRendering->stencilPath(path, *state.fStencil); |
| 1925 } | 1925 } |
| 1926 | 1926 |
| 1927 void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path, | 1927 void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path, |
| 1928 const GrStencilSettings& stencil) { | 1928 const GrStencilSettings& stencil) { |
| 1929 if (!this->flushGLState(args, false)) { | 1929 if (!this->flushGLState(args)) { |
| 1930 return; | 1930 return; |
| 1931 } | 1931 } |
| 1932 fPathRendering->drawPath(path, stencil); | 1932 fPathRendering->drawPath(path, stencil); |
| 1933 } | 1933 } |
| 1934 | 1934 |
| 1935 void GrGLGpu::onDrawPaths(const DrawArgs& args, | 1935 void GrGLGpu::onDrawPaths(const DrawArgs& args, |
| 1936 const GrPathRange* pathRange, | 1936 const GrPathRange* pathRange, |
| 1937 const void* indices, | 1937 const void* indices, |
| 1938 GrDrawTarget::PathIndexType indexType, | 1938 GrDrawTarget::PathIndexType indexType, |
| 1939 const float transformValues[], | 1939 const float transformValues[], |
| 1940 GrDrawTarget::PathTransformType transformType, | 1940 GrDrawTarget::PathTransformType transformType, |
| 1941 int count, | 1941 int count, |
| 1942 const GrStencilSettings& stencil) { | 1942 const GrStencilSettings& stencil) { |
| 1943 if (!this->flushGLState(args, false)) { | 1943 if (!this->flushGLState(args)) { |
| 1944 return; | 1944 return; |
| 1945 } | 1945 } |
| 1946 fPathRendering->drawPaths(pathRange, indices, indexType, transformValues, | 1946 fPathRendering->drawPaths(pathRange, indices, indexType, transformValues, |
| 1947 transformType, count, stencil); | 1947 transformType, count, stencil); |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { | 1950 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { |
| 1951 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); | 1951 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); |
| 1952 if (rt->needsResolve()) { | 1952 if (rt->needsResolve()) { |
| 1953 // Some extensions automatically resolves the texture when it is read. | 1953 // Some extensions automatically resolves the texture when it is read. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 set_gl_stencil(this->glInterface(), | 2068 set_gl_stencil(this->glInterface(), |
| 2069 stencilSettings, | 2069 stencilSettings, |
| 2070 GR_GL_FRONT_AND_BACK, | 2070 GR_GL_FRONT_AND_BACK, |
| 2071 GrStencilSettings::kFront_Face); | 2071 GrStencilSettings::kFront_Face); |
| 2072 } | 2072 } |
| 2073 } | 2073 } |
| 2074 fHWStencilSettings = stencilSettings; | 2074 fHWStencilSettings = stencilSettings; |
| 2075 } | 2075 } |
| 2076 } | 2076 } |
| 2077 | 2077 |
| 2078 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw)
{ | 2078 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
| 2079 // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA st
ate is enabled but | 2079 SkASSERT(!useHWAA || rt->isMultisampled()); |
| 2080 // the target is not multisampled. Single pixel wide lines are rendered thicker
than 1 pixel wide. | |
| 2081 #if 0 | |
| 2082 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe
r a relevant concern | |
| 2083 #define RT_HAS_MSAA rt->isMultisampled() | |
| 2084 #else | |
| 2085 #define RT_HAS_MSAA (rt->isMultisampled() || isLineDraw) | |
| 2086 #endif | |
| 2087 | 2080 |
| 2088 if (kGL_GrGLStandard == this->glStandard()) { | 2081 if (kGL_GrGLStandard == this->glStandard()) { |
| 2089 if (RT_HAS_MSAA) { | 2082 if (useHWAA) { |
| 2090 if (useHWAA) { | 2083 if (kYes_TriState != fMSAAEnabled) { |
| 2091 if (kYes_TriState != fMSAAEnabled) { | 2084 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
| 2092 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2085 fMSAAEnabled = kYes_TriState; |
| 2093 fMSAAEnabled = kYes_TriState; | 2086 } |
| 2094 } | 2087 } else { |
| 2095 } else { | 2088 if (kNo_TriState != fMSAAEnabled) { |
| 2096 if (kNo_TriState != fMSAAEnabled) { | 2089 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
| 2097 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2090 fMSAAEnabled = kNo_TriState; |
| 2098 fMSAAEnabled = kNo_TriState; | |
| 2099 } | |
| 2100 } | 2091 } |
| 2101 } | 2092 } |
| 2102 } | 2093 } |
| 2103 } | 2094 } |
| 2104 | 2095 |
| 2105 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { | 2096 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |
| 2106 // Any optimization to disable blending should have already been applied and | 2097 // Any optimization to disable blending should have already been applied and |
| 2107 // tweaked the coeffs to (1, 0). | 2098 // tweaked the coeffs to (1, 0). |
| 2108 | 2099 |
| 2109 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; | 2100 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2805 this->setVertexArrayID(gpu, 0); | 2796 this->setVertexArrayID(gpu, 0); |
| 2806 } | 2797 } |
| 2807 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2798 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2808 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2799 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2809 fDefaultVertexArrayAttribState.resize(attrCount); | 2800 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2810 } | 2801 } |
| 2811 attribState = &fDefaultVertexArrayAttribState; | 2802 attribState = &fDefaultVertexArrayAttribState; |
| 2812 } | 2803 } |
| 2813 return attribState; | 2804 return attribState; |
| 2814 } | 2805 } |
| OLD | NEW |