aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-02-16 09:35:50 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-16 09:35:50 -0800
commit54fac8b04a2583590c55d7b1e9339288c7370b28 (patch)
treeb492ba4a45408b9d5e204dac55af3e3a96c1c18a /src
parent351ba1b3218c436089805ebe8e72ad39020229f4 (diff)
Minor refactoring
This CL just de-dups some code in GrInOrderDrawBuffer. Review URL: https://codereview.chromium.org/930953003
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDrawTarget.h12
-rw-r--r--src/gpu/GrFlushToGpuDrawTarget.h7
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp26
-rw-r--r--src/gpu/GrInOrderDrawBuffer.h1
4 files changed, 12 insertions, 34 deletions
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index f9f25f15fa..e52ee6648f 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -711,6 +711,12 @@ protected:
void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline);
+ // A subclass can optionally overload this function to be notified before
+ // vertex and index space is reserved.
+ virtual void willReserveVertexAndIndexSpace(int vertexCount,
+ size_t vertexStride,
+ int indexCount) {}
+
private:
/**
* This will be called before allocating a texture as a dst for copySurface. This function
@@ -731,12 +737,6 @@ private:
const SkIRect& clippedSrcRect,
const SkIPoint& clippedDstRect);
- // A subclass can optionally overload this function to be notified before
- // vertex and index space is reserved.
- virtual void willReserveVertexAndIndexSpace(int vertexCount,
- size_t vertexStride,
- int indexCount) {}
-
// implemented by subclass to allocate space for reserved geom
virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0;
virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0;
diff --git a/src/gpu/GrFlushToGpuDrawTarget.h b/src/gpu/GrFlushToGpuDrawTarget.h
index 12881563b2..4c72f93572 100644
--- a/src/gpu/GrFlushToGpuDrawTarget.h
+++ b/src/gpu/GrFlushToGpuDrawTarget.h
@@ -69,6 +69,10 @@ protected:
typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateStack;
const GeoPoolStateStack& getGeoPoolStateStack() const { return fGeoPoolStateStack; }
+ void willReserveVertexAndIndexSpace(int vertexCount,
+ size_t vertexStride,
+ int indexCount) SK_OVERRIDE;
+
private:
virtual void onReset() = 0;
@@ -81,9 +85,6 @@ private:
void releaseReservedIndexSpace() SK_OVERRIDE;
void geometrySourceWillPush() SK_OVERRIDE;
void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRIDE;
- void willReserveVertexAndIndexSpace(int vertexCount,
- size_t vertexStride,
- int indexCount) SK_OVERRIDE;
bool onCanCopySurface(const GrSurface* dst,
const GrSurface* src,
const SkIRect& srcRect,
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index eb3d19da9c..a0aa5237e2 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -641,29 +641,5 @@ void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount,
int indexCount) {
this->closeBatch();
- // We use geometryHints() to know whether to flush the draw buffer. We
- // can't flush if we are inside an unbalanced pushGeometrySource.
- // Moreover, flushing blows away vertex and index data that was
- // previously reserved. So if the vertex or index data is pulled from
- // reserved space and won't be released by this request then we can't
- // flush.
- bool insideGeoPush = this->getGeoPoolStateStack().count() > 1;
-
- bool unreleasedVertexSpace =
- !vertexCount &&
- kReserved_GeometrySrcType == this->getGeomSrc().fVertexSrc;
-
- bool unreleasedIndexSpace =
- !indexCount &&
- kReserved_GeometrySrcType == this->getGeomSrc().fIndexSrc;
-
- int vcount = vertexCount;
- int icount = indexCount;
-
- if (!insideGeoPush &&
- !unreleasedVertexSpace &&
- !unreleasedIndexSpace &&
- this->geometryHints(vertexStride, &vcount, &icount)) {
- this->flush();
- }
+ this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, indexCount);
}
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index 73d0898149..333150a7ab 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -53,6 +53,7 @@ public:
void discard(GrRenderTarget*) SK_OVERRIDE;
+protected:
void willReserveVertexAndIndexSpace(int vertexCount,
size_t vertexStride,
int indexCount);