Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkGr.h
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkGr_DEFINED
9 #define SkGr_DEFINED
10 
11 #include "GrColor.h"
12 #include "GrTextureAccess.h"
13 #include "SkColor.h"
14 #include "SkColorPriv.h"
15 #include "SkFilterQuality.h"
16 #include "SkImageInfo.h"
17 
18 class GrCaps;
19 class GrContext;
20 class GrTexture;
21 class GrTextureParams;
22 class SkBitmap;
23 
25 // Sk to Gr Type conversions
26 
27 static inline GrColor SkColorToPremulGrColor(SkColor c) {
29  unsigned r = SkGetPackedR32(pm);
30  unsigned g = SkGetPackedG32(pm);
31  unsigned b = SkGetPackedB32(pm);
32  unsigned a = SkGetPackedA32(pm);
33  return GrColorPackRGBA(r, g, b, a);
34 }
35 
36 static inline GrColor SkColorToUnpremulGrColor(SkColor c) {
37  unsigned r = SkColorGetR(c);
38  unsigned g = SkColorGetG(c);
39  unsigned b = SkColorGetB(c);
40  unsigned a = SkColorGetA(c);
41  return GrColorPackRGBA(r, g, b, a);
42 }
43 
44 static inline GrColor SkColorToOpaqueGrColor(SkColor c) {
45  unsigned r = SkColorGetR(c);
46  unsigned g = SkColorGetG(c);
47  unsigned b = SkColorGetB(c);
48  return GrColorPackRGBA(r, g, b, 0xFF);
49 }
50 
52 static inline GrColor SkColorAlphaToGrColor(SkColor c) {
53  U8CPU a = SkColorGetA(c);
54  return GrColorPackRGBA(a, a, a, a);
55 }
56 
57 static inline SkPMColor GrColorToSkPMColor(GrColor c) {
58  GrColorIsPMAssert(c);
59  return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c), GrColorUnpackB(c));
60 }
61 
62 static inline GrColor SkPMColorToGrColor(SkPMColor c) {
63  return GrColorPackRGBA(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c),
64  SkGetPackedA32(c));
65 }
66 
68 
71 GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams&,
72  SkSourceGammaTreatment);
73 
74 sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams&,
75  SkSourceGammaTreatment);
76 
77 // TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses).
78 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, const SkColorSpace*,
79  const GrCaps&);
80 
81 static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& caps) {
82  return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.colorSpace(), caps);
83 }
84 
85 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
86  const SkMatrix& viewM,
87  const SkMatrix& localM,
88  bool* doBicubic);
89 
90 #endif
Represents the capabilities of a GrContext.
Definition: GrCaps.h:130
Definition: SkColorSpace.h:16
Describe an image's dimensions and pixel type.
Definition: SkImageInfo.h:181
Represents the filtering and tile modes used to access a texture.
Definition: GrTextureParams.h:17
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
Return a SkPMColor value from a SkColor value.
#define SkColorGetG(color)
return the green byte from a SkColor value
Definition: SkColor.h:66
The SkBitmap class specifies a raster bitmap.
Definition: SkBitmap.h:41
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:258
Definition: GrContext.h:48
uint32_t SkPMColor
32 bit ARGB color value, premultiplied.
Definition: SkColor.h:147
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
#define SkColorGetB(color)
return the blue byte from a SkColor value
Definition: SkColor.h:68
#define SkColorGetR(color)
return the red byte from a SkColor value
Definition: SkColor.h:64
#define SkColorGetA(color)
return the alpha byte from a SkColor value
Definition: SkColor.h:62
unsigned U8CPU
Fast type for unsigned 8 bits.
Definition: SkTypes.h:251
Definition: GrTexture.h:19
Types and macros for colors.