2010-12-22 21:39:39 +00:00
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2010-12-22 21:39:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
#ifndef SkGr_DEFINED
|
|
|
|
#define SkGr_DEFINED
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2011-03-03 13:54:13 +00:00
|
|
|
// Gr headers
|
2010-12-22 21:39:39 +00:00
|
|
|
#include "GrContext.h"
|
2015-08-12 19:57:54 +00:00
|
|
|
#include "GrTextureAccess.h"
|
|
|
|
#include "GrTypes.h"
|
2010-12-22 21:39:39 +00:00
|
|
|
|
|
|
|
// skia headers
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkPath.h"
|
|
|
|
#include "SkPoint.h"
|
|
|
|
#include "SkRegion.h"
|
2011-03-03 13:54:13 +00:00
|
|
|
#include "SkClipStack.h"
|
2010-12-22 21:39:39 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Sk to Gr Type conversions
|
|
|
|
|
2012-06-06 20:51:20 +00:00
|
|
|
GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff);
|
|
|
|
GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff);
|
2015-09-15 22:33:27 +00:00
|
|
|
GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10);
|
2011-02-22 20:34:01 +00:00
|
|
|
|
2015-09-15 22:33:27 +00:00
|
|
|
#define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X))
|
2010-12-22 21:39:39 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "SkColorPriv.h"
|
|
|
|
|
2014-12-22 16:31:49 +00:00
|
|
|
GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType);
|
2014-04-23 19:18:09 +00:00
|
|
|
|
|
|
|
static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {
|
2014-12-22 16:31:49 +00:00
|
|
|
return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.profileType());
|
2014-04-23 19:18:09 +00:00
|
|
|
}
|
|
|
|
|
2014-12-22 16:31:49 +00:00
|
|
|
bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*);
|
2012-07-18 21:47:40 +00:00
|
|
|
|
2015-09-28 13:26:28 +00:00
|
|
|
static inline GrColor SkColorToPremulGrColor(SkColor c) {
|
2012-07-18 21:47:40 +00:00
|
|
|
SkPMColor pm = SkPreMultiplyColor(c);
|
|
|
|
unsigned r = SkGetPackedR32(pm);
|
|
|
|
unsigned g = SkGetPackedG32(pm);
|
|
|
|
unsigned b = SkGetPackedB32(pm);
|
|
|
|
unsigned a = SkGetPackedA32(pm);
|
|
|
|
return GrColorPackRGBA(r, g, b, a);
|
|
|
|
}
|
|
|
|
|
2015-09-28 13:26:28 +00:00
|
|
|
static inline GrColor SkColorToUnpremulGrColor(SkColor c) {
|
|
|
|
unsigned r = SkColorGetR(c);
|
|
|
|
unsigned g = SkColorGetG(c);
|
|
|
|
unsigned b = SkColorGetB(c);
|
|
|
|
unsigned a = SkColorGetA(c);
|
|
|
|
return GrColorPackRGBA(r, g, b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline GrColor SkColorToOpaqueGrColor(SkColor c) {
|
|
|
|
unsigned r = SkColorGetR(c);
|
|
|
|
unsigned g = SkColorGetG(c);
|
|
|
|
unsigned b = SkColorGetB(c);
|
|
|
|
return GrColorPackRGBA(r, g, b, 0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Replicates the SkColor's alpha to all four channels of the GrColor. */
|
|
|
|
static inline GrColor SkColorAlphaToGrColor(SkColor c) {
|
2014-06-10 21:38:28 +00:00
|
|
|
U8CPU a = SkColorGetA(c);
|
|
|
|
return GrColorPackRGBA(a, a, a, a);
|
|
|
|
}
|
|
|
|
|
2015-09-15 22:33:27 +00:00
|
|
|
static inline SkPMColor GrColorToSkPMColor(GrColor c) {
|
|
|
|
GrColorIsPMAssert(c);
|
|
|
|
return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c), GrColorUnpackB(c));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline GrColor SkPMColorToGrColor(SkPMColor c) {
|
|
|
|
return GrColorPackRGBA(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c),
|
|
|
|
SkGetPackedA32(c));
|
|
|
|
}
|
|
|
|
|
2015-09-16 17:09:24 +00:00
|
|
|
GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
|
|
|
|
|
2012-07-18 21:47:40 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-09-08 15:37:36 +00:00
|
|
|
/**
|
|
|
|
* If the compressed data in the SkData is supported (as a texture format, this returns
|
|
|
|
* the pixel-config that should be used, and sets outStartOfDataToUpload to the ptr into
|
|
|
|
* the data where the actual raw data starts (skipping any header bytes).
|
|
|
|
*
|
|
|
|
* If the compressed data is not supported, this returns kUnknown_GrPixelConfig, and
|
|
|
|
* ignores outStartOfDataToUpload.
|
|
|
|
*/
|
|
|
|
GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
|
|
|
|
int expectedW, int expectedH,
|
|
|
|
const void** outStartOfDataToUpload);
|
|
|
|
|
2015-09-10 21:33:38 +00:00
|
|
|
// Helper that calls GrIsImageInCache assuming bitmap is not volatile.
|
2012-12-20 15:13:01 +00:00
|
|
|
bool GrIsBitmapInCache(const GrContext*, const SkBitmap&, const GrTextureParams*);
|
2015-09-10 21:33:38 +00:00
|
|
|
bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
|
|
|
|
GrTexture* nativeTexture, const GrTextureParams*);
|
2012-12-20 15:13:01 +00:00
|
|
|
|
2014-10-08 15:40:09 +00:00
|
|
|
GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams*);
|
2015-08-13 20:32:39 +00:00
|
|
|
GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, SkImageUsageType);
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2015-09-08 15:37:36 +00:00
|
|
|
GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey, GrSurfaceDesc,
|
|
|
|
SkPixelRef* pixelRefForInvalidationNotificationOrNull,
|
|
|
|
const void* pixels, size_t rowBytesOrZero);
|
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2014-05-15 20:32:48 +00:00
|
|
|
|
2015-05-07 22:36:17 +00:00
|
|
|
SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque);
|
|
|
|
|
|
|
|
// Using the dreaded SkGrPixelRef ...
|
2015-09-09 21:51:52 +00:00
|
|
|
SK_API void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque,
|
|
|
|
SkBitmap* dst);
|
2015-05-07 22:36:17 +00:00
|
|
|
|
2015-08-12 19:57:54 +00:00
|
|
|
GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
|
|
|
|
const SkMatrix& viewM,
|
|
|
|
const SkMatrix& localM,
|
|
|
|
bool* doBicubic);
|
|
|
|
|
2014-05-15 20:32:48 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-12-22 21:39:39 +00:00
|
|
|
// Classes
|
|
|
|
|
|
|
|
class SkGlyphCache;
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#endif
|