Move functions from SkGr to SkGrPriv.h
Review URL: https://codereview.chromium.org/1397123002
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index 0d12d0fb..c7c6bcd 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -10,6 +10,7 @@
#include "HelloWorld.h"
#include "gl/GrGLInterface.h"
+#include "GrContext.h"
#include "SkApplication.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
diff --git a/gyp/utils.gyp b/gyp/utils.gyp
index 9881aa1..e677b2a 100644
--- a/gyp/utils.gyp
+++ b/gyp/utils.gyp
@@ -29,6 +29,7 @@
'../include/utils/unix',
'../include/utils/win',
'../src/core',
+ '../src/gpu',
'../src/image',
'../src/opts',
'../src/utils',
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index bf92fe8..8ea3af1 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -6,54 +6,24 @@
* found in the LICENSE file.
*/
-
-
#ifndef SkGr_DEFINED
#define SkGr_DEFINED
-#include <stddef.h>
-
-// Gr headers
-#include "GrContext.h"
+#include "GrColor.h"
#include "GrTextureAccess.h"
-#include "GrTypes.h"
+#include "SkColor.h"
+#include "SkColorPriv.h"
+#include "SkFilterQuality.h"
+#include "SkImageInfo.h"
-// skia headers
-#include "SkBitmap.h"
-#include "SkPath.h"
-#include "SkPoint.h"
-#include "SkRegion.h"
-#include "SkClipStack.h"
+class GrContext;
+class GrTexture;
+class GrTextureParams;
+class SkBitmap;
////////////////////////////////////////////////////////////////////////////////
// Sk to Gr Type conversions
-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);
-
-#define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X))
-
-///////////////////////////////////////////////////////////////////////////////
-
-#include "SkColorPriv.h"
-
-GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType);
-
-static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {
- return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.profileType());
-}
-
-bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*);
-
static inline GrColor SkColorToPremulGrColor(SkColor c) {
SkPMColor pm = SkPreMultiplyColor(c);
unsigned r = SkGetPackedR32(pm);
@@ -94,31 +64,22 @@
SkGetPackedA32(c));
}
-GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
-
////////////////////////////////////////////////////////////////////////////////
-/**
- * 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);
-
-bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
- GrTexture* nativeTexture, const GrTextureParams*);
-
GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams*);
GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, SkImageUsageType);
-GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey, GrSurfaceDesc,
- SkPixelRef* pixelRefForInvalidationNotificationOrNull,
- const void* pixels, size_t rowBytesOrZero);
+// TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses).
+GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType);
+
+static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {
+ return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.profileType());
+}
+
+GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
+ const SkMatrix& viewM,
+ const SkMatrix& localM,
+ bool* doBicubic);
////////////////////////////////////////////////////////////////////////////////
@@ -128,16 +89,4 @@
SK_API void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque,
SkBitmap* dst);
-GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
- const SkMatrix& viewM,
- const SkMatrix& localM,
- bool* doBicubic);
-
-////////////////////////////////////////////////////////////////////////////////
-// Classes
-
-class SkGlyphCache;
-
-////////////////////////////////////////////////////////////////////////////////
-
#endif
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index b3bbb72..3dd528d 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -15,6 +15,7 @@
#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
+#include "SkGrPriv.h"
#include "effects/GrBicubicEffect.h"
#include "effects/GrSimpleTextureEffect.h"
#endif
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 3a1ea87..6121f215 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -133,6 +133,7 @@
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
+#include "SkGrPriv.h"
class LightingFP : public GrFragmentProcessor {
public:
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index ceb6663..f0ed7b4 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -5,13 +5,14 @@
* found in the LICENSE file.
*/
-#include "SkBitmap.h"
#include "SkTableColorFilter.h"
+
+#include "SkBitmap.h"
#include "SkColorPriv.h"
#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-#include "SkUnPreMultiply.h"
#include "SkString.h"
+#include "SkUnPreMultiply.h"
+#include "SkWriteBuffer.h"
class SkTable_ColorFilter : public SkColorFilter {
public:
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index c379bd6..d402604 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -37,7 +37,7 @@
#include "GrVertices.h"
#include "SkDashPathPriv.h"
#include "SkConfig8888.h"
-#include "SkGr.h"
+#include "SkGrPriv.h"
#include "SkRRect.h"
#include "SkStrokeRec.h"
#include "SkSurfacePriv.h"
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index a7be0f4..382550e 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -6,10 +6,11 @@
*/
#include "GrSurface.h"
+#include "GrContext.h"
#include "GrSurfacePriv.h"
#include "SkBitmap.h"
-#include "SkGr.h"
+#include "SkGrPriv.h"
#include "SkImageEncoder.h"
#include <stdio.h>
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index c4239bd..9d129d5 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -23,6 +23,7 @@
#include "SkErrorInternals.h"
#include "SkGlyphCache.h"
#include "SkGrTexturePixelRef.h"
+#include "SkGr.h"
#include "SkGrPriv.h"
#include "SkImage_Base.h"
#include "SkImageFilter.h"
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index cff6172..8f9555a 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -10,6 +10,7 @@
#include "SkGr.h"
#include "GrCaps.h"
+#include "GrContext.h"
#include "GrDrawContext.h"
#include "GrXferProcessor.h"
#include "GrYUVProvider.h"
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index 36601fc..88bee5c 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -9,6 +9,7 @@
#define SkGrPriv_DEFINED
#include "GrTypes.h"
+#include "GrBlend.h"
#include "GrTextureAccess.h"
#include "SkImageInfo.h"
#include "SkXfermode.h"
@@ -17,6 +18,7 @@
class GrContext;
class GrFragmentProcessor;
class GrPaint;
+class GrTexture;
class GrUniqueKey;
class SkPaint;
class SkMatrix;
@@ -94,6 +96,48 @@
false, grPaint);
}
+//////////////////////////////////////////////////////////////////////////////
+
bool GrTextureUsageSupported(const GrCaps&, int width, int height, SkImageUsageType);
+GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
+
+bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*);
+
+/**
+* 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);
+
+bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
+ GrTexture* nativeTexture, const GrTextureParams*);
+
+GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey, GrSurfaceDesc,
+ SkPixelRef* pixelRefForInvalidationNotificationOrNull,
+ const void* pixels, size_t rowBytesOrZero);
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+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);
+
+#define SkXfermodeCoeffToGrBlendCoeff(X) ((GrBlendCoeff)(X))
+
#endif
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index ca688d8..f2133d1 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -7,9 +7,11 @@
*/
#include "GrTextureStripAtlas.h"
+#include "GrContext.h"
+#include "GrTexture.h"
+#include "SkGr.h"
#include "SkPixelRef.h"
#include "SkTSearch.h"
-#include "GrTexture.h"
#ifdef SK_DEBUG
#define VALIDATE this->validate()
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index ec2f1f3..895838f 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -11,7 +11,7 @@
#include "effects/GrConstColorProcessor.h"
#include "gl/GrGLSLBlend.h"
#include "gl/builders/GrGLProgramBuilder.h"
-#include "SkGr.h"
+#include "SkGrPriv.h"
class ComposeTwoFragmentProcessor : public GrFragmentProcessor {
public:
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index 6c82fa9..cf613e8 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -78,6 +78,7 @@
#include "GrTextureAccess.h"
#include "SkGr.h"
+#include "SkGrPriv.h"
#include "effects/GrSimpleTextureEffect.h"
#include "effects/GrBicubicEffect.h"
#include "effects/GrSimpleTextureEffect.h"
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 00b5c35..72b98cd 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -14,7 +14,7 @@
#include "effects/GrYUVtoRGBEffect.h"
#include "SkCanvas.h"
#include "SkGpuDevice.h"
-#include "SkGrPriv.h"
+#include "SkGr.h"
#include "SkPixelRef.h"
SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex,
diff --git a/src/utils/SkImageGeneratorUtils.cpp b/src/utils/SkImageGeneratorUtils.cpp
index c9b2252..42a0fe5 100644
--- a/src/utils/SkImageGeneratorUtils.cpp
+++ b/src/utils/SkImageGeneratorUtils.cpp
@@ -47,7 +47,7 @@
#include "GrContext.h"
#include "GrTexture.h"
-#include "SkGr.h"
+#include "SkGrPriv.h"
class GeneratorFromTexture : public SkImageGenerator {
public:
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index 9234ac1..7f9b683 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -6,6 +6,7 @@
*/
#include "SkWindow.h"
+#include "GrContext.h"
#include "SkCanvas.h"
#include "SkOSMenu.h"
#include "SkSurface.h"
diff --git a/tests/GrGetCoeffBlendKnownComponentsTest.cpp b/tests/GrGetCoeffBlendKnownComponentsTest.cpp
index e733103..c55b02b 100644
--- a/tests/GrGetCoeffBlendKnownComponentsTest.cpp
+++ b/tests/GrGetCoeffBlendKnownComponentsTest.cpp
@@ -11,6 +11,7 @@
#include "GrBlend.h"
#include "SkGr.h"
+#include "SkGrPriv.h"
#include "SkRandom.h"
#include "SkXfermode.h"
diff --git a/tools/VisualBench/VisualBench.cpp b/tools/VisualBench/VisualBench.cpp
index 8164762..39d2491 100644
--- a/tools/VisualBench/VisualBench.cpp
+++ b/tools/VisualBench/VisualBench.cpp
@@ -8,6 +8,7 @@
#include "VisualBench.h"
+#include "GrContext.h"
#include "ProcStats.h"
#include "SkApplication.h"
#include "SkCanvas.h"