From 235ef3d0e253200af43bb69139df09744f5ddbef Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Sat, 20 Apr 2013 12:10:26 +0000 Subject: [PATCH] Remove GR_STATIC_RECT_VB https://codereview.chromium.org/14367030/ git-svn-id: http://skia.googlecode.com/svn/trunk@8786 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/gpu/GrConfig.h | 9 ------- include/gpu/GrUserConfig.h | 9 ------- src/gpu/GrContext.cpp | 64 +--------------------------------------------- src/gpu/GrGpu.cpp | 38 --------------------------- src/gpu/GrGpu.h | 8 ------ 5 files changed, 1 insertion(+), 127 deletions(-) diff --git a/include/gpu/GrConfig.h b/include/gpu/GrConfig.h index 856757b..94c65d8 100644 --- a/include/gpu/GrConfig.h +++ b/include/gpu/GrConfig.h @@ -316,15 +316,6 @@ inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); } #endif /** - * GR_STATIC_RECT_VB controls whether rects are drawn by issuing a vertex - * for each corner or using a static vb that is positioned by modifying the - * view / texture matrix. - */ -#if !defined(GR_STATIC_RECT_VB) - #define GR_STATIC_RECT_VB 0 -#endif - -/** * GR_GEOM_BUFFER_LOCK_THRESHOLD gives a threshold (in bytes) for when Gr should * lock a GrGeometryBuffer to update its contents. It will use lock() if the * size of the updated region is greater than the threshold. Otherwise it will diff --git a/include/gpu/GrUserConfig.h b/include/gpu/GrUserConfig.h index 594889b..a10d339 100644 --- a/include/gpu/GrUserConfig.h +++ b/include/gpu/GrUserConfig.h @@ -22,15 +22,6 @@ #endif /** - * When drawing rects this causes Ganesh to use a vertex buffer containing - * a unit square that is positioned by a matrix. Enable on systems where - * emitting per-rect-draw verts is more expensive than constant/matrix - * updates. Defaults to 0. - */ -//#define GR_STATIC_RECT_VB 1 - - -/** * This gives a threshold in bytes of when to lock a GrGeometryBuffer vs using * updateData. (Note the depending on the underlying 3D API the update functions * may always be implemented using a lock) diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 5ebe5b9..85c241a 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -853,30 +853,7 @@ void GrContext::drawRect(const GrPaint& paint, target->drawNonIndexed(primType, 0, vertCount); } else { // filled BW rect -#if GR_STATIC_RECT_VB - const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer(); - if (NULL == sqVB) { - GrPrintf("Failed to create static rect vb.\n"); - return; - } - - GrDrawState* drawState = target->drawState(); - target->drawState()->setDefaultVertexAttribs(); - target->setVertexSourceToBuffer(sqVB); - SkMatrix m; - m.setAll(rect.width(), 0, rect.fLeft, - 0, rect.height(), rect.fTop, - 0, 0, SkMatrix::I()[8]); - - if (NULL != matrix) { - m.postConcat(*matrix); - } - GrDrawState::AutoViewMatrixRestore avmr(drawState, m); - - target->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4); -#else - target->drawSimpleRect(rect, matrix); -#endif + target->drawSimpleRect(rect, matrix); } } @@ -890,46 +867,7 @@ void GrContext::drawRectToRect(const GrPaint& paint, GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); GrDrawState::AutoStageDisable atr(fDrawState); -#if GR_STATIC_RECT_VB - GrDrawState* drawState = target->drawState(); - - SkMatrix m; - - m.setAll(dstRect.width(), 0, dstRect.fLeft, - 0, dstRect.height(), dstRect.fTop, - 0, 0, SkMatrix::I()[8]); - if (NULL != dstMatrix) { - m.postConcat(*dstMatrix); - } - - // This code path plays a little fast and loose with the notion of local coords and coord - // change matrices in order to account for localRect and localMatrix. The unit square VB only - // has one set of coords. Rather than using AutoViewMatrixRestore we instead directly set concat - // with m and then call GrDrawState::localCoordChange() with a matrix that accounts for - // localRect and localMatrix. This code path is preventing some encapsulation in GrDrawState. - SkMatrix savedViewMatrix = drawState->getViewMatrix(); - drawState->preConcatViewMatrix(m); - - m.setAll(localRect.width(), 0, localRect.fLeft, - 0, localRect.height(), localRect.fTop, - 0, 0, SkMatrix::I()[8]); - if (NULL != localMatrix) { - m.postConcat(*localMatrix); - } - drawState->localCoordChange(m); - - const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer(); - if (NULL == sqVB) { - GrPrintf("Failed to create static rect vb.\n"); - return; - } - drawState->setDefaultVertexAttribs(); - target->setVertexSourceToBuffer(sqVB); - target->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4); - drawState->setViewMatrix(savedViewMatrix); -#else target->drawRect(dstRect, dstMatrix, &localRect, localMatrix); -#endif } void GrContext::drawVertices(const GrPaint& paint, diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 7fc2ab8..0c58430 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -34,7 +34,6 @@ GrGpu::GrGpu(GrContext* context) , fIndexPool(NULL) , fVertexPoolUseCnt(0) , fIndexPoolUseCnt(0) - , fUnitSquareVertexBuffer(NULL) , fQuadIndexBuffer(NULL) , fContextIsDirty(true) { @@ -67,10 +66,7 @@ void GrGpu::abandonResources() { } GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); - GrAssert(NULL == fUnitSquareVertexBuffer || - !fUnitSquareVertexBuffer->isValid()); GrSafeSetNull(fQuadIndexBuffer); - GrSafeSetNull(fUnitSquareVertexBuffer); delete fVertexPool; fVertexPool = NULL; delete fIndexPool; @@ -86,10 +82,7 @@ void GrGpu::releaseResources() { } GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); - GrAssert(NULL == fUnitSquareVertexBuffer || - !fUnitSquareVertexBuffer->isValid()); GrSafeSetNull(fQuadIndexBuffer); - GrSafeSetNull(fUnitSquareVertexBuffer); delete fVertexPool; fVertexPool = NULL; delete fIndexPool; @@ -297,37 +290,6 @@ const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { return fQuadIndexBuffer; } -const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const { - if (NULL == fUnitSquareVertexBuffer) { - - static const GrPoint DATA[] = { - { 0, 0 }, - { SK_Scalar1, 0 }, - { SK_Scalar1, SK_Scalar1 }, - { 0, SK_Scalar1 } -#if 0 - GrPoint(0, 0), - GrPoint(SK_Scalar1,0), - GrPoint(SK_Scalar1,SK_Scalar1), - GrPoint(0, SK_Scalar1) -#endif - }; - static const size_t SIZE = sizeof(DATA); - - GrGpu* me = const_cast(this); - fUnitSquareVertexBuffer = me->createVertexBuffer(SIZE, false); - if (NULL != fUnitSquareVertexBuffer) { - if (!fUnitSquareVertexBuffer->updateData(DATA, SIZE)) { - fUnitSquareVertexBuffer->unref(); - fUnitSquareVertexBuffer = NULL; - GrCrash("Can't get vertices into buffer!"); - } - } - } - - return fUnitSquareVertexBuffer; -} - //////////////////////////////////////////////////////////////////////////////// bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* dstCopy) { diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index f55c6ad..656761b 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -140,13 +140,6 @@ public: const GrIndexBuffer* getQuadIndexBuffer() const; /** - * Returns a vertex buffer with four position-only vertices [(0,0), (1,0), - * (1,1), (0,1)]. - * @ return unit square vertex buffer - */ - const GrVertexBuffer* getUnitSquareVertexBuffer() const; - - /** * Resolves MSAA. */ void resolveRenderTarget(GrRenderTarget* target); @@ -528,7 +521,6 @@ private: int fVertexPoolUseCnt; int fIndexPoolUseCnt; // these are mutable so they can be created on-demand - mutable GrVertexBuffer* fUnitSquareVertexBuffer; mutable GrIndexBuffer* fQuadIndexBuffer; bool fContextIsDirty; ResourceList fResourceList; -- 2.7.4