Index: src/gpu/gl/GrGLGpu.cpp |
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp |
index cb12fefc3291f48388275702a71e48d555ddd408..3e6f7865d2ca5ee33df433530446911ab4305820 100644 |
--- a/src/gpu/gl/GrGLGpu.cpp |
+++ b/src/gpu/gl/GrGLGpu.cpp |
@@ -1476,7 +1476,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) { |
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); |
this->flushStencil(pipeline.getStencil()); |
this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin()); |
- this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); |
+ this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled()); |
// This must come after textures are flushed because a texture may need |
// to be msaa-resolved (which will modify bound FBO state). |
@@ -1899,6 +1899,21 @@ bool GrGLGpu::onReadPixels(GrSurface* surface, |
return true; |
} |
+void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedSampleLocations) { |
+ GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget()); |
+ SkASSERT(0 != target->renderFBOID()); |
+ |
+ if (!rt->isStencilBufferMultisampled() || |
+ useColocatedSampleLocations == rt->renderTargetPriv().usesColocatedSampleLocations()) { |
+ return; |
+ } |
+ |
+ GL_CALL(NamedFramebufferParameteri(target->renderFBOID(), |
+ GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS, useColocatedSampleLocations)); |
bsalomon
2015/09/29 17:41:57
nit: wrap
vbuzinov
2015/09/30 06:08:29
Done.
|
+ |
+ rt->renderTargetPriv().flagAsUsingColocatedSampleLocations(useColocatedSampleLocations); |
+} |
+ |
void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { |
SkASSERT(target); |
@@ -2146,9 +2161,19 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { |
} |
} |
-void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
+void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled) { |
SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
+ if (rt->hasMixedSamples() && stencilEnabled && |
+ this->glCaps().glslCaps()->programmableSampleLocationsSupport()) { |
+ if (useHWAA) { |
+ setColocatedSampleLocations(rt, false); |
bsalomon
2015/09/29 17:41:57
this->
vbuzinov
2015/09/30 06:08:29
Done.
|
+ } else { |
+ setColocatedSampleLocations(rt, true); |
bsalomon
2015/09/29 17:41:57
this->
vbuzinov
2015/09/30 06:08:29
Done.
|
+ } |
+ useHWAA = true; |
+ } |
+ |
if (this->glCaps().multisampleDisableSupport()) { |
if (useHWAA) { |
if (kYes_TriState != fMSAAEnabled) { |
@@ -2916,7 +2941,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, |
this->flushBlend(blendInfo); |
this->flushColorWrite(true); |
this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
- this->flushHWAAState(dstRT, false); |
+ this->flushHWAAState(dstRT, false, false); |
this->disableScissor(); |
GrStencilSettings stencil; |
stencil.setDisabled(); |