| 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 GrFragmentProcessor_DEFINED | 8 #ifndef GrFragmentProcessor_DEFINED |
| 9 #define GrFragmentProcessor_DEFINED | 9 #define GrFragmentProcessor_DEFINED |
| 10 | 10 |
| 11 #include "GrProcessor.h" | 11 #include "GrProcessor.h" |
| 12 #include "GrStagedProcessor.h" | |
| 13 | 12 |
| 14 class GrCoordTransform; | 13 class GrCoordTransform; |
| 15 class GrGLSLCaps; | 14 class GrGLSLCaps; |
| 16 class GrGLFragmentProcessor; | 15 class GrGLFragmentProcessor; |
| 17 class GrProcessorKeyBuilder; | 16 class GrProcessorKeyBuilder; |
| 18 | 17 |
| 19 /** Provides custom fragment shader code. Fragment processors receive an input c
olor (vec4f) and | 18 /** Provides custom fragment shader code. Fragment processors receive an input c
olor (vec4f) and |
| 20 produce an output color. They may reference textures and uniforms. They may
use | 19 produce an output color. They may reference textures and uniforms. They may
use |
| 21 GrCoordTransforms to receive a transformation of the local coordinates that
map from local space | 20 GrCoordTransforms to receive a transformation of the local coordinates that
map from local space |
| 22 to the fragment being processed. | 21 to the fragment being processed. |
| 23 */ | 22 */ |
| 24 class GrFragmentProcessor : public GrProcessor { | 23 class GrFragmentProcessor : public GrProcessor { |
| 25 public: | 24 public: |
| 26 GrFragmentProcessor() | 25 GrFragmentProcessor() |
| 27 : INHERITED() | 26 : INHERITED() |
| 28 , fUsesLocalCoords(false) | 27 , fUsesLocalCoords(false) |
| 29 , fNumTexturesExclChildren(0) | 28 , fNumTexturesExclChildren(0) |
| 30 , fNumTransformsExclChildren(0) {} | 29 , fNumTransformsExclChildren(0) {} |
| 31 | 30 |
| 31 ~GrFragmentProcessor() override; |
| 32 |
| 32 GrGLFragmentProcessor* createGLInstance() const; | 33 GrGLFragmentProcessor* createGLInstance() const; |
| 33 | 34 |
| 34 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st { | 35 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st { |
| 35 this->onGetGLProcessorKey(caps, b); | 36 this->onGetGLProcessorKey(caps, b); |
| 36 for (int i = 0; i < fChildProcessors.count(); ++i) { | 37 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 37 fChildProcessors[i].processor()->getGLProcessorKey(caps, b); | 38 fChildProcessors[i]->getGLProcessorKey(caps, b); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 int numTexturesExclChildren() const { return fNumTexturesExclChildren; } | 42 int numTexturesExclChildren() const { return fNumTexturesExclChildren; } |
| 42 | 43 |
| 43 int numTransformsExclChildren() const { return fNumTransformsExclChildren; } | 44 int numTransformsExclChildren() const { return fNumTransformsExclChildren; } |
| 44 | 45 |
| 45 int numTransforms() const { return fCoordTransforms.count(); } | 46 int numTransforms() const { return fCoordTransforms.count(); } |
| 46 | 47 |
| 47 /** Returns the coordinate transformation at index. index must be valid acco
rding to | 48 /** Returns the coordinate transformation at index. index must be valid acco
rding to |
| 48 numTransforms(). */ | 49 numTransforms(). */ |
| 49 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran
sforms[index]; } | 50 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran
sforms[index]; } |
| 50 | 51 |
| 51 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const { | 52 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const { |
| 52 return fCoordTransforms; | 53 return fCoordTransforms; |
| 53 } | 54 } |
| 54 | 55 |
| 55 void gatherCoordTransforms(SkTArray<const GrCoordTransform*, true>* outTrans
forms) const { | 56 void gatherCoordTransforms(SkTArray<const GrCoordTransform*, true>* outTrans
forms) const { |
| 56 if (!fCoordTransforms.empty()) { | 57 if (!fCoordTransforms.empty()) { |
| 57 outTransforms->push_back_n(fCoordTransforms.count(), fCoordTransform
s.begin()); | 58 outTransforms->push_back_n(fCoordTransforms.count(), fCoordTransform
s.begin()); |
| 58 } | 59 } |
| 59 } | 60 } |
| 60 | 61 |
| 61 int numChildProcessors() const { return fChildProcessors.count(); } | 62 int numChildProcessors() const { return fChildProcessors.count(); } |
| 62 | 63 |
| 63 const GrFragmentProcessor& childProcessor(int index) const { | 64 const GrFragmentProcessor& childProcessor(int index) const { return *fChildP
rocessors[index]; } |
| 64 return *fChildProcessors[index].processor(); | |
| 65 } | |
| 66 | 65 |
| 67 /** Do any of the coordtransforms for this processor require local coords? *
/ | 66 /** Do any of the coordtransforms for this processor require local coords? *
/ |
| 68 bool usesLocalCoords() const { return fUsesLocalCoords; } | 67 bool usesLocalCoords() const { return fUsesLocalCoords; } |
| 69 | 68 |
| 70 /** Returns true if this and other processor conservatively draw identically
. It can only return | 69 /** Returns true if this and other processor conservatively draw identically
. It can only return |
| 71 true when the two processor are of the same subclass (i.e. they return t
he same object from | 70 true when the two processor are of the same subclass (i.e. they return t
he same object from |
| 72 from getFactory()). | 71 from getFactory()). |
| 73 | 72 |
| 74 A return value of true from isEqual() should not be used to test whether
the processor would | 73 A return value of true from isEqual() should not be used to test whether
the processor would |
| 75 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ | 74 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 * (C) (E) (F) | 168 * (C) (E) (F) |
| 170 * [c1] [e1,e2,e3] [f1,f2] | 169 * [c1] [e1,e2,e3] [f1,f2] |
| 171 * | 170 * |
| 172 * The same goes for fTextureAccesses with textures. | 171 * The same goes for fTextureAccesses with textures. |
| 173 */ | 172 */ |
| 174 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 173 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
| 175 | 174 |
| 176 int fNumTexturesExclChildren; | 175 int fNumTexturesExclChildren; |
| 177 int fNumTransformsExclChildren; | 176 int fNumTransformsExclChildren; |
| 178 | 177 |
| 179 SkTArray<GrFragmentStage, false> fChildProcessors; | 178 // TODO: These must convert their processors to pending-execution refs when
the parent is |
| 179 // converted (do this automatically in GrProgramElement?). |
| 180 SkTArray<const GrFragmentProcessor*, true> fChildProcessors; |
| 180 | 181 |
| 181 typedef GrProcessor INHERITED; | 182 typedef GrProcessor INHERITED; |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 #endif | 185 #endif |
| OLD | NEW |