blob: 42345704cf2ac1eabb582f2cdb25ff9eb3598772 [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,
joshualitt56995b52014-12-11 15:44:02 -080025 bool useColorAttrib, bool opaqueVertexColors) {
26 return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, useColorAttrib, opaqueVertexColors));
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000027 }
28
egdaniel309e3462014-12-09 10:35:58 -080029 virtual ~GrBitmapTextGeoProc() {}
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000030
joshualitteb2a6762014-12-04 11:35:33 -080031 virtual const char* name() const SK_OVERRIDE { return "Texture"; }
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000032
joshualitt2dd1ae02014-12-03 06:24:10 -080033 const GrAttribute* inPosition() const { return fInPosition; }
34 const GrAttribute* inColor() const { return fInColor; }
35 const GrAttribute* inTextureCoords() const { return fInTextureCoords; }
joshualitt249af152014-09-15 11:41:13 -070036
joshualitteb2a6762014-12-04 11:35:33 -080037 virtual void getGLProcessorKey(const GrBatchTracker& bt,
38 const GrGLCaps& caps,
39 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000040
joshualitteb2a6762014-12-04 11:35:33 -080041 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000042
joshualitt9b989322014-12-15 14:16:27 -080043 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE;
44 bool onCanMakeEqual(const GrBatchTracker&, const GrBatchTracker&) const SK_OVERRIDE;
45
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000046private:
joshualitt56995b52014-12-11 15:44:02 -080047 GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
48 bool useColorAttrib, bool opaqueVertexColors);
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000049
bsalomon0e08fc12014-10-15 08:19:04 -070050 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000051
joshualitt56995b52014-12-11 15:44:02 -080052 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
egdaniel1a8ecdf2014-10-03 06:24:12 -070053
joshualitt249af152014-09-15 11:41:13 -070054 GrTextureAccess fTextureAccess;
joshualitt2dd1ae02014-12-03 06:24:10 -080055 const GrAttribute* fInPosition;
56 const GrAttribute* fInColor;
57 const GrAttribute* fInTextureCoords;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000058
joshualittb0a8a372014-09-23 09:50:21 -070059 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000060
joshualitt249af152014-09-15 11:41:13 -070061 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000062};
63
64#endif