blob: 2664b2e00c7d5be82609a347b4d2f6a1724036e3 [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 Salomon514baff2016-11-17 15:17:07 -050019 * It allows explicit specification of the filtering and wrap modes (GrSamplerParams). 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:
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040024 static sk_sp<GrGeometryProcessor> Make(GrColor color,
Robert Phillipsdbc8eeb2017-02-21 10:04:31 -050025 sk_sp<GrTextureProxy> proxy, const GrSamplerParams& p,
26 GrMaskFormat format, const SkMatrix& localMatrix,
27 bool usesLocalCoords) {
28 return sk_sp<GrGeometryProcessor>(
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040029 new GrBitmapTextGeoProc(color, std::move(proxy), p, format,
Robert Phillipsdbc8eeb2017-02-21 10:04:31 -050030 localMatrix, usesLocalCoords));
31 }
32
Brian Salomond3b65972017-03-22 12:05:03 -040033 ~GrBitmapTextGeoProc() override {}
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000034
mtklein36352bf2015-03-25 18:17:31 -070035 const char* name() const override { return "Texture"; }
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000036
joshualitt71c92602015-01-14 08:12:47 -080037 const Attribute* inPosition() const { return fInPosition; }
38 const Attribute* inColor() const { return fInColor; }
39 const Attribute* inTextureCoords() const { return fInTextureCoords; }
joshualitt02b05012015-02-11 06:56:30 -080040 GrMaskFormat maskFormat() const { return fMaskFormat; }
joshualitt88c23fc2015-05-13 14:18:07 -070041 GrColor color() const { return fColor; }
joshualittb8c241a2015-05-19 08:23:30 -070042 bool hasVertexColor() const { return SkToBool(fInColor); }
joshualitte3ababe2015-05-15 07:56:07 -070043 const SkMatrix& localMatrix() const { return fLocalMatrix; }
joshualittb8c241a2015-05-19 08:23:30 -070044 bool usesLocalCoords() const { return fUsesLocalCoords; }
joshualitt249af152014-09-15 11:41:13 -070045
Brian Salomon94efbf52016-11-29 13:43:05 -050046 void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000047
Brian Salomon94efbf52016-11-29 13:43:05 -050048 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000049
50private:
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040051 GrBitmapTextGeoProc(GrColor, sk_sp<GrTextureProxy>,
Robert Phillips296b1cc2017-03-15 10:42:12 -040052 const GrSamplerParams& params,
Robert Phillipsdbc8eeb2017-02-21 10:04:31 -050053 GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords);
54
joshualitt88c23fc2015-05-13 14:18:07 -070055 GrColor fColor;
joshualitte3ababe2015-05-15 07:56:07 -070056 SkMatrix fLocalMatrix;
joshualittb8c241a2015-05-19 08:23:30 -070057 bool fUsesLocalCoords;
Brian Salomon0bbecb22016-11-17 11:38:22 -050058 TextureSampler fTextureSampler;
joshualitt71c92602015-01-14 08:12:47 -080059 const Attribute* fInPosition;
60 const Attribute* fInColor;
61 const Attribute* fInTextureCoords;
joshualitt02b05012015-02-11 06:56:30 -080062 GrMaskFormat fMaskFormat;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000063
Brian Salomon0c26a9d2017-07-06 10:09:38 -040064 GR_DECLARE_GEOMETRY_PROCESSOR_TEST
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000065
joshualitt249af152014-09-15 11:41:13 -070066 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000067};
68
69#endif