epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef SkGr_DEFINED |
| 12 | #define SkGr_DEFINED |
| 13 | |
| 14 | #include <stddef.h> |
| 15 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 16 | // Gr headers |
bsalomon@google.com | 6a2134e | 2011-11-23 21:33:11 +0000 | [diff] [blame] | 17 | #include "GrTypes.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 18 | #include "GrContext.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 19 | |
| 20 | // skia headers |
| 21 | #include "SkBitmap.h" |
| 22 | #include "SkPath.h" |
| 23 | #include "SkPoint.h" |
| 24 | #include "SkRegion.h" |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 25 | #include "SkClipStack.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 26 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 27 | //////////////////////////////////////////////////////////////////////////////// |
| 28 | // Sk to Gr Type conversions |
| 29 | |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 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); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 40 | |
bsalomon@google.com | ffca400 | 2011-02-22 20:34:01 +0000 | [diff] [blame] | 41 | #define sk_blend_to_grblend(X) ((GrBlendCoeff)(X)) |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 42 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 43 | /////////////////////////////////////////////////////////////////////////////// |
| 44 | |
| 45 | #include "SkColorPriv.h" |
| 46 | |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 47 | GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType); |
commit-bot@chromium.org | 3adcc34 | 2014-04-23 19:18:09 +0000 | [diff] [blame] | 48 | |
| 49 | static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) { |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 50 | return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.profileType()); |
commit-bot@chromium.org | 3adcc34 | 2014-04-23 19:18:09 +0000 | [diff] [blame] | 51 | } |
| 52 | |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 53 | bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 54 | |
rileya@google.com | 24f3ad1 | 2012-07-18 21:47:40 +0000 | [diff] [blame] | 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); |
| 62 | } |
| 63 | |
dandov | 9de5b51 | 2014-06-10 14:38:28 -0700 | [diff] [blame] | 64 | static inline GrColor SkColor2GrColorJustAlpha(SkColor c) { |
| 65 | U8CPU a = SkColorGetA(c); |
| 66 | return GrColorPackRGBA(a, a, a, a); |
| 67 | } |
| 68 | |
rileya@google.com | 24f3ad1 | 2012-07-18 21:47:40 +0000 | [diff] [blame] | 69 | //////////////////////////////////////////////////////////////////////////////// |
| 70 | |
bsalomon@google.com | 0797c2c | 2012-12-20 15:13:01 +0000 | [diff] [blame] | 71 | bool GrIsBitmapInCache(const GrContext*, const SkBitmap&, const GrTextureParams*); |
| 72 | |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 73 | GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams*); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 74 | |
| 75 | //////////////////////////////////////////////////////////////////////////////// |
commit-bot@chromium.org | 8dcff64 | 2014-05-15 20:32:48 +0000 | [diff] [blame] | 76 | |
commit-bot@chromium.org | 8dcff64 | 2014-05-15 20:32:48 +0000 | [diff] [blame] | 77 | // Converts a SkPaint to a GrPaint, ignoring the SkPaint's shader. |
bsalomon | 83d081a | 2014-07-08 09:56:10 -0700 | [diff] [blame] | 78 | // Sets the color of GrPaint to the value of the parameter paintColor |
commit-bot@chromium.org | 8dcff64 | 2014-05-15 20:32:48 +0000 | [diff] [blame] | 79 | // Callers may subsequently modify the GrPaint. Setting constantColor indicates |
| 80 | // that the final paint will draw the same color at every pixel. This allows |
bsalomon | c9c3e62 | 2015-04-02 11:12:09 -0700 | [diff] [blame] | 81 | // an optimization where the color filter can be applied to the SkPaint's |
| 82 | // color once while converting to GrPaint and then ignored. TODO: Remove this |
| 83 | // bool and use the invariant info to automatically apply the color filter. |
bsalomon | bed83a6 | 2015-04-15 14:18:34 -0700 | [diff] [blame] | 84 | bool SkPaint2GrPaintNoShader(GrContext* context, GrRenderTarget*, const SkPaint& skPaint, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 85 | GrColor paintColor, bool constantColor, GrPaint* grPaint); |
commit-bot@chromium.org | 8dcff64 | 2014-05-15 20:32:48 +0000 | [diff] [blame] | 86 | |
| 87 | // This function is similar to skPaint2GrPaintNoShader but also converts |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 88 | // skPaint's shader to a GrFragmentProcessor if possible. |
commit-bot@chromium.org | 8dcff64 | 2014-05-15 20:32:48 +0000 | [diff] [blame] | 89 | // constantColor has the same meaning as in skPaint2GrPaintNoShader. |
bsalomon | bed83a6 | 2015-04-15 14:18:34 -0700 | [diff] [blame] | 90 | bool SkPaint2GrPaint(GrContext* context, GrRenderTarget*, const SkPaint& skPaint, |
| 91 | const SkMatrix& viewM, bool constantColor, GrPaint* grPaint); |
commit-bot@chromium.org | 8dcff64 | 2014-05-15 20:32:48 +0000 | [diff] [blame] | 92 | |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 93 | |
| 94 | SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque); |
| 95 | |
| 96 | // Using the dreaded SkGrPixelRef ... |
| 97 | void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap* dst); |
| 98 | |
commit-bot@chromium.org | 8dcff64 | 2014-05-15 20:32:48 +0000 | [diff] [blame] | 99 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 100 | // Classes |
| 101 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 102 | class SkGlyphCache; |
| 103 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 104 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 105 | |
| 106 | #endif |