diff options
author | joshualitt <joshualitt@chromium.org> | 2014-11-19 09:38:51 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-19 09:38:51 -0800 |
commit | 54e0c12a5ab2d83fe249dd199d6879e8c0f04404 (patch) | |
tree | bfa048cfac5852f9944d1c83a1b99c112e38c67c /src/gpu | |
parent | 65d79cefe2452288228ec53fe0b7153934b0f9a3 (diff) |
scissor state on optstate
waiting
BUG=skia:
Review URL: https://codereview.chromium.org/742763002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrGpu.cpp | 14 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 8 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 39 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.h | 22 | ||||
-rw-r--r-- | src/gpu/GrOptDrawState.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrOptDrawState.h | 16 | ||||
-rw-r--r-- | src/gpu/GrTest.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.h | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 3 |
9 files changed, 50 insertions, 60 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 523c6177a9..cdbb01d1d6 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -283,13 +283,10 @@ const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { //////////////////////////////////////////////////////////////////////////////// -void GrGpu::draw(const GrOptDrawState& ds, - const GrDrawTarget::DrawInfo& info, - const GrClipMaskManager::ScissorState& scissorState) { +void GrGpu::draw(const GrOptDrawState& ds, const GrDrawTarget::DrawInfo& info) { this->handleDirtyContext(); if (!this->flushGraphicsState(ds, PrimTypeToDrawType(info.primitiveType()), - scissorState, info.getDstCopy())) { return; } @@ -298,11 +295,10 @@ void GrGpu::draw(const GrOptDrawState& ds, void GrGpu::stencilPath(const GrOptDrawState& ds, const GrPath* path, - const GrClipMaskManager::ScissorState& scissorState, const GrStencilSettings& stencilSettings) { this->handleDirtyContext(); - if (!this->flushGraphicsState(ds, kStencilPath_DrawType, scissorState, NULL)) { + if (!this->flushGraphicsState(ds, kStencilPath_DrawType, NULL)) { return; } @@ -312,12 +308,11 @@ void GrGpu::stencilPath(const GrOptDrawState& ds, void GrGpu::drawPath(const GrOptDrawState& ds, const GrPath* path, - const GrClipMaskManager::ScissorState& scissorState, const GrStencilSettings& stencilSettings, const GrDeviceCoordTexture* dstCopy) { this->handleDirtyContext(); - if (!this->flushGraphicsState(ds, kDrawPath_DrawType, scissorState, dstCopy)) { + if (!this->flushGraphicsState(ds, kDrawPath_DrawType, dstCopy)) { return; } @@ -330,12 +325,11 @@ void GrGpu::drawPaths(const GrOptDrawState& ds, int count, const float transforms[], GrDrawTarget::PathTransformType transformsType, - const GrClipMaskManager::ScissorState& scissorState, const GrStencilSettings& stencilSettings, const GrDeviceCoordTexture* dstCopy) { this->handleDirtyContext(); - if (!this->flushGraphicsState(ds, kDrawPaths_DrawType, scissorState, dstCopy)) { + if (!this->flushGraphicsState(ds, kDrawPaths_DrawType, dstCopy)) { return; } diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index bf259f92ed..94a0914843 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -356,16 +356,12 @@ public: const SkIRect& srcRect, const SkIPoint& dstPoint) = 0; - virtual void draw(const GrOptDrawState&, - const GrDrawTarget::DrawInfo&, - const GrClipMaskManager::ScissorState&); + virtual void draw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&); virtual void stencilPath(const GrOptDrawState&, const GrPath*, - const GrClipMaskManager::ScissorState&, const GrStencilSettings&); virtual void drawPath(const GrOptDrawState&, const GrPath*, - const GrClipMaskManager::ScissorState&, const GrStencilSettings&, const GrDeviceCoordTexture* dstCopy); virtual void drawPaths(const GrOptDrawState&, @@ -374,7 +370,6 @@ public: int count, const float transforms[], GrDrawTarget::PathTransformType, - const GrClipMaskManager::ScissorState&, const GrStencilSettings&, const GrDeviceCoordTexture*); @@ -476,7 +471,6 @@ private: // returns false if current state is unsupported. virtual bool flushGraphicsState(const GrOptDrawState&, DrawType, - const GrClipMaskManager::ScissorState&, const GrDeviceCoordTexture* dstCopy) = 0; // clears target's entire stencil buffer to 0 diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 7535a8d061..e5d6795214 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -190,9 +190,7 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, this->drawIndexedInstances(ds, kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds); } -int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, - const DrawInfo& info, - const GrClipMaskManager::ScissorState& scissorState) { +int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, const DrawInfo& info) { SkASSERT(!fCmdBuffer.empty()); SkASSERT(info.isInstanced()); @@ -219,8 +217,7 @@ int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, draw->fInfo.verticesPerInstance() != info.verticesPerInstance() || draw->fInfo.indicesPerInstance() != info.indicesPerInstance() || draw->fInfo.vertexBuffer() != vertexBuffer || - draw->fInfo.indexBuffer() != geomSrc.fIndexBuffer || - draw->fScissorState != scissorState) { + draw->fInfo.indexBuffer() != geomSrc.fIndexBuffer) { return 0; } // info does not yet account for the offset from the start of the pool's VB while the previous @@ -258,27 +255,27 @@ int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, const DrawInfo& info, - const GrClipMaskManager::ScissorState& scissorState) { + const ScissorState& scissorState) { SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); GeometryPoolState& poolState = fGeoPoolStateStack.back(); if (!this->recordStateAndShouldDraw(ds, GrGpu::PrimTypeToDrawType(info.primitiveType()), - info.getDstCopy())) { + scissorState, info.getDstCopy())) { return; } Draw* draw; if (info.isInstanced()) { - int instancesConcated = this->concatInstancedDraw(ds, info, scissorState); + int instancesConcated = this->concatInstancedDraw(ds, info); if (info.instanceCount() > instancesConcated) { - draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorState)); + draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); draw->fInfo.adjustInstanceCount(-instancesConcated); } else { return; } } else { - draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorState)); + draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); } this->recordTraceMarkersIfNecessary(); @@ -302,11 +299,10 @@ void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds, const GrClipMaskManager::ScissorState& scissorState, const GrStencilSettings& stencilSettings) { // Only compare the subset of GrDrawState relevant to path stenciling? - if (!this->recordStateAndShouldDraw(ds, GrGpu::kStencilPath_DrawType, NULL)) { + if (!this->recordStateAndShouldDraw(ds, GrGpu::kStencilPath_DrawType, scissorState, NULL)) { return; } StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, (path)); - sp->fScissorState = scissorState; sp->fStencilSettings = stencilSettings; this->recordTraceMarkersIfNecessary(); } @@ -317,14 +313,13 @@ void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, const GrStencilSettings& stencilSettings, const GrDeviceCoordTexture* dstCopy) { // TODO: Only compare the subset of GrDrawState relevant to path covering? - if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, dstCopy)) { + if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorState, dstCopy)) { return; } DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); if (dstCopy) { dp->fDstCopy = *dstCopy; } - dp->fScissorState = scissorState; dp->fStencilSettings = stencilSettings; this->recordTraceMarkersIfNecessary(); } @@ -342,7 +337,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, SkASSERT(indices); SkASSERT(transforms); - if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, dstCopy)) { + if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorState, dstCopy)) { return; } @@ -361,7 +356,6 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, DrawPaths* previous = static_cast<DrawPaths*>(&fCmdBuffer.back()); if (pathRange == previous->pathRange() && transformsType == previous->fTransformsType && - scissorState == previous->fScissorState && stencilSettings == previous->fStencilSettings && path_fill_type_is_winding(stencilSettings) && !ds.willBlendWithDst()) { @@ -376,7 +370,6 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, dp->fCount = count; dp->fTransformsLocation = savedTransforms - fPathTransformBuffer.begin(); dp->fTransformsType = transformsType; - dp->fScissorState = scissorState; dp->fStencilSettings = stencilSettings; if (dstCopy) { dp->fDstCopy = *dstCopy; @@ -514,17 +507,17 @@ void GrInOrderDrawBuffer::flush() { } void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const GrOptDrawState* optState) { - buf->fDstGpu->draw(*optState, fInfo, fScissorState); + buf->fDstGpu->draw(*optState, fInfo); } void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, const GrOptDrawState* optState) { - buf->fDstGpu->stencilPath(*optState, this->path(), fScissorState, fStencilSettings); + buf->fDstGpu->stencilPath(*optState, this->path(), fStencilSettings); } void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, const GrOptDrawState* optState) { - buf->fDstGpu->drawPath(*optState, this->path(), fScissorState, fStencilSettings, + buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings, fDstCopy.texture() ? &fDstCopy : NULL); } @@ -533,7 +526,7 @@ void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, buf->fDstGpu->drawPaths(*optState, this->pathRange(), &buf->fPathIndexBuffer[fIndicesLocation], fCount, &buf->fPathTransformBuffer[fTransformsLocation], fTransformsType, - fScissorState, fStencilSettings, fDstCopy.texture() ? &fDstCopy : NULL); + fStencilSettings, fDstCopy.texture() ? &fDstCopy : NULL); } void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDrawState*) { @@ -738,8 +731,10 @@ void GrInOrderDrawBuffer::geometrySourceWillPop(const GeometrySrcState& restored bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds, GrGpu::DrawType drawType, + const GrClipMaskManager::ScissorState& scissor, const GrDeviceCoordTexture* dstCopy) { - SkAutoTUnref<GrOptDrawState> optState(GrOptDrawState::Create(ds, fDstGpu, dstCopy, drawType)); + SkAutoTUnref<GrOptDrawState> optState(GrOptDrawState::Create(ds, fDstGpu, scissor, dstCopy, + drawType)); if (!optState) { return false; } diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h index 58b239baa4..ed5cdd42e6 100644 --- a/src/gpu/GrInOrderDrawBuffer.h +++ b/src/gpu/GrInOrderDrawBuffer.h @@ -116,15 +116,11 @@ private: }; struct Draw : public Cmd { - Draw(const DrawInfo& info, const ScissorState& scissorState) - : Cmd(kDraw_Cmd) - , fInfo(info) - , fScissorState(scissorState){} + Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); DrawInfo fInfo; - ScissorState fScissorState; }; struct StencilPath : public Cmd { @@ -134,7 +130,6 @@ private: virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); - ScissorState fScissorState; GrStencilSettings fStencilSettings; private: @@ -149,7 +144,6 @@ private: virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); GrDeviceCoordTexture fDstCopy; - ScissorState fScissorState; GrStencilSettings fStencilSettings; private: @@ -168,7 +162,6 @@ private: int fTransformsLocation; PathTransformType fTransformsType; GrDeviceCoordTexture fDstCopy; - ScissorState fScissorState; GrStencilSettings fStencilSettings; private: @@ -238,7 +231,7 @@ private: // overrides from GrDrawTarget void onDraw(const GrDrawState&, const DrawInfo&, - const GrClipMaskManager::ScissorState&) SK_OVERRIDE; + const ScissorState&) SK_OVERRIDE; void onDrawRect(GrDrawState*, const SkRect& rect, const SkRect* localRect, @@ -246,11 +239,11 @@ private: void onStencilPath(const GrDrawState&, const GrPath*, - const GrClipMaskManager::ScissorState&, + const ScissorState&, const GrStencilSettings&) SK_OVERRIDE; void onDrawPath(const GrDrawState&, const GrPath*, - const GrClipMaskManager::ScissorState&, + const ScissorState&, const GrStencilSettings&, const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; void onDrawPaths(const GrDrawState&, @@ -259,7 +252,7 @@ private: int count, const float transforms[], PathTransformType, - const GrClipMaskManager::ScissorState&, + const ScissorState&, const GrStencilSettings&, const GrDeviceCoordTexture*) SK_OVERRIDE; void onClear(const SkIRect* rect, @@ -280,15 +273,14 @@ private: // Attempts to concat instances from info onto the previous draw. info must represent an // instanced draw. The caller must have already recorded a new draw state and clip if necessary. - int concatInstancedDraw(const GrDrawState&, - const DrawInfo&, - const GrClipMaskManager::ScissorState&); + int concatInstancedDraw(const GrDrawState&, const DrawInfo&); // Determines whether the current draw operation requires a new GrOptDrawState and if so // records it. If the draw can be skipped false is returned and no new GrOptDrawState is // recorded. bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, GrGpu::DrawType, + const GrClipMaskManager::ScissorState&, const GrDeviceCoordTexture*); // We lazily record clip changes in order to skip clips that have no effect. void recordClipIfNecessary(); diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp index 4b20fa901c..2435e5fc33 100644 --- a/src/gpu/GrOptDrawState.cpp +++ b/src/gpu/GrOptDrawState.cpp @@ -18,9 +18,11 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff, GrGpu* gpu, + const ScissorState& scissorState, const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType) : fRenderTarget(drawState.fRenderTarget.get()) { + fScissorState = scissorState; fViewMatrix = drawState.getViewMatrix(); fBlendConstant = drawState.getBlendConstant(); fFlagBits = drawState.getFlagBits(); @@ -91,6 +93,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, GrGpu* gpu, + const ScissorState& scissorState, const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType) { GrBlendCoeff srcCoeff; @@ -109,7 +112,7 @@ GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, } return SkNEW_ARGS(GrOptDrawState, (drawState, blendFlags, srcCoeff, - dstCoeff, gpu, dstCopy, drawType)); + dstCoeff, gpu, scissorState, dstCopy, drawType)); } void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, @@ -261,6 +264,7 @@ bool GrOptDrawState::operator== (const GrOptDrawState& that) const { } if (this->getRenderTarget() != that.getRenderTarget() || + this->fScissorState != that.fScissorState || !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || this->fSrcBlend != that.fSrcBlend || this->fDstBlend != that.fDstBlend || diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h index ab531eed5e..903b227891 100644 --- a/src/gpu/GrOptDrawState.h +++ b/src/gpu/GrOptDrawState.h @@ -28,12 +28,15 @@ class GrOptDrawState : public SkRefCnt { public: SK_DECLARE_INST_COUNT(GrOptDrawState) + typedef GrClipMaskManager::ScissorState ScissorState; + /** * Returns a snapshot of the current optimized state. The GrOptDrawState is reffed and ownership * is given to the caller. */ static GrOptDrawState* Create(const GrDrawState& drawState, GrGpu*, + const ScissorState&, const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType); @@ -164,6 +167,15 @@ public: /// @} /////////////////////////////////////////////////////////////////////////// + /// @name ScissorState + //// + + const ScissorState& getScissorState() const { return fScissorState; } + + /// @} + + + /////////////////////////////////////////////////////////////////////////// /// @name State Flags //// @@ -268,7 +280,8 @@ private: */ GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff, - GrGpu*, const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); + GrGpu*, const ScissorState&, const GrDeviceCoordTexture* dstCopy, + GrGpu::DrawType); /** * Loops through all the color stage effects to check if the stage will ignore color input or @@ -321,6 +334,7 @@ private: typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryProcessor; RenderTarget fRenderTarget; + ScissorState fScissorState; GrColor fColor; SkMatrix fViewMatrix; GrColor fBlendConstant; diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index 5c03189861..063a2bb8fb 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -150,7 +150,6 @@ private: virtual bool flushGraphicsState(const GrOptDrawState&, DrawType, - const GrClipMaskManager::ScissorState&, const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE { return false; } diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index 778ee160e1..059a08e52d 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -159,7 +159,6 @@ private: virtual void clearStencil(GrRenderTarget*) SK_OVERRIDE; virtual bool flushGraphicsState(const GrOptDrawState&, DrawType, - const GrClipMaskManager::ScissorState&, const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; // GrDrawTarget overrides diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index cfea2c508c..864b453691 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -203,7 +203,6 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, D bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type, - const GrClipMaskManager::ScissorState& scissorState, const GrDeviceCoordTexture* dstCopy) { // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true. SkASSERT(optState.getRenderTarget()); @@ -246,7 +245,7 @@ bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget()); this->flushStencil(optState.getStencil(), type); - this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); + this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin()); this->flushAAState(optState, type); // This must come after textures are flushed because a texture may need |