Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: src/gpu/batches/GrDrawBatch.h

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/batches/GrDrawAtlasBatch.cpp ('k') | src/gpu/batches/GrDrawVerticesBatch.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrDrawBatch.h
diff --git a/src/gpu/batches/GrDrawBatch.h b/src/gpu/batches/GrDrawBatch.h
index d1083b30b6f44fe77d0badd16cc9dac7035cb003..bf93cf5a72115f2a2df4734e361d3cfdeacfcee8 100644
--- a/src/gpu/batches/GrDrawBatch.h
+++ b/src/gpu/batches/GrDrawBatch.h
@@ -8,6 +8,7 @@
#ifndef GrDrawBatch_DEFINED
#define GrDrawBatch_DEFINED
+#include <functional>
#include "GrBatch.h"
#include "GrPipeline.h"
@@ -19,18 +20,25 @@ struct GrInitInvariantOutput;
* to sequence the uploads relative to each other and to draws.
**/
-typedef uint64_t GrBatchToken;
-
-class GrBatchUploader : public SkRefCnt {
+class GrBatchDrawToken {
public:
- class TextureUploader;
+ static GrBatchDrawToken AlreadyFlushedToken() { return GrBatchDrawToken(0); }
- GrBatchUploader(GrBatchToken lastUploadToken) : fLastUploadToken(lastUploadToken) {}
- GrBatchToken lastUploadToken() const { return fLastUploadToken; }
- virtual void upload(TextureUploader*)=0;
+ GrBatchDrawToken(const GrBatchDrawToken& that) : fSequenceNumber(that.fSequenceNumber) {}
+ GrBatchDrawToken& operator =(const GrBatchDrawToken& that) {
+ fSequenceNumber = that.fSequenceNumber;
+ return *this;
+ }
+ bool operator==(const GrBatchDrawToken& that) const {
+ return fSequenceNumber == that.fSequenceNumber;
+ }
+ bool operator!=(const GrBatchDrawToken& that) const { return !(*this == that); }
private:
- GrBatchToken fLastUploadToken;
+ GrBatchDrawToken();
+ explicit GrBatchDrawToken(uint64_t sequenceNumber) : fSequenceNumber(sequenceNumber) {}
+ friend class GrBatchFlushState;
+ uint64_t fSequenceNumber;
};
/**
@@ -38,6 +46,14 @@ private:
*/
class GrDrawBatch : public GrBatch {
public:
+ /** Method that performs an upload on behalf of a DeferredUploadFn. */
+ using WritePixelsFn = std::function<bool(GrSurface* texture,
+ int left, int top, int width, int height,
+ GrPixelConfig config, const void* buffer,
+ size_t rowBytes)>;
+ /** See comments before GrDrawBatch::Target definition on how deferred uploaders work. */
+ using DeferredUploadFn = std::function<void(WritePixelsFn&)>;
+
class Target;
GrDrawBatch(uint32_t classID);
@@ -100,7 +116,14 @@ private:
virtual void initBatchTracker(const GrXPOverridesForBatch&) = 0;
protected:
- SkTArray<SkAutoTUnref<GrBatchUploader>, true> fInlineUploads;
+ struct QueuedUpload {
+ QueuedUpload(DeferredUploadFn&& upload, GrBatchDrawToken token)
+ : fUpload(std::move(upload))
+ , fUploadBeforeToken(token) {}
+ DeferredUploadFn fUpload;
+ GrBatchDrawToken fUploadBeforeToken;
+ };
+ SkTArray<QueuedUpload> fInlineUploads;
private:
SkAlignedSTStorage<1, GrPipeline> fPipelineStorage;
« no previous file with comments | « src/gpu/batches/GrDrawAtlasBatch.cpp ('k') | src/gpu/batches/GrDrawVerticesBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698