Some scissor state cleanup.
Separate flushing the enablement of scissor from the rect in GrGLGpu. Move GrPipeline::ScissorState to a global enum and use more broadly. Rename to GrScissorTest to avoid name conflict with existing GrScissorState. Change-Id: Ib32160b3300bc12de2d2e1761d152fd1bba8b683 Reviewed-on: https://skia-review.googlesource.com/137395 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
parent
00d2e8ebcb
commit
a219419c9d
@ -73,6 +73,11 @@ static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfig;
|
||||
#error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format."
|
||||
#endif
|
||||
|
||||
enum class GrScissorTest : bool {
|
||||
kDisabled = false,
|
||||
kEnabled = true
|
||||
};
|
||||
|
||||
/**
|
||||
* Geometric primitives used for drawing.
|
||||
*/
|
||||
|
@ -348,8 +348,7 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state) {
|
||||
}
|
||||
}
|
||||
|
||||
GrPipeline pipeline(state->drawOpArgs().fProxy, GrPipeline::ScissorState::kDisabled,
|
||||
SkBlendMode::kPlus);
|
||||
GrPipeline pipeline(state->drawOpArgs().fProxy, GrScissorTest::kDisabled, SkBlendMode::kPlus);
|
||||
|
||||
if (glGpu) {
|
||||
glGpu->handleDirtyContext();
|
||||
|
@ -11,10 +11,8 @@
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrScissorState.h"
|
||||
#include "GrWindowRectsState.h"
|
||||
|
||||
#include "SkClipStack.h"
|
||||
|
||||
|
||||
/**
|
||||
* Produced by GrHardClip. It provides a set of modifications to the hardware drawing state that
|
||||
* implement the clip.
|
||||
@ -55,7 +53,8 @@ public:
|
||||
}
|
||||
|
||||
bool doesClip() const {
|
||||
return fScissorState.enabled() || this->hasStencilClip() || fWindowRectsState.enabled();
|
||||
return fScissorState.scissorTest() == GrScissorTest::kEnabled || this->hasStencilClip() ||
|
||||
fWindowRectsState.enabled();
|
||||
}
|
||||
|
||||
bool operator==(const GrAppliedHardClip& that) const {
|
||||
|
@ -14,12 +14,13 @@ bool GrFixedClip::quickContains(const SkRect& rect) const {
|
||||
if (fWindowRectsState.enabled()) {
|
||||
return false;
|
||||
}
|
||||
return !fScissorState.enabled() || GrClip::IsInsideClip(fScissorState.rect(), rect);
|
||||
return fScissorState.scissorTest() == GrScissorTest::kDisabled ||
|
||||
GrClip::IsInsideClip(fScissorState.rect(), rect);
|
||||
}
|
||||
|
||||
void GrFixedClip::getConservativeBounds(int w, int h, SkIRect* devResult, bool* iior) const {
|
||||
devResult->setXYWH(0, 0, w, h);
|
||||
if (fScissorState.enabled()) {
|
||||
if (fScissorState.scissorTest() == GrScissorTest::kEnabled) {
|
||||
if (!devResult->intersect(fScissorState.rect())) {
|
||||
devResult->setEmpty();
|
||||
}
|
||||
@ -33,7 +34,7 @@ bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const {
|
||||
if (fWindowRectsState.enabled()) {
|
||||
return false;
|
||||
}
|
||||
if (fScissorState.enabled()) {
|
||||
if (fScissorState.scissorTest() == GrScissorTest::kEnabled) {
|
||||
SkRect rect = SkRect::Make(fScissorState.rect());
|
||||
if (!rect.intersects(rtBounds)) {
|
||||
return false;
|
||||
@ -46,7 +47,7 @@ bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const {
|
||||
};
|
||||
|
||||
bool GrFixedClip::apply(int rtWidth, int rtHeight, GrAppliedHardClip* out, SkRect* bounds) const {
|
||||
if (fScissorState.enabled()) {
|
||||
if (fScissorState.scissorTest() == GrScissorTest::kEnabled) {
|
||||
SkIRect tightScissor = SkIRect::MakeWH(rtWidth, rtHeight);
|
||||
if (!tightScissor.intersect(fScissorState.rect())) {
|
||||
return false;
|
||||
|
@ -21,14 +21,15 @@ public:
|
||||
explicit GrFixedClip(const SkIRect& scissorRect) : fScissorState(scissorRect) {}
|
||||
|
||||
const GrScissorState& scissorState() const { return fScissorState; }
|
||||
bool scissorEnabled() const { return fScissorState.enabled(); }
|
||||
const SkIRect& scissorRect() const { SkASSERT(scissorEnabled()); return fScissorState.rect(); }
|
||||
GrScissorTest scissorTest() const { return fScissorState.scissorTest(); }
|
||||
const SkIRect& scissorRect() const {
|
||||
SkASSERT(this->scissorTest() == GrScissorTest::kEnabled);
|
||||
return fScissorState.rect();
|
||||
}
|
||||
|
||||
void disableScissor() { fScissorState.setDisabled(); }
|
||||
|
||||
void setScissor(const SkIRect& irect) {
|
||||
fScissorState.set(irect);
|
||||
}
|
||||
void setScissor(const SkIRect& irect) { fScissorState = GrScissorState(irect); }
|
||||
bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) {
|
||||
return fScissorState.intersect(irect);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ bool GrGpuRTCommandBuffer::draw(const GrPrimitiveProcessor& primProc, const GrPi
|
||||
SkASSERT(primProc.hasInstanceAttributes() == meshes[i].isInstanced());
|
||||
}
|
||||
#endif
|
||||
SkASSERT(!pipeline.isScissorEnabled() || fixedDynamicState ||
|
||||
SkASSERT(pipeline.scissorTest() == GrScissorTest::kDisabled || fixedDynamicState ||
|
||||
(dynamicStateArrays && dynamicStateArrays->fScissorRects));
|
||||
|
||||
auto resourceProvider = this->gpu()->getContext()->contextPriv().resourceProvider();
|
||||
|
@ -28,7 +28,7 @@ GrPipeline::GrPipeline(const InitArgs& args,
|
||||
if (appliedClip.hasStencilClip()) {
|
||||
fFlags |= kHasStencilClip_Flag;
|
||||
}
|
||||
if (appliedClip.scissorState().enabled()) {
|
||||
if (appliedClip.scissorState().scissorTest() == GrScissorTest::kEnabled) {
|
||||
fFlags |= kScissorEnabled_Flag;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ GrXferBarrierType GrPipeline::xferBarrierType(const GrCaps& caps) const {
|
||||
return this->getXferProcessor().xferBarrierType(caps);
|
||||
}
|
||||
|
||||
GrPipeline::GrPipeline(GrRenderTargetProxy* proxy, ScissorState scissorState, SkBlendMode blendmode)
|
||||
GrPipeline::GrPipeline(GrRenderTargetProxy* proxy, GrScissorTest scissorTest, SkBlendMode blendmode)
|
||||
: fProxy(proxy)
|
||||
, fWindowRectsState()
|
||||
, fUserStencilSettings(&GrUserStencilSettings::kUnused)
|
||||
@ -108,7 +108,7 @@ GrPipeline::GrPipeline(GrRenderTargetProxy* proxy, ScissorState scissorState, Sk
|
||||
, fFragmentProcessors()
|
||||
, fNumColorProcessors(0) {
|
||||
SkASSERT(proxy);
|
||||
if (scissorState) {
|
||||
if (scissorTest == GrScissorTest::kEnabled) {
|
||||
fFlags |= kScissorEnabled_Flag;
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,6 @@ public:
|
||||
return flags;
|
||||
}
|
||||
|
||||
enum ScissorState : bool {
|
||||
kEnabled = true,
|
||||
kDisabled = false
|
||||
};
|
||||
|
||||
struct InitArgs {
|
||||
uint32_t fFlags = 0;
|
||||
const GrUserStencilSettings* fUserStencil = &GrUserStencilSettings::kUnused;
|
||||
@ -103,7 +98,7 @@ public:
|
||||
* must be "Porter Duff" (<= kLastCoeffMode). If using ScissorState::kEnabled, the caller must
|
||||
* specify a scissor rectangle through the DynamicState struct.
|
||||
**/
|
||||
GrPipeline(GrRenderTargetProxy*, ScissorState, SkBlendMode);
|
||||
GrPipeline(GrRenderTargetProxy*, GrScissorTest, SkBlendMode);
|
||||
|
||||
GrPipeline(const InitArgs&, GrProcessorSet&&, GrAppliedClip&&);
|
||||
|
||||
@ -179,8 +174,8 @@ public:
|
||||
|
||||
const GrUserStencilSettings* getUserStencil() const { return fUserStencilSettings; }
|
||||
|
||||
ScissorState isScissorEnabled() const {
|
||||
return ScissorState(SkToBool(fFlags & kScissorEnabled_Flag));
|
||||
GrScissorTest scissorTest() const {
|
||||
return GrScissorTest(SkToBool(fFlags & kScissorEnabled_Flag));
|
||||
}
|
||||
|
||||
const GrWindowRectsState& getWindowRectsState() const { return fWindowRectsState; }
|
||||
|
@ -329,7 +329,7 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
|
||||
CanClearFullscreen canClearFullscreen) {
|
||||
bool isFull = false;
|
||||
if (!clip.hasWindowRectangles()) {
|
||||
isFull = !clip.scissorEnabled() ||
|
||||
isFull = clip.scissorTest() == GrScissorTest::kDisabled ||
|
||||
(CanClearFullscreen::kYes == canClearFullscreen &&
|
||||
this->caps()->preferFullscreenClears()) ||
|
||||
clip.scissorRect().contains(SkIRect::MakeWH(this->width(), this->height()));
|
||||
|
@ -8,32 +8,29 @@
|
||||
#ifndef GrScissorState_DEFINED
|
||||
#define GrScissorState_DEFINED
|
||||
|
||||
#include "SkRect.h"
|
||||
|
||||
class GrScissorState {
|
||||
public:
|
||||
GrScissorState() : fEnabled(false) {}
|
||||
GrScissorState(const SkIRect& rect) : fEnabled(true), fRect(rect) {}
|
||||
void setDisabled() { fEnabled = false; }
|
||||
void set(const SkIRect& rect) { fRect = rect; fEnabled = true; }
|
||||
GrScissorState() = default;
|
||||
GrScissorState(const SkIRect& rect) : fScissorTest(GrScissorTest::kEnabled), fRect(rect) {}
|
||||
void setDisabled() { fScissorTest = GrScissorTest::kDisabled; }
|
||||
bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& rect) {
|
||||
if (!fEnabled) {
|
||||
this->set(rect);
|
||||
if (fScissorTest == GrScissorTest::kDisabled) {
|
||||
*this = GrScissorState(rect);
|
||||
return true;
|
||||
}
|
||||
return fRect.intersect(rect);
|
||||
}
|
||||
bool operator==(const GrScissorState& other) const {
|
||||
return fEnabled == other.fEnabled &&
|
||||
(false == fEnabled || fRect == other.fRect);
|
||||
return fScissorTest == other.fScissorTest &&
|
||||
(fScissorTest == GrScissorTest::kDisabled || fRect == other.fRect);
|
||||
}
|
||||
bool operator!=(const GrScissorState& other) const { return !(*this == other); }
|
||||
|
||||
bool enabled() const { return fEnabled; }
|
||||
GrScissorTest scissorTest() const { return fScissorTest; }
|
||||
const SkIRect& rect() const { return fRect; }
|
||||
|
||||
private:
|
||||
bool fEnabled;
|
||||
GrScissorTest fScissorTest = GrScissorTest::kDisabled;
|
||||
SkIRect fRect;
|
||||
};
|
||||
|
||||
|
@ -530,7 +530,7 @@ void GrCCPathParser::drawCoverageCount(GrOpFlushState* flushState, CoverageCount
|
||||
|
||||
const PrimitiveTallies& batchTotalCounts = fCoverageCountBatches[batchID].fTotalPrimitiveCounts;
|
||||
|
||||
GrPipeline pipeline(flushState->drawOpArgs().fProxy, GrPipeline::ScissorState::kEnabled,
|
||||
GrPipeline pipeline(flushState->drawOpArgs().fProxy, GrScissorTest::kEnabled,
|
||||
SkBlendMode::kPlus);
|
||||
|
||||
if (batchTotalCounts.fTriangles) {
|
||||
@ -564,7 +564,7 @@ void GrCCPathParser::drawPrimitives(GrOpFlushState* flushState, const GrPipeline
|
||||
GrCCCoverageProcessor::PrimitiveType primitiveType,
|
||||
int PrimitiveTallies::*instanceType,
|
||||
const SkIRect& drawBounds) const {
|
||||
SkASSERT(pipeline.isScissorEnabled());
|
||||
SkASSERT(pipeline.scissorTest() == GrScissorTest::kEnabled);
|
||||
|
||||
// Don't call reset(), as that also resets the reserve count.
|
||||
fMeshesScratchBuffer.pop_back_n(fMeshesScratchBuffer.count());
|
||||
|
@ -64,8 +64,7 @@ public:
|
||||
|
||||
void onExecute(GrOpFlushState* flushState) override {
|
||||
SkASSERT(fStashedAtlasProxy);
|
||||
GrPipeline pipeline(flushState->proxy(), GrPipeline::ScissorState::kDisabled,
|
||||
SkBlendMode::kSrc);
|
||||
GrPipeline pipeline(flushState->proxy(), GrScissorTest::kDisabled, SkBlendMode::kSrc);
|
||||
GrCCPathProcessor pathProc(flushState->resourceProvider(), std::move(fStashedAtlasProxy));
|
||||
pathProc.drawPaths(flushState, pipeline, nullptr, *fResources, fBaseInstance, fEndInstance,
|
||||
this->bounds());
|
||||
|
@ -1358,7 +1358,7 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
|
||||
GrGLIRect viewport;
|
||||
this->bindSurfaceFBOForPixelOps(tex.get(), GR_GL_FRAMEBUFFER, &viewport,
|
||||
kDst_TempFBOTarget);
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(GrScissorTest::kDisabled);
|
||||
this->disableWindowRectangles();
|
||||
GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
|
||||
fHWWriteToColor = kYes_TriState;
|
||||
@ -1605,29 +1605,45 @@ GrBuffer* GrGLGpu::onCreateBuffer(size_t size, GrBufferType intendedType,
|
||||
return GrGLBuffer::Create(this, size, intendedType, accessPattern, data);
|
||||
}
|
||||
|
||||
void GrGLGpu::flushScissor(const GrScissorState& scissorState,
|
||||
const GrGLIRect& rtViewport,
|
||||
GrSurfaceOrigin rtOrigin) {
|
||||
if (scissorState.enabled()) {
|
||||
GrGLIRect scissor;
|
||||
scissor.setRelativeTo(rtViewport, scissorState.rect(), rtOrigin);
|
||||
// if the scissor fully contains the viewport then we fall through and
|
||||
// disable the scissor test.
|
||||
if (!scissor.contains(rtViewport)) {
|
||||
if (fHWScissorSettings.fRect != scissor) {
|
||||
scissor.pushToGLScissor(this->glInterface());
|
||||
fHWScissorSettings.fRect = scissor;
|
||||
}
|
||||
if (kYes_TriState != fHWScissorSettings.fEnabled) {
|
||||
GL_CALL(Enable(GR_GL_SCISSOR_TEST));
|
||||
fHWScissorSettings.fEnabled = kYes_TriState;
|
||||
void GrGLGpu::flushScissorTest(GrScissorTest test) {
|
||||
if (test == GrScissorTest::kEnabled) {
|
||||
if (kYes_TriState != fHWScissorSettings.fEnabled) {
|
||||
GL_CALL(Enable(GR_GL_SCISSOR_TEST));
|
||||
fHWScissorSettings.fEnabled = kYes_TriState;
|
||||
}
|
||||
} else {
|
||||
if (kNo_TriState != fHWScissorSettings.fEnabled) {
|
||||
GL_CALL(Disable(GR_GL_SCISSOR_TEST));
|
||||
fHWScissorSettings.fEnabled = kNo_TriState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGpu::flushScissorRect(const SkIRect& scissorRect, const GrGLIRect& viewport,
|
||||
GrSurfaceOrigin origin) {
|
||||
GrGLIRect scissor;
|
||||
scissor.setRelativeTo(viewport, scissorRect, origin);
|
||||
if (fHWScissorSettings.fRect != scissor) {
|
||||
scissor.pushToGLScissor(this->glInterface());
|
||||
fHWScissorSettings.fRect = scissor;
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGpu::flushScissorState(const GrScissorState& clipScissor, const GrGLIRect& viewport,
|
||||
GrSurfaceOrigin origin) {
|
||||
if (clipScissor.scissorTest() == GrScissorTest::kEnabled) {
|
||||
GrGLIRect scissorRect;
|
||||
scissorRect.setRelativeTo(viewport, clipScissor.rect(), origin);
|
||||
if (!scissorRect.contains(viewport)) {
|
||||
this->flushScissorTest(GrScissorTest::kEnabled);
|
||||
if (fHWScissorSettings.fRect != scissorRect) {
|
||||
scissorRect.pushToGLScissor(this->glInterface());
|
||||
fHWScissorSettings.fRect = scissorRect;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// See fall through note above
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(GrScissorTest::kDisabled);
|
||||
}
|
||||
|
||||
void GrGLGpu::flushWindowRectangles(const GrWindowRectsState& windowState,
|
||||
@ -1721,12 +1737,10 @@ bool GrGLGpu::flushGLState(const GrPrimitiveProcessor& primProc,
|
||||
glRT->renderTargetPriv().numStencilBits());
|
||||
}
|
||||
this->flushStencil(stencil);
|
||||
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());
|
||||
} else {
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(pipeline.scissorTest());
|
||||
if (pipeline.scissorTest() == GrScissorTest::kEnabled && fixedDynamicState) {
|
||||
this->flushScissorRect(fixedDynamicState->fScissorRect, glRT->getViewport(),
|
||||
pipeline.proxy()->origin());
|
||||
}
|
||||
this->flushWindowRectangles(pipeline.getWindowRectsState(), glRT, pipeline.proxy()->origin());
|
||||
this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !stencil.isDisabled());
|
||||
@ -1860,14 +1874,6 @@ void GrGLGpu::notifyBufferReleased(const GrGLBuffer* buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGpu::disableScissor() {
|
||||
if (kNo_TriState != fHWScissorSettings.fEnabled) {
|
||||
GL_CALL(Disable(GR_GL_SCISSOR_TEST));
|
||||
fHWScissorSettings.fEnabled = kNo_TriState;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGpu::clear(const GrFixedClip& clip, GrColor color,
|
||||
GrRenderTarget* target, GrSurfaceOrigin origin) {
|
||||
// parent class should never let us get here with no RT
|
||||
@ -1890,12 +1896,12 @@ void GrGLGpu::clear(const GrFixedClip& clip, GrColor color,
|
||||
|
||||
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
|
||||
|
||||
if (clip.scissorEnabled()) {
|
||||
if (clip.scissorTest() == GrScissorTest::kEnabled) {
|
||||
this->flushRenderTarget(glRT, origin, clip.scissorRect());
|
||||
} else {
|
||||
this->flushRenderTarget(glRT);
|
||||
}
|
||||
this->flushScissor(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushScissorState(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushWindowRectangles(clip.windowRectsState(), glRT, origin);
|
||||
|
||||
GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
|
||||
@ -1924,7 +1930,7 @@ void GrGLGpu::clearStencil(GrRenderTarget* target, int clearValue) {
|
||||
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
|
||||
this->flushRenderTargetNoColorWrites(glRT);
|
||||
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(GrScissorTest::kDisabled);
|
||||
this->disableWindowRectangles();
|
||||
|
||||
GL_CALL(StencilMask(0xffffffff));
|
||||
@ -1972,7 +1978,7 @@ void GrGLGpu::clearStencilClip(const GrFixedClip& clip,
|
||||
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
|
||||
this->flushRenderTargetNoColorWrites(glRT);
|
||||
|
||||
this->flushScissor(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushScissorState(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushWindowRectangles(clip.windowRectsState(), glRT, origin);
|
||||
|
||||
GL_CALL(StencilMask((uint32_t) clipStencilMask));
|
||||
@ -2254,8 +2260,8 @@ void GrGLGpu::draw(const GrPrimitiveProcessor& primProc,
|
||||
return;
|
||||
}
|
||||
|
||||
bool dynamicScissor =
|
||||
pipeline.isScissorEnabled() && dynamicStateArrays && dynamicStateArrays->fScissorRects;
|
||||
bool dynamicScissor = pipeline.scissorTest() == GrScissorTest::kEnabled && dynamicStateArrays &&
|
||||
dynamicStateArrays->fScissorRects;
|
||||
for (int i = 0; i < meshCount; ++i) {
|
||||
if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*this->caps())) {
|
||||
this->xferBarrier(pipeline.renderTarget(), barrierType);
|
||||
@ -2263,8 +2269,8 @@ void GrGLGpu::draw(const GrPrimitiveProcessor& primProc,
|
||||
|
||||
if (dynamicScissor) {
|
||||
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.renderTarget());
|
||||
this->flushScissor(GrScissorState(dynamicStateArrays->fScissorRects[i]),
|
||||
glRT->getViewport(), pipeline.proxy()->origin());
|
||||
this->flushScissorRect(dynamicStateArrays->fScissorRects[i], glRT->getViewport(),
|
||||
pipeline.proxy()->origin());
|
||||
}
|
||||
if (this->glCaps().requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() &&
|
||||
GrIsPrimTypeLines(meshes[i].primitiveType()) &&
|
||||
@ -2408,9 +2414,7 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
|
||||
static constexpr auto kDirtyRectOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) {
|
||||
// Apple's extension uses the scissor as the blit bounds.
|
||||
GrScissorState scissorState;
|
||||
scissorState.set(dirtyRect);
|
||||
this->flushScissor(scissorState, vp, kDirtyRectOrigin);
|
||||
this->flushScissorState(GrScissorState(dirtyRect), vp, kDirtyRectOrigin);
|
||||
this->disableWindowRectangles();
|
||||
GL_CALL(ResolveMultisampleFramebuffer());
|
||||
} else {
|
||||
@ -2431,7 +2435,7 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
|
||||
}
|
||||
|
||||
// BlitFrameBuffer respects the scissor, so disable it.
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(GrScissorTest::kDisabled);
|
||||
this->disableWindowRectangles();
|
||||
GL_CALL(BlitFramebuffer(l, b, r, t, l, b, r, t,
|
||||
GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST));
|
||||
@ -3455,7 +3459,7 @@ void GrGLGpu::clearStencilClipAsDraw(const GrFixedClip& clip, bool insideStencil
|
||||
this->flushBlend(blendInfo, GrSwizzle::RGBA());
|
||||
this->flushColorWrite(false);
|
||||
this->flushHWAAState(glRT, false, false);
|
||||
this->flushScissor(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushScissorState(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushWindowRectangles(clip.windowRectsState(), glRT, origin);
|
||||
GrStencilAttachment* sb = rt->renderTargetPriv().getStencilAttachment();
|
||||
// This should only be called internally when we know we have a stencil buffer.
|
||||
@ -3563,7 +3567,7 @@ void GrGLGpu::clearColorAsDraw(const GrFixedClip& clip, GrGLfloat r, GrGLfloat g
|
||||
2 * sizeof(GrGLfloat), 0);
|
||||
|
||||
GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(dst);
|
||||
this->flushScissor(clip.scissorState(), glrt->getViewport(), origin);
|
||||
this->flushScissorState(clip.scissorState(), glrt->getViewport(), origin);
|
||||
this->flushWindowRectangles(clip.windowRectsState(), glrt, origin);
|
||||
|
||||
GL_CALL(Uniform4f(fClearColorProgram.fColorUniform, r, g, b, a));
|
||||
@ -3580,7 +3584,9 @@ void GrGLGpu::clearColorAsDraw(const GrFixedClip& clip, GrGLfloat r, GrGLfloat g
|
||||
|
||||
GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4));
|
||||
this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, dst);
|
||||
this->didWriteToSurface(dst, origin, clip.scissorEnabled() ? &clip.scissorRect() : nullptr);
|
||||
const auto* rect =
|
||||
clip.scissorTest() == GrScissorTest::kEnabled ? &clip.scissorRect() : nullptr;
|
||||
this->didWriteToSurface(dst, origin, rect);
|
||||
}
|
||||
|
||||
bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin,
|
||||
@ -3660,7 +3666,7 @@ bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin,
|
||||
this->flushBlend(blendInfo, GrSwizzle::RGBA());
|
||||
this->flushColorWrite(true);
|
||||
this->flushHWAAState(nullptr, false, false);
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(GrScissorTest::kDisabled);
|
||||
this->disableWindowRectangles();
|
||||
this->disableStencil();
|
||||
if (this->glCaps().srgbWriteControl()) {
|
||||
@ -3732,7 +3738,7 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst, GrSurfaceOrigin dstOr
|
||||
dstGLRect.setRelativeTo(dstVP, dstRect, dstOrigin);
|
||||
|
||||
// BlitFrameBuffer respects the scissor, so disable it.
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(GrScissorTest::kDisabled);
|
||||
this->disableWindowRectangles();
|
||||
|
||||
GrGLint srcY0;
|
||||
@ -3827,7 +3833,7 @@ bool GrGLGpu::onRegenerateMipMapLevels(GrTexture* texture) {
|
||||
this->flushBlend(blendInfo, GrSwizzle::RGBA());
|
||||
this->flushColorWrite(true);
|
||||
this->flushHWAAState(nullptr, false, false);
|
||||
this->disableScissor();
|
||||
this->flushScissorTest(GrScissorTest::kDisabled);
|
||||
this->disableWindowRectangles();
|
||||
this->disableStencil();
|
||||
|
||||
|
@ -328,14 +328,9 @@ private:
|
||||
|
||||
void flushColorWrite(bool writeColor);
|
||||
|
||||
// flushes the scissor. see the note on flushBoundTextureAndParams about
|
||||
// flushing the scissor after that function is called.
|
||||
void flushScissor(const GrScissorState&,
|
||||
const GrGLIRect& rtViewport,
|
||||
GrSurfaceOrigin rtOrigin);
|
||||
|
||||
// disables the scissor
|
||||
void disableScissor();
|
||||
void flushScissorTest(GrScissorTest);
|
||||
void flushScissorRect(const SkIRect& scissorRect, const GrGLIRect& viewport, GrSurfaceOrigin);
|
||||
void flushScissorState(const GrScissorState&, const GrGLIRect& viewport, GrSurfaceOrigin);
|
||||
|
||||
void flushWindowRectangles(const GrWindowRectsState&, const GrGLRenderTarget*, GrSurfaceOrigin);
|
||||
void disableWindowRectangles();
|
||||
|
@ -90,7 +90,7 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath*
|
||||
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(args.fProxy->priv().peekRenderTarget());
|
||||
SkISize size = SkISize::Make(rt->width(), rt->height());
|
||||
this->setProjectionMatrix(*args.fViewMatrix, size, args.fProxy->origin());
|
||||
gpu->flushScissor(*args.fScissor, rt->getViewport(), args.fProxy->origin());
|
||||
gpu->flushScissorState(*args.fScissor, rt->getViewport(), args.fProxy->origin());
|
||||
gpu->flushHWAAState(rt, args.fUseHWAA, true);
|
||||
gpu->flushRenderTarget(rt);
|
||||
|
||||
|
@ -17,7 +17,8 @@ std::unique_ptr<GrClearOp> GrClearOp::Make(GrContext* context,
|
||||
GrColor color,
|
||||
GrSurfaceProxy* dstProxy) {
|
||||
const SkIRect rect = SkIRect::MakeWH(dstProxy->width(), dstProxy->height());
|
||||
if (clip.scissorEnabled() && !SkIRect::Intersects(clip.scissorRect(), rect)) {
|
||||
if (clip.scissorTest() == GrScissorTest::kEnabled &&
|
||||
!SkIRect::Intersects(clip.scissorRect(), rect)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -42,7 +43,7 @@ GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* pro
|
||||
, fClip(clip)
|
||||
, fColor(color) {
|
||||
const SkIRect rtRect = SkIRect::MakeWH(proxy->width(), proxy->height());
|
||||
if (fClip.scissorEnabled()) {
|
||||
if (fClip.scissorTest() == GrScissorTest::kEnabled) {
|
||||
// Don't let scissors extend outside the RT. This may improve op combining.
|
||||
if (!fClip.intersect(rtRect)) {
|
||||
SkASSERT(0); // should be caught upstream
|
||||
@ -53,8 +54,10 @@ GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* pro
|
||||
fClip.disableScissor();
|
||||
}
|
||||
}
|
||||
this->setBounds(SkRect::Make(fClip.scissorEnabled() ? fClip.scissorRect() : rtRect),
|
||||
HasAABloat::kNo, IsZeroArea::kNo);
|
||||
this->setBounds(
|
||||
SkRect::Make(fClip.scissorTest() == GrScissorTest::kEnabled ? fClip.scissorRect()
|
||||
: rtRect),
|
||||
HasAABloat::kNo, IsZeroArea::kNo);
|
||||
}
|
||||
|
||||
void GrClearOp::onExecute(GrOpFlushState* state) {
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
SkString string;
|
||||
string.append(INHERITED::dumpInfo());
|
||||
string.appendf("Scissor [ ");
|
||||
if (fClip.scissorEnabled()) {
|
||||
if (fClip.scissorTest() == GrScissorTest::kEnabled) {
|
||||
const SkIRect& r = fClip.scissorRect();
|
||||
string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
|
||||
} else {
|
||||
@ -83,9 +83,11 @@ private:
|
||||
|
||||
bool contains(const GrClearOp* that) const {
|
||||
// The constructor ensures that scissor gets disabled on any clip that fills the entire RT.
|
||||
return !fClip.scissorEnabled() ||
|
||||
(that->fClip.scissorEnabled() &&
|
||||
fClip.scissorRect().contains(that->fClip.scissorRect()));
|
||||
if (fClip.scissorTest() == GrScissorTest::kDisabled) {
|
||||
return true;
|
||||
}
|
||||
return that->fClip.scissorTest() == GrScissorTest::kEnabled &&
|
||||
fClip.scissorRect().contains(that->fClip.scissorRect());
|
||||
}
|
||||
|
||||
void onPrepare(GrOpFlushState*) override {}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string("Scissor [");
|
||||
if (fClip.scissorEnabled()) {
|
||||
if (fClip.scissorTest() == GrScissorTest::kEnabled) {
|
||||
const SkIRect& r = fClip.scissorRect();
|
||||
string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
|
||||
} else {
|
||||
@ -46,9 +46,9 @@ private:
|
||||
: INHERITED(ClassID())
|
||||
, fClip(clip)
|
||||
, fInsideStencilMask(insideStencilMask) {
|
||||
const SkRect& bounds = fClip.scissorEnabled()
|
||||
? SkRect::Make(fClip.scissorRect())
|
||||
: SkRect::MakeIWH(proxy->width(), proxy->height());
|
||||
const SkRect& bounds = fClip.scissorTest() == GrScissorTest::kEnabled
|
||||
? SkRect::Make(fClip.scissorRect())
|
||||
: SkRect::MakeIWH(proxy->width(), proxy->height());
|
||||
this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
return true;
|
||||
}
|
||||
GrStencilClip stencilClip(appliedClip.stencilStackID());
|
||||
if (appliedClip.scissorState().enabled()) {
|
||||
if (appliedClip.scissorState().scissorTest() == GrScissorTest::kEnabled) {
|
||||
stencilClip.fixedClip().setScissor(appliedClip.scissorState().rect());
|
||||
}
|
||||
if (appliedClip.windowRectsState().enabled()) {
|
||||
|
@ -305,7 +305,7 @@ void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool in
|
||||
VkClearRect clearRect;
|
||||
// Flip rect if necessary
|
||||
SkIRect vkRect;
|
||||
if (!clip.scissorEnabled()) {
|
||||
if (clip.scissorTest() == GrScissorTest::kDisabled) {
|
||||
vkRect.setXYWH(0, 0, fRenderTarget->width(), fRenderTarget->height());
|
||||
} else if (kBottomLeft_GrSurfaceOrigin != fOrigin) {
|
||||
vkRect = clip.scissorRect();
|
||||
@ -333,7 +333,7 @@ void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool in
|
||||
cbInfo.fIsEmpty = false;
|
||||
|
||||
// Update command buffer bounds
|
||||
if (!clip.scissorEnabled()) {
|
||||
if (clip.scissorTest() == GrScissorTest::kDisabled) {
|
||||
cbInfo.fBounds.join(fRenderTarget->getBoundsRect());
|
||||
} else {
|
||||
cbInfo.fBounds.join(SkRect::Make(clip.scissorRect()));
|
||||
@ -351,7 +351,7 @@ void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) {
|
||||
VkClearColorValue vkColor;
|
||||
GrColorToRGBAFloat(color, vkColor.float32);
|
||||
|
||||
if (cbInfo.fIsEmpty && !clip.scissorEnabled()) {
|
||||
if (cbInfo.fIsEmpty && clip.scissorTest() == GrScissorTest::kDisabled) {
|
||||
// Change the render pass to do a clear load
|
||||
GrVkRenderPass::LoadStoreOps vkColorOps(VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||
VK_ATTACHMENT_STORE_OP_STORE);
|
||||
@ -390,7 +390,7 @@ void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) {
|
||||
VkClearRect clearRect;
|
||||
// Flip rect if necessary
|
||||
SkIRect vkRect;
|
||||
if (!clip.scissorEnabled()) {
|
||||
if (clip.scissorTest() == GrScissorTest::kDisabled) {
|
||||
vkRect.setXYWH(0, 0, fRenderTarget->width(), fRenderTarget->height());
|
||||
} else if (kBottomLeft_GrSurfaceOrigin != fOrigin) {
|
||||
vkRect = clip.scissorRect();
|
||||
@ -416,7 +416,7 @@ void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) {
|
||||
cbInfo.fIsEmpty = false;
|
||||
|
||||
// Update command buffer bounds
|
||||
if (!clip.scissorEnabled()) {
|
||||
if (clip.scissorTest() == GrScissorTest::kDisabled) {
|
||||
cbInfo.fBounds.join(fRenderTarget->getBoundsRect());
|
||||
} else {
|
||||
cbInfo.fBounds.join(SkRect::Make(clip.scissorRect()));
|
||||
@ -591,7 +591,7 @@ GrVkPipelineState* GrVkGpuRTCommandBuffer::prepareDrawState(
|
||||
|
||||
GrRenderTarget* rt = pipeline.renderTarget();
|
||||
|
||||
if (!pipeline.isScissorEnabled()) {
|
||||
if (pipeline.scissorTest() == GrScissorTest::kDisabled) {
|
||||
GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(),
|
||||
rt, pipeline.proxy()->origin(),
|
||||
SkIRect::MakeWH(rt->width(), rt->height()));
|
||||
@ -663,8 +663,8 @@ void GrVkGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
|
||||
return;
|
||||
}
|
||||
|
||||
bool dynamicScissor =
|
||||
pipeline.isScissorEnabled() && dynamicStateArrays && dynamicStateArrays->fScissorRects;
|
||||
bool dynamicScissor = (pipeline.scissorTest() == GrScissorTest::kEnabled) &&
|
||||
dynamicStateArrays && dynamicStateArrays->fScissorRects;
|
||||
|
||||
for (int i = 0; i < meshCount; ++i) {
|
||||
const GrMesh& mesh = meshes[i];
|
||||
|
@ -292,9 +292,6 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
||||
return false;
|
||||
}
|
||||
|
||||
// dummy scissor state
|
||||
GrScissorState scissor;
|
||||
|
||||
SkRandom random;
|
||||
static const int NUM_TESTS = 1024;
|
||||
for (int t = 0; t < NUM_TESTS; t++) {
|
||||
|
@ -392,7 +392,7 @@ sk_sp<const GrBuffer> DrawMeshHelper::getIndexBuffer() {
|
||||
|
||||
void DrawMeshHelper::drawMesh(const GrMesh& mesh) {
|
||||
GrRenderTargetProxy* proxy = fState->drawOpArgs().fProxy;
|
||||
GrPipeline pipeline(proxy, GrPipeline::ScissorState::kDisabled, SkBlendMode::kSrc);
|
||||
GrPipeline pipeline(proxy, GrScissorTest::kDisabled, SkBlendMode::kSrc);
|
||||
GrMeshTestProcessor mtp(mesh.isInstanced(), mesh.hasVertexData());
|
||||
fState->rtCommandBuffer()->draw(mtp, pipeline, nullptr, nullptr, &mesh, 1,
|
||||
SkRect::MakeIWH(kImageWidth, kImageHeight));
|
||||
|
@ -28,8 +28,6 @@
|
||||
* scissor rectangles then reads back the result to verify a successful test.
|
||||
*/
|
||||
|
||||
using ScissorState = GrPipeline::ScissorState;
|
||||
|
||||
static constexpr int kScreenSize = 6;
|
||||
static constexpr int kNumMeshes = 4;
|
||||
static constexpr int kScreenSplitX = kScreenSize/2;
|
||||
@ -113,20 +111,18 @@ public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
|
||||
ScissorState scissorState,
|
||||
GrScissorTest scissorTest,
|
||||
sk_sp<const GrBuffer> vbuff) {
|
||||
GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
|
||||
|
||||
return pool->allocate<GrPipelineDynamicStateTestOp>(scissorState, std::move(vbuff));
|
||||
return pool->allocate<GrPipelineDynamicStateTestOp>(scissorTest, std::move(vbuff));
|
||||
}
|
||||
|
||||
private:
|
||||
friend class GrOpMemoryPool;
|
||||
|
||||
GrPipelineDynamicStateTestOp(ScissorState scissorState, sk_sp<const GrBuffer> vbuff)
|
||||
: INHERITED(ClassID())
|
||||
, fScissorState(scissorState)
|
||||
, fVertexBuffer(std::move(vbuff)) {
|
||||
GrPipelineDynamicStateTestOp(GrScissorTest scissorTest, sk_sp<const GrBuffer> vbuff)
|
||||
: INHERITED(ClassID()), fScissorTest(scissorTest), fVertexBuffer(std::move(vbuff)) {
|
||||
this->setBounds(SkRect::MakeIWH(kScreenSize, kScreenSize),
|
||||
HasAABloat::kNo, IsZeroArea::kNo);
|
||||
}
|
||||
@ -141,7 +137,7 @@ private:
|
||||
void onPrepare(GrOpFlushState*) override {}
|
||||
void onExecute(GrOpFlushState* state) override {
|
||||
GrRenderTargetProxy* proxy = state->drawOpArgs().fProxy;
|
||||
GrPipeline pipeline(proxy, fScissorState, SkBlendMode::kSrc);
|
||||
GrPipeline pipeline(proxy, fScissorTest, SkBlendMode::kSrc);
|
||||
SkSTArray<kNumMeshes, GrMesh> meshes;
|
||||
for (int i = 0; i < kNumMeshes; ++i) {
|
||||
GrMesh& mesh = meshes.emplace_back(GrPrimitiveType::kTriangleStrip);
|
||||
@ -155,7 +151,7 @@ private:
|
||||
SkRect::MakeIWH(kScreenSize, kScreenSize));
|
||||
}
|
||||
|
||||
ScissorState fScissorState;
|
||||
GrScissorTest fScissorTest;
|
||||
const sk_sp<const GrBuffer> fVertexBuffer;
|
||||
|
||||
typedef GrDrawOp INHERITED;
|
||||
@ -208,17 +204,17 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo
|
||||
|
||||
uint32_t resultPx[kScreenSize * kScreenSize];
|
||||
|
||||
for (ScissorState scissorState : {ScissorState::kEnabled, ScissorState::kDisabled}) {
|
||||
for (GrScissorTest scissorTest : {GrScissorTest::kEnabled, GrScissorTest::kDisabled}) {
|
||||
rtc->clear(nullptr, 0xbaaaaaad, GrRenderTargetContext::CanClearFullscreen::kYes);
|
||||
rtc->priv().testingOnly_addDrawOp(
|
||||
GrPipelineDynamicStateTestOp::Make(context, scissorState, vbuff));
|
||||
GrPipelineDynamicStateTestOp::Make(context, scissorTest, vbuff));
|
||||
rtc->readPixels(SkImageInfo::Make(kScreenSize, kScreenSize,
|
||||
kRGBA_8888_SkColorType, kPremul_SkAlphaType),
|
||||
resultPx, 4 * kScreenSize, 0, 0, 0);
|
||||
for (int y = 0; y < kScreenSize; ++y) {
|
||||
for (int x = 0; x < kScreenSize; ++x) {
|
||||
int expectedColorIdx;
|
||||
if (ScissorState::kEnabled == scissorState) {
|
||||
if (scissorTest == GrScissorTest::kEnabled) {
|
||||
expectedColorIdx = (x < kScreenSplitX ? 0 : 2) + (y < kScreenSplitY ? 0 : 1);
|
||||
} else {
|
||||
expectedColorIdx = kNumMeshes - 1;
|
||||
@ -227,7 +223,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo
|
||||
uint32_t actual = resultPx[y * kScreenSize + x];
|
||||
if (expected != actual) {
|
||||
ERRORF(reporter, "[scissor=%s] pixel (%i,%i): got 0x%x expected 0x%x",
|
||||
ScissorState::kEnabled == scissorState ? "enabled" : "disabled", x, y,
|
||||
scissorTest == GrScissorTest::kEnabled ? "enabled" : "disabled", x, y,
|
||||
actual, expected);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user