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 GrFragmentProcessor; | 19 class GrFragmentProcessor; |
20 class GrPaint; | 20 class GrPaint; |
21 class GrTexture; | 21 class GrTexture; |
22 class GrTextureParams; | 22 class GrTextureParams; |
23 class GrUniqueKey; | 23 class GrUniqueKey; |
24 class SkData; | 24 class SkData; |
25 class SkPaint; | 25 class SkPaint; |
26 class SkPixelRef; | 26 class SkPixelRef; |
27 struct SkIRect; | 27 struct SkIRect; |
28 | 28 |
29 struct SkGrStretch { | |
30 enum Type { | |
31 kNone_Type, | |
32 kBilerp_Type, | |
33 kNearest_Type | |
34 } fType; | |
35 int fWidth; | |
36 int fHeight; | |
37 }; | |
38 | |
39 /** | 29 /** |
40 * Our key includes the offset, width, and height so that bitmaps created by ex
tractSubset() | 30 * Our key includes the offset, width, and height so that bitmaps created by ex
tractSubset() |
41 * are unique. | 31 * are unique. |
42 * | 32 * |
43 * The imageID is in the shared namespace (see SkNextID::ImageID() | 33 * The imageID is in the shared namespace (see SkNextID::ImageID()) |
44 * - SkBitmap/SkPixelRef | 34 * - SkBitmap/SkPixelRef |
45 * - SkImage | 35 * - SkImage |
46 * - SkImageGenerator | 36 * - SkImageGenerator |
47 * | 37 * |
48 * Note: width/height must fit in 16bits for this impl. | 38 * Note: width/height must fit in 16bits for this impl. |
49 */ | 39 */ |
50 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
geBounds, | 40 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
geBounds); |
51 const GrCaps&, const GrTextureParams&); | |
52 | |
53 /** | |
54 * Given an "unstretched" key, and a stretch rec, produce a stretched key. | |
55 */ | |
56 bool GrMakeStretchedKey(const GrUniqueKey& origKey, const SkGrStretch&, GrUnique
Key* stretchedKey); | |
57 | 41 |
58 /** Converts an SkPaint to a GrPaint for a given GrContext. The matrix is requir
ed in order | 42 /** Converts an SkPaint to a GrPaint for a given GrContext. The matrix is requir
ed in order |
59 to convert the SkShader (if any) on the SkPaint. The primitive itself has no
color. */ | 43 to convert the SkShader (if any) on the SkPaint. The primitive itself has no
color. */ |
60 bool SkPaintToGrPaint(GrContext*, | 44 bool SkPaintToGrPaint(GrContext*, |
61 const SkPaint& skPaint, | 45 const SkPaint& skPaint, |
62 const SkMatrix& viewM, | 46 const SkMatrix& viewM, |
63 GrPaint* grPaint); | 47 GrPaint* grPaint); |
64 | 48 |
65 /** Same as above but ignores the SkShader (if any) on skPaint. */ | 49 /** Same as above but ignores the SkShader (if any) on skPaint. */ |
66 bool SkPaintToGrPaintNoShader(GrContext* context, | 50 bool SkPaintToGrPaintNoShader(GrContext* context, |
(...skipping 29 matching lines...) Expand all Loading... |
96 false, grPaint); | 80 false, grPaint); |
97 } | 81 } |
98 | 82 |
99 ////////////////////////////////////////////////////////////////////////////// | 83 ////////////////////////////////////////////////////////////////////////////// |
100 | 84 |
101 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&); | 85 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&); |
102 | 86 |
103 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfi
leType*); | 87 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfi
leType*); |
104 | 88 |
105 /** | 89 /** |
106 * If the compressed data in the SkData is supported (as a texture format, this
returns | 90 * If the compressed data in the SkData is supported (as a texture format, this
returns |
107 * the pixel-config that should be used, and sets outStartOfDataToUpload to the
ptr into | 91 * the pixel-config that should be used, and sets outStartOfDataToUpload to the
ptr into |
108 * the data where the actual raw data starts (skipping any header bytes). | 92 * the data where the actual raw data starts (skipping any header bytes). |
109 * | 93 * |
110 * If the compressed data is not supported, this returns kUnknown_GrPixelConfig,
and | 94 * If the compressed data is not supported, this returns kUnknown_GrPixelConfig
, and |
111 * ignores outStartOfDataToUpload. | 95 * ignores outStartOfDataToUpload. |
112 */ | 96 */ |
113 GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data, | 97 GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data, |
114 int expectedW, int expectedH, | 98 int expectedW, int expectedH, |
115 const void** outStartOfDataToUp
load); | 99 const void** outStartOfDataToUp
load); |
116 | 100 |
117 GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey,
GrSurfaceDesc, | |
118 SkPixelRef* pixelRefForInvalidationNotificat
ionOrNull, | |
119 const void* pixels, size_t rowBytesOrZero); | |
120 | 101 |
| 102 /** |
| 103 * Creates a new texture for the bitmap. Does not concern itself with cache keys
or texture params. |
| 104 * The bitmap must have CPU-accessible pixels. Attempts to take advantage of fas
ter paths for |
| 105 * compressed textures and yuv planes. |
| 106 */ |
| 107 GrTexture* GrUploadBitmapToTexture(GrContext*, const SkBitmap&); |
121 | 108 |
122 ////////////////////////////////////////////////////////////////////////////// | 109 ////////////////////////////////////////////////////////////////////////////// |
123 | 110 |
124 GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff); | 111 GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff); |
125 GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff); | 112 GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff); |
126 GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff); | 113 GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff); |
127 GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff); | 114 GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff); |
128 GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff); | 115 GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff); |
129 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); | 116 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); |
130 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); | 117 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); |
131 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); | 118 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); |
132 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); | 119 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); |
133 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); | 120 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); |
134 GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10); | 121 GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10); |
135 | 122 |
136 #define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X)) | 123 #define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X)) |
137 | 124 |
138 #endif | 125 #endif |
OLD | NEW |