3 * Copyright 2010 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
18 #include "GrContext.h"
19 #include "GrFontScaler.h"
26 #include "SkClipStack.h"
28 ////////////////////////////////////////////////////////////////////////////////
29 // Sk to Gr Type conversions
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);
42 #define sk_blend_to_grblend(X) ((GrBlendCoeff)(X))
44 ///////////////////////////////////////////////////////////////////////////////
46 #include "SkColorPriv.h"
49 * Convert the SkBitmap::Config to the corresponding PixelConfig, or
50 * kUnknown_PixelConfig if the conversion cannot be done.
52 GrPixelConfig SkBitmapConfig2GrPixelConfig(SkBitmap::Config);
53 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType);
55 static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {
56 return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType());
59 bool GrPixelConfig2ColorType(GrPixelConfig, SkColorType*);
61 static inline GrColor SkColor2GrColor(SkColor c) {
62 SkPMColor pm = SkPreMultiplyColor(c);
63 unsigned r = SkGetPackedR32(pm);
64 unsigned g = SkGetPackedG32(pm);
65 unsigned b = SkGetPackedB32(pm);
66 unsigned a = SkGetPackedA32(pm);
67 return GrColorPackRGBA(r, g, b, a);
70 ////////////////////////////////////////////////////////////////////////////////
72 bool GrIsBitmapInCache(const GrContext*, const SkBitmap&, const GrTextureParams*);
74 GrTexture* GrLockAndRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams*);
76 void GrUnlockAndUnrefCachedBitmapTexture(GrTexture*);
78 ////////////////////////////////////////////////////////////////////////////////
83 class SkGrFontScaler : public GrFontScaler {
85 explicit SkGrFontScaler(SkGlyphCache* strike);
86 virtual ~SkGrFontScaler();
89 virtual const GrKey* getKey();
90 virtual GrMaskFormat getMaskFormat();
91 virtual bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds) SK_OVERRIDE;
92 virtual bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height,
93 int rowBytes, void* image) SK_OVERRIDE;
94 virtual bool getPackedGlyphDFBounds(GrGlyph::PackedID, SkIRect* bounds) SK_OVERRIDE;
95 virtual bool getPackedGlyphDFImage(GrGlyph::PackedID, int width, int height,
96 void* image) SK_OVERRIDE;
97 virtual bool getGlyphPath(uint16_t glyphID, SkPath*);
100 SkGlyphCache* fStrike;
102 // DECLARE_INSTANCE_COUNTER(SkGrFontScaler);
105 ////////////////////////////////////////////////////////////////////////////////