From 742e31de1599f3902810aecdf2e2e3eed3b40a09 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Wed, 7 Dec 2016 17:06:19 -0500 Subject: Rename GrBatchFlushState to GrOpFlushState Change-Id: I1a8052c61d7624929caf45ba44e2a465cd0dc1c2 Reviewed-on: https://skia-review.googlesource.com/5649 Commit-Queue: Brian Salomon Reviewed-by: Brian Osman --- gn/gpu.gni | 4 +- src/gpu/GrBatchAtlas.cpp | 2 +- src/gpu/GrBatchFlushState.cpp | 30 --- src/gpu/GrBatchFlushState.h | 211 --------------------- src/gpu/GrDrawingManager.h | 9 +- src/gpu/GrGpuCommandBuffer.h | 4 +- src/gpu/GrOpFlushState.cpp | 30 +++ src/gpu/GrOpFlushState.h | 211 +++++++++++++++++++++ src/gpu/GrOpList.h | 6 +- src/gpu/GrOvalRenderer.cpp | 2 +- src/gpu/GrRenderTargetOpList.cpp | 4 +- src/gpu/GrRenderTargetOpList.h | 4 +- src/gpu/GrTextureContext.cpp | 2 +- src/gpu/GrTextureOpList.cpp | 4 +- src/gpu/GrTextureOpList.h | 4 +- src/gpu/batches/GrAAConvexPathRenderer.cpp | 2 +- src/gpu/batches/GrAADistanceFieldPathRenderer.cpp | 2 +- src/gpu/batches/GrAAFillRectBatch.cpp | 2 +- src/gpu/batches/GrAAHairLinePathRenderer.cpp | 2 +- .../batches/GrAALinearizingConvexPathRenderer.cpp | 2 +- src/gpu/batches/GrAAStrokeRectBatch.cpp | 2 +- src/gpu/batches/GrAnalyticRectBatch.cpp | 2 +- src/gpu/batches/GrAtlasTextBatch.cpp | 2 +- src/gpu/batches/GrClearBatch.h | 6 +- src/gpu/batches/GrClearStencilClipBatch.h | 6 +- src/gpu/batches/GrCopySurfaceBatch.h | 6 +- src/gpu/batches/GrDefaultPathRenderer.cpp | 2 +- src/gpu/batches/GrDiscardBatch.h | 6 +- src/gpu/batches/GrDrawAtlasBatch.cpp | 4 +- src/gpu/batches/GrDrawOp.h | 2 +- src/gpu/batches/GrDrawPathBatch.cpp | 6 +- src/gpu/batches/GrDrawPathBatch.h | 10 +- src/gpu/batches/GrDrawVerticesBatch.cpp | 4 +- src/gpu/batches/GrDrawVerticesBatch.h | 2 +- src/gpu/batches/GrMSAAPathRenderer.cpp | 2 +- src/gpu/batches/GrMeshDrawOp.cpp | 24 +-- src/gpu/batches/GrMeshDrawOp.h | 6 +- src/gpu/batches/GrNinePatch.cpp | 2 +- src/gpu/batches/GrNonAAFillRectBatch.cpp | 2 +- .../batches/GrNonAAFillRectPerspectiveBatch.cpp | 2 +- src/gpu/batches/GrNonAAStrokeRectBatch.cpp | 2 +- src/gpu/batches/GrOp.h | 10 +- src/gpu/batches/GrPLSPathRenderer.cpp | 2 +- src/gpu/batches/GrRegionBatch.cpp | 2 +- src/gpu/batches/GrShadowRRectBatch.cpp | 2 +- src/gpu/batches/GrStencilPathBatch.h | 6 +- src/gpu/batches/GrTessellatingPathRenderer.cpp | 2 +- src/gpu/batches/GrTestBatch.h | 2 +- src/gpu/effects/GrDashingEffect.cpp | 2 +- src/gpu/gl/GrGLGpuCommandBuffer.h | 4 +- src/gpu/instanced/InstancedRendering.cpp | 4 +- src/gpu/instanced/InstancedRendering.h | 4 +- src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp | 2 +- src/gpu/vk/GrVkGpuCommandBuffer.cpp | 5 +- src/gpu/vk/GrVkGpuCommandBuffer.h | 9 +- tests/PrimitiveProcessorTest.cpp | 2 +- 56 files changed, 346 insertions(+), 349 deletions(-) delete mode 100644 src/gpu/GrBatchFlushState.cpp delete mode 100644 src/gpu/GrBatchFlushState.h create mode 100644 src/gpu/GrOpFlushState.cpp create mode 100644 src/gpu/GrOpFlushState.h diff --git a/gn/gpu.gni b/gn/gpu.gni index e87ea7c3e0..4df4461175 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -75,8 +75,6 @@ skia_gpu_sources = [ "$_src/gpu/GrAllocator.h", "$_src/gpu/GrBatchAtlas.cpp", "$_src/gpu/GrBatchAtlas.h", - "$_src/gpu/GrBatchFlushState.cpp", - "$_src/gpu/GrBatchFlushState.h", "$_src/gpu/GrBatchTest.cpp", "$_src/gpu/GrBatchTest.h", "$_src/gpu/GrBitmapTextureMaker.cpp", @@ -119,6 +117,8 @@ skia_gpu_sources = [ "$_src/gpu/GrMemoryPool.h", "$_src/gpu/GrMesh.h", "$_src/gpu/GrNonAtomicRef.h", + "$_src/gpu/GrOpFlushState.cpp", + "$_src/gpu/GrOpFlushState.h", "$_src/gpu/GrOpList.cpp", "$_src/gpu/GrOpList.h", "$_src/gpu/GrOvalRenderer.cpp", diff --git a/src/gpu/GrBatchAtlas.cpp b/src/gpu/GrBatchAtlas.cpp index 32e7b1c369..9f0909a49b 100644 --- a/src/gpu/GrBatchAtlas.cpp +++ b/src/gpu/GrBatchAtlas.cpp @@ -6,7 +6,7 @@ */ #include "GrBatchAtlas.h" -#include "GrBatchFlushState.h" +#include "GrOpFlushState.h" #include "GrRectanizer.h" #include "GrTracing.h" diff --git a/src/gpu/GrBatchFlushState.cpp b/src/gpu/GrBatchFlushState.cpp deleted file mode 100644 index 5bc02bdb83..0000000000 --- a/src/gpu/GrBatchFlushState.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrBatchFlushState.h" - -#include "GrBatchAtlas.h" -#include "GrPipeline.h" - -GrBatchFlushState::GrBatchFlushState(GrGpu* gpu, GrResourceProvider* resourceProvider) - : fGpu(gpu) - , fResourceProvider(resourceProvider) - , fCommandBuffer(nullptr) - , fVertexPool(gpu) - , fIndexPool(gpu) - , fLastIssuedToken(GrDrawOpUploadToken::AlreadyFlushedToken()) - , fLastFlushedToken(0) {} - -void* GrBatchFlushState::makeVertexSpace(size_t vertexSize, int vertexCount, - const GrBuffer** buffer, int* startVertex) { - return fVertexPool.makeSpace(vertexSize, vertexCount, buffer, startVertex); -} - -uint16_t* GrBatchFlushState::makeIndexSpace(int indexCount, - const GrBuffer** buffer, int* startIndex) { - return reinterpret_cast(fIndexPool.makeSpace(indexCount, buffer, startIndex)); -} diff --git a/src/gpu/GrBatchFlushState.h b/src/gpu/GrBatchFlushState.h deleted file mode 100644 index e4491407a3..0000000000 --- a/src/gpu/GrBatchFlushState.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrBatchBuffer_DEFINED -#define GrBatchBuffer_DEFINED - -#include "GrBufferAllocPool.h" -#include "GrGpu.h" -#include "batches/GrMeshDrawOp.h" - -class GrGpuCommandBuffer; -class GrResourceProvider; - -/** Tracks the state across all the GrBatches in a GrOpList flush. */ -class GrBatchFlushState { -public: - GrBatchFlushState(GrGpu*, GrResourceProvider*); - - ~GrBatchFlushState() { this->reset(); } - - /** Inserts an upload to be executed after all batches in the flush prepared their draws - but before the draws are executed to the backend 3D API. */ - void addASAPUpload(GrDrawOp::DeferredUploadFn&& upload) { - fAsapUploads.emplace_back(std::move(upload)); - } - - const GrCaps& caps() const { return *fGpu->caps(); } - GrResourceProvider* resourceProvider() const { return fResourceProvider; } - - /** Has the token been flushed to the backend 3D API. */ - bool hasDrawBeenFlushed(GrDrawOpUploadToken token) const { - return token.fSequenceNumber <= fLastFlushedToken.fSequenceNumber; - } - - /** Issue a token to an operation that is being enqueued. */ - GrDrawOpUploadToken issueDrawToken() { - return GrDrawOpUploadToken(++fLastIssuedToken.fSequenceNumber); - } - - /** Call every time a draw that was issued a token is flushed */ - void flushToken() { ++fLastFlushedToken.fSequenceNumber; } - - /** Gets the next draw token that will be issued. */ - GrDrawOpUploadToken nextDrawToken() const { - return GrDrawOpUploadToken(fLastIssuedToken.fSequenceNumber + 1); - } - - /** The last token flushed to all the way to the backend API. */ - GrDrawOpUploadToken nextTokenToFlush() const { - return GrDrawOpUploadToken(fLastFlushedToken.fSequenceNumber + 1); - } - - void* makeVertexSpace(size_t vertexSize, int vertexCount, - const GrBuffer** buffer, int* startVertex); - uint16_t* makeIndexSpace(int indexCount, const GrBuffer** buffer, int* startIndex); - - /** This is called after each batch has a chance to prepare its draws and before the draws - are issued. */ - void preIssueDraws() { - fVertexPool.unmap(); - fIndexPool.unmap(); - int uploadCount = fAsapUploads.count(); - - for (int i = 0; i < uploadCount; i++) { - this->doUpload(fAsapUploads[i]); - } - fAsapUploads.reset(); - } - - void doUpload(GrDrawOp::DeferredUploadFn& upload) { - GrDrawOp::WritePixelsFn wp = [this] (GrSurface* surface, - int left, int top, int width, int height, - GrPixelConfig config, const void* buffer, - size_t rowBytes) -> bool { - return this->fGpu->writePixels(surface, left, top, width, height, config, buffer, - rowBytes); - }; - upload(wp); - } - - void putBackIndices(size_t indices) { fIndexPool.putBack(indices * sizeof(uint16_t)); } - - void putBackVertexSpace(size_t sizeInBytes) { fVertexPool.putBack(sizeInBytes); } - - GrGpuCommandBuffer* commandBuffer() { return fCommandBuffer; } - void setCommandBuffer(GrGpuCommandBuffer* buffer) { fCommandBuffer = buffer; } - - GrGpu* gpu() { return fGpu; } - - void reset() { - fVertexPool.reset(); - fIndexPool.reset(); - } - -private: - - GrGpu* fGpu; - - GrResourceProvider* fResourceProvider; - - GrGpuCommandBuffer* fCommandBuffer; - - GrVertexBufferAllocPool fVertexPool; - GrIndexBufferAllocPool fIndexPool; - - SkSTArray<4, GrDrawOp::DeferredUploadFn> fAsapUploads; - - GrDrawOpUploadToken fLastIssuedToken; - - GrDrawOpUploadToken fLastFlushedToken; -}; - -/** - * A word about uploads and tokens: Batches should usually schedule their uploads to occur at the - * begining of a frame whenever possible. These are called ASAP uploads. Of course, this requires - * that there are no draws that have yet to be flushed that rely on the old texture contents. In - * that case the ASAP upload would happen prior to the previous draw causing the draw to read the - * new (wrong) texture data. In that case they should schedule an inline upload. - * - * Batches, in conjunction with helpers such as GrBatchAtlas, can use the token system to know - * what the most recent draw was that referenced a resource (or portion of a resource). Each draw - * is assigned a token. A resource (or portion) can be tagged with the most recent draw's - * token. The target provides a facility for testing whether the draw corresponding to the token - * has been flushed. If it has not been flushed then the batch must perform an inline upload - * instead. When scheduling an inline upload the batch provides the token of the draw that the - * upload must occur before. The upload will then occur between the draw that requires the new - * data but after the token that requires the old data. - * - * TODO: Currently the token/upload interface is spread over GrDrawOp, GrMeshDrawOp, - * GrDrawOp::Target, and GrMeshDrawOp::Target. However, the interface at the GrDrawOp level is not - * complete and isn't useful. We should push it down to GrMeshDrawOp until it is required at the - * GrDrawOp level. - */ - -/** - * GrDrawOp instances use this object to allocate space for their geometry and to issue the draws - * that render their batch. - */ -class GrDrawOp::Target { -public: - Target(GrBatchFlushState* state, GrDrawOp* batch) : fState(state), fBatch(batch) {} - - /** Returns the token of the draw that this upload will occur before. */ - GrDrawOpUploadToken addInlineUpload(DeferredUploadFn&& upload) { - fBatch->fInlineUploads.emplace_back(std::move(upload), fState->nextDrawToken()); - return fBatch->fInlineUploads.back().fUploadBeforeToken; - } - - /** Returns the token of the draw that this upload will occur before. Since ASAP uploads - are done first during a flush, this will be the first token since the most recent - flush. */ - GrDrawOpUploadToken addAsapUpload(DeferredUploadFn&& upload) { - fState->addASAPUpload(std::move(upload)); - return fState->nextTokenToFlush(); - } - - bool hasDrawBeenFlushed(GrDrawOpUploadToken token) const { - return fState->hasDrawBeenFlushed(token); - } - - /** Gets the next draw token that will be issued by this target. This can be used by a batch - to record that the next draw it issues will use a resource (e.g. texture) while preparing - that draw. */ - GrDrawOpUploadToken nextDrawToken() const { return fState->nextDrawToken(); } - - const GrCaps& caps() const { return fState->caps(); } - - GrResourceProvider* resourceProvider() const { return fState->resourceProvider(); } - -protected: - GrDrawOp* batch() { return fBatch; } - GrBatchFlushState* state() { return fState; } - -private: - GrBatchFlushState* fState; - GrDrawOp* fBatch; -}; - -/** Extension of GrDrawOp::Target for use by GrMeshDrawOp. Adds the ability to create vertex - draws. */ -class GrMeshDrawOp::Target : public GrDrawOp::Target { -public: - Target(GrBatchFlushState* state, GrMeshDrawOp* batch) : INHERITED(state, batch) {} - - void draw(const GrGeometryProcessor* gp, const GrMesh& mesh); - - void* makeVertexSpace(size_t vertexSize, int vertexCount, - const GrBuffer** buffer, int* startVertex) { - return this->state()->makeVertexSpace(vertexSize, vertexCount, buffer, startVertex); - } - - uint16_t* makeIndexSpace(int indexCount, const GrBuffer** buffer, int* startIndex) { - return this->state()->makeIndexSpace(indexCount, buffer, startIndex); - } - - /** Helpers for batches which over-allocate and then return data to the pool. */ - void putBackIndices(int indices) { this->state()->putBackIndices(indices); } - void putBackVertices(int vertices, size_t vertexStride) { - this->state()->putBackVertexSpace(vertices * vertexStride); - } - -private: - GrMeshDrawOp* vertexBatch() { return static_cast(this->batch()); } - typedef GrDrawOp::Target INHERITED; -}; - -#endif diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h index 90a3064e24..9a05215f5b 100644 --- a/src/gpu/GrDrawingManager.h +++ b/src/gpu/GrDrawingManager.h @@ -8,14 +8,13 @@ #ifndef GrDrawingManager_DEFINED #define GrDrawingManager_DEFINED -#include "text/GrAtlasTextContext.h" -#include "GrBatchFlushState.h" -#include "GrPathRendererChain.h" +#include "GrOpFlushState.h" #include "GrPathRenderer.h" +#include "GrPathRendererChain.h" #include "GrRenderTargetOpList.h" #include "GrResourceCache.h" #include "SkTDArray.h" - +#include "text/GrAtlasTextContext.h" class GrContext; class GrRenderTargetContext; @@ -112,7 +111,7 @@ private: GrPathRendererChain* fPathRendererChain; GrSoftwarePathRenderer* fSoftwarePathRenderer; - GrBatchFlushState fFlushState; + GrOpFlushState fFlushState; bool fFlushing; bool fIsImmediateMode; diff --git a/src/gpu/GrGpuCommandBuffer.h b/src/gpu/GrGpuCommandBuffer.h index 3bb00711fb..13b73346e3 100644 --- a/src/gpu/GrGpuCommandBuffer.h +++ b/src/gpu/GrGpuCommandBuffer.h @@ -11,7 +11,7 @@ #include "GrColor.h" #include "batches/GrDrawOp.h" -class GrBatchFlushState; +class GrOpFlushState; class GrFixedClip; class GrGpu; class GrMesh; @@ -73,7 +73,7 @@ public: const SkRect& bounds); // Performs an upload of vertex data in the middle of a set of a set of draws - virtual void inlineUpload(GrBatchFlushState* state, GrDrawOp::DeferredUploadFn& upload) = 0; + virtual void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) = 0; /** * Clear the passed in render target. Ignores the draw state and clip. diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp new file mode 100644 index 0000000000..e936c45733 --- /dev/null +++ b/src/gpu/GrOpFlushState.cpp @@ -0,0 +1,30 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrOpFlushState.h" + +#include "GrBatchAtlas.h" +#include "GrPipeline.h" + +GrOpFlushState::GrOpFlushState(GrGpu* gpu, GrResourceProvider* resourceProvider) + : fGpu(gpu) + , fResourceProvider(resourceProvider) + , fCommandBuffer(nullptr) + , fVertexPool(gpu) + , fIndexPool(gpu) + , fLastIssuedToken(GrDrawOpUploadToken::AlreadyFlushedToken()) + , fLastFlushedToken(0) {} + +void* GrOpFlushState::makeVertexSpace(size_t vertexSize, int vertexCount, + const GrBuffer** buffer, int* startVertex) { + return fVertexPool.makeSpace(vertexSize, vertexCount, buffer, startVertex); +} + +uint16_t* GrOpFlushState::makeIndexSpace(int indexCount, + const GrBuffer** buffer, int* startIndex) { + return reinterpret_cast(fIndexPool.makeSpace(indexCount, buffer, startIndex)); +} diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h new file mode 100644 index 0000000000..9b8baffcb2 --- /dev/null +++ b/src/gpu/GrOpFlushState.h @@ -0,0 +1,211 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrBatchBuffer_DEFINED +#define GrBatchBuffer_DEFINED + +#include "GrBufferAllocPool.h" +#include "GrGpu.h" +#include "batches/GrMeshDrawOp.h" + +class GrGpuCommandBuffer; +class GrResourceProvider; + +/** Tracks the state across all the GrOps (really just the GrDrawOps) in a GrOpList flush. */ +class GrOpFlushState { +public: + GrOpFlushState(GrGpu*, GrResourceProvider*); + + ~GrOpFlushState() { this->reset(); } + + /** Inserts an upload to be executed after all ops in the flush prepared their draws but before + the draws are executed to the backend 3D API. */ + void addASAPUpload(GrDrawOp::DeferredUploadFn&& upload) { + fAsapUploads.emplace_back(std::move(upload)); + } + + const GrCaps& caps() const { return *fGpu->caps(); } + GrResourceProvider* resourceProvider() const { return fResourceProvider; } + + /** Has the token been flushed to the backend 3D API. */ + bool hasDrawBeenFlushed(GrDrawOpUploadToken token) const { + return token.fSequenceNumber <= fLastFlushedToken.fSequenceNumber; + } + + /** Issue a token to an operation that is being enqueued. */ + GrDrawOpUploadToken issueDrawToken() { + return GrDrawOpUploadToken(++fLastIssuedToken.fSequenceNumber); + } + + /** Call every time a draw that was issued a token is flushed */ + void flushToken() { ++fLastFlushedToken.fSequenceNumber; } + + /** Gets the next draw token that will be issued. */ + GrDrawOpUploadToken nextDrawToken() const { + return GrDrawOpUploadToken(fLastIssuedToken.fSequenceNumber + 1); + } + + /** The last token flushed to all the way to the backend API. */ + GrDrawOpUploadToken nextTokenToFlush() const { + return GrDrawOpUploadToken(fLastFlushedToken.fSequenceNumber + 1); + } + + void* makeVertexSpace(size_t vertexSize, int vertexCount, + const GrBuffer** buffer, int* startVertex); + uint16_t* makeIndexSpace(int indexCount, const GrBuffer** buffer, int* startIndex); + + /** This is called after each op has a chance to prepare its draws and before the draws are + issued. */ + void preIssueDraws() { + fVertexPool.unmap(); + fIndexPool.unmap(); + int uploadCount = fAsapUploads.count(); + + for (int i = 0; i < uploadCount; i++) { + this->doUpload(fAsapUploads[i]); + } + fAsapUploads.reset(); + } + + void doUpload(GrDrawOp::DeferredUploadFn& upload) { + GrDrawOp::WritePixelsFn wp = [this] (GrSurface* surface, + int left, int top, int width, int height, + GrPixelConfig config, const void* buffer, + size_t rowBytes) -> bool { + return this->fGpu->writePixels(surface, left, top, width, height, config, buffer, + rowBytes); + }; + upload(wp); + } + + void putBackIndices(size_t indices) { fIndexPool.putBack(indices * sizeof(uint16_t)); } + + void putBackVertexSpace(size_t sizeInBytes) { fVertexPool.putBack(sizeInBytes); } + + GrGpuCommandBuffer* commandBuffer() { return fCommandBuffer; } + void setCommandBuffer(GrGpuCommandBuffer* buffer) { fCommandBuffer = buffer; } + + GrGpu* gpu() { return fGpu; } + + void reset() { + fVertexPool.reset(); + fIndexPool.reset(); + } + +private: + + GrGpu* fGpu; + + GrResourceProvider* fResourceProvider; + + GrGpuCommandBuffer* fCommandBuffer; + + GrVertexBufferAllocPool fVertexPool; + GrIndexBufferAllocPool fIndexPool; + + SkSTArray<4, GrDrawOp::DeferredUploadFn> fAsapUploads; + + GrDrawOpUploadToken fLastIssuedToken; + + GrDrawOpUploadToken fLastFlushedToken; +}; + +/** + * A word about uploads and tokens: Ops should usually schedule their uploads to occur at the + * begining of a frame whenever possible. These are called ASAP uploads. Of course, this requires + * that there are no draws that have yet to be flushed that rely on the old texture contents. In + * that case the ASAP upload would happen prior to the previous draw causing the draw to read the + * new (wrong) texture data. In that case they should schedule an inline upload. + * + * Ops, in conjunction with helpers such as GrBatchAtlas, can use the token system to know + * what the most recent draw was that referenced a resource (or portion of a resource). Each draw + * is assigned a token. A resource (or portion) can be tagged with the most recent draw's + * token. The target provides a facility for testing whether the draw corresponding to the token + * has been flushed. If it has not been flushed then the op must perform an inline upload instead. + * When scheduling an inline upload the op provides the token of the draw that the upload must occur + * before. The upload will then occur between the draw that requires the new data but after the + * token that requires the old data. + * + * TODO: Currently the token/upload interface is spread over GrDrawOp, GrMeshDrawOp, + * GrDrawOp::Target, and GrMeshDrawOp::Target. However, the interface at the GrDrawOp level is not + * complete and isn't useful. We should push it down to GrMeshDrawOp until it is required at the + * GrDrawOp level. + */ + +/** + * GrDrawOp instances use this object to allocate space for their geometry and to issue the draws + * that render their op. + */ +class GrDrawOp::Target { +public: + Target(GrOpFlushState* state, GrDrawOp* op) : fState(state), fOp(op) {} + + /** Returns the token of the draw that this upload will occur before. */ + GrDrawOpUploadToken addInlineUpload(DeferredUploadFn&& upload) { + fOp->fInlineUploads.emplace_back(std::move(upload), fState->nextDrawToken()); + return fOp->fInlineUploads.back().fUploadBeforeToken; + } + + /** Returns the token of the draw that this upload will occur before. Since ASAP uploads + are done first during a flush, this will be the first token since the most recent + flush. */ + GrDrawOpUploadToken addAsapUpload(DeferredUploadFn&& upload) { + fState->addASAPUpload(std::move(upload)); + return fState->nextTokenToFlush(); + } + + bool hasDrawBeenFlushed(GrDrawOpUploadToken token) const { + return fState->hasDrawBeenFlushed(token); + } + + /** Gets the next draw token that will be issued by this target. This can be used by an op + to record that the next draw it issues will use a resource (e.g. texture) while preparing + that draw. */ + GrDrawOpUploadToken nextDrawToken() const { return fState->nextDrawToken(); } + + const GrCaps& caps() const { return fState->caps(); } + + GrResourceProvider* resourceProvider() const { return fState->resourceProvider(); } + +protected: + GrDrawOp* op() { return fOp; } + GrOpFlushState* state() { return fState; } + +private: + GrOpFlushState* fState; + GrDrawOp* fOp; +}; + +/** Extension of GrDrawOp::Target for use by GrMeshDrawOp. Adds the ability to create vertex + draws. */ +class GrMeshDrawOp::Target : public GrDrawOp::Target { +public: + Target(GrOpFlushState* state, GrMeshDrawOp* op) : INHERITED(state, op) {} + + void draw(const GrGeometryProcessor* gp, const GrMesh& mesh); + + void* makeVertexSpace(size_t vertexSize, int vertexCount, + const GrBuffer** buffer, int* startVertex) { + return this->state()->makeVertexSpace(vertexSize, vertexCount, buffer, startVertex); + } + + uint16_t* makeIndexSpace(int indexCount, const GrBuffer** buffer, int* startIndex) { + return this->state()->makeIndexSpace(indexCount, buffer, startIndex); + } + + /** Helpers for ops which over-allocate and then return data to the pool. */ + void putBackIndices(int indices) { this->state()->putBackIndices(indices); } + void putBackVertices(int vertices, size_t vertexStride) { + this->state()->putBackVertexSpace(vertices * vertexStride); + } + +private: + GrMeshDrawOp* meshDrawOp() { return static_cast(this->op()); } + typedef GrDrawOp::Target INHERITED; +}; + +#endif diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h index 873cdcb650..75fc5e63d1 100644 --- a/src/gpu/GrOpList.h +++ b/src/gpu/GrOpList.h @@ -14,7 +14,7 @@ //#define ENABLE_MDB 1 class GrAuditTrail; -class GrBatchFlushState; +class GrOpFlushState; class GrRenderTargetOpList; class GrSurface; class GrSurfaceProxy; @@ -26,8 +26,8 @@ public: ~GrOpList() override; // These two methods are invoked as flush time - virtual void prepareOps(GrBatchFlushState* flushState) = 0; - virtual bool executeOps(GrBatchFlushState* flushState) = 0; + virtual void prepareOps(GrOpFlushState* flushState) = 0; + virtual bool executeOps(GrOpFlushState* flushState) = 0; virtual void makeClosed() { // We only close GrOpLists when MDB is enabled. When MDB is disabled there is only diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index 735b92fcc1..9adfb0c1e0 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -7,10 +7,10 @@ #include "GrOvalRenderer.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" +#include "GrOpFlushState.h" #include "GrProcessor.h" #include "GrResourceProvider.h" #include "GrShaderCaps.h" diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 226bfed99c..41c0d4f9fd 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -151,7 +151,7 @@ void GrRenderTargetOpList::setupDstTexture(GrRenderTarget* rt, dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); } -void GrRenderTargetOpList::prepareOps(GrBatchFlushState* flushState) { +void GrRenderTargetOpList::prepareOps(GrOpFlushState* flushState) { // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed // but need to be flushed anyway. Closing such GrOpLists here will mean new @@ -173,7 +173,7 @@ void GrRenderTargetOpList::prepareOps(GrBatchFlushState* flushState) { // TODO: this is where GrOp::renderTarget is used (which is fine since it // is at flush time). However, we need to store the RenderTargetProxy in the // Ops and instantiate them here. -bool GrRenderTargetOpList::executeOps(GrBatchFlushState* flushState) { +bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) { if (0 == fRecordedOps.count()) { return false; } diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index 5029b4bdaf..d7f8ba1bab 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -74,8 +74,8 @@ public: * Together these two functions flush all queued up draws to GrCommandBuffer. The return value * of executeOps() indicates whether any commands were actually issued to the GPU. */ - void prepareOps(GrBatchFlushState* flushState) override; - bool executeOps(GrBatchFlushState* flushState) override; + void prepareOps(GrOpFlushState* flushState) override; + bool executeOps(GrOpFlushState* flushState) override; /** * Gets the capabilities of the draw target. diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp index 66030f9ee0..22620fed0f 100644 --- a/src/gpu/GrTextureContext.cpp +++ b/src/gpu/GrTextureContext.cpp @@ -73,7 +73,7 @@ bool GrTextureContext::copySurface(GrSurface* src, const SkIRect& srcRect, bool result = opList->copySurface(tex.get(), src, srcRect, dstPoint); #ifndef ENABLE_MDB - GrBatchFlushState flushState(fContext->getGpu(), nullptr); + GrOpFlushState flushState(fContext->getGpu(), nullptr); opList->prepareOps(&flushState); opList->executeOps(&flushState); opList->reset(); diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp index e9021da895..10136439ce 100644 --- a/src/gpu/GrTextureOpList.cpp +++ b/src/gpu/GrTextureOpList.cpp @@ -44,7 +44,7 @@ void GrTextureOpList::dump() const { } #endif -void GrTextureOpList::prepareOps(GrBatchFlushState* flushState) { +void GrTextureOpList::prepareOps(GrOpFlushState* flushState) { // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed // but need to be flushed anyway. Closing such GrOpLists here will mean new @@ -59,7 +59,7 @@ void GrTextureOpList::prepareOps(GrBatchFlushState* flushState) { } } -bool GrTextureOpList::executeOps(GrBatchFlushState* flushState) { +bool GrTextureOpList::executeOps(GrOpFlushState* flushState) { if (0 == fRecordedOps.count()) { return false; } diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h index 0b28421aa1..10ebd1bf34 100644 --- a/src/gpu/GrTextureOpList.h +++ b/src/gpu/GrTextureOpList.h @@ -37,8 +37,8 @@ public: * Together these two functions flush all queued up draws to GrCommandBuffer. The return value * of drawOps() indicates whether any commands were actually issued to the GPU. */ - void prepareOps(GrBatchFlushState* flushState) override; - bool executeOps(GrBatchFlushState* flushState) override; + void prepareOps(GrOpFlushState* flushState) override; + bool executeOps(GrOpFlushState* flushState) override; /** * Copies a pixel rectangle from one surface to another. This call may finalize diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp index 7de67f60d3..56a5e7ae14 100644 --- a/src/gpu/batches/GrAAConvexPathRenderer.cpp +++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp @@ -8,13 +8,13 @@ #include "GrAAConvexPathRenderer.h" #include "GrAAConvexTessellator.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrCaps.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" +#include "GrOpFlushState.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" #include "GrProcessor.h" diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp index 8f7c679b1d..0aa451df86 100644 --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp @@ -7,10 +7,10 @@ #include "GrAADistanceFieldPathRenderer.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrBuffer.h" #include "GrContext.h" +#include "GrOpFlushState.h" #include "GrPipelineBuilder.h" #include "GrResourceProvider.h" #include "GrSWMaskHelper.h" diff --git a/src/gpu/batches/GrAAFillRectBatch.cpp b/src/gpu/batches/GrAAFillRectBatch.cpp index 826c7fd818..01392d099e 100644 --- a/src/gpu/batches/GrAAFillRectBatch.cpp +++ b/src/gpu/batches/GrAAFillRectBatch.cpp @@ -7,10 +7,10 @@ #include "GrAAFillRectBatch.h" -#include "GrBatchFlushState.h" #include "GrColor.h" #include "GrDefaultGeoProcFactory.h" #include "GrMeshDrawOp.h" +#include "GrOpFlushState.h" #include "GrResourceKey.h" #include "GrResourceProvider.h" #include "GrTypes.h" diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp index 8ff4231ac2..70d0d4c81e 100644 --- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp @@ -7,12 +7,12 @@ #include "GrAAHairLinePathRenderer.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrBuffer.h" #include "GrCaps.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" +#include "GrOpFlushState.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" #include "GrProcessor.h" diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp index f959df6c08..f961c5eb74 100644 --- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp @@ -8,12 +8,12 @@ #include "GrAALinearizingConvexPathRenderer.h" #include "GrAAConvexTessellator.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" +#include "GrOpFlushState.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" #include "GrProcessor.h" diff --git a/src/gpu/batches/GrAAStrokeRectBatch.cpp b/src/gpu/batches/GrAAStrokeRectBatch.cpp index fcdb7c04dd..008faa0f44 100644 --- a/src/gpu/batches/GrAAStrokeRectBatch.cpp +++ b/src/gpu/batches/GrAAStrokeRectBatch.cpp @@ -7,8 +7,8 @@ #include "GrAAStrokeRectBatch.h" -#include "GrBatchFlushState.h" #include "GrDefaultGeoProcFactory.h" +#include "GrOpFlushState.h" #include "GrResourceKey.h" #include "GrResourceProvider.h" diff --git a/src/gpu/batches/GrAnalyticRectBatch.cpp b/src/gpu/batches/GrAnalyticRectBatch.cpp index ff68000f79..e87319c4b6 100644 --- a/src/gpu/batches/GrAnalyticRectBatch.cpp +++ b/src/gpu/batches/GrAnalyticRectBatch.cpp @@ -7,10 +7,10 @@ #include "GrAnalyticRectBatch.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" +#include "GrOpFlushState.h" #include "GrProcessor.h" #include "GrResourceProvider.h" #include "SkRRect.h" diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp index 75bbfcaed4..1b450956af 100644 --- a/src/gpu/batches/GrAtlasTextBatch.cpp +++ b/src/gpu/batches/GrAtlasTextBatch.cpp @@ -7,7 +7,7 @@ #include "GrAtlasTextBatch.h" -#include "GrBatchFlushState.h" +#include "GrOpFlushState.h" #include "GrResourceProvider.h" #include "SkGlyphCache.h" diff --git a/src/gpu/batches/GrClearBatch.h b/src/gpu/batches/GrClearBatch.h index f1870486df..2571c26b8f 100644 --- a/src/gpu/batches/GrClearBatch.h +++ b/src/gpu/batches/GrClearBatch.h @@ -8,11 +8,11 @@ #ifndef GrClearBatch_DEFINED #define GrClearBatch_DEFINED -#include "GrBatchFlushState.h" #include "GrFixedClip.h" #include "GrGpu.h" #include "GrGpuCommandBuffer.h" #include "GrOp.h" +#include "GrOpFlushState.h" #include "GrRenderTarget.h" class GrClearBatch final : public GrOp { @@ -95,9 +95,9 @@ private: fClip.scissorRect().contains(that->fClip.scissorRect())); } - void onPrepare(GrBatchFlushState*) override {} + void onPrepare(GrOpFlushState*) override {} - void onDraw(GrBatchFlushState* state, const SkRect& /*bounds*/) override { + void onDraw(GrOpFlushState* state, const SkRect& /*bounds*/) override { state->commandBuffer()->clear(fRenderTarget.get(), fClip, fColor); } diff --git a/src/gpu/batches/GrClearStencilClipBatch.h b/src/gpu/batches/GrClearStencilClipBatch.h index 87c12f0a26..f9843ce301 100644 --- a/src/gpu/batches/GrClearStencilClipBatch.h +++ b/src/gpu/batches/GrClearStencilClipBatch.h @@ -8,11 +8,11 @@ #ifndef GrClearStencilClipBatch_DEFINED #define GrClearStencilClipBatch_DEFINED -#include "GrBatchFlushState.h" #include "GrFixedClip.h" #include "GrGpu.h" #include "GrGpuCommandBuffer.h" #include "GrOp.h" +#include "GrOpFlushState.h" #include "GrRenderTarget.h" class GrClearStencilClipBatch final : public GrOp { @@ -51,9 +51,9 @@ public: private: bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; } - void onPrepare(GrBatchFlushState*) override {} + void onPrepare(GrOpFlushState*) override {} - void onDraw(GrBatchFlushState* state, const SkRect& /*bounds*/) override { + void onDraw(GrOpFlushState* state, const SkRect& /*bounds*/) override { state->commandBuffer()->clearStencilClip(fRenderTarget.get(), fClip, fInsideStencilMask); } diff --git a/src/gpu/batches/GrCopySurfaceBatch.h b/src/gpu/batches/GrCopySurfaceBatch.h index a808b2f181..b28b38348f 100644 --- a/src/gpu/batches/GrCopySurfaceBatch.h +++ b/src/gpu/batches/GrCopySurfaceBatch.h @@ -8,9 +8,9 @@ #ifndef GrCopySurfaceBatch_DEFINED #define GrCopySurfaceBatch_DEFINED -#include "GrBatchFlushState.h" #include "GrGpu.h" #include "GrOp.h" +#include "GrOpFlushState.h" #include "GrRenderTarget.h" class GrCopySurfaceBatch final : public GrOp { @@ -66,9 +66,9 @@ private: bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; } - void onPrepare(GrBatchFlushState*) override {} + void onPrepare(GrOpFlushState*) override {} - void onDraw(GrBatchFlushState* state, const SkRect& /*bounds*/) override { + void onDraw(GrOpFlushState* state, const SkRect& /*bounds*/) override { if (!state->commandBuffer()) { state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoint); } else { diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp index ce51cf099b..f3f9e73155 100644 --- a/src/gpu/batches/GrDefaultPathRenderer.cpp +++ b/src/gpu/batches/GrDefaultPathRenderer.cpp @@ -7,12 +7,12 @@ #include "GrDefaultPathRenderer.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrFixedClip.h" #include "GrMesh.h" +#include "GrOpFlushState.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" #include "SkGeometry.h" diff --git a/src/gpu/batches/GrDiscardBatch.h b/src/gpu/batches/GrDiscardBatch.h index a53feffd9c..419239039f 100644 --- a/src/gpu/batches/GrDiscardBatch.h +++ b/src/gpu/batches/GrDiscardBatch.h @@ -8,9 +8,9 @@ #ifndef GrDiscardBatch_DEFINED #define GrDiscardBatch_DEFINED -#include "GrBatchFlushState.h" #include "GrGpu.h" #include "GrOp.h" +#include "GrOpFlushState.h" #include "GrRenderTarget.h" class GrDiscardBatch final : public GrOp { @@ -43,9 +43,9 @@ private: return this->renderTargetUniqueID() == that->renderTargetUniqueID(); } - void onPrepare(GrBatchFlushState*) override {} + void onPrepare(GrOpFlushState*) override {} - void onDraw(GrBatchFlushState* state, const SkRect& /*bounds*/) override { + void onDraw(GrOpFlushState* state, const SkRect& /*bounds*/) override { state->commandBuffer()->discard(fRenderTarget.get()); } diff --git a/src/gpu/batches/GrDrawAtlasBatch.cpp b/src/gpu/batches/GrDrawAtlasBatch.cpp index 95c8f2cf32..f94dc97435 100644 --- a/src/gpu/batches/GrDrawAtlasBatch.cpp +++ b/src/gpu/batches/GrDrawAtlasBatch.cpp @@ -6,11 +6,11 @@ */ #include "GrDrawAtlasBatch.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" +#include "GrOpFlushState.h" #include "SkGr.h" -#include "SkRandom.h" #include "SkRSXform.h" +#include "SkRandom.h" void GrDrawAtlasBatch::initBatchTracker(const GrXPOverridesForBatch& overrides) { SkASSERT(fGeoData.count() == 1); diff --git a/src/gpu/batches/GrDrawOp.h b/src/gpu/batches/GrDrawOp.h index 8ad22d9ac3..7606b0c27c 100644 --- a/src/gpu/batches/GrDrawOp.h +++ b/src/gpu/batches/GrDrawOp.h @@ -37,7 +37,7 @@ public: private: GrDrawOpUploadToken(); explicit GrDrawOpUploadToken(uint64_t sequenceNumber) : fSequenceNumber(sequenceNumber) {} - friend class GrBatchFlushState; + friend class GrOpFlushState; uint64_t fSequenceNumber; }; diff --git a/src/gpu/batches/GrDrawPathBatch.cpp b/src/gpu/batches/GrDrawPathBatch.cpp index 8d0bc42261..264078c969 100644 --- a/src/gpu/batches/GrDrawPathBatch.cpp +++ b/src/gpu/batches/GrDrawPathBatch.cpp @@ -13,7 +13,7 @@ static void pre_translate_transform_values(const float* xforms, GrPathRendering::PathTransformType type, int count, SkScalar x, SkScalar y, float* dst); -void GrDrawPathBatchBase::onPrepare(GrBatchFlushState*) { +void GrDrawPathBatchBase::onPrepare(GrOpFlushState*) { const GrRenderTargetPriv& rtPriv = this->pipeline()->getRenderTarget()->renderTargetPriv(); fStencilPassSettings.reset(GrPathRendering::GetStencilPassSettings(fFillType), this->pipeline()->hasStencilClip(), rtPriv.numStencilBits()); @@ -27,7 +27,7 @@ SkString GrDrawPathBatch::dumpInfo() const { return string; } -void GrDrawPathBatch::onDraw(GrBatchFlushState* state, const SkRect& bounds) { +void GrDrawPathBatch::onDraw(GrOpFlushState* state, const SkRect& bounds) { GrProgramDesc desc; sk_sp pathProc(GrPathProcessor::Create(this->color(), @@ -118,7 +118,7 @@ bool GrDrawPathRangeBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) { return true; } -void GrDrawPathRangeBatch::onDraw(GrBatchFlushState* state, const SkRect& bounds) { +void GrDrawPathRangeBatch::onDraw(GrOpFlushState* state, const SkRect& bounds) { const Draw& head = *fDraws.head(); SkMatrix drawMatrix(this->viewMatrix()); diff --git a/src/gpu/batches/GrDrawPathBatch.h b/src/gpu/batches/GrDrawPathBatch.h index 6dca9dcd98..c6bb55eaee 100644 --- a/src/gpu/batches/GrDrawPathBatch.h +++ b/src/gpu/batches/GrDrawPathBatch.h @@ -8,12 +8,12 @@ #ifndef GrDrawPathBatch_DEFINED #define GrDrawPathBatch_DEFINED -#include "GrBatchFlushState.h" #include "GrDrawOp.h" #include "GrGpu.h" +#include "GrOpFlushState.h" #include "GrPath.h" -#include "GrPathRendering.h" #include "GrPathProcessor.h" +#include "GrPathRendering.h" #include "GrStencilSettings.h" #include "SkTLList.h" @@ -50,7 +50,7 @@ private: fOverrides = overrides; } - void onPrepare(GrBatchFlushState*) override; // Initializes fStencilPassSettings. + void onPrepare(GrOpFlushState*) override; // Initializes fStencilPassSettings. SkMatrix fViewMatrix; GrColor fColor; @@ -82,7 +82,7 @@ private: bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; } - void onDraw(GrBatchFlushState* state, const SkRect& bounds) override; + void onDraw(GrOpFlushState* state, const SkRect& bounds) override; GrPendingIOResource fPath; @@ -175,7 +175,7 @@ private: bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override; - void onDraw(GrBatchFlushState* state, const SkRect& bounds) override; + void onDraw(GrOpFlushState* state, const SkRect& bounds) override; struct Draw { void set(const InstanceData* instanceData, SkScalar x, SkScalar y) { diff --git a/src/gpu/batches/GrDrawVerticesBatch.cpp b/src/gpu/batches/GrDrawVerticesBatch.cpp index 1d023200c2..3cc69cb964 100644 --- a/src/gpu/batches/GrDrawVerticesBatch.cpp +++ b/src/gpu/batches/GrDrawVerticesBatch.cpp @@ -7,9 +7,9 @@ #include "GrDrawVerticesBatch.h" -#include "GrBatchFlushState.h" -#include "GrInvariantOutput.h" #include "GrDefaultGeoProcFactory.h" +#include "GrInvariantOutput.h" +#include "GrOpFlushState.h" static sk_sp set_vertex_attributes(bool hasLocalCoords, int* colorOffset, diff --git a/src/gpu/batches/GrDrawVerticesBatch.h b/src/gpu/batches/GrDrawVerticesBatch.h index 26f23b5996..4a38707105 100644 --- a/src/gpu/batches/GrDrawVerticesBatch.h +++ b/src/gpu/batches/GrDrawVerticesBatch.h @@ -15,7 +15,7 @@ #include "SkRect.h" #include "SkTDArray.h" -class GrBatchFlushState; +class GrOpFlushState; struct GrInitInvariantOutput; class GrDrawVerticesBatch : public GrMeshDrawOp { diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp index 6b96349793..f073db0a28 100644 --- a/src/gpu/batches/GrMSAAPathRenderer.cpp +++ b/src/gpu/batches/GrMSAAPathRenderer.cpp @@ -8,11 +8,11 @@ #include "GrMSAAPathRenderer.h" #include "GrAuditTrail.h" -#include "GrBatchFlushState.h" #include "GrClip.h" #include "GrDefaultGeoProcFactory.h" #include "GrFixedClip.h" #include "GrMesh.h" +#include "GrOpFlushState.h" #include "GrPathStencilSettings.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" diff --git a/src/gpu/batches/GrMeshDrawOp.cpp b/src/gpu/batches/GrMeshDrawOp.cpp index 4f6b9390aa..5f132eeccc 100644 --- a/src/gpu/batches/GrMeshDrawOp.cpp +++ b/src/gpu/batches/GrMeshDrawOp.cpp @@ -6,13 +6,13 @@ */ #include "GrMeshDrawOp.h" -#include "GrBatchFlushState.h" +#include "GrOpFlushState.h" #include "GrResourceProvider.h" GrMeshDrawOp::GrMeshDrawOp(uint32_t classID) : INHERITED(classID), fBaseDrawToken(GrDrawOpUploadToken::AlreadyFlushedToken()) {} -void GrMeshDrawOp::onPrepare(GrBatchFlushState* state) { +void GrMeshDrawOp::onPrepare(GrOpFlushState* state) { Target target(state, this); this->onPrepareDraws(&target); } @@ -59,7 +59,7 @@ void* GrMeshDrawOp::QuadHelper::init(Target* target, size_t vertexStride, int qu quadsToDraw); } -void GrMeshDrawOp::onDraw(GrBatchFlushState* state, const SkRect& bounds) { +void GrMeshDrawOp::onDraw(GrOpFlushState* state, const SkRect& bounds) { int currUploadIdx = 0; int currMeshIdx = 0; @@ -86,24 +86,24 @@ void GrMeshDrawOp::onDraw(GrBatchFlushState* state, const SkRect& bounds) { ////////////////////////////////////////////////////////////////////////////// void GrMeshDrawOp::Target::draw(const GrGeometryProcessor* gp, const GrMesh& mesh) { - GrMeshDrawOp* batch = this->vertexBatch(); - batch->fMeshes.push_back(mesh); - if (!batch->fQueuedDraws.empty()) { + GrMeshDrawOp* op = this->meshDrawOp(); + op->fMeshes.push_back(mesh); + if (!op->fQueuedDraws.empty()) { // If the last draw shares a geometry processor and there are no intervening uploads, // add this mesh to it. - GrMeshDrawOp::QueuedDraw& lastDraw = this->vertexBatch()->fQueuedDraws.back(); + GrMeshDrawOp::QueuedDraw& lastDraw = op->fQueuedDraws.back(); if (lastDraw.fGeometryProcessor == gp && - (batch->fInlineUploads.empty() || - batch->fInlineUploads.back().fUploadBeforeToken != this->nextDrawToken())) { + (op->fInlineUploads.empty() || + op->fInlineUploads.back().fUploadBeforeToken != this->nextDrawToken())) { ++lastDraw.fMeshCnt; return; } } - GrMeshDrawOp::QueuedDraw& draw = this->vertexBatch()->fQueuedDraws.push_back(); + GrMeshDrawOp::QueuedDraw& draw = op->fQueuedDraws.push_back(); GrDrawOpUploadToken token = this->state()->issueDrawToken(); draw.fGeometryProcessor.reset(gp); draw.fMeshCnt = 1; - if (batch->fQueuedDraws.count() == 1) { - batch->fBaseDrawToken = token; + if (op->fQueuedDraws.count() == 1) { + op->fBaseDrawToken = token; } } diff --git a/src/gpu/batches/GrMeshDrawOp.h b/src/gpu/batches/GrMeshDrawOp.h index b0292ae0a1..6100166126 100644 --- a/src/gpu/batches/GrMeshDrawOp.h +++ b/src/gpu/batches/GrMeshDrawOp.h @@ -15,7 +15,7 @@ #include "SkTLList.h" -class GrBatchFlushState; +class GrOpFlushState; /** * Base class for mesh-drawing GrDrawOps. @@ -63,8 +63,8 @@ protected: }; private: - void onPrepare(GrBatchFlushState* state) final; - void onDraw(GrBatchFlushState* state, const SkRect& bounds) final; + void onPrepare(GrOpFlushState* state) final; + void onDraw(GrOpFlushState* state, const SkRect& bounds) final; virtual void onPrepareDraws(Target*) const = 0; diff --git a/src/gpu/batches/GrNinePatch.cpp b/src/gpu/batches/GrNinePatch.cpp index a99a073c5f..21a4185067 100644 --- a/src/gpu/batches/GrNinePatch.cpp +++ b/src/gpu/batches/GrNinePatch.cpp @@ -7,9 +7,9 @@ #include "GrNinePatch.h" -#include "GrBatchFlushState.h" #include "GrDefaultGeoProcFactory.h" #include "GrMeshDrawOp.h" +#include "GrOpFlushState.h" #include "GrResourceProvider.h" #include "SkBitmap.h" #include "SkLatticeIter.h" diff --git a/src/gpu/batches/GrNonAAFillRectBatch.cpp b/src/gpu/batches/GrNonAAFillRectBatch.cpp index 175b5564fb..abebe627d0 100644 --- a/src/gpu/batches/GrNonAAFillRectBatch.cpp +++ b/src/gpu/batches/GrNonAAFillRectBatch.cpp @@ -7,10 +7,10 @@ #include "GrNonAAFillRectBatch.h" -#include "GrBatchFlushState.h" #include "GrColor.h" #include "GrDefaultGeoProcFactory.h" #include "GrMeshDrawOp.h" +#include "GrOpFlushState.h" #include "GrPrimitiveProcessor.h" #include "GrQuad.h" #include "GrResourceProvider.h" diff --git a/src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp b/src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp index 8698e8fdf7..9bcab05721 100644 --- a/src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp +++ b/src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp @@ -7,10 +7,10 @@ #include "GrNonAAFillRectBatch.h" -#include "GrBatchFlushState.h" #include "GrColor.h" #include "GrDefaultGeoProcFactory.h" #include "GrMeshDrawOp.h" +#include "GrOpFlushState.h" #include "GrPrimitiveProcessor.h" #include "GrQuad.h" #include "GrResourceProvider.h" diff --git a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp index 4649edf047..f5493c6a72 100644 --- a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp +++ b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp @@ -7,11 +7,11 @@ #include "GrNonAAStrokeRectBatch.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrColor.h" #include "GrDefaultGeoProcFactory.h" #include "GrMeshDrawOp.h" +#include "GrOpFlushState.h" #include "SkRandom.h" /* create a triangle strip that strokes the specified rect. There are 8 diff --git a/src/gpu/batches/GrOp.h b/src/gpu/batches/GrOp.h index 79fbfa4b90..827e58e77f 100644 --- a/src/gpu/batches/GrOp.h +++ b/src/gpu/batches/GrOp.h @@ -19,7 +19,7 @@ class GrCaps; class GrGpuCommandBuffer; -class GrBatchFlushState; +class GrOpFlushState; /** * GrOp is the base class for all Ganesh deferred GPU operations. To facilitate reorderable @@ -121,10 +121,10 @@ public: /** Called prior to drawing. The op should perform any resource creation necessary to to quickly issue its draw when draw is called. */ - void prepare(GrBatchFlushState* state) { this->onPrepare(state); } + void prepare(GrOpFlushState* state) { this->onPrepare(state); } /** Issues the op's commands to GrGpu. */ - void draw(GrBatchFlushState* state, const SkRect& bounds) { this->onDraw(state, bounds); } + void draw(GrOpFlushState* state, const SkRect& bounds) { this->onDraw(state, bounds); } /** Used to block batching across render target changes. Remove this once we store GrOps for different RTs in different targets. */ @@ -187,8 +187,8 @@ protected: private: virtual bool onCombineIfPossible(GrOp*, const GrCaps& caps) = 0; - virtual void onPrepare(GrBatchFlushState*) = 0; - virtual void onDraw(GrBatchFlushState*, const SkRect& bounds) = 0; + virtual void onPrepare(GrOpFlushState*) = 0; + virtual void onDraw(GrOpFlushState*, const SkRect& bounds) = 0; static uint32_t GenID(int32_t* idCounter) { // The atomic inc returns the old value not the incremented value. So we add diff --git a/src/gpu/batches/GrPLSPathRenderer.cpp b/src/gpu/batches/GrPLSPathRenderer.cpp index bdc102494f..6dd2199671 100644 --- a/src/gpu/batches/GrPLSPathRenderer.cpp +++ b/src/gpu/batches/GrPLSPathRenderer.cpp @@ -7,12 +7,12 @@ #include "GrPLSPathRenderer.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrCaps.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrInvariantOutput.h" +#include "GrOpFlushState.h" #include "GrPLSGeometryProcessor.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" diff --git a/src/gpu/batches/GrRegionBatch.cpp b/src/gpu/batches/GrRegionBatch.cpp index 5f9877e788..72be6c8c12 100644 --- a/src/gpu/batches/GrRegionBatch.cpp +++ b/src/gpu/batches/GrRegionBatch.cpp @@ -7,9 +7,9 @@ #include "GrRegionBatch.h" -#include "GrBatchFlushState.h" #include "GrDefaultGeoProcFactory.h" #include "GrMeshDrawOp.h" +#include "GrOpFlushState.h" #include "GrResourceProvider.h" #include "SkMatrixPriv.h" #include "SkRegion.h" diff --git a/src/gpu/batches/GrShadowRRectBatch.cpp b/src/gpu/batches/GrShadowRRectBatch.cpp index 84e2a157dd..b2997879cf 100755 --- a/src/gpu/batches/GrShadowRRectBatch.cpp +++ b/src/gpu/batches/GrShadowRRectBatch.cpp @@ -7,8 +7,8 @@ #include "GrShadowRRectBatch.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" +#include "GrOpFlushState.h" #include "GrResourceProvider.h" #include "GrStyle.h" diff --git a/src/gpu/batches/GrStencilPathBatch.h b/src/gpu/batches/GrStencilPathBatch.h index 293da124ad..0e7936a107 100644 --- a/src/gpu/batches/GrStencilPathBatch.h +++ b/src/gpu/batches/GrStencilPathBatch.h @@ -8,9 +8,9 @@ #ifndef GrStencilPathBatch_DEFINED #define GrStencilPathBatch_DEFINED -#include "GrBatchFlushState.h" #include "GrGpu.h" #include "GrOp.h" +#include "GrOpFlushState.h" #include "GrPath.h" #include "GrPathRendering.h" #include "GrRenderTarget.h" @@ -66,9 +66,9 @@ private: bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; } - void onPrepare(GrBatchFlushState*) override {} + void onPrepare(GrOpFlushState*) override {} - void onDraw(GrBatchFlushState* state, const SkRect& bounds) override { + void onDraw(GrOpFlushState* state, const SkRect& bounds) override { GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix, &fScissor, &fStencil); state->gpu()->pathRendering()->stencilPath(args, fPath.get()); diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp index e0327d0694..86cf88392c 100644 --- a/src/gpu/batches/GrTessellatingPathRenderer.cpp +++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp @@ -8,11 +8,11 @@ #include "GrTessellatingPathRenderer.h" #include "GrAuditTrail.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrClip.h" #include "GrDefaultGeoProcFactory.h" #include "GrMesh.h" +#include "GrOpFlushState.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" #include "GrResourceCache.h" diff --git a/src/gpu/batches/GrTestBatch.h b/src/gpu/batches/GrTestBatch.h index 700e1c8a99..66df7763cd 100644 --- a/src/gpu/batches/GrTestBatch.h +++ b/src/gpu/batches/GrTestBatch.h @@ -8,8 +8,8 @@ #ifndef GrTestBatch_DEFINED #define GrTestBatch_DEFINED -#include "GrBatchFlushState.h" #include "GrGeometryProcessor.h" +#include "GrOpFlushState.h" #include "batches/GrMeshDrawOp.h" diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index 311bad3b40..02c0d22915 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -7,7 +7,6 @@ #include "GrDashingEffect.h" -#include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrCaps.h" #include "GrContext.h" @@ -15,6 +14,7 @@ #include "GrDefaultGeoProcFactory.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" +#include "GrOpFlushState.h" #include "GrProcessor.h" #include "GrStyle.h" #include "SkGr.h" diff --git a/src/gpu/gl/GrGLGpuCommandBuffer.h b/src/gpu/gl/GrGLGpuCommandBuffer.h index 76bff91a88..519272f116 100644 --- a/src/gpu/gl/GrGLGpuCommandBuffer.h +++ b/src/gpu/gl/GrGLGpuCommandBuffer.h @@ -10,8 +10,8 @@ #include "GrGpuCommandBuffer.h" -#include "GrBatchFlushState.h" #include "GrGLGpu.h" +#include "GrOpFlushState.h" class GrGLRenderTarget; @@ -36,7 +36,7 @@ public: SkASSERT(target == fRenderTarget); } - void inlineUpload(GrBatchFlushState* state, GrDrawOp::DeferredUploadFn& upload) override { + void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) override { state->doUpload(upload); } diff --git a/src/gpu/instanced/InstancedRendering.cpp b/src/gpu/instanced/InstancedRendering.cpp index fb0d53cac0..135a0610ad 100644 --- a/src/gpu/instanced/InstancedRendering.cpp +++ b/src/gpu/instanced/InstancedRendering.cpp @@ -7,8 +7,8 @@ #include "InstancedRendering.h" -#include "GrBatchFlushState.h" #include "GrCaps.h" +#include "GrOpFlushState.h" #include "GrPipeline.h" #include "GrResourceProvider.h" #include "instanced/InstanceProcessor.h" @@ -462,7 +462,7 @@ void InstancedRendering::beginFlush(GrResourceProvider* rp) { this->onBeginFlush(rp); } -void InstancedRendering::Batch::onDraw(GrBatchFlushState* state, const SkRect& bounds) { +void InstancedRendering::Batch::onDraw(GrOpFlushState* state, const SkRect& bounds) { SkASSERT(State::kFlushing == fInstancedRendering->fState); SkASSERT(state->gpu() == fInstancedRendering->gpu()); diff --git a/src/gpu/instanced/InstancedRendering.h b/src/gpu/instanced/InstancedRendering.h index d5cb3096ef..d3a01523a6 100644 --- a/src/gpu/instanced/InstancedRendering.h +++ b/src/gpu/instanced/InstancedRendering.h @@ -143,8 +143,8 @@ protected: GrInitInvariantOutput* coverage, GrBatchToXPOverrides*) const override; - void onPrepare(GrBatchFlushState*) override {} - void onDraw(GrBatchFlushState*, const SkRect& bounds) override; + void onPrepare(GrOpFlushState*) override {} + void onDraw(GrOpFlushState*, const SkRect& bounds) override; InstancedRendering* const fInstancedRendering; BatchInfo fInfo; diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp index 238489d254..68f00fc5be 100644 --- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp +++ b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp @@ -7,7 +7,7 @@ #include "GrAtlasTextBlob.h" -#include "GrBatchFlushState.h" +#include "GrOpFlushState.h" #include "GrTextUtils.h" #include "SkDistanceFieldGen.h" diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp index 4dd042b7f6..d2d5ee8324 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp +++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp @@ -7,9 +7,9 @@ #include "GrVkGpuCommandBuffer.h" -#include "GrBatchFlushState.h" #include "GrFixedClip.h" #include "GrMesh.h" +#include "GrOpFlushState.h" #include "GrPipeline.h" #include "GrRenderTargetPriv.h" #include "GrTexturePriv.h" @@ -400,8 +400,7 @@ void GrVkGpuCommandBuffer::addAdditionalCommandBuffer() { cbInfo.fCommandBuffer->begin(fGpu, fRenderTarget->framebuffer(), cbInfo.fRenderPass); } -void GrVkGpuCommandBuffer::inlineUpload(GrBatchFlushState* state, - GrDrawOp::DeferredUploadFn& upload) { +void GrVkGpuCommandBuffer::inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) { if (!fCommandBufferInfos[fCurrentCmdBuffer].fIsEmpty) { this->addAdditionalCommandBuffer(); } diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.h b/src/gpu/vk/GrVkGpuCommandBuffer.h index 76c756e130..d3eece3ce1 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.h +++ b/src/gpu/vk/GrVkGpuCommandBuffer.h @@ -33,7 +33,7 @@ public: void discard(GrRenderTarget*) override; - void inlineUpload(GrBatchFlushState* state, GrDrawOp::DeferredUploadFn& upload) override; + void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) override; private: // Performs lazy initialization on the first operation seen by the command buffer. @@ -64,11 +64,10 @@ private: void addAdditionalCommandBuffer(); struct InlineUploadInfo { - InlineUploadInfo(GrBatchFlushState* state, const GrDrawOp::DeferredUploadFn& upload) - : fFlushState(state) - , fUpload(upload) {} + InlineUploadInfo(GrOpFlushState* state, const GrDrawOp::DeferredUploadFn& upload) + : fFlushState(state), fUpload(upload) {} - GrBatchFlushState* fFlushState; + GrOpFlushState* fFlushState; GrDrawOp::DeferredUploadFn fUpload; }; diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 10891b7fcc..816b4e45a2 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -11,7 +11,7 @@ #include "Test.h" #if SK_SUPPORT_GPU -#include "GrBatchFlushState.h" +#include "GrOpFlushState.h" #include "GrContext.h" #include "GrGeometryProcessor.h" #include "GrGpu.h" -- cgit v1.2.3