OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrXferProcessor_DEFINED |
| 9 #define GrXferProcessor_DEFINED |
| 10 |
| 11 #include "GrColor.h" |
| 12 #include "GrFragmentProcessor.h" |
| 13 #include "GrTypes.h" |
| 14 #include "SkXfermode.h" |
| 15 |
| 16 /** |
| 17 * GrXferProcessor is responsible for implementing the xfer mode that blends the
src color and dst |
| 18 * color. It does this by emitting fragment shader code and controlling the fixe
d-function blend |
| 19 * state. The inputs to its shader code are the final computed src color and fra
ctional pixel |
| 20 * coverage. The GrXferProcessor's shader code writes the fragment shader output
color that goes |
| 21 * into the fixed-function blend. When dual-source blending is available, it may
also write a |
| 22 * seconday fragment shader output color. When allowed by the backend API, the G
rXferProcessor may |
| 23 * read the destination color. The GrXferProcessor is responsible for setting th
e blend coefficients |
| 24 * and blend constant color. |
| 25 * |
| 26 * A GrXferProcessor is never installed directly into our draw state, but instea
d is created from a |
| 27 * GrXPFactory once we have finalized the state of our draw. |
| 28 */ |
| 29 class GrXferProcessor : public GrFragmentProcessor { |
| 30 private: |
| 31 |
| 32 typedef GrFragmentProcessor INHERITED; |
| 33 }; |
| 34 |
| 35 /** |
| 36 * We install a GrXPFactory (XPF) early on in the pipeline before all the final
draw information is |
| 37 * known (e.g. whether there is fractional pixel coverage, will coverage be 1 or
4 channel, is the |
| 38 * draw opaque, etc.). Once the state of the draw is finalized, we use the XPF a
long with all the |
| 39 * draw information to create a GrXferProcessor (XP) which can implement the des
ired blending for |
| 40 * the draw. |
| 41 * |
| 42 * Before the XP is created, the XPF is able to answer queries about what functi
onality the XPs it |
| 43 * creates will have. For example, can it create an XP that supports RGB coverag
e or will the XP |
| 44 * blend with the destination color. |
| 45 */ |
| 46 class GrXPFactory : public GrProgramElement { |
| 47 public: |
| 48 virtual const GrXferProcessor* createXferProcessor() const = 0; |
| 49 |
| 50 /** |
| 51 * This function returns true if the GrXferProcessor generated from this fac
tory will be able to |
| 52 * correctly blend when using RGB coverage. The knownColor and knownColorFla
gs represent the |
| 53 * final computed color from the color stages. |
| 54 */ |
| 55 virtual bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlag
s) const = 0; |
| 56 |
| 57 private: |
| 58 typedef GrProgramElement INHERITED; |
| 59 }; |
| 60 |
| 61 #endif |
| 62 |
OLD | NEW |