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"
25 #include "SkClipStack.h"
27 ////////////////////////////////////////////////////////////////////////////////
28 // Sk to Gr Type conversions
30 GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff);
31 GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff);
32 GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff);
33 GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff);
34 GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff);
35 GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff);
36 GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff);
37 GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff);
38 GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff);
39 GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff);
41 #define sk_blend_to_grblend(X) ((GrBlendCoeff)(X))
43 ///////////////////////////////////////////////////////////////////////////////
45 #include "SkColorPriv.h"
47 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType);
49 static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {
50 return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType());
53 bool GrPixelConfig2ColorType(GrPixelConfig, SkColorType*);
55 static inline GrColor SkColor2GrColor(SkColor c) {
56 SkPMColor pm = SkPreMultiplyColor(c);
57 unsigned r = SkGetPackedR32(pm);
58 unsigned g = SkGetPackedG32(pm);
59 unsigned b = SkGetPackedB32(pm);
60 unsigned a = SkGetPackedA32(pm);
61 return GrColorPackRGBA(r, g, b, a);
64 static inline GrColor SkColor2GrColorJustAlpha(SkColor c) {
65 U8CPU a = SkColorGetA(c);
66 return GrColorPackRGBA(a, a, a, a);
69 ////////////////////////////////////////////////////////////////////////////////
71 bool GrIsBitmapInCache(const GrContext*, const SkBitmap&, const GrTextureParams*);
73 GrTexture* GrLockAndRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams*);
75 void GrUnlockAndUnrefCachedBitmapTexture(GrTexture*);
77 ////////////////////////////////////////////////////////////////////////////////
79 // Converts a SkPaint to a GrPaint, ignoring the SkPaint's shader.
80 // Sets the color of GrPaint to the value of the parameter paintColor
81 // Callers may subsequently modify the GrPaint. Setting constantColor indicates
82 // that the final paint will draw the same color at every pixel. This allows
83 // an optimization where the the color filter can be applied to the SkPaint's
84 // color once while converting to GrPaint and then ignored.
85 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
86 bool constantColor, GrPaint* grPaint);
88 // This function is similar to skPaint2GrPaintNoShader but also converts
89 // skPaint's shader to a GrTexture/GrProcessorStage if possible.
90 // constantColor has the same meaning as in skPaint2GrPaintNoShader.
91 void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint,
92 bool constantColor, GrPaint* grPaint);
94 ////////////////////////////////////////////////////////////////////////////////
99 ////////////////////////////////////////////////////////////////////////////////