blob: d5684d746edceaa82729ac2e310c1945f5ef7404 [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,
joshualitt8fc6c2d2014-12-22 15:27:05 -080025 bool useColorAttrib, bool opaqueVertexColors,
26 const SkMatrix& localMatrix) {
27 return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, useColorAttrib, opaqueVertexColors,
28 localMatrix));
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
mtklein72c9faa2015-01-09 10:06:39 -080033 const char* name() const SK_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; }
joshualitt249af152014-09-15 11:41:13 -070038
joshualitteb2a6762014-12-04 11:35:33 -080039 virtual void getGLProcessorKey(const GrBatchTracker& bt,
40 const GrGLCaps& caps,
41 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000042
joshualittabb52a12015-01-13 15:02:10 -080043 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
44 const GrGLCaps& caps) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000045
joshualittd5a7db42015-01-27 15:39:06 -080046 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const SK_OVERRIDE;
joshualitt290c09b2014-12-19 13:45:20 -080047 bool onCanMakeEqual(const GrBatchTracker&,
48 const GrGeometryProcessor&,
49 const GrBatchTracker&) const SK_OVERRIDE;
joshualitt9b989322014-12-15 14:16:27 -080050
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000051private:
joshualitt56995b52014-12-11 15:44:02 -080052 GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
joshualitt8fc6c2d2014-12-22 15:27:05 -080053 bool useColorAttrib, bool opaqueVertexColors, const SkMatrix& localMatrix);
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000054
mtklein72c9faa2015-01-09 10:06:39 -080055 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000056
mtklein72c9faa2015-01-09 10:06:39 -080057 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
egdaniel1a8ecdf2014-10-03 06:24:12 -070058
joshualitt249af152014-09-15 11:41:13 -070059 GrTextureAccess fTextureAccess;
joshualitt71c92602015-01-14 08:12:47 -080060 const Attribute* fInPosition;
61 const Attribute* fInColor;
62 const Attribute* fInTextureCoords;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000063
joshualittb0a8a372014-09-23 09:50:21 -070064 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