Chromium Code Reviews| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 if (resetBits & kRenderTarget_GrGLBackendState) { | 343 if (resetBits & kRenderTarget_GrGLBackendState) { |
| 344 for (size_t i = 0; i < SK_ARRAY_COUNT(fHWFBOBinding); ++i) { | 344 for (size_t i = 0; i < SK_ARRAY_COUNT(fHWFBOBinding); ++i) { |
| 345 fHWFBOBinding[i].invalidate(); | 345 fHWFBOBinding[i].invalidate(); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 if (resetBits & kPathRendering_GrGLBackendState) { | 349 if (resetBits & kPathRendering_GrGLBackendState) { |
| 350 if (this->caps()->pathRenderingSupport()) { | 350 if (this->caps()->pathRenderingSupport()) { |
| 351 this->glPathRendering()->resetContext(); | 351 this->glPathRendering()->resetContext(); |
| 352 } | 352 } |
| 353 if (this->glCaps().fbMixedSamplesSupport()) { | |
| 354 GL_CALL(CoverageModulation(GR_GL_RGBA)); | |
|
Chris Dalton
2015/03/12 07:43:35
Let's verify there isn't a performance penalty to
Chris Dalton
2015/03/12 08:04:52
One more thing:
The coverage modulation we use ma
vbuzinov
2015/03/13 13:37:22
1-Done. 2-Not done
| |
| 355 } | |
| 353 } | 356 } |
| 354 | 357 |
| 355 // we assume these values | 358 // we assume these values |
| 356 if (resetBits & kPixelStore_GrGLBackendState) { | 359 if (resetBits & kPixelStore_GrGLBackendState) { |
| 357 if (this->glCaps().unpackRowLengthSupport()) { | 360 if (this->glCaps().unpackRowLengthSupport()) { |
| 358 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); | 361 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); |
| 359 } | 362 } |
| 360 if (this->glCaps().packRowLengthSupport()) { | 363 if (this->glCaps().packRowLengthSupport()) { |
| 361 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0)); | 364 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0)); |
| 362 } | 365 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 } | 443 } |
| 441 | 444 |
| 442 return texture; | 445 return texture; |
| 443 } | 446 } |
| 444 | 447 |
| 445 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { | 448 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { |
| 446 GrGLRenderTarget::IDDesc idDesc; | 449 GrGLRenderTarget::IDDesc idDesc; |
| 447 GrGLuint fboID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); | 450 GrGLuint fboID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); |
| 448 idDesc.fRenderFBO.reset(SkNEW_ARGS(GrGLFBO, (fboID))); | 451 idDesc.fRenderFBO.reset(SkNEW_ARGS(GrGLFBO, (fboID))); |
| 449 idDesc.fMSColorRenderbufferID = 0; | 452 idDesc.fMSColorRenderbufferID = 0; |
| 453 idDesc.fSampleConfig = wrapDesc.fSampleConfig; | |
| 450 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 454 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
| 451 | 455 |
| 452 GrSurfaceDesc desc; | 456 GrSurfaceDesc desc; |
| 453 desc.fConfig = wrapDesc.fConfig; | 457 desc.fConfig = wrapDesc.fConfig; |
| 454 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 458 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
| 455 desc.fWidth = wrapDesc.fWidth; | 459 desc.fWidth = wrapDesc.fWidth; |
| 456 desc.fHeight = wrapDesc.fHeight; | 460 desc.fHeight = wrapDesc.fHeight; |
| 457 desc.fSampleCnt = wrapDesc.fSampleCnt; | 461 desc.fSampleCnt = wrapDesc.fSampleCnt; |
| 458 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 462 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
| 459 | 463 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 | 791 |
| 788 static bool renderbuffer_storage_msaa(GrGLContext& ctx, | 792 static bool renderbuffer_storage_msaa(GrGLContext& ctx, |
| 789 int sampleCount, | 793 int sampleCount, |
| 790 GrGLenum format, | 794 GrGLenum format, |
| 791 int width, int height) { | 795 int width, int height) { |
| 792 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); | 796 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); |
| 793 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); | 797 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); |
| 794 switch (ctx.caps()->msFBOType()) { | 798 switch (ctx.caps()->msFBOType()) { |
| 795 case GrGLCaps::kDesktop_ARB_MSFBOType: | 799 case GrGLCaps::kDesktop_ARB_MSFBOType: |
| 796 case GrGLCaps::kDesktop_EXT_MSFBOType: | 800 case GrGLCaps::kDesktop_EXT_MSFBOType: |
| 801 case GrGLCaps::kStencil_MSFBOType: | |
| 797 case GrGLCaps::kES_3_0_MSFBOType: | 802 case GrGLCaps::kES_3_0_MSFBOType: |
| 798 GL_ALLOC_CALL(ctx.interface(), | 803 GL_ALLOC_CALL(ctx.interface(), |
| 799 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 804 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
| 800 sampleCount, | 805 sampleCount, |
| 801 format, | 806 format, |
| 802 width, height)); | 807 width, height)); |
| 803 break; | 808 break; |
| 804 case GrGLCaps::kES_Apple_MSFBOType: | 809 case GrGLCaps::kES_Apple_MSFBOType: |
| 805 GL_ALLOC_CALL(ctx.interface(), | 810 GL_ALLOC_CALL(ctx.interface(), |
| 806 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, | 811 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 821 break; | 826 break; |
| 822 } | 827 } |
| 823 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; | 828 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; |
| 824 } | 829 } |
| 825 | 830 |
| 826 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, | 831 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, |
| 827 GrGLRenderTarget::IDDesc* idDesc) { | 832 GrGLRenderTarget::IDDesc* idDesc) { |
| 828 idDesc->fMSColorRenderbufferID = 0; | 833 idDesc->fMSColorRenderbufferID = 0; |
| 829 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : | 834 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
| 830 GrGpuResource::kUncached_LifeCycle; | 835 GrGpuResource::kUncached_LifeCycle; |
| 836 idDesc->fSampleConfig = GrGLCaps::kStencil_MSFBOType == | |
| 837 this->glCaps().msFBOType() ? kStencil_GrSampleConfig : | |
| 838 kUnified_GrSampleConfig ; | |
| 831 | 839 |
| 832 GrGLenum status; | 840 GrGLenum status; |
| 833 | 841 |
| 834 GrGLenum msColorFormat = 0; // suppress warning | 842 GrGLenum msColorFormat = 0; // suppress warning |
| 835 GrGLenum fboTarget = 0; // suppress warning | 843 GrGLenum fboTarget = 0; // suppress warning |
| 836 | 844 |
| 837 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { | 845 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { |
| 838 goto FAILED; | 846 goto FAILED; |
| 839 } | 847 } |
| 840 | 848 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1140 } | 1148 } |
| 1141 } | 1149 } |
| 1142 | 1150 |
| 1143 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) { | 1151 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) { |
| 1144 // All internally created RTs are also textures. We don't create | 1152 // All internally created RTs are also textures. We don't create |
| 1145 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . | 1153 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . |
| 1146 SkASSERT(rt->asTexture()); | 1154 SkASSERT(rt->asTexture()); |
| 1147 SkASSERT(width >= rt->width()); | 1155 SkASSERT(width >= rt->width()); |
| 1148 SkASSERT(height >= rt->height()); | 1156 SkASSERT(height >= rt->height()); |
| 1149 | 1157 |
| 1150 int samples = rt->numSamples(); | 1158 int samples = rt->numSamples(kStencil_GrSampleConfig); |
| 1151 GrGLStencilBuffer::IDDesc sbDesc; | 1159 GrGLStencilBuffer::IDDesc sbDesc; |
| 1152 | 1160 |
| 1153 int stencilFmtCnt = this->glCaps().stencilFormats().count(); | 1161 int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
| 1154 for (int i = 0; i < stencilFmtCnt; ++i) { | 1162 for (int i = 0; i < stencilFmtCnt; ++i) { |
| 1155 if (!sbDesc.fRenderbufferID) { | 1163 if (!sbDesc.fRenderbufferID) { |
| 1156 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); | 1164 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); |
| 1157 } | 1165 } |
| 1158 if (!sbDesc.fRenderbufferID) { | 1166 if (!sbDesc.fRenderbufferID) { |
| 1159 return false; | 1167 return false; |
| 1160 } | 1168 } |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2094 } | 2102 } |
| 2095 } | 2103 } |
| 2096 | 2104 |
| 2097 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw) { | 2105 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw) { |
| 2098 // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA st ate is enabled but | 2106 // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA st ate is enabled but |
| 2099 // the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide. | 2107 // the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide. |
| 2100 #if 0 | 2108 #if 0 |
| 2101 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe r a relevant concern | 2109 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe r a relevant concern |
| 2102 #define RT_HAS_MSAA rt->isMultisampled() | 2110 #define RT_HAS_MSAA rt->isMultisampled() |
| 2103 #else | 2111 #else |
| 2104 #define RT_HAS_MSAA (rt->isMultisampled() || isLineDraw) | 2112 #define RT_HAS_MSAA (rt->isMultisampled(kStencil_GrSampleConfig) || isLineDr aw) |
|
Chris Dalton
2015/03/12 07:43:35
This feels awkward to check the stencil. Ideally t
| |
| 2105 #endif | 2113 #endif |
| 2106 | 2114 |
| 2107 if (kGL_GrGLStandard == this->glStandard()) { | 2115 if (kGL_GrGLStandard == this->glStandard()) { |
| 2108 if (RT_HAS_MSAA) { | 2116 if (RT_HAS_MSAA) { |
| 2109 if (useHWAA) { | 2117 if (useHWAA) { |
| 2110 if (kYes_TriState != fMSAAEnabled) { | 2118 if (kYes_TriState != fMSAAEnabled) { |
| 2111 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2119 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
| 2112 fMSAAEnabled = kYes_TriState; | 2120 fMSAAEnabled = kYes_TriState; |
| 2113 } | 2121 } |
| 2114 } else { | 2122 } else { |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2822 this->setVertexArrayID(gpu, 0); | 2830 this->setVertexArrayID(gpu, 0); |
| 2823 } | 2831 } |
| 2824 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2832 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2825 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2833 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2826 fDefaultVertexArrayAttribState.resize(attrCount); | 2834 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2827 } | 2835 } |
| 2828 attribState = &fDefaultVertexArrayAttribState; | 2836 attribState = &fDefaultVertexArrayAttribState; |
| 2829 } | 2837 } |
| 2830 return attribState; | 2838 return attribState; |
| 2831 } | 2839 } |
| OLD | NEW |