OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "SkColorPriv.h" | 47 #include "SkColorPriv.h" |
48 | 48 |
49 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfile
Type); | 49 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfile
Type); |
50 | 50 |
51 static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) { | 51 static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) { |
52 return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.pr
ofileType()); | 52 return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.pr
ofileType()); |
53 } | 53 } |
54 | 54 |
55 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfi
leType*); | 55 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfi
leType*); |
56 | 56 |
57 static inline GrColor SkColor2GrColor(SkColor c) { | 57 static inline GrColor SkColorToPremulGrColor(SkColor c) { |
58 SkPMColor pm = SkPreMultiplyColor(c); | 58 SkPMColor pm = SkPreMultiplyColor(c); |
59 unsigned r = SkGetPackedR32(pm); | 59 unsigned r = SkGetPackedR32(pm); |
60 unsigned g = SkGetPackedG32(pm); | 60 unsigned g = SkGetPackedG32(pm); |
61 unsigned b = SkGetPackedB32(pm); | 61 unsigned b = SkGetPackedB32(pm); |
62 unsigned a = SkGetPackedA32(pm); | 62 unsigned a = SkGetPackedA32(pm); |
63 return GrColorPackRGBA(r, g, b, a); | 63 return GrColorPackRGBA(r, g, b, a); |
64 } | 64 } |
65 | 65 |
66 static inline GrColor SkColor2GrColorJustAlpha(SkColor c) { | 66 static inline GrColor SkColorToUnpremulGrColor(SkColor c) { |
| 67 unsigned r = SkColorGetR(c); |
| 68 unsigned g = SkColorGetG(c); |
| 69 unsigned b = SkColorGetB(c); |
| 70 unsigned a = SkColorGetA(c); |
| 71 return GrColorPackRGBA(r, g, b, a); |
| 72 } |
| 73 |
| 74 static inline GrColor SkColorToOpaqueGrColor(SkColor c) { |
| 75 unsigned r = SkColorGetR(c); |
| 76 unsigned g = SkColorGetG(c); |
| 77 unsigned b = SkColorGetB(c); |
| 78 return GrColorPackRGBA(r, g, b, 0xFF); |
| 79 } |
| 80 |
| 81 /** Replicates the SkColor's alpha to all four channels of the GrColor. */ |
| 82 static inline GrColor SkColorAlphaToGrColor(SkColor c) { |
67 U8CPU a = SkColorGetA(c); | 83 U8CPU a = SkColorGetA(c); |
68 return GrColorPackRGBA(a, a, a, a); | 84 return GrColorPackRGBA(a, a, a, a); |
69 } | 85 } |
70 | 86 |
71 static inline SkPMColor GrColorToSkPMColor(GrColor c) { | 87 static inline SkPMColor GrColorToSkPMColor(GrColor c) { |
72 GrColorIsPMAssert(c); | 88 GrColorIsPMAssert(c); |
73 return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c),
GrColorUnpackB(c)); | 89 return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c),
GrColorUnpackB(c)); |
74 } | 90 } |
75 | 91 |
76 static inline GrColor SkPMColorToGrColor(SkPMColor c) { | 92 static inline GrColor SkPMColorToGrColor(SkPMColor c) { |
(...skipping 24 matching lines...) Expand all Loading... |
101 | 117 |
102 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTexture
Params*); | 118 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTexture
Params*); |
103 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, SkImageUsageTyp
e); | 119 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, SkImageUsageTyp
e); |
104 | 120 |
105 GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey,
GrSurfaceDesc, | 121 GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey,
GrSurfaceDesc, |
106 SkPixelRef* pixelRefForInvalidationNotificat
ionOrNull, | 122 SkPixelRef* pixelRefForInvalidationNotificat
ionOrNull, |
107 const void* pixels, size_t rowBytesOrZero); | 123 const void* pixels, size_t rowBytesOrZero); |
108 | 124 |
109 //////////////////////////////////////////////////////////////////////////////// | 125 //////////////////////////////////////////////////////////////////////////////// |
110 | 126 |
111 // Converts a SkPaint to a GrPaint, ignoring the SkPaint's shader. | |
112 // Sets the color of GrPaint to the value of the parameter paintColor | |
113 // Callers may subsequently modify the GrPaint. Setting constantColor indicates | |
114 // that the final paint will draw the same color at every pixel. This allows | |
115 // an optimization where the color filter can be applied to the SkPaint's | |
116 // color once while converting to GrPaint and then ignored. TODO: Remove this | |
117 // bool and use the invariant info to automatically apply the color filter. | |
118 bool SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
paintColor, | |
119 bool constantColor, GrPaint* grPaint); | |
120 | |
121 // This function is similar to skPaint2GrPaintNoShader but also converts | |
122 // skPaint's shader to a GrFragmentProcessor if possible. | |
123 // constantColor has the same meaning as in skPaint2GrPaintNoShader. | |
124 bool SkPaint2GrPaint(GrContext* context, const SkPaint& skPaint, const SkMatrix&
viewM, | |
125 bool constantColor, GrPaint* grPaint); | |
126 | |
127 | |
128 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque); | 127 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque); |
129 | 128 |
130 // Using the dreaded SkGrPixelRef ... | 129 // Using the dreaded SkGrPixelRef ... |
131 SK_API void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, | 130 SK_API void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, |
132 SkBitmap* dst); | 131 SkBitmap* dst); |
133 | 132 |
134 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, | 133 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, |
135 const SkMatrix& view
M, | 134 const SkMatrix& view
M, |
136 const SkMatrix& loca
lM, | 135 const SkMatrix& loca
lM, |
137 bool* doBicubic); | 136 bool* doBicubic); |
138 | 137 |
139 //////////////////////////////////////////////////////////////////////////////// | 138 //////////////////////////////////////////////////////////////////////////////// |
140 // Classes | 139 // Classes |
141 | 140 |
142 class SkGlyphCache; | 141 class SkGlyphCache; |
143 | 142 |
144 //////////////////////////////////////////////////////////////////////////////// | 143 //////////////////////////////////////////////////////////////////////////////// |
145 | 144 |
146 #endif | 145 #endif |
OLD | NEW |