Make SkGr.h private and remove unused functions
authorBrian Osman <brianosman@google.com>
Tue, 7 Mar 2017 21:58:08 +0000 (16:58 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 8 Mar 2017 20:55:21 +0000 (20:55 +0000)
BUG=skia:

Change-Id: I6699d00c5412ed9d9bf14b032a08b06b1c766bce
Reviewed-on: https://skia-review.googlesource.com/9398
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>

42 files changed:
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
gm/constcolorprocessor.cpp
gn/gpu.gni
include/gpu/SkGr.h [deleted file]
src/core/SkCanvas.cpp
src/core/SkImageCacherator.cpp
src/core/SkImageFilter.cpp
src/core/SkLightingShader.cpp
src/core/SkRadialShadowMapShader.cpp
src/core/SkShadowShader.cpp
src/core/SkSpecialImage.cpp
src/effects/SkArithmeticImageFilter.cpp
src/effects/SkDisplacementMapEffect.cpp
src/effects/SkLightingImageFilter.cpp
src/effects/SkMorphologyImageFilter.cpp
src/effects/SkPerlinNoiseShader.cpp
src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
src/effects/SkTableColorFilter.cpp
src/effects/SkXfermodeImageFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/gpu/GrBitmapTextureMaker.cpp
src/gpu/GrBlurUtils.cpp
src/gpu/GrContext.cpp
src/gpu/GrImageTextureMaker.cpp
src/gpu/GrSurface.cpp
src/gpu/GrTextureAdjuster.cpp
src/gpu/SkGpuDevice.cpp
src/gpu/SkGpuDevice.h
src/gpu/SkGpuDevice_drawTexture.cpp
src/gpu/SkGr.cpp
src/gpu/SkGr.h [moved from src/gpu/SkGrPriv.h with 74% similarity]
src/gpu/effects/GrXfermodeFragmentProcessor.cpp
src/gpu/ops/GrDrawVerticesOp.cpp
src/gpu/text/GrAtlasTextContext.cpp
src/gpu/text/GrStencilAndCoverTextContext.cpp
src/gpu/text/GrTextUtils.cpp
src/image/SkImageShader.cpp
src/image/SkImage_Gpu.cpp
src/image/SkImage_Raster.cpp
tests/GrGetCoeffBlendKnownComponentsTest.cpp
tests/SpecialImageTest.cpp
tools/gpu/GrTest.cpp

index a90baae..be8b1b1 100644 (file)
@@ -20,7 +20,6 @@
 #include "GrContext.h"
 #include "GrCoordTransform.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "effects/GrConstColorProcessor.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
index 17a1bc5..831ba69 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "GrContext.h"
 #include "GrRenderTargetContextPriv.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkGradientShader.h"
 #include "effects/GrConstColorProcessor.h"
 #include "ops/GrDrawOp.h"
index 4cab21f..e34ff45 100644 (file)
@@ -453,13 +453,11 @@ skia_gpu_sources = [
   "$_src/gpu/glsl/GrGLSLXferProcessor.h",
 
   # Sk files
-  "$_include/gpu/SkGr.h",
-
   "$_src/gpu/SkGpuDevice.cpp",
   "$_src/gpu/SkGpuDevice.h",
   "$_src/gpu/SkGpuDevice_drawTexture.cpp",
+  "$_src/gpu/SkGr.h",
   "$_src/gpu/SkGr.cpp",
-  "$_src/gpu/SkGrPriv.h",
 
   "$_src/image/SkImage_Gpu.h",
   "$_src/image/SkImage_Gpu.cpp",
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
deleted file mode 100644 (file)
index 02df699..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkGr_DEFINED
-#define SkGr_DEFINED
-
-#include "GrColor.h"
-#include "GrSamplerParams.h"
-#include "SkColor.h"
-#include "SkColorPriv.h"
-#include "SkFilterQuality.h"
-#include "SkImageInfo.h"
-
-class GrCaps;
-class GrColorSpaceXform;
-class GrContext;
-class GrTexture;
-class SkBitmap;
-
-////////////////////////////////////////////////////////////////////////////////
-// Sk to Gr Type conversions
-
-static inline GrColor SkColorToPremulGrColor(SkColor c) {
-    SkPMColor pm = SkPreMultiplyColor(c);
-    unsigned r = SkGetPackedR32(pm);
-    unsigned g = SkGetPackedG32(pm);
-    unsigned b = SkGetPackedB32(pm);
-    unsigned a = SkGetPackedA32(pm);
-    return GrColorPackRGBA(r, g, b, a);
-}
-
-static inline GrColor SkColorToUnpremulGrColor(SkColor c) {
-    unsigned r = SkColorGetR(c);
-    unsigned g = SkColorGetG(c);
-    unsigned b = SkColorGetB(c);
-    unsigned a = SkColorGetA(c);
-    return GrColorPackRGBA(r, g, b, a);
-}
-
-/** Transform an SkColor (sRGB bytes) to GrColor4f for the specified color space. */
-GrColor4f SkColorToPremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace);
-GrColor4f SkColorToUnpremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace);
-
-/**
- * As above, but with a caller-supplied color space xform object. Faster for the cases where we
- * have that cached.
- */
-GrColor4f SkColorToPremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace,
-                                   GrColorSpaceXform* gamutXform);
-GrColor4f SkColorToUnpremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace,
-                                     GrColorSpaceXform* gamutXform);
-
-static inline GrColor SkColorToOpaqueGrColor(SkColor c) {
-    unsigned r = SkColorGetR(c);
-    unsigned g = SkColorGetG(c);
-    unsigned b = SkColorGetB(c);
-    return GrColorPackRGBA(r, g, b, 0xFF);
-}
-
-/** Replicates the SkColor's alpha to all four channels of the GrColor. */
-static inline GrColor SkColorAlphaToGrColor(SkColor c) {
-    U8CPU a = SkColorGetA(c);
-    return GrColorPackRGBA(a, a, a, a);
-}
-
-static inline SkPMColor GrColorToSkPMColor(GrColor c) {
-    GrColorIsPMAssert(c);
-    return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c), GrColorUnpackB(c));
-}
-
-static inline GrColor SkPMColorToGrColor(SkPMColor c) {
-    return GrColorPackRGBA(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c),
-                           SkGetPackedA32(c));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/** Returns a texture representing the bitmap that is compatible with the GrSamplerParams. The
- *  texture is inserted into the cache (unless the bitmap is marked volatile) and can be
- *  retrieved again via this function.
- *  The 'scaleAdjust' in/out parameter will be updated to hold any rescaling that needs to be
- *  performed on the absolute texture coordinates (e.g., if the texture is resized out to
- *  the next power of two). It can be null if the caller is sure the bitmap won't be resized.
- */
-GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&,
-                                    const GrSamplerParams&, SkScalar scaleAdjust[2]);
-
-// TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses).
-GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& caps);
-
-GrSamplerParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
-                                                            const SkMatrix& viewM,
-                                                            const SkMatrix& localM,
-                                                            bool* doBicubic);
-
-#endif
index 68a11bf..fc1c23a 100644 (file)
@@ -45,7 +45,7 @@
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
 #include "GrRenderTarget.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 
 #endif
 #include "SkClipOpPriv.h"
index b4f9e8b..196723c 100644 (file)
@@ -25,7 +25,6 @@
 #include "GrSamplerParams.h"
 #include "GrYUVProvider.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #endif
 
 // Until we actually have codecs/etc. that can contain/support a GPU texture format
index d66d99c..a0d3df7 100644 (file)
@@ -24,7 +24,7 @@
 #include "GrFixedClip.h"
 #include "GrRenderTargetContext.h"
 #include "GrTextureProxy.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #endif
 
 #ifndef SK_IGNORE_TO_STRING
index 2deacc2..e1e1882 100644 (file)
@@ -105,7 +105,6 @@ private:
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "glsl/GrGLSLUniformHandler.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 
 // This FP expects a premul'd color input for its diffuse color. Premul'ing of the paint's color is
 // handled by the asFragmentProcessor() factory, but shaders providing diffuse color must output it
index 0cc60f1..45cc1d9 100644 (file)
@@ -87,7 +87,6 @@ private:
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "SkImage_Base.h"
 #include "GrInvariantOutput.h"
 #include "SkSpecialImage.h"
index afefa95..5f4ce66 100644 (file)
@@ -101,7 +101,6 @@ private:
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "SkSpecialImage.h"
 #include "SkImage_Base.h"
 #include "GrContext.h"
index 9ded6aa..1940fb9 100644 (file)
@@ -23,7 +23,6 @@
 #include "GrSamplerParams.h"
 #include "GrTextureProxy.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "SkImage_Gpu.h"
 #endif
 
index 7f9dc7f..189171a 100644 (file)
@@ -19,7 +19,6 @@
 #include "GrRenderTargetContext.h"
 #include "GrTextureProxy.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "effects/GrConstColorProcessor.h"
 #include "effects/GrTextureDomain.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
index 8384058..0a3b6a8 100644 (file)
@@ -20,7 +20,6 @@
 #include "GrTextureProxy.h"
 
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "effects/GrTextureDomain.h"
 #include "glsl/GrGLSLColorSpaceXformHelper.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
index 3ed017e..6e1e8b8 100644 (file)
@@ -23,7 +23,6 @@
 #include "GrTextureProxy.h"
 
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "effects/GrSingleTextureEffect.h"
 #include "effects/GrTextureDomain.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
index 81d9f8d..e54b5c1 100644 (file)
@@ -23,7 +23,6 @@
 #include "GrTextureProxy.h"
 
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "effects/Gr1DKernelEffect.h"
 #include "effects/GrProxyMove.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
index 4ebf36a..73e1018 100644 (file)
@@ -19,7 +19,6 @@
 #include "GrContext.h"
 #include "GrCoordTransform.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "effects/GrConstColorProcessor.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
index b3967ec..609f37e 100644 (file)
@@ -195,7 +195,6 @@ bool SkRRectsGaussianEdgeMaskFilterImpl::filterMask(SkMask* dst, const SkMask& s
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "glsl/GrGLSLUniformHandler.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 
 class RRectsGaussianEdgeFP : public GrFragmentProcessor {
 public:
index ba3f084..099846d 100644 (file)
@@ -363,7 +363,6 @@ sk_sp<SkColorFilter> SkTable_ColorFilter::makeComposed(sk_sp<SkColorFilter> inne
 #include "GrFragmentProcessor.h"
 #include "GrTextureStripAtlas.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
index c9e5a8a..5e1a8b5 100644 (file)
@@ -23,7 +23,6 @@
 #include "effects/GrTextureDomain.h"
 #include "effects/GrSimpleTextureEffect.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #endif
 #include "SkClipOpPriv.h"
 
index 8538ddd..afb4f8b 100644 (file)
@@ -1131,7 +1131,6 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "glsl/GrGLSLUniformHandler.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 
 static inline bool close_to_one_half(const SkFixed& val) {
     return SkScalarNearlyEqual(SkFixedToScalar(val), SK_ScalarHalf);
index 24cb05f..d2bf67e 100644 (file)
@@ -11,7 +11,7 @@
 #include "GrGpuResourcePriv.h"
 #include "GrResourceProvider.h"
 #include "SkBitmap.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkPixelRef.h"
 
 static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); }
index 6716fde..c2b8809 100644 (file)
@@ -18,7 +18,7 @@
 #include "GrTexture.h"
 #include "GrTextureProxy.h"
 #include "SkDraw.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkMaskFilter.h"
 #include "SkPaint.h"
 #include "SkTLazy.h"
index 38ab1a4..67c497b 100644 (file)
@@ -21,7 +21,7 @@
 #include "GrTextureContext.h"
 
 #include "SkConvertPixels.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkUnPreMultiplyPriv.h"
 
 #include "effects/GrConfigConversionEffect.h"
index 086e40e..fa96656 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "GrContext.h"
 #include "GrGpuResourcePriv.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkImage_Base.h"
 #include "SkImageCacherator.h"
 #include "SkPixelRef.h"
index c3ac224..b292377 100644 (file)
@@ -10,7 +10,7 @@
 #include "GrOpList.h"
 #include "GrSurfacePriv.h"
 
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkMathPriv.h"
 
 GrSurface::~GrSurface() {
index 63d9a11..6baf299 100644 (file)
@@ -12,7 +12,7 @@
 #include "GrGpuResourcePriv.h"
 #include "GrResourceProvider.h"
 #include "GrTexture.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 
 GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, SkAlphaType alphaType,
                                      const SkIRect& contentArea, uint32_t uniqueID,
index bcc2930..e7e776f 100644 (file)
@@ -22,7 +22,6 @@
 #include "SkDraw.h"
 #include "SkGlyphCache.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "SkImageCacherator.h"
 #include "SkImageFilter.h"
 #include "SkImageFilterCache.h"
index 655724c..a331269 100644 (file)
@@ -9,7 +9,6 @@
 #define SkGpuDevice_DEFINED
 
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "SkBitmap.h"
 #include "SkClipStackDevice.h"
 #include "SkPicture.h"
index cff26b4..187152a 100644 (file)
@@ -13,7 +13,7 @@
 #include "GrStyle.h"
 #include "GrTextureAdjuster.h"
 #include "SkDraw.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkMaskFilter.h"
 #include "effects/GrBicubicEffect.h"
 #include "effects/GrSimpleTextureEffect.h"
index 69f6061..2ba71bc 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "SkGr.h"
-#include "SkGrPriv.h"
 
 #include "GrBitmapTextureMaker.h"
 #include "GrCaps.h"
similarity index 74%
rename from src/gpu/SkGrPriv.h
rename to src/gpu/SkGr.h
index 7f52ee8..9844e8a 100644 (file)
@@ -1,23 +1,28 @@
 /*
- * Copyright 2015 Google Inc.
+ * Copyright 2017 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
 
-#ifndef SkGrPriv_DEFINED
-#define SkGrPriv_DEFINED
+#ifndef SkGr_DEFINED
+#define SkGr_DEFINED
 
 #include "GrBlend.h"
+#include "GrColor.h"
 #include "GrSamplerParams.h"
 #include "GrTypes.h"
 #include "SkCanvas.h"
+#include "SkColor.h"
+#include "SkColorPriv.h"
+#include "SkFilterQuality.h"
 #include "SkImageInfo.h"
 #include "SkMatrix.h"
 #include "SkPM4f.h"
 #include "SkXfermodePriv.h"
 
 class GrCaps;
+class GrColorSpaceXform;
 class GrContext;
 class GrRenderTargetContext;
 class GrFragmentProcessor;
@@ -32,22 +37,62 @@ class SkPixelRef;
 class SkPixmap;
 struct SkIRect;
 
+////////////////////////////////////////////////////////////////////////////////
+// Color type conversions
+
+static inline GrColor SkColorToPremulGrColor(SkColor c) {
+    SkPMColor pm = SkPreMultiplyColor(c);
+    unsigned r = SkGetPackedR32(pm);
+    unsigned g = SkGetPackedG32(pm);
+    unsigned b = SkGetPackedB32(pm);
+    unsigned a = SkGetPackedA32(pm);
+    return GrColorPackRGBA(r, g, b, a);
+}
+
+static inline GrColor SkColorToUnpremulGrColor(SkColor c) {
+    unsigned r = SkColorGetR(c);
+    unsigned g = SkColorGetG(c);
+    unsigned b = SkColorGetB(c);
+    unsigned a = SkColorGetA(c);
+    return GrColorPackRGBA(r, g, b, a);
+}
+
+/** Transform an SkColor (sRGB bytes) to GrColor4f for the specified color space. */
+GrColor4f SkColorToPremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace);
+GrColor4f SkColorToUnpremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace);
+
 /**
- *  Our key includes the offset, width, and height so that bitmaps created by extractSubset()
- *  are unique.
- *
- *  The imageID is in the shared namespace (see SkNextID::ImageID())
- *      - SkBitmap/SkPixelRef
- *      - SkImage
- *      - SkImageGenerator
- *
- *  Note: width/height must fit in 16bits for this impl.
+ * As above, but with a caller-supplied color space xform object. Faster for the cases where we
+ * have that cached.
  */
-void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& imageBounds);
+GrColor4f SkColorToPremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace,
+                                   GrColorSpaceXform* gamutXform);
+GrColor4f SkColorToUnpremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace,
+                                     GrColorSpaceXform* gamutXform);
+
+/** Replicates the SkColor's alpha to all four channels of the GrColor. */
+static inline GrColor SkColorAlphaToGrColor(SkColor c) {
+    U8CPU a = SkColorGetA(c);
+    return GrColorPackRGBA(a, a, a, a);
+}
 
-/** Call this after installing a GrUniqueKey on texture. It will cause the texture's key to be
-    removed should the bitmap's contents change or be destroyed. */
-void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pixelRef);
+//////////////////////////////////////////////////////////////////////////////
+
+static inline SkPM4f GrColor4fToSkPM4f(const GrColor4f& c) {
+    SkPM4f pm4f;
+    pm4f.fVec[SkPM4f::R] = c.fRGBA[0];
+    pm4f.fVec[SkPM4f::G] = c.fRGBA[1];
+    pm4f.fVec[SkPM4f::B] = c.fRGBA[2];
+    pm4f.fVec[SkPM4f::A] = c.fRGBA[3];
+    return pm4f;
+}
+
+static inline GrColor4f SkPM4fToGrColor4f(const SkPM4f& c) {
+    return GrColor4f{c.r(), c.g(), c.b(), c.a()};
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Paint conversion
 
 /** Converts an SkPaint to a GrPaint for a given GrContext. The matrix is required in order
     to convert the SkShader (if any) on the SkPaint. The primitive itself has no color. */
@@ -104,6 +149,19 @@ bool SkPaintToGrPaintWithTexture(GrContext* context,
                                  bool textureIsAlphaOnly,
                                  GrPaint* grPaint);
 
+////////////////////////////////////////////////////////////////////////////////
+// Misc Sk to Gr type conversions
+
+GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&);
+GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& caps);
+
+bool GrPixelConfigToColorType(GrPixelConfig, SkColorType*);
+
+GrSamplerParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
+                                                            const SkMatrix& viewM,
+                                                            const SkMatrix& localM,
+                                                            bool* doBicubic);
+
 //////////////////////////////////////////////////////////////////////////////
 
 static inline GrPrimitiveType SkVertexModeToGrPrimitiveType(const SkCanvas::VertexMode mode) {
@@ -121,43 +179,32 @@ static inline GrPrimitiveType SkVertexModeToGrPrimitiveType(const SkCanvas::Vert
 
 //////////////////////////////////////////////////////////////////////////////
 
-static inline SkPM4f GrColor4fToSkPM4f(const GrColor4f& c) {
-    SkPM4f pm4f;
-    pm4f.fVec[SkPM4f::R] = c.fRGBA[0];
-    pm4f.fVec[SkPM4f::G] = c.fRGBA[1];
-    pm4f.fVec[SkPM4f::B] = c.fRGBA[2];
-    pm4f.fVec[SkPM4f::A] = c.fRGBA[3];
-    return pm4f;
-}
-
-static inline GrColor4f SkPM4fToGrColor4f(const SkPM4f& c) {
-    return GrColor4f{c.r(), c.g(), c.b(), c.a()};
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&);
+GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff);
+GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff);
+GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff);
+GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff);
+GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff);
+GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff);
+GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff);
+GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff);
+GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff);
+GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff);
+GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10);
 
-bool GrPixelConfigToColorType(GrPixelConfig, SkColorType*);
+#define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X))
 
-/** When image filter code needs to construct a render target context to do intermediate rendering,
-    we need a renderable pixel config. The source (SkSpecialImage) may not be in a renderable
-    format, but we want to preserve the color space of that source. This picks an appropriate format
-    to use. */
-GrPixelConfig GrRenderableConfigForColorSpace(const SkColorSpace*);
+////////////////////////////////////////////////////////////////////////////////
+// Texture management
 
-/**
- *  If the compressed data in the SkData is supported (as a texture format, this returns
- *  the pixel-config that should be used, and sets outStartOfDataToUpload to the ptr into
- *  the data where the actual raw data starts (skipping any header bytes).
- *
- *  If the compressed data is not supported, this returns kUnknown_GrPixelConfig, and
- *  ignores outStartOfDataToUpload.
+/** Returns a texture representing the bitmap that is compatible with the GrSamplerParams. The
+ *  texture is inserted into the cache (unless the bitmap is marked volatile) and can be
+ *  retrieved again via this function.
+ *  The 'scaleAdjust' in/out parameter will be updated to hold any rescaling that needs to be
+ *  performed on the absolute texture coordinates (e.g., if the texture is resized out to
+ *  the next power of two). It can be null if the caller is sure the bitmap won't be resized.
  */
-GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
-                                                 int expectedW, int expectedH,
-                                                 const void** outStartOfDataToUpload);
-
+GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&,
+                                    const GrSamplerParams&, SkScalar scaleAdjust[2]);
 
 /**
  * Creates a new texture for the bitmap. Does not concern itself with cache keys or texture params.
@@ -196,20 +243,44 @@ sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext*, const SkBitmap&,
 //    }
 sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrContext* context, const SkBitmap& bitmap);
 
+
+/**
+ *  Our key includes the offset, width, and height so that bitmaps created by extractSubset()
+ *  are unique.
+ *
+ *  The imageID is in the shared namespace (see SkNextID::ImageID())
+ *      - SkBitmap/SkPixelRef
+ *      - SkImage
+ *      - SkImageGenerator
+ *
+ *  Note: width/height must fit in 16bits for this impl.
+ */
+void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& imageBounds);
+
+/** Call this after installing a GrUniqueKey on texture. It will cause the texture's key to be
+    removed should the bitmap's contents change or be destroyed. */
+void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pixelRef);
+
 //////////////////////////////////////////////////////////////////////////////
 
-GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff);
-GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkXfermode::kOne_Coeff);
-GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkXfermode::kSC_Coeff);
-GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkXfermode::kISC_Coeff);
-GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkXfermode::kDC_Coeff);
-GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkXfermode::kIDC_Coeff);
-GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkXfermode::kSA_Coeff);
-GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkXfermode::kISA_Coeff);
-GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkXfermode::kDA_Coeff);
-GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff);
-GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10);
+/** When image filter code needs to construct a render target context to do intermediate rendering,
+    we need a renderable pixel config. The source (SkSpecialImage) may not be in a renderable
+    format, but we want to preserve the color space of that source. This picks an appropriate format
+    to use. */
+GrPixelConfig GrRenderableConfigForColorSpace(const SkColorSpace*);
+
+/**
+ *  If the compressed data in the SkData is supported (as a texture format, this returns
+ *  the pixel-config that should be used, and sets outStartOfDataToUpload to the ptr into
+ *  the data where the actual raw data starts (skipping any header bytes).
+ *
+ *  If the compressed data is not supported, this returns kUnknown_GrPixelConfig, and
+ *  ignores outStartOfDataToUpload.
+ */
+GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
+                                                 int expectedW, int expectedH,
+                                                 const void** outStartOfDataToUpload);
+
 
-#define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X))
 
 #endif
index eb6f04b..923c82f 100644 (file)
@@ -12,7 +12,7 @@
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLBlend.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 
 // Some of the cpu implementations of blend modes differ too much from the GPU enough that
 // we can't use the cpu implementation to implement constantOutputForConstantInput.
index 79f7c0a..5b59b13 100644 (file)
@@ -8,7 +8,7 @@
 #include "GrDrawVerticesOp.h"
 #include "GrDefaultGeoProcFactory.h"
 #include "GrOpFlushState.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 
 std::unique_ptr<GrDrawOp> GrDrawVerticesOp::Make(
         GrColor color, GrPrimitiveType primitiveType, const SkMatrix& viewMatrix,
index e1dc7e2..512df0a 100644 (file)
@@ -11,7 +11,7 @@
 #include "GrTextBlobCache.h"
 #include "SkDraw.h"
 #include "SkDrawFilter.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 
 GrAtlasTextContext::GrAtlasTextContext()
     : fDistanceAdjustTable(new GrDistanceFieldAdjustTable) {
index ab28ae7..afa54d5 100644 (file)
@@ -20,7 +20,7 @@
 #include "SkDrawFilter.h"
 #include "SkDrawProcs.h"
 #include "SkGlyphCache.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkPath.h"
 #include "SkTextBlobRunIterator.h"
 #include "SkTextFormatParams.h"
index a199d8c..4c74dbe 100644 (file)
@@ -18,7 +18,7 @@
 #include "SkDrawProcs.h"
 #include "SkFindAndPlaceGlyph.h"
 #include "SkGlyphCache.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkPaint.h"
 #include "SkRect.h"
 #include "SkTextBlobRunIterator.h"
index 7e38748..4f739f3 100644 (file)
@@ -123,7 +123,6 @@ void SkImageShader::toString(SkString* str) const {
 #if SK_SUPPORT_GPU
 
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "effects/GrSimpleTextureEffect.h"
 #include "effects/GrBicubicEffect.h"
 #include "effects/GrSimpleTextureEffect.h"
index ced5447..bac4b40 100644 (file)
@@ -26,7 +26,7 @@
 #include "SkCanvas.h"
 #include "SkCrossContextImageData.h"
 #include "SkBitmapCache.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkImage_Gpu.h"
 #include "SkImageCacherator.h"
 #include "SkImageInfoPriv.h"
index 01b92a7..61be7b7 100644 (file)
@@ -19,7 +19,6 @@
 #include "GrContext.h"
 #include "GrTextureAdjuster.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #endif
 
 // fixes https://bug.skia.org/5096
index 31a4194..53bd09e 100644 (file)
 
 #include "GrBlend.h"
 #include "SkGr.h"
-#include "SkGrPriv.h"
 #include "SkRandom.h"
 
+static inline SkPMColor GrColorToSkPMColor(GrColor c) {
+    GrColorIsPMAssert(c);
+    return SkPackARGB32(GrColorUnpackA(c), GrColorUnpackR(c), GrColorUnpackG(c), GrColorUnpackB(c));
+}
+
+static inline GrColor SkPMColorToGrColor(SkPMColor c) {
+    return GrColorPackRGBA(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c),
+                           SkGetPackedA32(c));
+}
+
 static GrColor make_baseline_color(GrColor src, GrColor dst, const SkXfermode* xm) {
     SkPMColor skSrc = GrColorToSkPMColor(src);
     SkPMColor skDst = GrColorToSkPMColor(dst);
index c033ebc..f9a0147 100644 (file)
@@ -18,7 +18,7 @@
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
 #include "GrSurfaceProxy.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #endif
 
 
index 7e27583..f70aa26 100644 (file)
@@ -17,7 +17,7 @@
 #include "GrResourceCache.h"
 #include "GrSemaphore.h"
 
-#include "SkGrPriv.h"
+#include "SkGr.h"
 #include "SkImage_Gpu.h"
 #include "SkMathPriv.h"
 #include "SkString.h"