Chromium Code Reviews| 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. */ |
|
egdaniel
2016/03/30 15:52:33
Can you comment on where GrDrawBatch::Target defin
bsalomon
2016/03/30 16:59:11
Not crazy about doing that for 3 reasons: 1) Likel
|
| + 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; |