OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 SkGrPriv_DEFINED | 8 #ifndef SkGrPriv_DEFINED |
9 #define SkGrPriv_DEFINED | 9 #define SkGrPriv_DEFINED |
10 | 10 |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
12 #include "GrBlend.h" | 12 #include "GrBlend.h" |
13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
15 #include "SkXfermode.h" | 15 #include "SkXfermode.h" |
16 | 16 |
17 class GrCaps; | 17 class GrCaps; |
18 class GrContext; | 18 class GrContext; |
| 19 class GrDrawContext; |
19 class GrFragmentProcessor; | 20 class GrFragmentProcessor; |
20 class GrPaint; | 21 class GrPaint; |
21 class GrTexture; | 22 class GrTexture; |
22 class GrTextureParams; | 23 class GrTextureParams; |
23 class GrUniqueKey; | 24 class GrUniqueKey; |
24 class SkData; | 25 class SkData; |
25 class SkPaint; | 26 class SkPaint; |
26 class SkPixelRef; | 27 class SkPixelRef; |
27 struct SkIRect; | 28 struct SkIRect; |
28 | 29 |
(...skipping 10 matching lines...) Expand all Loading... |
39 */ | 40 */ |
40 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
geBounds); | 41 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
geBounds); |
41 | 42 |
42 /** Call this after installing a GrUniqueKey on texture. It will cause the textu
re's key to be | 43 /** Call this after installing a GrUniqueKey on texture. It will cause the textu
re's key to be |
43 removed should the bitmap's contents change or be destroyed. */ | 44 removed should the bitmap's contents change or be destroyed. */ |
44 void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix
elRef); | 45 void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix
elRef); |
45 | 46 |
46 /** Converts an SkPaint to a GrPaint for a given GrContext. The matrix is requir
ed in order | 47 /** Converts an SkPaint to a GrPaint for a given GrContext. The matrix is requir
ed in order |
47 to convert the SkShader (if any) on the SkPaint. The primitive itself has no
color. */ | 48 to convert the SkShader (if any) on the SkPaint. The primitive itself has no
color. */ |
48 bool SkPaintToGrPaint(GrContext*, | 49 bool SkPaintToGrPaint(GrContext*, |
| 50 GrDrawContext*, |
49 const SkPaint& skPaint, | 51 const SkPaint& skPaint, |
50 const SkMatrix& viewM, | 52 const SkMatrix& viewM, |
51 bool allowSRGBInputs, | |
52 SkColorSpace* dstColorSpace, | |
53 GrPaint* grPaint); | 53 GrPaint* grPaint); |
54 | 54 |
55 /** Same as above but ignores the SkShader (if any) on skPaint. */ | 55 /** Same as above but ignores the SkShader (if any) on skPaint. */ |
56 bool SkPaintToGrPaintNoShader(GrContext* context, | 56 bool SkPaintToGrPaintNoShader(GrContext* context, |
| 57 GrDrawContext* dc, |
57 const SkPaint& skPaint, | 58 const SkPaint& skPaint, |
58 bool allowSRGBInputs, | |
59 SkColorSpace* dstColorSpace, | |
60 GrPaint* grPaint); | 59 GrPaint* grPaint); |
61 | 60 |
62 /** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProce
ssor. The processor | 61 /** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProce
ssor. The processor |
63 should expect an unpremul input color and produce a premultiplied output col
or. There is | 62 should expect an unpremul input color and produce a premultiplied output col
or. There is |
64 no primitive color. */ | 63 no primitive color. */ |
65 bool SkPaintToGrPaintReplaceShader(GrContext*, | 64 bool SkPaintToGrPaintReplaceShader(GrContext*, |
| 65 GrDrawContext*, |
66 const SkPaint& skPaint, | 66 const SkPaint& skPaint, |
67 sk_sp<GrFragmentProcessor> shaderFP, | 67 sk_sp<GrFragmentProcessor> shaderFP, |
68 bool allowSRGBInputs, | |
69 SkColorSpace* dstColorSpace, | |
70 GrPaint* grPaint); | 68 GrPaint* grPaint); |
71 | 69 |
72 /** Blends the SkPaint's shader (or color if no shader) with the color which spe
cified via a | 70 /** Blends the SkPaint's shader (or color if no shader) with the color which spe
cified via a |
73 GrBatch's GrPrimitiveProcesssor. Currently there is a bool param to indicate
whether the | 71 GrBatch's GrPrimitiveProcesssor. Currently there is a bool param to indicate
whether the |
74 primitive color is the dst or src color to the blend in order to work around
differences between | 72 primitive color is the dst or src color to the blend in order to work around
differences between |
75 drawVertices and drawAtlas. */ | 73 drawVertices and drawAtlas. */ |
76 bool SkPaintToGrPaintWithXfermode(GrContext* context, | 74 bool SkPaintToGrPaintWithXfermode(GrContext* context, |
| 75 GrDrawContext* dc, |
77 const SkPaint& skPaint, | 76 const SkPaint& skPaint, |
78 const SkMatrix& viewM, | 77 const SkMatrix& viewM, |
79 SkXfermode::Mode primColorMode, | 78 SkXfermode::Mode primColorMode, |
80 bool primitiveIsSrc, | 79 bool primitiveIsSrc, |
81 bool allowSRGBInputs, | |
82 SkColorSpace* dstColorSpace, | |
83 GrPaint* grPaint); | 80 GrPaint* grPaint); |
84 | 81 |
85 /** This is used when there is a primitive color, but the shader should be ignor
ed. Currently, | 82 /** This is used when there is a primitive color, but the shader should be ignor
ed. Currently, |
86 the expectation is that the primitive color will be premultiplied, though it
really should be | 83 the expectation is that the primitive color will be premultiplied, though it
really should be |
87 unpremultiplied so that interpolation is done in unpremul space. The paint's
alpha will be | 84 unpremultiplied so that interpolation is done in unpremul space. The paint's
alpha will be |
88 applied to the primitive color after interpolation. */ | 85 applied to the primitive color after interpolation. */ |
89 inline bool SkPaintToGrPaintWithPrimitiveColor(GrContext* context, const SkPaint
& skPaint, | 86 inline bool SkPaintToGrPaintWithPrimitiveColor(GrContext* context, GrDrawContext
* dc, |
90 bool allowSRGBInputs, SkColorSpac
e* dstColorSpace, | 87 const SkPaint& skPaint, GrPaint*
grPaint) { |
91 GrPaint* grPaint) { | 88 return SkPaintToGrPaintWithXfermode(context, dc, skPaint, SkMatrix::I(), SkX
fermode::kDst_Mode, |
92 return SkPaintToGrPaintWithXfermode(context, skPaint, SkMatrix::I(), SkXferm
ode::kDst_Mode, | 89 false, grPaint); |
93 false, allowSRGBInputs, dstColorSpace, g
rPaint); | |
94 } | 90 } |
95 | 91 |
96 /** This is used when there may or may not be a shader, and the caller wants to
plugin a texture | 92 /** This is used when there may or may not be a shader, and the caller wants to
plugin a texture |
97 lookup. If there is a shader, then its output will only be used if the text
ure is alpha8. */ | 93 lookup. If there is a shader, then its output will only be used if the text
ure is alpha8. */ |
98 bool SkPaintToGrPaintWithTexture(GrContext* context, | 94 bool SkPaintToGrPaintWithTexture(GrContext* context, |
| 95 GrDrawContext* dc, |
99 const SkPaint& paint, | 96 const SkPaint& paint, |
100 const SkMatrix& viewM, | 97 const SkMatrix& viewM, |
101 sk_sp<GrFragmentProcessor> fp, | 98 sk_sp<GrFragmentProcessor> fp, |
102 bool textureIsAlphaOnly, | 99 bool textureIsAlphaOnly, |
103 bool allowSRGBInputs, | |
104 SkColorSpace* dstColorSpace, | |
105 GrPaint* grPaint); | 100 GrPaint* grPaint); |
106 | 101 |
107 ////////////////////////////////////////////////////////////////////////////// | 102 ////////////////////////////////////////////////////////////////////////////// |
108 | 103 |
109 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&); | 104 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&); |
110 | 105 |
111 bool GrPixelConfigToColorType(GrPixelConfig, SkColorType*); | 106 bool GrPixelConfigToColorType(GrPixelConfig, SkColorType*); |
112 | 107 |
113 /** | 108 /** |
114 * If the compressed data in the SkData is supported (as a texture format, this
returns | 109 * If the compressed data in the SkData is supported (as a texture format, this
returns |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); | 148 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); |
154 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); | 149 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); |
155 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); | 150 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); |
156 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); | 151 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); |
157 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); | 152 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); |
158 GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10); | 153 GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10); |
159 | 154 |
160 #define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X)) | 155 #define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X)) |
161 | 156 |
162 #endif | 157 #endif |
OLD | NEW |