aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDeferredUpload.h
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-01-18 12:59:22 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-18 18:31:58 +0000
commit40a29d7705d970be03ff94f9fa062db75dccbd0f (patch)
tree67908df5424d112ea27a012de435819586f23793 /src/gpu/GrDeferredUpload.h
parent3af7f6e2ce32c0909159145b23378d119e900bbe (diff)
Move GrOpFlushState out of GrDrawingManager and onto the stack
Change-Id: If1b3481af7637bfed8a73d75be41c6422319951f Reviewed-on: https://skia-review.googlesource.com/96540 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrDeferredUpload.h')
-rw-r--r--src/gpu/GrDeferredUpload.h55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/gpu/GrDeferredUpload.h b/src/gpu/GrDeferredUpload.h
index 54f56b7139..cc8de959c5 100644
--- a/src/gpu/GrDeferredUpload.h
+++ b/src/gpu/GrDeferredUpload.h
@@ -81,6 +81,34 @@ private:
uint64_t fSequenceNumber;
};
+/*
+ * The GrTokenTracker encapsulates the incrementing and distribution of tokens.
+ */
+class GrTokenTracker {
+public:
+ /** Gets the token one beyond the last token that has been flushed. */
+ GrDeferredUploadToken nextTokenToFlush() const { return fLastFlushedToken.next(); }
+
+ /** 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. */
+ GrDeferredUploadToken nextDrawToken() const { return fLastIssuedToken.next(); }
+
+private:
+ // Only these two classes get to increment the token counters
+ friend class SkInternalAtlasTextContext;
+ friend class GrOpFlushState;
+
+ /** Issues the next token for a draw. */
+ GrDeferredUploadToken issueDrawToken() { return ++fLastIssuedToken; }
+
+ /** Advances the last flushed token by one. */
+ GrDeferredUploadToken flushToken() { return ++fLastFlushedToken; }
+
+ GrDeferredUploadToken fLastIssuedToken = GrDeferredUploadToken::AlreadyFlushedToken();
+ GrDeferredUploadToken fLastFlushedToken = GrDeferredUploadToken::AlreadyFlushedToken();
+};
+
/**
* Passed to a deferred upload when it is executed, this method allows the deferred upload to
* actually write its pixel data into a texture.
@@ -97,13 +125,14 @@ using GrDeferredTextureUploadWritePixelsFn =
using GrDeferredTextureUploadFn = std::function<void(GrDeferredTextureUploadWritePixelsFn&)>;
/**
- * An interface for scheduling deferred uploads. It provides sequence tokens and accepts asap and
- * deferred inline uploads.
+ * An interface for scheduling deferred uploads. It accepts asap and deferred inline uploads.
*/
class GrDeferredUploadTarget {
public:
virtual ~GrDeferredUploadTarget() {}
+ virtual const GrTokenTracker* tokenTracker() = 0;
+
/** Returns the token of the draw that this upload will occur before. */
virtual GrDeferredUploadToken addInlineUpload(GrDeferredTextureUploadFn&&) = 0;
@@ -111,28 +140,6 @@ public:
are done first during a flush, this will be the first token since the most recent
flush. */
virtual GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&& upload) = 0;
-
- /** Gets the token one beyond the last token that has been flushed. */
- GrDeferredUploadToken nextTokenToFlush() const { return fLastFlushedToken.next(); }
-
- /** 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. */
- GrDeferredUploadToken nextDrawToken() const { return fLastIssuedToken.next(); }
-
-protected:
- // Methods that advance the internal tokens are protected so that the subclass can determine
- // access.
-
- /** Issues the next token for a draw. */
- GrDeferredUploadToken issueDrawToken() { return ++fLastIssuedToken; }
-
- /** Advances the last flushed token by one. */
- GrDeferredUploadToken flushToken() { return ++fLastFlushedToken; }
-
-private:
- GrDeferredUploadToken fLastIssuedToken = GrDeferredUploadToken::AlreadyFlushedToken();
- GrDeferredUploadToken fLastFlushedToken = GrDeferredUploadToken::AlreadyFlushedToken();
};
#endif