blob: 5501d938f5601984daffe40df6575dc9c178a0a5 [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.
19 * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input
20 * 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:
joshualitt2e3b3e32014-12-09 13:31:14 -080024 static GrGeometryProcessor* Create(GrColor color, GrTexture* tex, const GrTextureParams& p,
joshualittb8c241a2015-05-19 08:23:30 -070025 GrMaskFormat format, const SkMatrix& localMatrix,
26 bool usesLocalCoords) {
halcanary385fe4d2015-08-26 13:07:48 -070027 return new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords);
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000028 }
29
egdaniel309e3462014-12-09 10:35:58 -080030 virtual ~GrBitmapTextGeoProc() {}
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000031
mtklein36352bf2015-03-25 18:17:31 -070032 const char* name() const override { return "Texture"; }
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000033
joshualitt71c92602015-01-14 08:12:47 -080034 const Attribute* inPosition() const { return fInPosition; }
35 const Attribute* inColor() const { return fInColor; }
36 const Attribute* inTextureCoords() const { return fInTextureCoords; }
joshualitt02b05012015-02-11 06:56:30 -080037 GrMaskFormat maskFormat() const { return fMaskFormat; }
joshualitt88c23fc2015-05-13 14:18:07 -070038 GrColor color() const { return fColor; }
joshualittb8c241a2015-05-19 08:23:30 -070039 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
40 bool hasVertexColor() const { return SkToBool(fInColor); }
joshualitte3ababe2015-05-15 07:56:07 -070041 const SkMatrix& localMatrix() const { return fLocalMatrix; }
joshualittb8c241a2015-05-19 08:23:30 -070042 bool usesLocalCoords() const { return fUsesLocalCoords; }
joshualitt249af152014-09-15 11:41:13 -070043
egdaniel57d3b032015-11-13 11:57:27 -080044 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000045
egdaniel57d3b032015-11-13 11:57:27 -080046 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000047
48private:
joshualitt56995b52014-12-11 15:44:02 -080049 GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
joshualittb8c241a2015-05-19 08:23:30 -070050 GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords);
egdaniel1a8ecdf2014-10-03 06:24:12 -070051
joshualitt88c23fc2015-05-13 14:18:07 -070052 GrColor fColor;
joshualitte3ababe2015-05-15 07:56:07 -070053 SkMatrix fLocalMatrix;
joshualittb8c241a2015-05-19 08:23:30 -070054 bool fUsesLocalCoords;
joshualitt02b05012015-02-11 06:56:30 -080055 GrTextureAccess fTextureAccess;
joshualitt71c92602015-01-14 08:12:47 -080056 const Attribute* fInPosition;
57 const Attribute* fInColor;
58 const Attribute* fInTextureCoords;
joshualitt02b05012015-02-11 06:56:30 -080059 GrMaskFormat fMaskFormat;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000060
joshualittb0a8a372014-09-23 09:50:21 -070061 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000062
joshualitt249af152014-09-15 11:41:13 -070063 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000064};
65
66#endif