diff options
author | 2014-11-04 07:47:55 -0800 | |
---|---|---|
committer | 2014-11-04 07:47:55 -0800 | |
commit | d1aa8ff8700cbc083c8c27b7368a8482e65cdb08 (patch) | |
tree | 3c800bc0ae4dddcd4d3d44c5c8bc3af70a94221b /src/gpu | |
parent | 7a10fb6bead0f63623307a7ff71b1dd323534a7f (diff) |
removing setVertexArraySource from drawtarget
BUG=skia:
Review URL: https://codereview.chromium.org/699733002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrBufferAllocPool.cpp | 29 | ||||
-rw-r--r-- | src/gpu/GrBufferAllocPool.h | 17 | ||||
-rwxr-xr-x | src/gpu/GrContext.cpp | 37 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 27 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 27 | ||||
-rw-r--r-- | src/gpu/GrGpu.cpp | 53 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 4 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 52 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 2 |
10 files changed, 23 insertions, 231 deletions
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index 226f45196e..9fafcb35ac 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -419,22 +419,6 @@ void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize, return ptr; } -bool GrVertexBufferAllocPool::appendVertices(size_t vertexSize, - int vertexCount, - const void* vertices, - const GrVertexBuffer** buffer, - int* startVertex) { - void* space = makeSpace(vertexSize, vertexCount, buffer, startVertex); - if (space) { - memcpy(space, - vertices, - vertexSize * vertexCount); - return true; - } else { - return false; - } -} - int GrVertexBufferAllocPool::preallocatedBufferVertices(size_t vertexSize) const { return static_cast<int>(INHERITED::preallocatedBufferSize() / vertexSize); } @@ -477,19 +461,6 @@ void* GrIndexBufferAllocPool::makeSpace(int indexCount, return ptr; } -bool GrIndexBufferAllocPool::appendIndices(int indexCount, - const void* indices, - const GrIndexBuffer** buffer, - int* startIndex) { - void* space = makeSpace(indexCount, buffer, startIndex); - if (space) { - memcpy(space, indices, sizeof(uint16_t) * indexCount); - return true; - } else { - return false; - } -} - int GrIndexBufferAllocPool::preallocatedBufferIndices() const { return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_t)); } diff --git a/src/gpu/GrBufferAllocPool.h b/src/gpu/GrBufferAllocPool.h index e3d398204b..40904cf871 100644 --- a/src/gpu/GrBufferAllocPool.h +++ b/src/gpu/GrBufferAllocPool.h @@ -231,15 +231,6 @@ public: int* startVertex); /** - * Shortcut to make space and then write verts into the made space. - */ - bool appendVertices(size_t vertexSize, - int vertexCount, - const void* vertices, - const GrVertexBuffer** buffer, - int* startVertex); - - /** * Gets the number of vertices that can be added to the current VB without * spilling to another VB. If the pool has been reset, or the previous * makeSpace completely exhausted a VB then the returned number of vertices @@ -315,14 +306,6 @@ public: int* startIndex); /** - * Shortcut to make space and then write indices into the made space. - */ - bool appendIndices(int indexCount, - const void* indices, - const GrIndexBuffer** buffer, - int* startIndex); - - /** * Gets the number of indices that can be added to the current IB without * spilling to another IB. If the pool has been reset, or the previous * makeSpace completely exhausted a IB then the returned number of indices diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index d95b4fe088..5891840ac6 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -910,35 +910,32 @@ void GrContext::drawVertices(const GrPaint& paint, set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset); size_t VertexStride = drawState->getVertexStride(); - if (sizeof(SkPoint) != VertexStride) { - if (!geo.set(target, vertexCount, 0)) { - SkDebugf("Failed to get space for vertices!\n"); - return; - } - void* curVertex = geo.vertices(); + if (!geo.set(target, vertexCount, indexCount)) { + SkDebugf("Failed to get space for vertices!\n"); + return; + } + void* curVertex = geo.vertices(); - for (int i = 0; i < vertexCount; ++i) { - *((SkPoint*)curVertex) = positions[i]; + for (int i = 0; i < vertexCount; ++i) { + *((SkPoint*)curVertex) = positions[i]; - if (texOffset >= 0) { - *(SkPoint*)((intptr_t)curVertex + texOffset) = texCoords[i]; - } - if (colorOffset >= 0) { - *(GrColor*)((intptr_t)curVertex + colorOffset) = colors[i]; - } - curVertex = (void*)((intptr_t)curVertex + VertexStride); + if (texOffset >= 0) { + *(SkPoint*)((intptr_t)curVertex + texOffset) = texCoords[i]; } - } else { - target->setVertexSourceToArray(positions, vertexCount); + if (colorOffset >= 0) { + *(GrColor*)((intptr_t)curVertex + colorOffset) = colors[i]; + } + curVertex = (void*)((intptr_t)curVertex + VertexStride); } // we don't currently apply offscreen AA to this path. Need improved // management of GrDrawTarget's geometry to avoid copying points per-tile. - if (indices) { - target->setIndexSourceToArray(indices, indexCount); + uint16_t* curIndex = (uint16_t*)geo.indices(); + for (int i = 0; i < indexCount; ++i) { + curIndex[i] = indices[i]; + } target->drawIndexed(primitiveType, 0, 0, vertexCount, indexCount); - target->resetIndexSource(); } else { target->drawNonIndexed(primitiveType, 0, vertexCount); } diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index cd422ea525..8f436f2906 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -232,9 +232,6 @@ void GrDrawTarget::releasePreviousVertexSource() { switch (geoSrc.fVertexSrc) { case kNone_GeometrySrcType: break; - case kArray_GeometrySrcType: - this->releaseVertexArray(); - break; case kReserved_GeometrySrcType: this->releaseReservedVertexSpace(); break; @@ -255,9 +252,6 @@ void GrDrawTarget::releasePreviousIndexSource() { switch (geoSrc.fIndexSrc) { case kNone_GeometrySrcType: // these two don't require break; - case kArray_GeometrySrcType: - this->releaseIndexArray(); - break; case kReserved_GeometrySrcType: this->releaseReservedIndexSpace(); break; @@ -273,25 +267,6 @@ void GrDrawTarget::releasePreviousIndexSource() { } } -void GrDrawTarget::setVertexSourceToArray(const void* vertexArray, - int vertexCount) { - this->releasePreviousVertexSource(); - GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); - geoSrc.fVertexSrc = kArray_GeometrySrcType; - geoSrc.fVertexSize = this->drawState()->getVertexStride(); - geoSrc.fVertexCount = vertexCount; - this->onSetVertexSourceToArray(vertexArray, vertexCount); -} - -void GrDrawTarget::setIndexSourceToArray(const void* indexArray, - int indexCount) { - this->releasePreviousIndexSource(); - GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); - geoSrc.fIndexSrc = kArray_GeometrySrcType; - geoSrc.fIndexCount = indexCount; - this->onSetIndexSourceToArray(indexArray, indexCount); -} - void GrDrawTarget::setVertexSourceToBuffer(const GrVertexBuffer* buffer) { this->releasePreviousVertexSource(); GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); @@ -358,7 +333,6 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex, case kNone_GeometrySrcType: SkFAIL("Attempting to draw without vertex src."); case kReserved_GeometrySrcType: // fallthrough - case kArray_GeometrySrcType: maxValidVertex = geoSrc.fVertexCount; break; case kBuffer_GeometrySrcType: @@ -375,7 +349,6 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex, case kNone_GeometrySrcType: SkFAIL("Attempting to draw indexed geom without index src."); case kReserved_GeometrySrcType: // fallthrough - case kArray_GeometrySrcType: maxValidIndex = geoSrc.fIndexCount; break; case kBuffer_GeometrySrcType: diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 4e922d723d..b1f758a731 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -201,25 +201,6 @@ public: int* indexCount) const; /** - * Sets source of vertex data for the next draw. Array must contain - * the vertex data when this is called. - * - * @param vertexArray cpu array containing vertex data. - * @param vertexCount the number of vertices in the array. Vertex size is - * queried from the current GrDrawState. - */ - void setVertexSourceToArray(const void* vertexArray, int vertexCount); - - /** - * Sets source of index data for the next indexed draw. Array must contain - * the indices when this is called. - * - * @param indexArray cpu array containing index data. - * @param indexCount the number of indices in the array. - */ - void setIndexSourceToArray(const void* indexArray, int indexCount); - - /** * Sets source of vertex data for the next draw. Data does not have to be * in the buffer until drawIndexed, drawNonIndexed, or drawIndexedInstances. * @@ -700,7 +681,6 @@ protected: enum GeometrySrcType { kNone_GeometrySrcType, //<! src has not been specified kReserved_GeometrySrcType, //<! src was set using reserve*Space - kArray_GeometrySrcType, //<! src was set using set*SourceToArray kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer }; @@ -730,7 +710,6 @@ protected: case kNone_GeometrySrcType: return 0; case kReserved_GeometrySrcType: - case kArray_GeometrySrcType: return src.fIndexCount; case kBuffer_GeometrySrcType: return static_cast<int>(src.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t)); @@ -853,12 +832,6 @@ private: // implemented by subclass to handle release of reserved geom space virtual void releaseReservedVertexSpace() = 0; virtual void releaseReservedIndexSpace() = 0; - // subclass must consume array contents when set - virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCount) = 0; - virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount) = 0; - // subclass is notified that geom source will be set away from an array - virtual void releaseVertexArray() = 0; - virtual void releaseIndexArray() = 0; // subclass overrides to be notified just before geo src state is pushed/popped. virtual void geometrySourceWillPush() = 0; virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index f7b9537ecc..8cccd35fff 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -291,12 +291,10 @@ bool GrGpu::setupClipAndFlushState(DrawType type, void GrGpu::geometrySourceWillPush() { const GeometrySrcState& geoSrc = this->getGeomSrc(); - if (kArray_GeometrySrcType == geoSrc.fVertexSrc || - kReserved_GeometrySrcType == geoSrc.fVertexSrc) { + if (kReserved_GeometrySrcType == geoSrc.fVertexSrc) { this->finalizeReservedVertices(); } - if (kArray_GeometrySrcType == geoSrc.fIndexSrc || - kReserved_GeometrySrcType == geoSrc.fIndexSrc) { + if (kReserved_GeometrySrcType == geoSrc.fIndexSrc) { this->finalizeReservedIndices(); } GeometryPoolState& newState = fGeomPoolStateStack.push_back(); @@ -514,50 +512,3 @@ void GrGpu::releaseReservedIndexSpace() { fIndexPool->putBack(bytes); --fIndexPoolUseCnt; } - -void GrGpu::onSetVertexSourceToArray(const void* vertexArray, int vertexCount) { - this->prepareVertexPool(); - GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); -#ifdef SK_DEBUG - bool success = -#endif - fVertexPool->appendVertices(this->getVertexSize(), - vertexCount, - vertexArray, - &geomPoolState.fPoolVertexBuffer, - &geomPoolState.fPoolStartVertex); - ++fVertexPoolUseCnt; - GR_DEBUGASSERT(success); -} - -void GrGpu::onSetIndexSourceToArray(const void* indexArray, int indexCount) { - this->prepareIndexPool(); - GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); -#ifdef SK_DEBUG - bool success = -#endif - fIndexPool->appendIndices(indexCount, - indexArray, - &geomPoolState.fPoolIndexBuffer, - &geomPoolState.fPoolStartIndex); - ++fIndexPoolUseCnt; - GR_DEBUGASSERT(success); -} - -void GrGpu::releaseVertexArray() { - // if vertex source was array, we stowed data in the pool - const GeometrySrcState& geoSrc = this->getGeomSrc(); - SkASSERT(kArray_GeometrySrcType == geoSrc.fVertexSrc); - size_t bytes = geoSrc.fVertexCount * geoSrc.fVertexSize; - fVertexPool->putBack(bytes); - --fVertexPoolUseCnt; -} - -void GrGpu::releaseIndexArray() { - // if index source was array, we stowed data in the pool - const GeometrySrcState& geoSrc = this->getGeomSrc(); - SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); - size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); - fIndexPool->putBack(bytes); - --fIndexPoolUseCnt; -} diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 5f6505549b..2dcee06d56 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -372,10 +372,6 @@ private: virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE; virtual void releaseReservedVertexSpace() SK_OVERRIDE; virtual void releaseReservedIndexSpace() SK_OVERRIDE; - virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCount) SK_OVERRIDE; - virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount) SK_OVERRIDE; - virtual void releaseVertexArray() SK_OVERRIDE; - virtual void releaseIndexArray() SK_OVERRIDE; virtual void geometrySourceWillPush() SK_OVERRIDE; virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRIDE; diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 04b9ba23d8..ec8972c95f 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -709,8 +709,7 @@ void GrInOrderDrawBuffer::releaseReservedVertexSpace() { // If we get a release vertex space call then our current source should either be reserved // or array (which we copied into reserved space). - SkASSERT(kReserved_GeometrySrcType == geoSrc.fVertexSrc || - kArray_GeometrySrcType == geoSrc.fVertexSrc); + SkASSERT(kReserved_GeometrySrcType == geoSrc.fVertexSrc); // When the caller reserved vertex buffer space we gave it back a pointer // provided by the vertex buffer pool. At each draw we tracked the largest @@ -730,8 +729,7 @@ void GrInOrderDrawBuffer::releaseReservedIndexSpace() { // If we get a release index space call then our current source should either be reserved // or array (which we copied into reserved space). - SkASSERT(kReserved_GeometrySrcType == geoSrc.fIndexSrc || - kArray_GeometrySrcType == geoSrc.fIndexSrc); + SkASSERT(kReserved_GeometrySrcType == geoSrc.fIndexSrc); // Similar to releaseReservedVertexSpace we return any unused portion at // the tail @@ -742,46 +740,6 @@ void GrInOrderDrawBuffer::releaseReservedIndexSpace() { poolState.fPoolStartIndex = 0; } -void GrInOrderDrawBuffer::onSetVertexSourceToArray(const void* vertexArray, int vertexCount) { - GeometryPoolState& poolState = fGeoPoolStateStack.back(); - SkASSERT(0 == poolState.fUsedPoolVertexBytes); -#ifdef SK_DEBUG - bool success = -#endif - fVertexPool.appendVertices(this->getVertexSize(), - vertexCount, - vertexArray, - &poolState.fPoolVertexBuffer, - &poolState.fPoolStartVertex); - GR_DEBUGASSERT(success); -} - -void GrInOrderDrawBuffer::onSetIndexSourceToArray(const void* indexArray, - int indexCount) { - GeometryPoolState& poolState = fGeoPoolStateStack.back(); - SkASSERT(0 == poolState.fUsedPoolIndexBytes); -#ifdef SK_DEBUG - bool success = -#endif - fIndexPool.appendIndices(indexCount, - indexArray, - &poolState.fPoolIndexBuffer, - &poolState.fPoolStartIndex); - GR_DEBUGASSERT(success); -} - -void GrInOrderDrawBuffer::releaseVertexArray() { - // When the client provides an array as the vertex source we handled it - // by copying their array into reserved space. - this->GrInOrderDrawBuffer::releaseReservedVertexSpace(); -} - -void GrInOrderDrawBuffer::releaseIndexArray() { - // When the client provides an array as the index source we handled it - // by copying their array into reserved space. - this->GrInOrderDrawBuffer::releaseReservedIndexSpace(); -} - void GrInOrderDrawBuffer::geometrySourceWillPush() { GeometryPoolState& poolState = fGeoPoolStateStack.push_back(); poolState.fUsedPoolVertexBytes = 0; @@ -801,12 +759,10 @@ void GrInOrderDrawBuffer::geometrySourceWillPop(const GeometrySrcState& restored // we have to assume that any slack we had in our vertex/index data // is now unreleasable because data may have been appended later in the // pool. - if (kReserved_GeometrySrcType == restoredState.fVertexSrc || - kArray_GeometrySrcType == restoredState.fVertexSrc) { + if (kReserved_GeometrySrcType == restoredState.fVertexSrc) { poolState.fUsedPoolVertexBytes = restoredState.fVertexSize * restoredState.fVertexCount; } - if (kReserved_GeometrySrcType == restoredState.fIndexSrc || - kArray_GeometrySrcType == restoredState.fIndexSrc) { + if (kReserved_GeometrySrcType == restoredState.fIndexSrc) { poolState.fUsedPoolIndexBytes = sizeof(uint16_t) * restoredState.fIndexCount; } diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h index 1e8b5a6d3c..714d822dd5 100644 --- a/src/gpu/GrInOrderDrawBuffer.h +++ b/src/gpu/GrInOrderDrawBuffer.h @@ -282,12 +282,6 @@ private: void** indices) SK_OVERRIDE; virtual void releaseReservedVertexSpace() SK_OVERRIDE; virtual void releaseReservedIndexSpace() SK_OVERRIDE; - virtual void onSetVertexSourceToArray(const void* vertexArray, - int vertexCount) SK_OVERRIDE; - virtual void onSetIndexSourceToArray(const void* indexArray, - int indexCount) SK_OVERRIDE; - virtual void releaseVertexArray() SK_OVERRIDE; - virtual void releaseIndexArray() SK_OVERRIDE; virtual void geometrySourceWillPush() SK_OVERRIDE; virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRIDE; virtual void willReserveVertexAndIndexSpace(int vertexCount, diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index 330f348d86..4ad333e2bf 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -290,7 +290,6 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { case kBuffer_GeometrySrcType: vbuf = (GrGLVertexBuffer*) this->getGeomSrc().fVertexBuffer; break; - case kArray_GeometrySrcType: case kReserved_GeometrySrcType: this->finalizeReservedVertices(); vertexOffsetInBytes += geoPoolState.fPoolStartVertex * this->getGeomSrc().fVertexSize; @@ -314,7 +313,6 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { *indexOffsetInBytes = 0; ibuf = (GrGLIndexBuffer*)this->getGeomSrc().fIndexBuffer; break; - case kArray_GeometrySrcType: case kReserved_GeometrySrcType: this->finalizeReservedIndices(); *indexOffsetInBytes = geoPoolState.fPoolStartIndex * sizeof(GrGLushort); |