| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrTargetCommands_DEFINED | 8 #ifndef GrTargetCommands_DEFINED |
| 9 #define GrTargetCommands_DEFINED | 9 #define GrTargetCommands_DEFINED |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 kClear_CmdType = 2, | 39 kClear_CmdType = 2, |
| 40 kClearStencil_CmdType = 3, | 40 kClearStencil_CmdType = 3, |
| 41 kCopySurface_CmdType = 4, | 41 kCopySurface_CmdType = 4, |
| 42 kDrawPath_CmdType = 5, | 42 kDrawPath_CmdType = 5, |
| 43 kDrawPaths_CmdType = 6, | 43 kDrawPaths_CmdType = 6, |
| 44 kDrawBatch_CmdType = 7, | 44 kDrawBatch_CmdType = 7, |
| 45 kXferBarrier_CmdType = 8, | 45 kXferBarrier_CmdType = 8, |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 Cmd(CmdType type) | 48 Cmd(CmdType type) |
| 49 : fMarkerID(-1) | 49 : fType(type) |
| 50 , fType(type) | |
| 51 #if GR_BATCH_SPEW | 50 #if GR_BATCH_SPEW |
| 52 , fUniqueID(GenID(&gUniqueID)) | 51 , fUniqueID(GenID(&gUniqueID)) |
| 53 #endif | 52 #endif |
| 54 {} | 53 {} |
| 55 virtual ~Cmd() {} | 54 virtual ~Cmd() {} |
| 56 | 55 |
| 57 virtual void execute(GrGpu*) = 0; | 56 virtual void execute(GrGpu*) = 0; |
| 58 | 57 |
| 59 CmdType type() const { return fType; } | 58 CmdType type() const { return fType; } |
| 60 | 59 |
| 61 // trace markers | |
| 62 bool isTraced() const { return -1 != fMarkerID; } | |
| 63 void setMarkerID(int markerID) { SkASSERT(-1 == fMarkerID); fMarkerID =
markerID; } | |
| 64 int markerID() const { return fMarkerID; } | |
| 65 GrBATCH_SPEW(uint32_t uniqueID() const { return fUniqueID;} ) | 60 GrBATCH_SPEW(uint32_t uniqueID() const { return fUniqueID;} ) |
| 66 | 61 |
| 67 private: | 62 private: |
| 68 // TODO move this to a common header so it can be shared with GrBatch | 63 // TODO move this to a common header so it can be shared with GrBatch |
| 69 static uint32_t GenID(int32_t* idCounter) { | 64 static uint32_t GenID(int32_t* idCounter) { |
| 70 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1; | 65 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1; |
| 71 if (!id) { | 66 if (!id) { |
| 72 SkFAIL("This should never wrap\n"); | 67 SkFAIL("This should never wrap\n"); |
| 73 } | 68 } |
| 74 return id; | 69 return id; |
| 75 } | 70 } |
| 76 int fMarkerID; | |
| 77 CmdType fType; | 71 CmdType fType; |
| 78 GrBATCH_SPEW(uint32_t fUniqueID); | 72 GrBATCH_SPEW(uint32_t fUniqueID); |
| 79 GrBATCH_SPEW(static int32_t gUniqueID;) | 73 GrBATCH_SPEW(static int32_t gUniqueID;) |
| 80 }; | 74 }; |
| 81 | 75 |
| 82 void reset(); | 76 void reset(); |
| 83 void flush(GrBufferedDrawTarget*); | 77 void flush(GrBufferedDrawTarget*); |
| 84 | 78 |
| 85 private: | 79 private: |
| 86 friend class GrCommandBuilder; | 80 friend class GrCommandBuilder; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 272 |
| 279 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } | 273 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } |
| 280 GrBatchTarget* batchTarget() { return &fBatchTarget; } | 274 GrBatchTarget* batchTarget() { return &fBatchTarget; } |
| 281 | 275 |
| 282 CmdBuffer fCmdBuffer; | 276 CmdBuffer fCmdBuffer; |
| 283 GrBatchTarget fBatchTarget; | 277 GrBatchTarget fBatchTarget; |
| 284 }; | 278 }; |
| 285 | 279 |
| 286 #endif | 280 #endif |
| 287 | 281 |
| OLD | NEW |