diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-07-27 12:38:35 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-27 19:04:46 +0000 |
commit | 49d14e98fe43fdff818e7571c1a61cd5045fedc0 (patch) | |
tree | 18d48cd1922c646b6dafa851fbe214c8904aef87 /src/gpu/gl/GrGLGpu.cpp | |
parent | f4f6bbfadac327619a3832acad9c8afe06629b55 (diff) |
sksl: Add a "sk_Clockwise" built-in
This allows us to identify clockwise-winding triangles, in terms of
Skia device space, in all backends and with all render target origins.
Bug: skia:
Change-Id: I220e1c459e0129d1cc4dee6458ef94277fbedd21
Reviewed-on: https://skia-review.googlesource.com/142662
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 18ff4c670f..e04a40d8ab 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -359,9 +359,9 @@ void GrGLGpu::onResetContext(uint32_t resetBits) { // We don't use face culling. GL_CALL(Disable(GR_GL_CULL_FACE)); - // We do use separate stencil. Our algorithms don't care which face is front vs. back so - // just set this to the default for self-consistency. - GL_CALL(FrontFace(GR_GL_CCW)); + + // Setting the front face keeps gl_FrontFacing consistent in device space. + fHWFrontFace = GR_GL_NONE; fHWBufferState[kTexel_GrBufferType].invalidate(); fHWBufferState[kDrawIndirect_GrBufferType].invalidate(); @@ -1704,6 +1704,7 @@ bool GrGLGpu::flushGLState(const GrPrimitiveProcessor& primProc, fHWProgram->setData(primProc, pipeline); GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.renderTarget()); + GrSurfaceOrigin origin = pipeline.proxy()->origin(); GrStencilSettings stencil; if (pipeline.isStencilEnabled()) { // TODO: attach stencil and create settings during render target flush. @@ -1715,16 +1716,16 @@ bool GrGLGpu::flushGLState(const GrPrimitiveProcessor& primProc, if (pipeline.isScissorEnabled()) { static constexpr SkIRect kBogusScissor{0, 0, 1, 1}; GrScissorState state(fixedDynamicState ? fixedDynamicState->fScissorRect : kBogusScissor); - this->flushScissor(state, glRT->getViewport(), pipeline.proxy()->origin()); + this->flushScissor(state, glRT->getViewport(), origin); } else { this->disableScissor(); } - this->flushWindowRectangles(pipeline.getWindowRectsState(), glRT, pipeline.proxy()->origin()); + this->flushWindowRectangles(pipeline.getWindowRectsState(), glRT, origin); this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !stencil.isDisabled()); // This must come after textures are flushed because a texture may need // to be msaa-resolved (which will modify bound FBO state). - this->flushRenderTarget(glRT); + this->flushRenderTarget(glRT, origin); return true; } @@ -1856,9 +1857,9 @@ void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); if (clip.scissorEnabled()) { - this->flushRenderTarget(glRT, origin, clip.scissorRect()); + this->flushRenderTarget(glRT, origin, &clip.scissorRect()); } else { - this->flushRenderTarget(glRT); + this->flushRenderTarget(glRT, origin); } this->flushScissor(clip.scissorState(), glRT->getViewport(), origin); this->flushWindowRectangles(clip.windowRectsState(), glRT, origin); @@ -2121,14 +2122,17 @@ GrGpuTextureCommandBuffer* GrGLGpu::createCommandBuffer(GrTexture* texture, } void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, GrSurfaceOrigin origin, - const SkIRect& bounds) { + const SkIRect* bounds) { this->flushRenderTargetNoColorWrites(target); - this->didWriteToSurface(target, origin, &bounds); -} -void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target) { - this->flushRenderTargetNoColorWrites(target); - this->didWriteToSurface(target, kTopLeft_GrSurfaceOrigin, nullptr); + // A triangle is front-facing if it winds clockwise in device space. + GrGLenum frontFace = (kBottomLeft_GrSurfaceOrigin == origin) ? GR_GL_CW : GR_GL_CCW; + if (frontFace != fHWFrontFace) { + GL_CALL(FrontFace(frontFace)); + fHWFrontFace = frontFace; + } + + this->didWriteToSurface(target, origin, bounds); } void GrGLGpu::flushRenderTargetNoColorWrites(GrGLRenderTarget* target) { @@ -3360,7 +3364,7 @@ void GrGLGpu::clearStencilClipAsDraw(const GrFixedClip& clip, bool insideStencil } GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(rt->asRenderTarget()); - this->flushRenderTarget(glRT); + this->flushRenderTarget(glRT, origin); this->flushProgram(fStencilClipClearProgram); |