blob: 1bc062003ed475b7669ea1528dde33762c061fc4 [file] [log] [blame]
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +00001/*
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
egdaniel309e3462014-12-09 10:35:58 -08008#ifndef GrBitmapTextGeoProc_DEFINED
9#define GrBitmapTextGeoProc_DEFINED
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000010
joshualittb0a8a372014-09-23 09:50:21 -070011#include "GrProcessor.h"
joshualitt249af152014-09-15 11:41:13 -070012#include "GrGeometryProcessor.h"
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000013
egdaniel309e3462014-12-09 10:35:58 -080014class GrGLBitmapTextGeoProc;
egdaniel605dd0f2014-11-12 08:35:25 -080015class GrInvariantOutput;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000016
17/**
18 * The output color of this effect is a modulation of the input color and a sample from a texture.
Brian Salomon2bbdcc42017-09-07 12:36:34 -040019 * It allows explicit specification of the filtering and wrap modes (GrSamplerState). The input
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000020 * coords are a custom attribute.
21 */
egdaniel309e3462014-12-09 10:35:58 -080022class GrBitmapTextGeoProc : public GrGeometryProcessor {
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000023public:
Jim Van Vertha950b632017-09-12 11:54:11 -040024
25 static sk_sp<GrGeometryProcessor> Make(GrColor color,
Robert Phillips4bc70112018-03-01 10:24:02 -050026 const sk_sp<GrTextureProxy>* proxies,
Jim Van Verthcbeae032018-05-16 14:54:41 -040027 int numActiveProxies,
Brian Salomon2bbdcc42017-09-07 12:36:34 -040028 const GrSamplerState& p, GrMaskFormat format,
Jim Van Verthb515ae72018-05-23 16:44:55 -040029 const SkMatrix& localMatrix, bool usesW) {
Robert Phillipsdbc8eeb2017-02-21 10:04:31 -050030 return sk_sp<GrGeometryProcessor>(
Jim Van Verthcbeae032018-05-16 14:54:41 -040031 new GrBitmapTextGeoProc(color, proxies, numActiveProxies, p, format,
Jim Van Verthb515ae72018-05-23 16:44:55 -040032 localMatrix, usesW));
Robert Phillipsdbc8eeb2017-02-21 10:04:31 -050033 }
34
Brian Salomond3b65972017-03-22 12:05:03 -040035 ~GrBitmapTextGeoProc() override {}
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000036
mtklein36352bf2015-03-25 18:17:31 -070037 const char* name() const override { return "Texture"; }
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000038
Brian Salomon92be2f72018-06-19 14:33:47 -040039 const Attribute& inPosition() const { return fInPosition; }
40 const Attribute& inColor() const { return fInColor; }
41 const Attribute& inTextureCoords() const { return fInTextureCoords; }
joshualitt02b05012015-02-11 06:56:30 -080042 GrMaskFormat maskFormat() const { return fMaskFormat; }
joshualitt88c23fc2015-05-13 14:18:07 -070043 GrColor color() const { return fColor; }
Brian Salomon92be2f72018-06-19 14:33:47 -040044 bool hasVertexColor() const { return fInColor.isInitialized(); }
joshualitte3ababe2015-05-15 07:56:07 -070045 const SkMatrix& localMatrix() const { return fLocalMatrix; }
Jim Van Verthb515ae72018-05-23 16:44:55 -040046 bool usesW() const { return fUsesW; }
joshualitt249af152014-09-15 11:41:13 -070047
Jim Van Verthcbeae032018-05-16 14:54:41 -040048 void addNewProxies(const sk_sp<GrTextureProxy>*, int numActiveProxies, const GrSamplerState&);
Jim Van Vertheafa64b2017-09-18 10:05:00 -040049
Brian Salomon94efbf52016-11-29 13:43:05 -050050 void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000051
Brian Salomon94efbf52016-11-29 13:43:05 -050052 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000053
54private:
Robert Phillips4bc70112018-03-01 10:24:02 -050055 static constexpr int kMaxTextures = 4;
56
57 GrBitmapTextGeoProc(GrColor, const sk_sp<GrTextureProxy>* proxies, int numProxies,
Jim Van Vertha950b632017-09-12 11:54:11 -040058 const GrSamplerState& params, GrMaskFormat format,
Jim Van Verthb515ae72018-05-23 16:44:55 -040059 const SkMatrix& localMatrix, bool usesW);
Robert Phillipsdbc8eeb2017-02-21 10:04:31 -050060
Brian Salomon92be2f72018-06-19 14:33:47 -040061 const Attribute& onVertexAttribute(int i) const override;
Brian Salomonf7dcd762018-07-30 14:48:15 -040062 const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
Brian Salomon92be2f72018-06-19 14:33:47 -040063
joshualitt88c23fc2015-05-13 14:18:07 -070064 GrColor fColor;
joshualitte3ababe2015-05-15 07:56:07 -070065 SkMatrix fLocalMatrix;
Jim Van Verthb515ae72018-05-23 16:44:55 -040066 bool fUsesW;
Jim Van Vertha950b632017-09-12 11:54:11 -040067 TextureSampler fTextureSamplers[kMaxTextures];
Brian Salomon92be2f72018-06-19 14:33:47 -040068 Attribute fInPosition;
69 Attribute fInColor;
70 Attribute fInTextureCoords;
joshualitt02b05012015-02-11 06:56:30 -080071 GrMaskFormat fMaskFormat;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000072
Brian Salomon0c26a9d2017-07-06 10:09:38 -040073 GR_DECLARE_GEOMETRY_PROCESSOR_TEST
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000074
joshualitt249af152014-09-15 11:41:13 -070075 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000076};
77
78#endif