diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-20 12:10:26 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-20 12:10:26 +0000 |
commit | 235ef3d0e253200af43bb69139df09744f5ddbef (patch) | |
tree | 7831374f09769e4f2d74ef4ab29e76c64d8b6fa2 | |
parent | 64b682ca42c75667e49251d3ab04f192f92d0dd8 (diff) |
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
-rw-r--r-- | include/gpu/GrConfig.h | 9 | ||||
-rw-r--r-- | include/gpu/GrUserConfig.h | 9 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 64 | ||||
-rw-r--r-- | src/gpu/GrGpu.cpp | 38 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 8 |
5 files changed, 1 insertions, 127 deletions
diff --git a/include/gpu/GrConfig.h b/include/gpu/GrConfig.h index 856757b547..94c65d84a4 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 594889b1a7..a10d339381 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 5ebe5b949d..85c241a8e3 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 7fc2ab8c04..0c58430dd1 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<GrGpu*>(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 f55c6ada29..656761bd32 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; |