From 6af0c9394301b9f976813cc6dbdbbfe779030fe1 Mon Sep 17 00:00:00 2001 From: wangyix Date: Wed, 22 Jul 2015 10:21:17 -0700 Subject: Moved GrGLFragmentProcessor definition to its own file BUG=skia: Review URL: https://codereview.chromium.org/1246193002 --- src/gpu/effects/GrBezierEffect.cpp | 2 +- src/gpu/effects/GrBicubicEffect.h | 2 +- src/gpu/effects/GrBitmapTextGeoProc.cpp | 2 +- src/gpu/effects/GrConfigConversionEffect.cpp | 2 +- src/gpu/effects/GrConstColorProcessor.cpp | 2 +- src/gpu/effects/GrConvexPolyEffect.cpp | 2 +- src/gpu/effects/GrConvolutionEffect.cpp | 2 +- src/gpu/effects/GrCustomXfermode.cpp | 2 +- src/gpu/effects/GrDashingEffect.cpp | 2 +- src/gpu/effects/GrDistanceFieldGeoProc.cpp | 2 +- src/gpu/effects/GrDitherEffect.cpp | 2 +- src/gpu/effects/GrMatrixConvolutionEffect.cpp | 2 +- src/gpu/effects/GrOvalEffect.cpp | 2 +- src/gpu/effects/GrRRectEffect.cpp | 2 +- src/gpu/effects/GrSimpleTextureEffect.cpp | 2 +- src/gpu/effects/GrTextureDomain.cpp | 2 +- src/gpu/effects/GrTextureDomain.h | 2 +- src/gpu/effects/GrYUVtoRGBEffect.cpp | 2 +- src/gpu/gl/GrGLFragmentProcessor.h | 67 +++++++++++++++++++++++++++ src/gpu/gl/GrGLGpuProgramCache.cpp | 2 +- src/gpu/gl/GrGLProcessor.h | 52 --------------------- src/gpu/gl/GrGLProgramDesc.cpp | 2 +- src/gpu/gl/GrGLXferProcessor.h | 2 +- src/gpu/gl/builders/GrGLShaderBuilder.h | 2 +- 24 files changed, 89 insertions(+), 74 deletions(-) create mode 100644 src/gpu/gl/GrGLFragmentProcessor.h (limited to 'src/gpu') diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index 6f492c76ac..6a39be439d 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -7,7 +7,7 @@ #include "GrBezierEffect.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLGeometryProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index 11075f2398..86118f7b78 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -10,7 +10,7 @@ #include "GrSingleTextureEffect.h" #include "GrTextureDomain.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" class GrGLBicubicEffect; class GrInvariantOutput; diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 4bfa01644c..a0350e99f5 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -9,7 +9,7 @@ #include "GrFontAtlasSizes.h" #include "GrInvariantOutput.h" #include "GrTexture.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLTexture.h" #include "gl/GrGLGeometryProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index 4927e29f8a..fa97f324be 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -11,7 +11,7 @@ #include "GrInvariantOutput.h" #include "GrSimpleTextureEffect.h" #include "SkMatrix.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" class GrGLConfigConversionEffect : public GrGLFragmentProcessor { diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp index 964e85c708..bc09156a71 100644 --- a/src/gpu/effects/GrConstColorProcessor.cpp +++ b/src/gpu/effects/GrConstColorProcessor.cpp @@ -6,7 +6,7 @@ */ #include "effects/GrConstColorProcessor.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" class GLConstColorProcessor : public GrGLFragmentProcessor { diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp index a3d032f4a0..6ecba24c5f 100644 --- a/src/gpu/effects/GrConvexPolyEffect.cpp +++ b/src/gpu/effects/GrConvexPolyEffect.cpp @@ -8,7 +8,7 @@ #include "GrConvexPolyEffect.h" #include "GrInvariantOutput.h" #include "SkPathPriv.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp index f5b5e22ce1..7bb5434f8d 100644 --- a/src/gpu/effects/GrConvolutionEffect.cpp +++ b/src/gpu/effects/GrConvolutionEffect.cpp @@ -6,7 +6,7 @@ */ #include "GrConvolutionEffect.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLTexture.h" #include "gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index 7fc65a477c..350243ebc7 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -18,7 +18,7 @@ #include "SkXfermode.h" #include "gl/GrGLCaps.h" #include "gl/GrGLGpu.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLProgramDataManager.h" #include "gl/builders/GrGLProgramBuilder.h" #include "glsl/GrGLSLCaps.h" diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index f6fe81ba36..550823aacb 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -22,7 +22,7 @@ #include "GrVertexBuffer.h" #include "SkGr.h" #include "gl/GrGLGeometryProcessor.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 393a99db57..8af5631cc5 100755 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -12,7 +12,7 @@ #include "SkDistanceFieldGen.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLTexture.h" #include "gl/GrGLGeometryProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp index eb8466b0b5..1638b1fdec 100644 --- a/src/gpu/effects/GrDitherEffect.cpp +++ b/src/gpu/effects/GrDitherEffect.cpp @@ -9,7 +9,7 @@ #include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" #include "SkRect.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index 24e78208d5..87b38eee3b 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ #include "GrMatrixConvolutionEffect.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLTexture.h" #include "gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp index 1b6df12790..e7b52359fc 100644 --- a/src/gpu/effects/GrOvalEffect.cpp +++ b/src/gpu/effects/GrOvalEffect.cpp @@ -10,7 +10,7 @@ #include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" #include "SkRect.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index a31e89ce3e..432e6ff402 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -12,7 +12,7 @@ #include "GrInvariantOutput.h" #include "GrOvalEffect.h" #include "SkRRect.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" // The effects defined here only handle rrect radii >= kRadiusMin. diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index c1b28116d8..8e6243dca0 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -9,7 +9,7 @@ #include "GrInvariantOutput.h" #include "GrTexture.h" #include "gl/GrGLCaps.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLTexture.h" #include "gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 00067c491c..1ebbea8303 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -9,7 +9,7 @@ #include "GrInvariantOutput.h" #include "GrSimpleTextureEffect.h" #include "SkFloatingPoint.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index f9de4fa75e..77c6ce3d3a 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -9,7 +9,7 @@ #define GrTextureDomainEffect_DEFINED #include "GrSingleTextureEffect.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" class GrGLProgramBuilder; class GrGLShaderBuilder; diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index dd1b48082c..7e62868c95 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -10,7 +10,7 @@ #include "GrCoordTransform.h" #include "GrInvariantOutput.h" #include "GrProcessor.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" namespace { diff --git a/src/gpu/gl/GrGLFragmentProcessor.h b/src/gpu/gl/GrGLFragmentProcessor.h new file mode 100644 index 0000000000..723806feab --- /dev/null +++ b/src/gpu/gl/GrGLFragmentProcessor.h @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrGLFragmentProcessor_DEFINED +#define GrGLFragmentProcessor_DEFINED + +#include "GrGLProgramDataManager.h" +#include "GrGLProcessor.h" +#include "GrTextureAccess.h" + +class GrGLFPBuilder; + +class GrGLFragmentProcessor { +public: + GrGLFragmentProcessor() {} + + virtual ~GrGLFragmentProcessor() {} + + typedef GrGLProgramDataManager::UniformHandle UniformHandle; + typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; + typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; + + /** Called when the program stage should insert its code into the shaders. The code in each + shader will be in its own block ({}) and so locally scoped names will not collide across + stages. + + @param builder Interface used to emit code in the shaders. + @param processor The processor that generated this program stage. + @param key The key that was computed by GenKey() from the generating GrProcessor. + @param outputColor A predefined vec4 in the FS in which the stage should place its output + color (or coverage). + @param inputColor A vec4 that holds the input color to the stage in the FS. This may be + NULL in which case the implied input is solid white (all ones). + TODO: Better system for communicating optimization info (e.g. input + color is solid white, trans black, known to be opaque, etc.) that allows + the processor to communicate back similar known info about its output. + @param samplers Contains one entry for each GrTextureAccess of the GrProcessor. These + can be passed to the builder to emit texture reads in the generated + code. + TODO this should take a struct + */ + virtual void emitCode(GrGLFPBuilder* builder, + const GrFragmentProcessor&, + const char* outputColor, + const char* inputColor, + const TransformedCoordsArray& coords, + const TextureSamplerArray& samplers) = 0; + + /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProcessor that produces + the same stage key; this function reads data from a GrFragmentProcessor and uploads any + uniform variables required by the shaders created in emitCode(). The GrFragmentProcessor + parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and + to have an identical processor key as the one that created this GrGLFragmentProcessor. */ + // TODO update this to pass in GrFragmentProcessor + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} + + static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {} + +private: + typedef GrGLProcessor INHERITED; +}; + +#endif diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index 919e9bbb9f..11e237a73c 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -9,7 +9,7 @@ #include "builders/GrGLProgramBuilder.h" #include "GrProcessor.h" -#include "GrGLProcessor.h" +#include "GrGLFragmentProcessor.h" #include "GrGLPathRendering.h" #include "SkRTConf.h" #include "SkTSearch.h" diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h index 017585d306..f99b1c5030 100644 --- a/src/gpu/gl/GrGLProcessor.h +++ b/src/gpu/gl/GrGLProcessor.h @@ -65,56 +65,4 @@ public: typedef SkTArray TextureSamplerArray; }; -class GrGLFPBuilder; - -class GrGLFragmentProcessor { -public: - GrGLFragmentProcessor() {} - - virtual ~GrGLFragmentProcessor() {} - - typedef GrGLProgramDataManager::UniformHandle UniformHandle; - typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; - typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; - - /** Called when the program stage should insert its code into the shaders. The code in each - shader will be in its own block ({}) and so locally scoped names will not collide across - stages. - - @param builder Interface used to emit code in the shaders. - @param processor The processor that generated this program stage. - @param key The key that was computed by GenKey() from the generating GrProcessor. - @param outputColor A predefined vec4 in the FS in which the stage should place its output - color (or coverage). - @param inputColor A vec4 that holds the input color to the stage in the FS. This may be - NULL in which case the implied input is solid white (all ones). - TODO: Better system for communicating optimization info (e.g. input - color is solid white, trans black, known to be opaque, etc.) that allows - the processor to communicate back similar known info about its output. - @param samplers Contains one entry for each GrTextureAccess of the GrProcessor. These - can be passed to the builder to emit texture reads in the generated - code. - TODO this should take a struct - */ - virtual void emitCode(GrGLFPBuilder* builder, - const GrFragmentProcessor&, - const char* outputColor, - const char* inputColor, - const TransformedCoordsArray& coords, - const TextureSamplerArray& samplers) = 0; - - /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProcessor that produces - the same stage key; this function reads data from a GrFragmentProcessor and uploads any - uniform variables required by the shaders created in emitCode(). The GrFragmentProcessor - parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and - to have an identical processor key as the one that created this GrGLFragmentProcessor. */ - // TODO update this to pass in GrFragmentProcessor - virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} - - static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {} - -private: - typedef GrGLProcessor INHERITED; -}; - #endif diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index 34cb11463b..7eb4fe1517 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -6,7 +6,7 @@ */ #include "GrGLProgramDesc.h" -#include "GrGLProcessor.h" +#include "GrGLFragmentProcessor.h" #include "GrProcessor.h" #include "GrGLGpu.h" #include "GrPipeline.h" diff --git a/src/gpu/gl/GrGLXferProcessor.h b/src/gpu/gl/GrGLXferProcessor.h index 4b913d5a98..c9c6cb5c41 100644 --- a/src/gpu/gl/GrGLXferProcessor.h +++ b/src/gpu/gl/GrGLXferProcessor.h @@ -8,7 +8,7 @@ #ifndef GrGLXferProcessor_DEFINED #define GrGLXferProcessor_DEFINED -#include "GrGLProcessor.h" +#include "GrGLFragmentProcessor.h" class GrGLXPBuilder; class GrXferProcessor; diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.h b/src/gpu/gl/builders/GrGLShaderBuilder.h index 95337683c6..4a6d2e13d8 100644 --- a/src/gpu/gl/builders/GrGLShaderBuilder.h +++ b/src/gpu/gl/builders/GrGLShaderBuilder.h @@ -9,7 +9,7 @@ #define GrGLShaderBuilder_DEFINED #include "SkTArray.h" -#include "gl/GrGLProcessor.h" +#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLProgramDesc.h" #include "gl/GrGLProgramDataManager.h" -- cgit v1.2.3