blob: c8fc99b0203c0f0bd862b6fa1e18cda7dfdd1262 [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:
Brian Salomon514baff2016-11-17 15:17:07 -050024 static sk_sp<GrGeometryProcessor> Make(GrColor color, GrTexture* tex, const GrSamplerParams& p,
joshualittb8c241a2015-05-19 08:23:30 -070025 GrMaskFormat format, const SkMatrix& localMatrix,
26 bool usesLocalCoords) {
bungeman06ca8ec2016-06-09 08:01:03 -070027 return sk_sp<GrGeometryProcessor>(
28 new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords));
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000029 }
30
egdaniel309e3462014-12-09 10:35:58 -080031 virtual ~GrBitmapTextGeoProc() {}
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000032
mtklein36352bf2015-03-25 18:17:31 -070033 const char* name() const override { return "Texture"; }
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000034
joshualitt71c92602015-01-14 08:12:47 -080035 const Attribute* inPosition() const { return fInPosition; }
36 const Attribute* inColor() const { return fInColor; }
37 const Attribute* inTextureCoords() const { return fInTextureCoords; }
joshualitt02b05012015-02-11 06:56:30 -080038 GrMaskFormat maskFormat() const { return fMaskFormat; }
joshualitt88c23fc2015-05-13 14:18:07 -070039 GrColor color() const { return fColor; }
joshualittb8c241a2015-05-19 08:23:30 -070040 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
41 bool hasVertexColor() const { return SkToBool(fInColor); }
joshualitte3ababe2015-05-15 07:56:07 -070042 const SkMatrix& localMatrix() const { return fLocalMatrix; }
joshualittb8c241a2015-05-19 08:23:30 -070043 bool usesLocalCoords() const { return fUsesLocalCoords; }
joshualitt249af152014-09-15 11:41:13 -070044
egdaniel57d3b032015-11-13 11:57:27 -080045 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000046
egdaniel57d3b032015-11-13 11:57:27 -080047 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000048
49private:
Brian Salomon514baff2016-11-17 15:17:07 -050050 GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrSamplerParams& params,
joshualittb8c241a2015-05-19 08:23:30 -070051 GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords);
egdaniel1a8ecdf2014-10-03 06:24:12 -070052
joshualitt88c23fc2015-05-13 14:18:07 -070053 GrColor fColor;
joshualitte3ababe2015-05-15 07:56:07 -070054 SkMatrix fLocalMatrix;
joshualittb8c241a2015-05-19 08:23:30 -070055 bool fUsesLocalCoords;
Brian Salomon0bbecb22016-11-17 11:38:22 -050056 TextureSampler fTextureSampler;
joshualitt71c92602015-01-14 08:12:47 -080057 const Attribute* fInPosition;
58 const Attribute* fInColor;
59 const Attribute* fInTextureCoords;
joshualitt02b05012015-02-11 06:56:30 -080060 GrMaskFormat fMaskFormat;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000061
joshualittb0a8a372014-09-23 09:50:21 -070062 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000063
joshualitt249af152014-09-15 11:41:13 -070064 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000065};
66
67#endif