| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef GrTargetCommands_DEFINED | |
| 9 #define GrTargetCommands_DEFINED | |
| 10 | |
| 11 #include "GrDrawTarget.h" | |
| 12 #include "GrPath.h" | |
| 13 #include "GrPendingProgramElement.h" | |
| 14 #include "GrPrimitiveProcessor.h" | |
| 15 #include "GrRenderTarget.h" | |
| 16 #include "GrTRecorder.h" | |
| 17 | |
| 18 #include "batches/GrBatch.h" | |
| 19 | |
| 20 #include "SkRect.h" | |
| 21 | |
| 22 class GrResourceProvider; | |
| 23 class GrBatchFlushState; | |
| 24 | |
| 25 // TODO: Convert all commands into GrBatch and remove this class. | |
| 26 class GrTargetCommands : ::SkNoncopyable { | |
| 27 public: | |
| 28 GrTargetCommands() : fCmdBuffer(kCmdBufferInitialSizeInBytes), fLastFlushTok
en(0) {} | |
| 29 | |
| 30 class Cmd : ::SkNoncopyable { | |
| 31 public: | |
| 32 enum CmdType { | |
| 33 kDrawBatch_CmdType = 4, | |
| 34 }; | |
| 35 | |
| 36 Cmd(CmdType type) | |
| 37 : fType(type) | |
| 38 #if GR_BATCH_SPEW | |
| 39 , fUniqueID(GenID(&gUniqueID)) | |
| 40 #endif | |
| 41 {} | |
| 42 virtual ~Cmd() {} | |
| 43 | |
| 44 virtual void execute(GrBatchFlushState*) = 0; | |
| 45 | |
| 46 CmdType type() const { return fType; } | |
| 47 | |
| 48 GrBATCH_SPEW(uint32_t uniqueID() const { return fUniqueID;} ) | |
| 49 | |
| 50 private: | |
| 51 // TODO move this to a common header so it can be shared with GrBatch | |
| 52 static uint32_t GenID(int32_t* idCounter) { | |
| 53 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1; | |
| 54 if (!id) { | |
| 55 SkFAIL("This should never wrap\n"); | |
| 56 } | |
| 57 return id; | |
| 58 } | |
| 59 CmdType fType; | |
| 60 GrBATCH_SPEW(uint32_t fUniqueID); | |
| 61 GrBATCH_SPEW(static int32_t gUniqueID;) | |
| 62 }; | |
| 63 | |
| 64 void reset(); | |
| 65 void flush(GrGpu*, GrResourceProvider*); | |
| 66 | |
| 67 private: | |
| 68 friend class GrCommandBuilder; | |
| 69 friend class GrBufferedDrawTarget; // This goes away when State becomes just
a pipeline | |
| 70 friend class GrReorderCommandBuilder; | |
| 71 | |
| 72 typedef GrGpu::DrawArgs DrawArgs; | |
| 73 | |
| 74 struct DrawBatch : public Cmd { | |
| 75 DrawBatch(GrBatch* batch) | |
| 76 : Cmd(kDrawBatch_CmdType) | |
| 77 , fBatch(SkRef(batch)){ | |
| 78 SkASSERT(!batch->isUsed()); | |
| 79 } | |
| 80 | |
| 81 GrBatch* batch() { return fBatch; } | |
| 82 void execute(GrBatchFlushState*) override; | |
| 83 | |
| 84 private: | |
| 85 SkAutoTUnref<GrBatch> fBatch; | |
| 86 }; | |
| 87 | |
| 88 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | |
| 89 | |
| 90 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | |
| 91 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | |
| 92 | |
| 93 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } | |
| 94 | |
| 95 CmdBuffer fCmdBuffer; | |
| 96 GrBatchToken fLastFlushToken; | |
| 97 }; | |
| 98 | |
| 99 #endif | |
| OLD | NEW |