Chromium Code Reviews| 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 GrXferProcessor_DEFINED | 8 #ifndef GrXferProcessor_DEFINED |
| 9 #define GrXferProcessor_DEFINED | 9 #define GrXferProcessor_DEFINED |
| 10 | 10 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrFragmentProcessor.h" | 12 #include "GrProcessor.h" |
| 13 #include "GrTypes.h" | 13 #include "GrTypes.h" |
| 14 #include "SkXfermode.h" | 14 #include "SkXfermode.h" |
| 15 | 15 |
| 16 class GrDrawTargetCaps; | |
| 17 class GrGLCaps; | |
| 18 class GrGLXferProcessor; | |
| 16 class GrProcOptInfo; | 19 class GrProcOptInfo; |
| 17 | 20 |
| 18 /** | 21 /** |
| 19 * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst | 22 * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst |
| 20 * color. It does this by emitting fragment shader code and controlling the fixe d-function blend | 23 * color. It does this by emitting fragment shader code and controlling the fixe d-function blend |
| 21 * state. The inputs to its shader code are the final computed src color and fra ctional pixel | 24 * state. The inputs to its shader code are the final computed src color and fra ctional pixel |
| 22 * coverage. The GrXferProcessor's shader code writes the fragment shader output color that goes | 25 * coverage. The GrXferProcessor's shader code writes the fragment shader output color that goes |
| 23 * into the fixed-function blend. When dual-source blending is available, it may also write a | 26 * into the fixed-function blend. When dual-source blending is available, it may also write a |
| 24 * seconday fragment shader output color. When allowed by the backend API, the G rXferProcessor may | 27 * seconday fragment shader output color. When allowed by the backend API, the G rXferProcessor may |
| 25 * read the destination color. The GrXferProcessor is responsible for setting th e blend coefficients | 28 * read the destination color. The GrXferProcessor is responsible for setting th e blend coefficients |
| 26 * and blend constant color. | 29 * and blend constant color. |
| 27 * | 30 * |
| 28 * A GrXferProcessor is never installed directly into our draw state, but instea d is created from a | 31 * A GrXferProcessor is never installed directly into our draw state, but instea d is created from a |
| 29 * GrXPFactory once we have finalized the state of our draw. | 32 * GrXPFactory once we have finalized the state of our draw. |
| 30 */ | 33 */ |
| 31 class GrXferProcessor : public GrFragmentProcessor { | 34 class GrXferProcessor : public GrProcessor { |
| 32 public: | 35 public: |
| 36 /** Implemented using GLFragmentProcessor::GenKey as described in this class 's comment. */ | |
|
bsalomon
2014/12/08 19:58:59
Is this comment correct?
egdaniel
2014/12/09 21:10:46
Nope no longer, updated.
| |
| 37 virtual void getGLProcessorKey(const GrGLCaps& caps, | |
| 38 GrProcessorKeyBuilder* b) const = 0; | |
| 39 | |
| 40 /** Returns a new instance of the appropriate *GL* implementation class | |
| 41 for the given GrXferProcessor; caller is responsible for deleting | |
| 42 the object. */ | |
| 43 virtual GrGLXferProcessor* createGLInstance() const = 0; | |
| 44 | |
| 33 /** | 45 /** |
| 34 * Optimizations for blending / coverage that an OptDrawState should apply t o itself. | 46 * Optimizations for blending / coverage that an OptDrawState should apply t o itself. |
| 35 */ | 47 */ |
| 36 enum OptFlags { | 48 enum OptFlags { |
| 37 /** | 49 /** |
| 38 * No optimizations needed | 50 * No optimizations needed |
| 39 */ | 51 */ |
| 40 kNone_Opt = 0, | 52 kNone_Opt = 0, |
| 41 /** | 53 /** |
| 42 * The draw can be skipped completely. | 54 * The draw can be skipped completely. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 67 * and color/coverage values for its draw. | 79 * and color/coverage values for its draw. |
| 68 */ | 80 */ |
| 69 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X P. | 81 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X P. |
| 70 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o wn XP. | 82 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o wn XP. |
| 71 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 83 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
| 72 const GrProcOptInfo& coveragePOI, | 84 const GrProcOptInfo& coveragePOI, |
| 73 bool isCoverageDrawing, | 85 bool isCoverageDrawing, |
| 74 bool colorWriteDisabled, | 86 bool colorWriteDisabled, |
| 75 bool doesStencilWrite, | 87 bool doesStencilWrite, |
| 76 GrColor* color, | 88 GrColor* color, |
| 77 uint8_t* coverage) = 0; | 89 uint8_t* coverage, |
| 90 const GrDrawTargetCaps& caps) = 0; | |
| 78 | 91 |
| 79 struct BlendInfo { | 92 struct BlendInfo { |
| 80 GrBlendCoeff fSrcBlend; | 93 GrBlendCoeff fSrcBlend; |
| 81 GrBlendCoeff fDstBlend; | 94 GrBlendCoeff fDstBlend; |
| 82 GrColor fBlendConstant; | 95 GrColor fBlendConstant; |
| 83 }; | 96 }; |
| 84 | 97 |
| 85 virtual void getBlendInfo(BlendInfo* blendInfo) const = 0; | 98 virtual void getBlendInfo(BlendInfo* blendInfo) const = 0; |
| 86 | 99 |
| 87 /** Will this prceossor read the destination pixel value? */ | 100 /** Will this prceossor read the destination pixel value? */ |
| 88 bool willReadDstColor() const { return fWillReadDstColor; } | 101 bool willReadDstColor() const { return fWillReadDstColor; } |
| 89 | 102 |
| 103 virtual bool hasSecondaryOutput() const { return false; } | |
|
bsalomon
2014/12/08 19:58:58
Document?
egdaniel
2014/12/09 21:10:46
Done.
| |
| 104 | |
| 105 /** Returns true if this and other processor conservatively draw identically . It can only return | |
| 106 true when the two processor are of the same subclass (i.e. they return t he same object from | |
| 107 from getFactory()). | |
| 108 | |
| 109 A return value of true from isEqual() should not be used to test whether the processor would | |
| 110 generate the same shader code. To test for identical code generation use getGLProcessorKey*/ | |
| 111 | |
| 112 bool isEqual(const GrXferProcessor& that) const { | |
| 113 if (this->classID() != that.classID()) { | |
| 114 return false; | |
| 115 } | |
| 116 return this->onIsEqual(that); | |
| 117 } | |
| 118 | |
| 119 | |
| 90 protected: | 120 protected: |
| 91 GrXferProcessor() : fWillReadDstColor(false) {} | 121 GrXferProcessor() : fWillReadDstColor(false) {} |
| 92 | 122 |
| 93 /** | 123 /** |
| 94 * If the prceossor subclass will read the destination pixel value then it m ust call this | 124 * If the prceossor subclass will read the destination pixel value then it m ust call this |
| 95 * function from its constructor. Otherwise, when its generated backend-spec ific prceossor class | 125 * function from its constructor. Otherwise, when its generated backend-spec ific prceossor class |
| 96 * attempts to generate code that reads the destination pixel it will fail. | 126 * attempts to generate code that reads the destination pixel it will fail. |
| 97 */ | 127 */ |
| 98 void setWillReadDstColor() { fWillReadDstColor = true; } | 128 void setWillReadDstColor() { fWillReadDstColor = true; } |
| 99 | 129 |
| 100 private: | 130 private: |
| 131 virtual bool onIsEqual(const GrXferProcessor&) const = 0; | |
| 101 | 132 |
| 102 bool fWillReadDstColor; | 133 bool fWillReadDstColor; |
| 103 | 134 |
| 104 typedef GrFragmentProcessor INHERITED; | 135 typedef GrFragmentProcessor INHERITED; |
| 105 }; | 136 }; |
| 106 | 137 |
| 107 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); | 138 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); |
| 108 | 139 |
| 109 /** | 140 /** |
| 110 * We install a GrXPFactory (XPF) early on in the pipeline before all the final draw information is | 141 * We install a GrXPFactory (XPF) early on in the pipeline before all the final draw information is |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 enum { | 236 enum { |
| 206 kIllegalXPFClassID = 0, | 237 kIllegalXPFClassID = 0, |
| 207 }; | 238 }; |
| 208 static int32_t gCurrXPFClassID; | 239 static int32_t gCurrXPFClassID; |
| 209 | 240 |
| 210 typedef GrProgramElement INHERITED; | 241 typedef GrProgramElement INHERITED; |
| 211 }; | 242 }; |
| 212 | 243 |
| 213 #endif | 244 #endif |
| 214 | 245 |
| OLD | NEW |