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
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;
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;
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,
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);
}
void discard(GrRenderTarget*) SK_OVERRIDE;
+protected:
void willReserveVertexAndIndexSpace(int vertexCount,
size_t vertexStride,
int indexCount);