Minor refactoring
authorrobertphillips <robertphillips@google.com>
Mon, 16 Feb 2015 17:35:50 +0000 (09:35 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 16 Feb 2015 17:35:50 +0000 (09:35 -0800)
This CL just de-dups some code in GrInOrderDrawBuffer.

Review URL: https://codereview.chromium.org/930953003

src/gpu/GrDrawTarget.h
src/gpu/GrFlushToGpuDrawTarget.h
src/gpu/GrInOrderDrawBuffer.cpp
src/gpu/GrInOrderDrawBuffer.h

index f9f25f1..e52ee66 100644 (file)
@@ -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;
index 1288156..4c72f93 100644 (file)
@@ -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,
index eb3d19d..a0aa523 100644 (file)
@@ -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);
 }
index 73d0898..333150a 100644 (file)
@@ -53,6 +53,7 @@ public:
 
     void discard(GrRenderTarget*) SK_OVERRIDE;
 
+protected:
     void willReserveVertexAndIndexSpace(int vertexCount,
                                         size_t vertexStride,
                                         int indexCount);