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

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: add comments 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 4d4209ab404439a6944dce94becae8c463e6f0a8..53fdb8062dec727cc822dbadf052edc31e4e30d9 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,21 @@ 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)>;
+
+ /**
+ * Batches can insert uploads when preparing their draws. The can eithe be inserted before
egdaniel 2016/03/28 20:05:20 The->They, eithe->either
+ * all the draws (of all batches in a flush), which is called an "asap upload", or schedule
+ * them between draws, which is called an "inline upload". ASAP uploads are typically used
egdaniel 2016/03/28 20:05:20 Wouldn't you want inline uploads in the case where
bsalomon 2016/03/28 20:11:02 Yes, mental slip
+ * when the content of the GrSurface must be modified between draws because two draws require
+ * different contents to appear in the surface.
+ */
+ using DeferredUploadFn = std::function<void(WritePixelsFn&)>;
+
class Target;
GrDrawBatch(uint32_t classID);
@@ -100,7 +123,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