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 | |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 11 | #include "src/core/SkArenaAlloc.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "src/gpu/GrGeometryProcessor.h" |
| 13 | #include "src/gpu/GrProcessor.h" |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 14 | |
egdaniel | 309e346 | 2014-12-09 10:35:58 -0800 | [diff] [blame] | 15 | class GrGLBitmapTextGeoProc; |
Brian Salomon | 1127c0b | 2019-06-13 20:22:10 +0000 | [diff] [blame] | 16 | class GrInvariantOutput; |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 17 | class GrSurfaceProxyView; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * The output color of this effect is a modulation of the input color and a sample from a texture. |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 21 | * It allows explicit specification of the filtering and wrap modes (GrSamplerState). The input |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 22 | * coords are a custom attribute. |
| 23 | */ |
egdaniel | 309e346 | 2014-12-09 10:35:58 -0800 | [diff] [blame] | 24 | class GrBitmapTextGeoProc : public GrGeometryProcessor { |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 25 | public: |
Brian Salomon | 7eae3e0 | 2018-08-07 14:02:38 +0000 | [diff] [blame] | 26 | static constexpr int kMaxTextures = 4; |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 27 | |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 28 | static GrGeometryProcessor* Make(SkArenaAlloc* arena, |
| 29 | const GrShaderCaps& caps, |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 30 | const SkPMColor4f& color, |
| 31 | bool wideColor, |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 32 | const GrSurfaceProxyView* views, |
| 33 | int numActiveViews, |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 34 | GrSamplerState p, |
| 35 | GrMaskFormat format, |
| 36 | const SkMatrix& localMatrix, |
| 37 | bool usesW) { |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 38 | return arena->make<GrBitmapTextGeoProc>(caps, color, wideColor, views, numActiveViews, |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 39 | p, format, localMatrix, usesW); |
Robert Phillips | dbc8eeb | 2017-02-21 10:04:31 -0500 | [diff] [blame] | 40 | } |
| 41 | |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 42 | ~GrBitmapTextGeoProc() override {} |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 43 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 44 | const char* name() const override { return "Texture"; } |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 45 | |
Brian Salomon | 92be2f7 | 2018-06-19 14:33:47 -0400 | [diff] [blame] | 46 | const Attribute& inPosition() const { return fInPosition; } |
| 47 | const Attribute& inColor() const { return fInColor; } |
| 48 | const Attribute& inTextureCoords() const { return fInTextureCoords; } |
joshualitt | 02b0501 | 2015-02-11 06:56:30 -0800 | [diff] [blame] | 49 | GrMaskFormat maskFormat() const { return fMaskFormat; } |
Brian Osman | cf86085 | 2018-10-31 14:04:39 -0400 | [diff] [blame] | 50 | const SkPMColor4f& color() const { return fColor; } |
Brian Salomon | 92be2f7 | 2018-06-19 14:33:47 -0400 | [diff] [blame] | 51 | bool hasVertexColor() const { return fInColor.isInitialized(); } |
joshualitt | e3ababe | 2015-05-15 07:56:07 -0700 | [diff] [blame] | 52 | const SkMatrix& localMatrix() const { return fLocalMatrix; } |
Jim Van Verth | b515ae7 | 2018-05-23 16:44:55 -0400 | [diff] [blame] | 53 | bool usesW() const { return fUsesW; } |
Brian Salomon | 2638f3d | 2019-10-22 12:20:37 -0400 | [diff] [blame] | 54 | const SkISize& atlasDimensions() const { return fAtlasDimensions; } |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 55 | |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 56 | void addNewViews(const GrSurfaceProxyView*, int numActiveViews, GrSamplerState); |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 57 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 58 | void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 59 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 60 | GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 61 | |
| 62 | private: |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 63 | friend class ::SkArenaAlloc; // for access to ctor |
| 64 | |
Brian Osman | c906d25 | 2018-12-04 11:17:46 -0500 | [diff] [blame] | 65 | GrBitmapTextGeoProc(const GrShaderCaps&, const SkPMColor4f&, bool wideColor, |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 66 | const GrSurfaceProxyView* views, int numViews, GrSamplerState params, |
| 67 | GrMaskFormat format, const SkMatrix& localMatrix, bool usesW); |
Robert Phillips | dbc8eeb | 2017-02-21 10:04:31 -0500 | [diff] [blame] | 68 | |
Brian Salomon | f7dcd76 | 2018-07-30 14:48:15 -0400 | [diff] [blame] | 69 | const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; } |
Brian Salomon | 92be2f7 | 2018-06-19 14:33:47 -0400 | [diff] [blame] | 70 | |
Brian Osman | cf86085 | 2018-10-31 14:04:39 -0400 | [diff] [blame] | 71 | SkPMColor4f fColor; |
joshualitt | e3ababe | 2015-05-15 07:56:07 -0700 | [diff] [blame] | 72 | SkMatrix fLocalMatrix; |
Jim Van Verth | b515ae7 | 2018-05-23 16:44:55 -0400 | [diff] [blame] | 73 | bool fUsesW; |
Brian Salomon | 2638f3d | 2019-10-22 12:20:37 -0400 | [diff] [blame] | 74 | SkISize fAtlasDimensions; // dimensions for all textures used with fTextureSamplers[]. |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 75 | TextureSampler fTextureSamplers[kMaxTextures]; |
Brian Salomon | 92be2f7 | 2018-06-19 14:33:47 -0400 | [diff] [blame] | 76 | Attribute fInPosition; |
| 77 | Attribute fInColor; |
| 78 | Attribute fInTextureCoords; |
joshualitt | 02b0501 | 2015-02-11 06:56:30 -0800 | [diff] [blame] | 79 | GrMaskFormat fMaskFormat; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 80 | |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 81 | GR_DECLARE_GEOMETRY_PROCESSOR_TEST |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 82 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 83 | typedef GrGeometryProcessor INHERITED; |
commit-bot@chromium.org | 76eaf74 | 2013-09-30 18:41:38 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | #endif |