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 | |
10 | |
11 #ifndef SkGr_DEFINED | 9 #ifndef SkGr_DEFINED |
12 #define SkGr_DEFINED | 10 #define SkGr_DEFINED |
13 | 11 |
14 #include <stddef.h> | 12 #include "GrColor.h" |
| 13 #include "GrTextureAccess.h" |
| 14 #include "SkColor.h" |
| 15 #include "SkColorPriv.h" |
| 16 #include "SkFilterQuality.h" |
| 17 #include "SkImageInfo.h" |
15 | 18 |
16 // Gr headers | 19 class GrContext; |
17 #include "GrContext.h" | 20 class GrTexture; |
18 #include "GrTextureAccess.h" | 21 class GrTextureParams; |
19 #include "GrTypes.h" | 22 class SkBitmap; |
20 | |
21 // skia headers | |
22 #include "SkBitmap.h" | |
23 #include "SkPath.h" | |
24 #include "SkPoint.h" | |
25 #include "SkRegion.h" | |
26 #include "SkClipStack.h" | |
27 | 23 |
28 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
29 // Sk to Gr Type conversions | 25 // Sk to Gr Type conversions |
30 | 26 |
31 GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff); | |
32 GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff); | |
33 GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff); | |
34 GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff); | |
35 GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff); | |
36 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); | |
37 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); | |
38 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); | |
39 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); | |
40 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); | |
41 GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10); | |
42 | |
43 #define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X)) | |
44 | |
45 /////////////////////////////////////////////////////////////////////////////// | |
46 | |
47 #include "SkColorPriv.h" | |
48 | |
49 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfile
Type); | |
50 | |
51 static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) { | |
52 return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.pr
ofileType()); | |
53 } | |
54 | |
55 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfi
leType*); | |
56 | |
57 static inline GrColor SkColorToPremulGrColor(SkColor c) { | 27 static inline GrColor SkColorToPremulGrColor(SkColor c) { |
58 SkPMColor pm = SkPreMultiplyColor(c); | 28 SkPMColor pm = SkPreMultiplyColor(c); |
59 unsigned r = SkGetPackedR32(pm); | 29 unsigned r = SkGetPackedR32(pm); |
60 unsigned g = SkGetPackedG32(pm); | 30 unsigned g = SkGetPackedG32(pm); |
61 unsigned b = SkGetPackedB32(pm); | 31 unsigned b = SkGetPackedB32(pm); |
62 unsigned a = SkGetPackedA32(pm); | 32 unsigned a = SkGetPackedA32(pm); |
63 return GrColorPackRGBA(r, g, b, a); | 33 return GrColorPackRGBA(r, g, b, a); |
64 } | 34 } |
65 | 35 |
66 static inline GrColor SkColorToUnpremulGrColor(SkColor c) { | 36 static inline GrColor SkColorToUnpremulGrColor(SkColor c) { |
(...skipping 20 matching lines...) Expand all Loading... |
87 static inline SkPMColor GrColorToSkPMColor(GrColor c) { | 57 static inline SkPMColor GrColorToSkPMColor(GrColor c) { |
88 GrColorIsPMAssert(c); | 58 GrColorIsPMAssert(c); |
89 return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c),
GrColorUnpackB(c)); | 59 return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c),
GrColorUnpackB(c)); |
90 } | 60 } |
91 | 61 |
92 static inline GrColor SkPMColorToGrColor(SkPMColor c) { | 62 static inline GrColor SkPMColorToGrColor(SkPMColor c) { |
93 return GrColorPackRGBA(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(
c), | 63 return GrColorPackRGBA(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(
c), |
94 SkGetPackedA32(c)); | 64 SkGetPackedA32(c)); |
95 } | 65 } |
96 | 66 |
97 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&); | |
98 | |
99 //////////////////////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////////////////////// |
100 | 68 |
101 /** | |
102 * If the compressed data in the SkData is supported (as a texture format, this
returns | |
103 * the pixel-config that should be used, and sets outStartOfDataToUpload to the
ptr into | |
104 * the data where the actual raw data starts (skipping any header bytes). | |
105 * | |
106 * If the compressed data is not supported, this returns kUnknown_GrPixelConfig
, and | |
107 * ignores outStartOfDataToUpload. | |
108 */ | |
109 GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data, | |
110 int expectedW, int expectedH, | |
111 const void** outStartOfDataToUp
load); | |
112 | |
113 bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& sub
set, | |
114 GrTexture* nativeTexture, const GrTextureParams*); | |
115 | |
116 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTexture
Params*); | 69 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTexture
Params*); |
117 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, SkImageUsageTyp
e); | 70 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, SkImageUsageTyp
e); |
118 | 71 |
119 GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey,
GrSurfaceDesc, | 72 // TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWin
dow its subclasses). |
120 SkPixelRef* pixelRefForInvalidationNotificat
ionOrNull, | 73 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfile
Type); |
121 const void* pixels, size_t rowBytesOrZero); | |
122 | 74 |
123 //////////////////////////////////////////////////////////////////////////////// | 75 static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) { |
124 | 76 return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.pr
ofileType()); |
125 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque); | 77 } |
126 | |
127 // Using the dreaded SkGrPixelRef ... | |
128 SK_API void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, | |
129 SkBitmap* dst); | |
130 | 78 |
131 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, | 79 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, |
132 const SkMatrix& view
M, | 80 const SkMatrix& view
M, |
133 const SkMatrix& loca
lM, | 81 const SkMatrix& loca
lM, |
134 bool* doBicubic); | 82 bool* doBicubic); |
135 | 83 |
136 //////////////////////////////////////////////////////////////////////////////// | 84 //////////////////////////////////////////////////////////////////////////////// |
137 // Classes | |
138 | 85 |
139 class SkGlyphCache; | 86 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque); |
140 | 87 |
141 //////////////////////////////////////////////////////////////////////////////// | 88 // Using the dreaded SkGrPixelRef ... |
| 89 SK_API void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, |
| 90 SkBitmap* dst); |
142 | 91 |
143 #endif | 92 #endif |
OLD | NEW |