OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrPendingProcessorStage_DEFINED | 8 #ifndef GrPendingProcessorStage_DEFINED |
9 #define GrPendingProcessorStage_DEFINED | 9 #define GrPendingProcessorStage_DEFINED |
10 | 10 |
11 #include "GrFragmentStage.h" | 11 #include "GrFragmentStage.h" |
12 #include "GrCoordTransform.h" | 12 #include "GrCoordTransform.h" |
13 #include "GrFragmentProcessor.h" | 13 #include "GrFragmentProcessor.h" |
14 #include "GrPendingProgramElement.h" | 14 #include "GrPendingProgramElement.h" |
15 #include "SkMatrix.h" | |
16 | 15 |
17 /** | 16 /** |
18 * This a baked variant of GrFragmentStage, as recorded in GrOptDrawState. | 17 * This a baked variant of GrFragmentStage, as recorded in GrOptDrawState. |
19 */ | 18 */ |
20 class GrPendingFragmentStage { | 19 class GrPendingFragmentStage { |
21 public: | 20 public: |
22 GrPendingFragmentStage(const GrFragmentStage& stage, bool ignoreMatrix) | 21 GrPendingFragmentStage(const GrFragmentStage& stage) : fProc(stage.processor
()) {} |
23 : fProc(stage.getProcessor()) | |
24 , fCoordChangeMatrix(ignoreMatrix ? SkMatrix::I() : stage.getCoordChangeMatr
ix()) { | |
25 } | |
26 | 22 |
27 GrPendingFragmentStage(const GrPendingFragmentStage& that) { *this = that; } | 23 GrPendingFragmentStage(const GrPendingFragmentStage& that) { *this = that; } |
28 | 24 |
29 GrPendingFragmentStage& operator=(const GrPendingFragmentStage& that) { | 25 GrPendingFragmentStage& operator=(const GrPendingFragmentStage& that) { |
30 fProc.reset(that.fProc.get()); | 26 fProc.reset(that.fProc.get()); |
31 fCoordChangeMatrix = that.fCoordChangeMatrix; | |
32 return *this; | 27 return *this; |
33 } | 28 } |
34 | 29 |
35 bool operator==(const GrPendingFragmentStage& that) const { | 30 bool operator==(const GrPendingFragmentStage& that) const { |
36 return this->getProcessor()->isEqual(*that.getProcessor()) && | 31 return this->processor()->isEqual(*that.processor()); |
37 fCoordChangeMatrix == that.fCoordChangeMatrix; | |
38 } | 32 } |
39 | 33 |
40 bool operator!=(const GrPendingFragmentStage& that) const { return !(*this =
= that); } | 34 bool operator!=(const GrPendingFragmentStage& that) const { return !(*this =
= that); } |
41 | 35 |
42 const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; } | |
43 | |
44 /** | 36 /** |
45 * For a coord transform on the fragment processor, does it or the coord cha
nge matrix (if | 37 * For a coord transform on the fragment processor, does it or the coord cha
nge matrix (if |
46 * relevant) contain perspective? | 38 * relevant) contain perspective? |
47 */ | 39 */ |
48 bool isPerspectiveCoordTransform(int matrixIndex) const { | 40 bool isPerspectiveCoordTransform(int matrixIndex) const { |
49 const GrCoordTransform& coordTransform = this->getProcessor()->coordTran
sform(matrixIndex); | 41 const GrCoordTransform& coordTransform = this->processor()->coordTransfo
rm(matrixIndex); |
50 uint32_t type = coordTransform.getMatrix().getType(); | 42 uint32_t type = coordTransform.getMatrix().getType(); |
51 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { | |
52 type |= this->getCoordChangeMatrix().getType(); | |
53 } | |
54 | |
55 return SkToBool(SkMatrix::kPerspective_Mask & type); | 43 return SkToBool(SkMatrix::kPerspective_Mask & type); |
56 } | 44 } |
57 | 45 |
58 const char* name() const { return fProc->name(); } | 46 const char* name() const { return fProc->name(); } |
59 | 47 |
60 const GrFragmentProcessor* getProcessor() const { return fProc.get(); } | 48 const GrFragmentProcessor* processor() const { return fProc.get(); } |
61 | 49 |
62 protected: | 50 protected: |
63 GrPendingProgramElement<const GrFragmentProcessor> fProc; | 51 GrPendingProgramElement<const GrFragmentProcessor> fProc; |
64 SkMatrix fCoordChangeMatrix; | |
65 }; | 52 }; |
66 #endif | 53 #endif |
OLD | NEW |