blob: ecbf4f947035b714f52a2dd883b907e6baa5303c [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:
egdaniel309e3462014-12-09 10:35:58 -080024 static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& p,
25 bool useColorAttrib) {
26 return SkNEW_ARGS(GrBitmapTextGeoProc, (tex, p, useColorAttrib));
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
43private:
egdaniel309e3462014-12-09 10:35:58 -080044 GrBitmapTextGeoProc(GrTexture* texture, const GrTextureParams& params, bool useColorAttrib);
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000045
bsalomon0e08fc12014-10-15 08:19:04 -070046 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000047
egdaniel605dd0f2014-11-12 08:35:25 -080048 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
egdaniel1a8ecdf2014-10-03 06:24:12 -070049
joshualitt249af152014-09-15 11:41:13 -070050 GrTextureAccess fTextureAccess;
joshualitt2dd1ae02014-12-03 06:24:10 -080051 const GrAttribute* fInPosition;
52 const GrAttribute* fInColor;
53 const GrAttribute* fInTextureCoords;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000054
joshualittb0a8a372014-09-23 09:50:21 -070055 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000056
joshualitt249af152014-09-15 11:41:13 -070057 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000058};
59
60#endif