michael@0: michael@0: /* michael@0: * Copyright 2010 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: michael@0: #ifndef SkGr_DEFINED michael@0: #define SkGr_DEFINED michael@0: michael@0: #include michael@0: michael@0: // Gr headers michael@0: #include "GrTypes.h" michael@0: #include "GrContext.h" michael@0: #include "GrFontScaler.h" michael@0: michael@0: // skia headers michael@0: #include "SkBitmap.h" michael@0: #include "SkPath.h" michael@0: #include "SkPoint.h" michael@0: #include "SkRegion.h" michael@0: #include "SkClipStack.h" michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // Sk to Gr Type conversions michael@0: michael@0: GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff); michael@0: GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff); michael@0: GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff); michael@0: GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff); michael@0: GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff); michael@0: GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff); michael@0: GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff); michael@0: GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff); michael@0: GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff); michael@0: GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff); michael@0: michael@0: #define sk_blend_to_grblend(X) ((GrBlendCoeff)(X)) michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #include "SkColorPriv.h" michael@0: michael@0: /** michael@0: * Convert the SkBitmap::Config to the corresponding PixelConfig, or michael@0: * kUnknown_PixelConfig if the conversion cannot be done. michael@0: */ michael@0: GrPixelConfig SkBitmapConfig2GrPixelConfig(SkBitmap::Config); michael@0: GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType); michael@0: bool GrPixelConfig2ColorType(GrPixelConfig, SkColorType*); michael@0: michael@0: static inline GrColor SkColor2GrColor(SkColor c) { michael@0: SkPMColor pm = SkPreMultiplyColor(c); michael@0: unsigned r = SkGetPackedR32(pm); michael@0: unsigned g = SkGetPackedG32(pm); michael@0: unsigned b = SkGetPackedB32(pm); michael@0: unsigned a = SkGetPackedA32(pm); michael@0: return GrColorPackRGBA(r, g, b, a); michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: bool GrIsBitmapInCache(const GrContext*, const SkBitmap&, const GrTextureParams*); michael@0: michael@0: GrTexture* GrLockAndRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams*); michael@0: michael@0: void GrUnlockAndUnrefCachedBitmapTexture(GrTexture*); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // Classes michael@0: michael@0: class SkGlyphCache; michael@0: michael@0: class SkGrFontScaler : public GrFontScaler { michael@0: public: michael@0: explicit SkGrFontScaler(SkGlyphCache* strike); michael@0: virtual ~SkGrFontScaler(); michael@0: michael@0: // overrides michael@0: virtual const GrKey* getKey(); michael@0: virtual GrMaskFormat getMaskFormat(); michael@0: virtual bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds); michael@0: virtual bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height, michael@0: int rowBytes, void* image); michael@0: virtual bool getGlyphPath(uint16_t glyphID, SkPath*); michael@0: michael@0: private: michael@0: SkGlyphCache* fStrike; michael@0: GrKey* fKey; michael@0: // DECLARE_INSTANCE_COUNTER(SkGrFontScaler); michael@0: }; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #endif