Index: src/gpu/gl/GrGLGpu.cpp |
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp |
index b7901400fbd68c132c4b448e20874b9bb64ba291..265545d0062110f27e1bc9c271e7aab0f78e600e 100644 |
--- a/src/gpu/gl/GrGLGpu.cpp |
+++ b/src/gpu/gl/GrGLGpu.cpp |
@@ -447,6 +447,7 @@ GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe |
GrGLuint fboID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); |
idDesc.fRenderFBO.reset(SkNEW_ARGS(GrGLFBO, (fboID))); |
idDesc.fMSColorRenderbufferID = 0; |
+ idDesc.fSampleConfig = wrapDesc.fSampleConfig; |
idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
GrSurfaceDesc desc; |
@@ -794,6 +795,7 @@ static bool renderbuffer_storage_msaa(GrGLContext& ctx, |
switch (ctx.caps()->msFBOType()) { |
case GrGLCaps::kDesktop_ARB_MSFBOType: |
case GrGLCaps::kDesktop_EXT_MSFBOType: |
+ case GrGLCaps::kStencil_MSFBOType: |
case GrGLCaps::kES_3_0_MSFBOType: |
GL_ALLOC_CALL(ctx.interface(), |
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
@@ -828,6 +830,9 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted |
idDesc->fMSColorRenderbufferID = 0; |
idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
GrGpuResource::kUncached_LifeCycle; |
+ idDesc->fSampleConfig = GrGLCaps::kStencil_MSFBOType == |
+ this->glCaps().msFBOType() ? kStencil_GrSampleConfig : |
+ kUnified_GrSampleConfig; |
GrGLenum status; |
@@ -1147,7 +1152,7 @@ bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, |
SkASSERT(width >= rt->width()); |
SkASSERT(height >= rt->height()); |
- int samples = rt->numSamples(); |
+ int samples = rt->numSamples(kStencil_GrSampleConfig); |
GrGLStencilBuffer::IDDesc sbDesc; |
int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
@@ -1390,7 +1395,7 @@ void GrGLGpu::flushScissor(const GrScissorState& scissorState, |
this->disableScissor(); |
} |
-bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) { |
+bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw, GrSampleConfig sampleConfig) { |
GrXferProcessor::BlendInfo blendInfo; |
const GrPipeline& pipeline = *args.fPipeline; |
args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); |
@@ -1422,7 +1427,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) { |
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); |
this->flushStencil(pipeline.getStencil()); |
this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin()); |
- this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), isLineDraw); |
+ this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), isLineDraw, sampleConfig); |
// This must come after textures are flushed because a texture may need |
// to be msaa-resolved (which will modify bound FBO state). |
@@ -1950,7 +1955,7 @@ void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { |
void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path, |
const GrStencilSettings& stencil) { |
- if (!this->flushGLState(args, false)) { |
+ if (!this->flushGLState(args, false, kStencil_GrSampleConfig)) { |
return; |
} |
fPathRendering->drawPath(path, stencil); |
@@ -1964,7 +1969,7 @@ void GrGLGpu::onDrawPaths(const DrawArgs& args, |
GrDrawTarget::PathTransformType transformType, |
int count, |
const GrStencilSettings& stencil) { |
- if (!this->flushGLState(args, false)) { |
+ if (!this->flushGLState(args, false, kStencil_GrSampleConfig)) { |
return; |
} |
fPathRendering->drawPaths(pathRange, indices, indexType, transformValues, |
@@ -2094,31 +2099,37 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { |
} |
} |
-void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw) { |
+void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw, |
+ GrSampleConfig sampleConfig) { |
// At least some ATI linux drivers will render GL_LINES incorrectly when MSAA state is enabled but |
// the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide. |
#if 0 |
// Replace RT_HAS_MSAA with this definition once this driver bug is no longer a relevant concern |
- #define RT_HAS_MSAA rt->isMultisampled() |
+ #define RT_HAS_MSAA rt->isMultisampled(sampleConfig) |
#else |
- #define RT_HAS_MSAA (rt->isMultisampled() || isLineDraw) |
+ #define RT_HAS_MSAA (rt->isMultisampled(sampleConfig) || isLineDraw) |
#endif |
if (kGL_GrGLStandard == this->glStandard()) { |
Chris Dalton
2015/03/14 02:51:30
GL_MULTISAMPLE doesn't traditionally exist in ES 2
|
- if (RT_HAS_MSAA) { |
- if (useHWAA) { |
- if (kYes_TriState != fMSAAEnabled) { |
- GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
- fMSAAEnabled = kYes_TriState; |
- } |
- } else { |
- if (kNo_TriState != fMSAAEnabled) { |
- GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
- fMSAAEnabled = kNo_TriState; |
- } |
+ if (RT_HAS_MSAA && useHWAA) { |
+ if (kYes_TriState != fMSAAEnabled) { |
+ GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
+ fMSAAEnabled = kYes_TriState; |
+ } |
+ } else { |
+ if (kNo_TriState != fMSAAEnabled) { |
+ GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
+ fMSAAEnabled = kNo_TriState; |
} |
} |
} |
+ if (this->glCaps().fbMixedSamplesSupport()) { |
+ if (rt->isMultisampled(kStencil_GrSampleConfig)) { |
Chris Dalton
2015/03/14 02:51:30
I think this would want to say: (after applying ht
|
+ GL_CALL(CoverageModulation(GR_GL_RGBA)); |
Chris Dalton
2015/03/14 02:51:30
We should add a state variable for fCoverageModula
|
+ } else { |
+ GL_CALL(CoverageModulation(GR_GL_NONE)); |
+ } |
+ } |
} |
void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |