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