commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
egdaniel | 309e346 | 2014-12-09 10:35:58 -0800 | [diff] [blame] | 8 | #ifndef GrBitmapTextGeoProc_DEFINED |
| 9 | #define GrBitmapTextGeoProc_DEFINED |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 10 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 11 | #include "GrProcessor.h" |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 12 | #include "GrGeometryProcessor.h" |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 13 | |
egdaniel | 309e346 | 2014-12-09 10:35:58 -0800 | [diff] [blame] | 14 | class GrGLBitmapTextGeoProc; |
egdaniel | 605dd0f | 2014-11-12 08:35:25 -0800 | [diff] [blame] | 15 | class GrInvariantOutput; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * The output color of this effect is a modulation of the input color and a sample from a texture. |
| 19 | * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input |
| 20 | * coords are a custom attribute. |
| 21 | */ |
egdaniel | 309e346 | 2014-12-09 10:35:58 -0800 | [diff] [blame] | 22 | class GrBitmapTextGeoProc : public GrGeometryProcessor { |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 23 | public: |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 24 | static sk_sp<GrGeometryProcessor> Make(GrColor color, GrTexture* tex, const GrTextureParams& p, |
joshualitt | b8c241a | 2015-05-19 08:23:30 -0700 | [diff] [blame] | 25 | GrMaskFormat format, const SkMatrix& localMatrix, |
| 26 | bool usesLocalCoords) { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 27 | return sk_sp<GrGeometryProcessor>( |
| 28 | new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords)); |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 29 | } |
| 30 | |
egdaniel | 309e346 | 2014-12-09 10:35:58 -0800 | [diff] [blame] | 31 | virtual ~GrBitmapTextGeoProc() {} |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 32 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 33 | const char* name() const override { return "Texture"; } |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 34 | |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 35 | const Attribute* inPosition() const { return fInPosition; } |
| 36 | const Attribute* inColor() const { return fInColor; } |
| 37 | const Attribute* inTextureCoords() const { return fInTextureCoords; } |
joshualitt | 02b0501 | 2015-02-11 06:56:30 -0800 | [diff] [blame] | 38 | GrMaskFormat maskFormat() const { return fMaskFormat; } |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame] | 39 | GrColor color() const { return fColor; } |
joshualitt | b8c241a | 2015-05-19 08:23:30 -0700 | [diff] [blame] | 40 | bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
| 41 | bool hasVertexColor() const { return SkToBool(fInColor); } |
joshualitt | e3ababe | 2015-05-15 07:56:07 -0700 | [diff] [blame] | 42 | const SkMatrix& localMatrix() const { return fLocalMatrix; } |
joshualitt | b8c241a | 2015-05-19 08:23:30 -0700 | [diff] [blame] | 43 | bool usesLocalCoords() const { return fUsesLocalCoords; } |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 44 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 45 | void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 46 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 47 | GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const override; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 48 | |
| 49 | private: |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 50 | GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params, |
joshualitt | b8c241a | 2015-05-19 08:23:30 -0700 | [diff] [blame] | 51 | GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords); |
egdaniel | 1a8ecdf | 2014-10-03 06:24:12 -0700 | [diff] [blame] | 52 | |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame] | 53 | GrColor fColor; |
joshualitt | e3ababe | 2015-05-15 07:56:07 -0700 | [diff] [blame] | 54 | SkMatrix fLocalMatrix; |
joshualitt | b8c241a | 2015-05-19 08:23:30 -0700 | [diff] [blame] | 55 | bool fUsesLocalCoords; |
joshualitt | 02b0501 | 2015-02-11 06:56:30 -0800 | [diff] [blame] | 56 | GrTextureAccess fTextureAccess; |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 57 | const Attribute* fInPosition; |
| 58 | const Attribute* fInColor; |
| 59 | const Attribute* fInTextureCoords; |
joshualitt | 02b0501 | 2015-02-11 06:56:30 -0800 | [diff] [blame] | 60 | GrMaskFormat fMaskFormat; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 61 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 62 | GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 63 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 64 | typedef GrGeometryProcessor INHERITED; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | #endif |