| 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 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 void localCoordChange(const SkMatrix& matrix) { | 75 void localCoordChange(const SkMatrix& matrix) { |
| 76 if (fCoordChangeMatrixSet) { | 76 if (fCoordChangeMatrixSet) { |
| 77 fCoordChangeMatrix.preConcat(matrix); | 77 fCoordChangeMatrix.preConcat(matrix); |
| 78 } else { | 78 } else { |
| 79 fCoordChangeMatrixSet = true; | 79 fCoordChangeMatrixSet = true; |
| 80 fCoordChangeMatrix = matrix; | 80 fCoordChangeMatrix = matrix; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 class SavedCoordChange { | 84 class SavedCoordChange { |
| 85 public: |
| 86 SkDEBUGCODE(SavedCoordChange() : fEffectUniqueID(SK_InvalidUniqueID) {}) |
| 85 private: | 87 private: |
| 86 bool fCoordChangeMatrixSet; | 88 bool fCoordChangeMatrixSet; |
| 87 SkMatrix fCoordChangeMatrix; | 89 SkMatrix fCoordChangeMatrix; |
| 88 SkDEBUGCODE(mutable SkAutoTUnref<const GrEffect> fEffect;) | 90 SkDEBUGCODE(mutable uint32_t fEffectUniqueID;) |
| 89 | 91 |
| 90 friend class GrEffectStage; | 92 friend class GrEffectStage; |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 /** | 95 /** |
| 94 * This gets the current coordinate system change. It is the accumulation of | 96 * This gets the current coordinate system change. It is the accumulation of |
| 95 * localCoordChange calls since the effect was installed. It is used when th
en caller | 97 * localCoordChange calls since the effect was installed. It is used when th
en caller |
| 96 * wants to temporarily change the source geometry coord system, draw someth
ing, and then | 98 * wants to temporarily change the source geometry coord system, draw someth
ing, and then |
| 97 * restore the previous coord system (e.g. temporarily draw in device coords
). | 99 * restore the previous coord system (e.g. temporarily draw in device coords
). |
| 98 */ | 100 */ |
| 99 void saveCoordChange(SavedCoordChange* savedCoordChange) const { | 101 void saveCoordChange(SavedCoordChange* savedCoordChange) const { |
| 100 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; | 102 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; |
| 101 if (fCoordChangeMatrixSet) { | 103 if (fCoordChangeMatrixSet) { |
| 102 savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix; | 104 savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix; |
| 103 } | 105 } |
| 104 SkASSERT(NULL == savedCoordChange->fEffect.get()); | 106 SkASSERT(SK_InvalidUniqueID == savedCoordChange->fEffectUniqueID); |
| 105 SkDEBUGCODE(SkRef(fEffect.get());) | 107 SkDEBUGCODE(savedCoordChange->fEffectUniqueID = fEffect->getUniqueID();) |
| 106 SkDEBUGCODE(savedCoordChange->fEffect.reset(fEffect.get());) | |
| 107 } | 108 } |
| 108 | 109 |
| 109 /** | 110 /** |
| 110 * This balances the saveCoordChange call. | 111 * This balances the saveCoordChange call. |
| 111 */ | 112 */ |
| 112 void restoreCoordChange(const SavedCoordChange& savedCoordChange) { | 113 void restoreCoordChange(const SavedCoordChange& savedCoordChange) { |
| 113 fCoordChangeMatrixSet = savedCoordChange.fCoordChangeMatrixSet; | 114 fCoordChangeMatrixSet = savedCoordChange.fCoordChangeMatrixSet; |
| 114 if (fCoordChangeMatrixSet) { | 115 if (fCoordChangeMatrixSet) { |
| 115 fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix; | 116 fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix; |
| 116 } | 117 } |
| 117 SkASSERT(savedCoordChange.fEffect.get() == fEffect); | 118 SkASSERT(savedCoordChange.fEffectUniqueID == fEffect->getUniqueID()); |
| 118 SkDEBUGCODE(savedCoordChange.fEffect.reset(NULL);) | 119 SkDEBUGCODE(savedCoordChange.fEffectUniqueID = SK_InvalidUniqueID); |
| 119 } | 120 } |
| 120 | 121 |
| 121 /** | 122 /** |
| 122 * Gets the matrix representing all changes of coordinate system since the G
rEffect was | 123 * Gets the matrix representing all changes of coordinate system since the G
rEffect was |
| 123 * installed in the stage. | 124 * installed in the stage. |
| 124 */ | 125 */ |
| 125 const SkMatrix& getCoordChangeMatrix() const { | 126 const SkMatrix& getCoordChangeMatrix() const { |
| 126 if (fCoordChangeMatrixSet) { | 127 if (fCoordChangeMatrixSet) { |
| 127 return fCoordChangeMatrix; | 128 return fCoordChangeMatrix; |
| 128 } else { | 129 } else { |
| 129 return SkMatrix::I(); | 130 return SkMatrix::I(); |
| 130 } | 131 } |
| 131 } | 132 } |
| 132 | 133 |
| 133 const GrEffect* getEffect() const { return fEffect.get(); } | 134 const GrEffect* getEffect() const { return fEffect.get(); } |
| 134 | 135 |
| 135 const int* getVertexAttribIndices() const { return fVertexAttribIndices; } | 136 const int* getVertexAttribIndices() const { return fVertexAttribIndices; } |
| 136 int getVertexAttribIndexCount() const { return fEffect->numVertexAttribs();
} | 137 int getVertexAttribIndexCount() const { return fEffect->numVertexAttribs();
} |
| 137 | 138 |
| 138 void convertToPendingExec() { fEffect.convertToPendingExec(); } | 139 void convertToPendingExec() { fEffect.convertToPendingExec(); } |
| 139 | 140 |
| 140 private: | 141 private: |
| 141 bool fCoordChangeMatrixSet; | 142 bool fCoordChangeMatrixSet; |
| 142 SkMatrix fCoordChangeMatrix; | 143 SkMatrix fCoordChangeMatrix; |
| 143 GrProgramElementRef<const GrEffect> fEffect; | 144 GrProgramElementRef<const GrEffect> fEffect; |
| 144 int fVertexAttribIndices[2]; | 145 int fVertexAttribIndices[2]; |
| 145 }; | 146 }; |
| 146 | 147 |
| 147 #endif | 148 #endif |
| OLD | NEW |