Chromium Code Reviews| 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; |