OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef GrPaint_DEFINED | 10 #ifndef GrPaint_DEFINED |
11 #define GrPaint_DEFINED | 11 #define GrPaint_DEFINED |
12 | 12 |
13 #include "GrColor.h" | 13 #include "GrColor.h" |
14 #include "GrFragmentStage.h" | 14 #include "GrFragmentStage.h" |
15 #include "GrXferProcessor.h" | 15 #include "GrXferProcessor.h" |
16 #include "effects/GrPorterDuffXferProcessor.h" | 16 #include "effects/GrPorterDuffXferProcessor.h" |
17 | 17 |
18 #include "SkXfermode.h" | 18 #include "SkXfermode.h" |
19 | 19 |
20 /** | 20 /** |
21 * The paint describes how color and coverage are computed at each pixel by GrCo
ntext draw | 21 * The paint describes how color and coverage are computed at each pixel by GrCo
ntext draw |
22 * functions and the how color is blended with the destination pixel. | 22 * functions and the how color is blended with the destination pixel. |
23 * | 23 * |
24 * The paint allows installation of custom color and coverage stages. New types
of stages are | 24 * The paint allows installation of custom color and coverage stages. New types
of stages are |
25 * created by subclassing GrProcessor. | 25 * created by subclassing GrProcessor. |
26 * | 26 * |
27 * The primitive color computation starts with the color specified by setColor()
. This color is the | 27 * The primitive color computation starts with the color specified by setColor()
. This color is the |
28 * input to the first color stage. Each color stage feeds its output to the next
color stage. | 28 * input to the first color stage. Each color stage feeds its output to the next
color stage. The |
| 29 * final color stage's output color is input to the color filter specified by |
| 30 * setXfermodeColorFilter which produces the final source color, S. |
29 * | 31 * |
30 * Fractional pixel coverage follows a similar flow. The coverage is initially t
he value specified | 32 * Fractional pixel coverage follows a similar flow. The coverage is initially t
he value specified |
31 * by setCoverage(). This is input to the first coverage stage. Coverage stages
are chained | 33 * by setCoverage(). This is input to the first coverage stage. Coverage stages
are chained |
32 * together in the same manner as color stages. The output of the last stage is
modulated by any | 34 * together in the same manner as color stages. The output of the last stage is
modulated by any |
33 * fractional coverage produced by anti-aliasing. This last step produces the fi
nal coverage, C. | 35 * fractional coverage produced by anti-aliasing. This last step produces the fi
nal coverage, C. |
34 * | 36 * |
35 * setXPFactory is used to control blending between the output color and dest. I
t also implements | 37 * setBlendFunc() specifies blending coefficients for S (described above) and D,
the initial value |
36 * the application of fractional coverage from the coverage pipeline. | 38 * of the destination pixel, labeled Bs and Bd respectively. The final value of
the destination |
| 39 * pixel is then D' = (1-C)*D + C*(Bd*D + Bs*S). |
| 40 * |
| 41 * Note that the coverage is applied after the blend. This is why they are compu
ted as distinct |
| 42 * values. |
| 43 * |
| 44 * TODO: Encapsulate setXfermodeColorFilter in a GrProcessor and remove from GrP
aint. |
37 */ | 45 */ |
38 class GrPaint { | 46 class GrPaint { |
39 public: | 47 public: |
40 GrPaint(); | 48 GrPaint(); |
41 | 49 |
42 GrPaint(const GrPaint& paint) { *this = paint; } | 50 GrPaint(const GrPaint& paint) { *this = paint; } |
43 | 51 |
44 ~GrPaint() {} | 52 ~GrPaint() {} |
45 | 53 |
46 /** | 54 /** |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 SkSTArray<4, GrFragmentStage> fColorStages; | 148 SkSTArray<4, GrFragmentStage> fColorStages; |
141 SkSTArray<2, GrFragmentStage> fCoverageStages; | 149 SkSTArray<2, GrFragmentStage> fCoverageStages; |
142 | 150 |
143 bool fAntiAlias; | 151 bool fAntiAlias; |
144 bool fDither; | 152 bool fDither; |
145 | 153 |
146 GrColor fColor; | 154 GrColor fColor; |
147 }; | 155 }; |
148 | 156 |
149 #endif | 157 #endif |
OLD | NEW |