| 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 "GrTextureAccess.h" | |
| 14 #include "SkImageInfo.h" | 13 #include "SkImageInfo.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 GrUniqueKey; | 23 class GrUniqueKey; |
| 24 class SkData; |
| 23 class SkPaint; | 25 class SkPaint; |
| 24 class SkMatrix; | 26 class SkPixelRef; |
| 25 struct SkIRect; | 27 struct SkIRect; |
| 26 | 28 |
| 27 struct SkGrStretch { | 29 struct SkGrStretch { |
| 28 enum Type { | 30 enum Type { |
| 29 kNone_Type, | 31 kNone_Type, |
| 30 kBilerp_Type, | 32 kBilerp_Type, |
| 31 kNearest_Type | 33 kNearest_Type |
| 32 } fType; | 34 } fType; |
| 33 int fWidth; | 35 int fWidth; |
| 34 int fHeight; | 36 int fHeight; |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 GrTextureParams GrImageUsageToTextureParams(SkImageUsageType); | |
| 38 | |
| 39 /** | 39 /** |
| 40 * Our key includes the offset, width, and height so that bitmaps created by ex
tractSubset() | 40 * Our key includes the offset, width, and height so that bitmaps created by ex
tractSubset() |
| 41 * are unique. | 41 * are unique. |
| 42 * | 42 * |
| 43 * The imageID is in the shared namespace (see SkNextID::ImageID() | 43 * The imageID is in the shared namespace (see SkNextID::ImageID() |
| 44 * - SkBitmap/SkPixelRef | 44 * - SkBitmap/SkPixelRef |
| 45 * - SkImage | 45 * - SkImage |
| 46 * - SkImageGenerator | 46 * - SkImageGenerator |
| 47 * | 47 * |
| 48 * Note: width/height must fit in 16bits for this impl. | 48 * Note: width/height must fit in 16bits for this impl. |
| 49 */ | 49 */ |
| 50 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
geBounds, | 50 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
geBounds, |
| 51 const GrCaps&, SkImageUsageType); | 51 const GrCaps&, const GrTextureParams&); |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Given an "unstretched" key, and a stretch rec, produce a stretched key. | 54 * Given an "unstretched" key, and a stretch rec, produce a stretched key. |
| 55 */ | 55 */ |
| 56 bool GrMakeStretchedKey(const GrUniqueKey& origKey, const SkGrStretch&, GrUnique
Key* stretchedKey); | 56 bool GrMakeStretchedKey(const GrUniqueKey& origKey, const SkGrStretch&, GrUnique
Key* stretchedKey); |
| 57 | 57 |
| 58 /** Converts an SkPaint to a GrPaint for a given GrContext. The matrix is requir
ed in order | 58 /** 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. */ | 59 to convert the SkShader (if any) on the SkPaint. The primitive itself has no
color. */ |
| 60 bool SkPaintToGrPaint(GrContext*, | 60 bool SkPaintToGrPaint(GrContext*, |
| 61 const SkPaint& skPaint, | 61 const SkPaint& skPaint, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 91 unpremultiplied so that interpolation is done in unpremul space. The paint's
alpha will be | 91 unpremultiplied so that interpolation is done in unpremul space. The paint's
alpha will be |
| 92 applied to the primitive color after interpolation. */ | 92 applied to the primitive color after interpolation. */ |
| 93 inline bool SkPaintToGrPaintWithPrimitiveColor(GrContext* context, const SkPaint
& skPaint, | 93 inline bool SkPaintToGrPaintWithPrimitiveColor(GrContext* context, const SkPaint
& skPaint, |
| 94 GrPaint* grPaint) { | 94 GrPaint* grPaint) { |
| 95 return SkPaintToGrPaintWithXfermode(context, skPaint, SkMatrix::I(), SkXferm
ode::kDst_Mode, | 95 return SkPaintToGrPaintWithXfermode(context, skPaint, SkMatrix::I(), SkXferm
ode::kDst_Mode, |
| 96 false, grPaint); | 96 false, grPaint); |
| 97 } | 97 } |
| 98 | 98 |
| 99 ////////////////////////////////////////////////////////////////////////////// | 99 ////////////////////////////////////////////////////////////////////////////// |
| 100 | 100 |
| 101 bool GrTextureUsageSupported(const GrCaps&, int width, int height, SkImageUsageT
ype); | |
| 102 | |
| 103 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&); | 101 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&); |
| 104 | 102 |
| 105 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfi
leType*); | 103 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfi
leType*); |
| 106 | 104 |
| 107 /** | 105 /** |
| 108 * If the compressed data in the SkData is supported (as a texture format, this
returns | 106 * If the compressed data in the SkData is supported (as a texture format, this
returns |
| 109 * the pixel-config that should be used, and sets outStartOfDataToUpload to the
ptr into | 107 * the pixel-config that should be used, and sets outStartOfDataToUpload to the
ptr into |
| 110 * the data where the actual raw data starts (skipping any header bytes). | 108 * the data where the actual raw data starts (skipping any header bytes). |
| 111 * | 109 * |
| 112 * If the compressed data is not supported, this returns kUnknown_GrPixelConfig,
and | 110 * If the compressed data is not supported, this returns kUnknown_GrPixelConfig,
and |
| 113 * ignores outStartOfDataToUpload. | 111 * ignores outStartOfDataToUpload. |
| 114 */ | 112 */ |
| 115 GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data, | 113 GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data, |
| 116 int expectedW, int expectedH, | 114 int expectedW, int expectedH, |
| 117 const void** outStartOfDataToUp
load); | 115 const void** outStartOfDataToUp
load); |
| 118 | 116 |
| 119 bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& sub
set, | 117 bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& sub
set, |
| 120 GrTexture* nativeTexture, const GrTextureParams*); | 118 GrTexture* nativeTexture, const GrTextureParams&); |
| 121 | 119 |
| 122 GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey,
GrSurfaceDesc, | 120 GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey,
GrSurfaceDesc, |
| 123 SkPixelRef* pixelRefForInvalidationNotificat
ionOrNull, | 121 SkPixelRef* pixelRefForInvalidationNotificat
ionOrNull, |
| 124 const void* pixels, size_t rowBytesOrZero); | 122 const void* pixels, size_t rowBytesOrZero); |
| 125 | 123 |
| 126 | 124 |
| 127 ////////////////////////////////////////////////////////////////////////////// | 125 ////////////////////////////////////////////////////////////////////////////// |
| 128 | 126 |
| 129 GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff); | 127 GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff); |
| 130 GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff); | 128 GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff); |
| 131 GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff); | 129 GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff); |
| 132 GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff); | 130 GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff); |
| 133 GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff); | 131 GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff); |
| 134 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); | 132 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); |
| 135 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); | 133 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); |
| 136 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); | 134 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); |
| 137 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); | 135 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); |
| 138 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); | 136 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); |
| 139 GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10); | 137 GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10); |
| 140 | 138 |
| 141 #define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X)) | 139 #define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X)) |
| 142 | 140 |
| 143 #endif | 141 #endif |
| OLD | NEW |