| 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 GrBatch_DEFINED | 8 #ifndef GrBatch_DEFINED |
| 9 #define GrBatch_DEFINED | 9 #define GrBatch_DEFINED |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 * initBatchTracker is a hook for the some additional overrides / optimizati
on possibilities | 50 * initBatchTracker is a hook for the some additional overrides / optimizati
on possibilities |
| 51 * from the GrXferProcessor. | 51 * from the GrXferProcessor. |
| 52 */ | 52 */ |
| 53 virtual void initBatchTracker(const GrPipelineInfo& init) = 0; | 53 virtual void initBatchTracker(const GrPipelineInfo& init) = 0; |
| 54 | 54 |
| 55 bool combineIfPossible(GrBatch* that) { | 55 bool combineIfPossible(GrBatch* that) { |
| 56 if (this->classID() != that->classID()) { | 56 if (this->classID() != that->classID()) { |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (!this->pipeline()->isEqual(*that->pipeline())) { | |
| 61 return false; | |
| 62 } | |
| 63 | |
| 64 return this->onCombineIfPossible(that); | 60 return this->onCombineIfPossible(that); |
| 65 } | 61 } |
| 66 | 62 |
| 67 virtual bool onCombineIfPossible(GrBatch*) = 0; | 63 virtual bool onCombineIfPossible(GrBatch*) = 0; |
| 68 | 64 |
| 69 virtual void generateGeometry(GrBatchTarget*, const GrPipeline*) = 0; | 65 virtual void generateGeometry(GrBatchTarget*, const GrPipeline*) = 0; |
| 70 | 66 |
| 71 const SkRect& bounds() const { return fBounds; } | 67 const SkRect& bounds() const { return fBounds; } |
| 72 | 68 |
| 73 // TODO this goes away when batches are everywhere | 69 // TODO this goes away when batches are everywhere |
| (...skipping 16 matching lines...) Expand all Loading... |
| 90 template <typename T> const T& cast() const { return *static_cast<const T*>(
this); } | 86 template <typename T> const T& cast() const { return *static_cast<const T*>(
this); } |
| 91 template <typename T> T* cast() { return static_cast<T*>(this); } | 87 template <typename T> T* cast() { return static_cast<T*>(this); } |
| 92 | 88 |
| 93 uint32_t classID() const { SkASSERT(kIllegalBatchClassID != fClassID); retur
n fClassID; } | 89 uint32_t classID() const { SkASSERT(kIllegalBatchClassID != fClassID); retur
n fClassID; } |
| 94 | 90 |
| 95 // TODO no GrPrimitiveProcessors yet read fragment position | 91 // TODO no GrPrimitiveProcessors yet read fragment position |
| 96 bool willReadFragmentPosition() const { return false; } | 92 bool willReadFragmentPosition() const { return false; } |
| 97 | 93 |
| 98 SkDEBUGCODE(bool isUsed() const { return fUsed; }) | 94 SkDEBUGCODE(bool isUsed() const { return fUsed; }) |
| 99 | 95 |
| 96 const GrPipeline* pipeline() const { return fPipeline; } |
| 100 void setPipeline(const GrPipeline* pipeline) { fPipeline.reset(SkRef(pipelin
e)); } | 97 void setPipeline(const GrPipeline* pipeline) { fPipeline.reset(SkRef(pipelin
e)); } |
| 101 | 98 |
| 102 protected: | 99 protected: |
| 103 template <typename PROC_SUBCLASS> void initClassID() { | 100 template <typename PROC_SUBCLASS> void initClassID() { |
| 104 static uint32_t kClassID = GenClassID(); | 101 static uint32_t kClassID = GenClassID(); |
| 105 fClassID = kClassID; | 102 fClassID = kClassID; |
| 106 } | 103 } |
| 107 | 104 |
| 108 // NOTE, compute some bounds, even if extremely conservative. Do *NOT* setL
argest on the bounds | 105 // NOTE, compute some bounds, even if extremely conservative. Do *NOT* setL
argest on the bounds |
| 109 // rect because we outset it for dst copy textures | 106 // rect because we outset it for dst copy textures |
| 110 void setBounds(const SkRect& newBounds) { fBounds = newBounds; } | 107 void setBounds(const SkRect& newBounds) { fBounds = newBounds; } |
| 111 | 108 |
| 112 void joinBounds(const SkRect& otherBounds) { | 109 void joinBounds(const SkRect& otherBounds) { |
| 113 return fBounds.joinPossiblyEmptyRect(otherBounds); | 110 return fBounds.joinPossiblyEmptyRect(otherBounds); |
| 114 } | 111 } |
| 115 | 112 |
| 116 const GrPipeline* pipeline() const { return fPipeline; } | |
| 117 | |
| 118 /** Helper for rendering instances using an instanced index index buffer. Th
is class creates the | 113 /** Helper for rendering instances using an instanced index index buffer. Th
is class creates the |
| 119 space for the vertices and flushes the draws to the batch target.*/ | 114 space for the vertices and flushes the draws to the batch target.*/ |
| 120 class InstancedHelper { | 115 class InstancedHelper { |
| 121 public: | 116 public: |
| 122 InstancedHelper() {} | 117 InstancedHelper() {} |
| 123 /** Returns the allocated storage for the vertices. The caller should po
pulate the before | 118 /** Returns the allocated storage for the vertices. The caller should po
pulate the before |
| 124 vertices before calling issueDraws(). */ | 119 vertices before calling issueDraws(). */ |
| 125 void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStr
ide, | 120 void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStr
ide, |
| 126 const GrIndexBuffer*, int verticesPerInstance, int indicesPer
Instance, | 121 const GrIndexBuffer*, int verticesPerInstance, int indicesPer
Instance, |
| 127 int instancesToDraw); | 122 int instancesToDraw); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 }; | 169 }; |
| 175 SkAutoTUnref<const GrPipeline> fPipeline; | 170 SkAutoTUnref<const GrPipeline> fPipeline; |
| 176 static int32_t gCurrBatchClassID; | 171 static int32_t gCurrBatchClassID; |
| 177 int fNumberOfDraws; | 172 int fNumberOfDraws; |
| 178 SkDEBUGCODE(bool fUsed;) | 173 SkDEBUGCODE(bool fUsed;) |
| 179 | 174 |
| 180 typedef SkRefCnt INHERITED; | 175 typedef SkRefCnt INHERITED; |
| 181 }; | 176 }; |
| 182 | 177 |
| 183 #endif | 178 #endif |
| OLD | NEW |