Chromium Code Reviews| 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 virtual ~GrFragmentStage() {} |
|
bsalomon
2014/10/09 18:35:45
delete virtual?
| |
| 35 | 35 |
| 36 GrProcessorStage(const GrProcessorStage& other) { | 36 GrFragmentStage(const GrFragmentStage& other) { |
| 37 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; | 37 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; |
| 38 if (other.fCoordChangeMatrixSet) { | 38 if (other.fCoordChangeMatrixSet) { |
| 39 fCoordChangeMatrix = other.fCoordChangeMatrix; | 39 fCoordChangeMatrix = other.fCoordChangeMatrix; |
| 40 } | 40 } |
| 41 fProc.initAndRef(other.fProc); | 41 fProc.initAndRef(other.fProc); |
| 42 } | 42 } |
| 43 | 43 |
| 44 static bool AreCompatible(const GrProcessorStage& a, const GrProcessorStage& b, | 44 static bool AreCompatible(const GrFragmentStage& a, const GrFragmentStage& b , |
| 45 bool usingExplicitLocalCoords) { | 45 bool usingExplicitLocalCoords) { |
| 46 SkASSERT(a.fProc.get()); | 46 SkASSERT(a.fProc.get()); |
| 47 SkASSERT(b.fProc.get()); | 47 SkASSERT(b.fProc.get()); |
| 48 | 48 |
| 49 if (!a.getProcessor()->isEqual(*b.getProcessor())) { | 49 if (!a.getProcessor()->isEqual(*b.getProcessor())) { |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // We always track the coord change matrix, but it has no effect when ex plicit local coords | 53 // We always track the coord change matrix, but it has no effect when ex plicit local coords |
| 54 // are used. | 54 // are used. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 83 } | 83 } |
| 84 | 84 |
| 85 class SavedCoordChange { | 85 class SavedCoordChange { |
| 86 public: | 86 public: |
| 87 SkDEBUGCODE(SavedCoordChange() : fEffectUniqueID(SK_InvalidUniqueID) {}) | 87 SkDEBUGCODE(SavedCoordChange() : fEffectUniqueID(SK_InvalidUniqueID) {}) |
| 88 private: | 88 private: |
| 89 bool fCoordChangeMatrixSet; | 89 bool fCoordChangeMatrixSet; |
| 90 SkMatrix fCoordChangeMatrix; | 90 SkMatrix fCoordChangeMatrix; |
| 91 SkDEBUGCODE(mutable uint32_t fEffectUniqueID;) | 91 SkDEBUGCODE(mutable uint32_t fEffectUniqueID;) |
| 92 | 92 |
| 93 friend class GrProcessorStage; | 93 friend class GrFragmentStage; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * This gets the current coordinate system change. It is the accumulation of | 97 * 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 | 98 * 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 | 99 * 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 ). | 100 * restore the previous coord system (e.g. temporarily draw in device coords ). |
| 101 */ | 101 */ |
| 102 void saveCoordChange(SavedCoordChange* savedCoordChange) const { | 102 void saveCoordChange(SavedCoordChange* savedCoordChange) const { |
| 103 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; | 103 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 } | 142 } |
| 143 | 143 |
| 144 int combinedTypes = type0 | type1; | 144 int combinedTypes = type0 | type1; |
| 145 if (SkMatrix::kPerspective_Mask & combinedTypes) { | 145 if (SkMatrix::kPerspective_Mask & combinedTypes) { |
| 146 return true; | 146 return true; |
| 147 } else { | 147 } else { |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 virtual const GrProcessor* getProcessor() const = 0; | 152 virtual const GrFragmentProcessor* getProcessor() const { return fProc.get() ; } |
|
bsalomon
2014/10/09 18:35:45
delete virtual?
| |
| 153 | 153 |
| 154 void convertToPendingExec() { fProc.convertToPendingExec(); } | 154 void convertToPendingExec() { fProc.convertToPendingExec(); } |
| 155 | 155 |
| 156 protected: | 156 protected: |
| 157 bool fCoordChangeMatrixSet; | 157 bool fCoordChangeMatrixSet; |
| 158 SkMatrix fCoordChangeMatrix; | 158 SkMatrix fCoordChangeMatrix; |
| 159 GrProgramElementRef<const GrProcessor> fProc; | 159 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 }; | 160 }; |
| 185 | 161 |
| 186 #endif | 162 #endif |
| OLD | NEW |