| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 | 10 |
| 11 #ifndef GrProcessorStage_DEFINED | 11 #ifndef GrProcessorStage_DEFINED |
| 12 #define GrProcessorStage_DEFINED | 12 #define GrProcessorStage_DEFINED |
| 13 | 13 |
| 14 #include "GrBackendProcessorFactory.h" | 14 #include "GrBackendProcessorFactory.h" |
| 15 #include "GrCoordTransform.h" | 15 #include "GrCoordTransform.h" |
| 16 #include "GrProcessor.h" | 16 #include "GrProcessor.h" |
| 17 #include "GrGeometryProcessor.h" | 17 #include "GrGeometryProcessor.h" |
| 18 #include "GrProgramElementRef.h" | 18 #include "GrProgramElementRef.h" |
| 19 #include "SkMatrix.h" | 19 #include "SkMatrix.h" |
| 20 #include "SkShader.h" | 20 #include "SkShader.h" |
| 21 | 21 |
| 22 // TODO: Make two variations on this class: One for GrDrawState that only owns r
egular refs | 22 // TODO: Make two variations on this class: One for GrDrawState that only owns r
egular refs |
| 23 // and supports compatibility checks and changing local coords. The second is fo
r GrOptDrawState, | 23 // and supports compatibility checks and changing local coords. The second is fo
r GrOptDrawState, |
| 24 // is immutable, and only owns pending execution refs. This requries removing th
e common base | 24 // is immutable, and only owns pending execution refs. This requries removing th
e common base |
| 25 // class from GrDrawState and GrOptDrawState called GrRODrawState and converting
to GrOptDrawState | 25 // class from GrDrawState and GrOptDrawState called GrRODrawState and converting
to GrOptDrawState |
| 26 // when draws are enqueued in the GrInOrderDrawBuffer. | 26 // when draws are enqueued in the GrInOrderDrawBuffer. |
| 27 class GrProcessorStage { | 27 class GrFragmentStage { |
| 28 public: | 28 public: |
| 29 explicit GrProcessorStage(const GrProcessor* proc) | 29 explicit GrFragmentStage(const GrFragmentProcessor* proc) |
| 30 : fProc(SkRef(proc)) { | 30 : fProc(SkRef(proc)) { |
| 31 fCoordChangeMatrixSet = false; | 31 fCoordChangeMatrixSet = false; |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual ~GrProcessorStage() {} | 34 GrFragmentStage(const GrFragmentStage& other) { |
| 35 | |
| 36 GrProcessorStage(const GrProcessorStage& other) { | |
| 37 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; | 35 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; |
| 38 if (other.fCoordChangeMatrixSet) { | 36 if (other.fCoordChangeMatrixSet) { |
| 39 fCoordChangeMatrix = other.fCoordChangeMatrix; | 37 fCoordChangeMatrix = other.fCoordChangeMatrix; |
| 40 } | 38 } |
| 41 fProc.initAndRef(other.fProc); | 39 fProc.initAndRef(other.fProc); |
| 42 } | 40 } |
| 43 | 41 |
| 44 static bool AreCompatible(const GrProcessorStage& a, const GrProcessorStage&
b, | 42 static bool AreCompatible(const GrFragmentStage& a, const GrFragmentStage& b
, |
| 45 bool usingExplicitLocalCoords) { | 43 bool usingExplicitLocalCoords) { |
| 46 SkASSERT(a.fProc.get()); | 44 SkASSERT(a.fProc.get()); |
| 47 SkASSERT(b.fProc.get()); | 45 SkASSERT(b.fProc.get()); |
| 48 | 46 |
| 49 if (!a.getProcessor()->isEqual(*b.getProcessor())) { | 47 if (!a.getProcessor()->isEqual(*b.getProcessor())) { |
| 50 return false; | 48 return false; |
| 51 } | 49 } |
| 52 | 50 |
| 53 // We always track the coord change matrix, but it has no effect when ex
plicit local coords | 51 // We always track the coord change matrix, but it has no effect when ex
plicit local coords |
| 54 // are used. | 52 // are used. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 83 } | 81 } |
| 84 | 82 |
| 85 class SavedCoordChange { | 83 class SavedCoordChange { |
| 86 public: | 84 public: |
| 87 SkDEBUGCODE(SavedCoordChange() : fEffectUniqueID(SK_InvalidUniqueID) {}) | 85 SkDEBUGCODE(SavedCoordChange() : fEffectUniqueID(SK_InvalidUniqueID) {}) |
| 88 private: | 86 private: |
| 89 bool fCoordChangeMatrixSet; | 87 bool fCoordChangeMatrixSet; |
| 90 SkMatrix fCoordChangeMatrix; | 88 SkMatrix fCoordChangeMatrix; |
| 91 SkDEBUGCODE(mutable uint32_t fEffectUniqueID;) | 89 SkDEBUGCODE(mutable uint32_t fEffectUniqueID;) |
| 92 | 90 |
| 93 friend class GrProcessorStage; | 91 friend class GrFragmentStage; |
| 94 }; | 92 }; |
| 95 | 93 |
| 96 /** | 94 /** |
| 97 * This gets the current coordinate system change. It is the accumulation of | 95 * This gets the current coordinate system change. It is the accumulation of |
| 98 * localCoordChange calls since the effect was installed. It is used when th
en caller | 96 * localCoordChange calls since the effect was installed. It is used when th
en caller |
| 99 * wants to temporarily change the source geometry coord system, draw someth
ing, and then | 97 * wants to temporarily change the source geometry coord system, draw someth
ing, and then |
| 100 * restore the previous coord system (e.g. temporarily draw in device coords
). | 98 * restore the previous coord system (e.g. temporarily draw in device coords
). |
| 101 */ | 99 */ |
| 102 void saveCoordChange(SavedCoordChange* savedCoordChange) const { | 100 void saveCoordChange(SavedCoordChange* savedCoordChange) const { |
| 103 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; | 101 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 140 } |
| 143 | 141 |
| 144 int combinedTypes = type0 | type1; | 142 int combinedTypes = type0 | type1; |
| 145 if (SkMatrix::kPerspective_Mask & combinedTypes) { | 143 if (SkMatrix::kPerspective_Mask & combinedTypes) { |
| 146 return true; | 144 return true; |
| 147 } else { | 145 } else { |
| 148 return false; | 146 return false; |
| 149 } | 147 } |
| 150 } | 148 } |
| 151 | 149 |
| 152 virtual const GrProcessor* getProcessor() const = 0; | 150 const GrFragmentProcessor* getProcessor() const { return fProc.get(); } |
| 153 | 151 |
| 154 void convertToPendingExec() { fProc.convertToPendingExec(); } | 152 void convertToPendingExec() { fProc.convertToPendingExec(); } |
| 155 | 153 |
| 156 protected: | 154 protected: |
| 157 bool fCoordChangeMatrixSet; | 155 bool fCoordChangeMatrixSet; |
| 158 SkMatrix fCoordChangeMatrix; | 156 SkMatrix fCoordChangeMatrix; |
| 159 GrProgramElementRef<const GrProcessor> fProc; | 157 GrProgramElementRef<const GrFragmentProcessor> fProc; |
| 160 }; | |
| 161 | |
| 162 class GrFragmentStage : public GrProcessorStage { | |
| 163 public: | |
| 164 GrFragmentStage(const GrFragmentProcessor* fp) : GrProcessorStage(fp) {} | |
| 165 | |
| 166 virtual const GrFragmentProcessor* getProcessor() const { | |
| 167 return static_cast<const GrFragmentProcessor*>(fProc.get()); | |
| 168 } | |
| 169 | |
| 170 typedef GrFragmentProcessor Processor; | |
| 171 typedef GrGLFragmentProcessor GLProcessor; | |
| 172 }; | |
| 173 | |
| 174 class GrGeometryStage : public GrProcessorStage { | |
| 175 public: | |
| 176 GrGeometryStage(const GrGeometryProcessor* gp) : GrProcessorStage(gp) {} | |
| 177 | |
| 178 virtual const GrGeometryProcessor* getProcessor() const { | |
| 179 return static_cast<const GrGeometryProcessor*>(fProc.get()); | |
| 180 } | |
| 181 | |
| 182 typedef GrGeometryProcessor Processor; | |
| 183 typedef GrGLGeometryProcessor GLProcessor; | |
| 184 }; | 158 }; |
| 185 | 159 |
| 186 #endif | 160 #endif |
| OLD | NEW |