blob: 837dcb6fe5587553bcdf63deb7a89294bbd750ad [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,
joshualitt1ba8cc92015-05-13 12:24:23 -070025 GrMaskFormat format,
joshualitt8fc6c2d2014-12-22 15:27:05 -080026 const SkMatrix& localMatrix) {
joshualitt1ba8cc92015-05-13 12:24:23 -070027 return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, format, localMatrix));
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; }
joshualitte3ababe2015-05-15 07:56:07 -070039 const SkMatrix& localMatrix() const { return fLocalMatrix; }
joshualitt249af152014-09-15 11:41:13 -070040
joshualitteb2a6762014-12-04 11:35:33 -080041 virtual void getGLProcessorKey(const GrBatchTracker& bt,
jvanverthcfc18862015-04-28 08:48:20 -070042 const GrGLSLCaps& caps,
mtklein36352bf2015-03-25 18:17:31 -070043 GrProcessorKeyBuilder* b) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000044
joshualittabb52a12015-01-13 15:02:10 -080045 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
jvanverthcfc18862015-04-28 08:48:20 -070046 const GrGLSLCaps& caps) const override;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000047
mtklein36352bf2015-03-25 18:17:31 -070048 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override;
joshualitt9b989322014-12-15 14:16:27 -080049
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000050private:
joshualitt56995b52014-12-11 15:44:02 -080051 GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
joshualitt1ba8cc92015-05-13 12:24:23 -070052 GrMaskFormat format, const SkMatrix& localMatrix);
egdaniel1a8ecdf2014-10-03 06:24:12 -070053
joshualitt88c23fc2015-05-13 14:18:07 -070054 GrColor fColor;
joshualitte3ababe2015-05-15 07:56:07 -070055 SkMatrix fLocalMatrix;
joshualitt02b05012015-02-11 06:56:30 -080056 GrTextureAccess fTextureAccess;
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