blob: b5a41453677c4d6eeee8166f27d79985641e95a4 [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,
joshualitt02b05012015-02-11 06:56:30 -080025 GrMaskFormat format, bool opaqueVertexColors,
joshualitt8fc6c2d2014-12-22 15:27:05 -080026 const SkMatrix& localMatrix) {
joshualitt02b05012015-02-11 06:56:30 -080027 return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, format, opaqueVertexColors,
joshualitt8fc6c2d2014-12-22 15:27:05 -080028 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; }
joshualitt02b05012015-02-11 06:56:30 -080038 GrMaskFormat maskFormat() const { return fMaskFormat; }
joshualitt249af152014-09-15 11:41:13 -070039
joshualitteb2a6762014-12-04 11:35:33 -080040 virtual void getGLProcessorKey(const GrBatchTracker& bt,
41 const GrGLCaps& caps,
42 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000043
joshualittabb52a12015-01-13 15:02:10 -080044 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
45 const GrGLCaps& caps) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000046
joshualitt4d8da812015-01-28 12:53:54 -080047 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const SK_OVERRIDE;
joshualitt290c09b2014-12-19 13:45:20 -080048 bool onCanMakeEqual(const GrBatchTracker&,
49 const GrGeometryProcessor&,
50 const GrBatchTracker&) const SK_OVERRIDE;
joshualitt9b989322014-12-15 14:16:27 -080051
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000052private:
joshualitt56995b52014-12-11 15:44:02 -080053 GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
joshualitt02b05012015-02-11 06:56:30 -080054 GrMaskFormat format, bool opaqueVertexColors, const SkMatrix& localMatrix);
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000055
mtklein72c9faa2015-01-09 10:06:39 -080056 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000057
joshualitt02b05012015-02-11 06:56:30 -080058 void onGetInvariantOutputColor(GrInitInvariantOutput*) const SK_OVERRIDE;
59
mtklein72c9faa2015-01-09 10:06:39 -080060 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
egdaniel1a8ecdf2014-10-03 06:24:12 -070061
joshualitt02b05012015-02-11 06:56:30 -080062 GrTextureAccess fTextureAccess;
joshualitt71c92602015-01-14 08:12:47 -080063 const Attribute* fInPosition;
64 const Attribute* fInColor;
65 const Attribute* fInTextureCoords;
joshualitt02b05012015-02-11 06:56:30 -080066 GrMaskFormat fMaskFormat;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000067
joshualittb0a8a372014-09-23 09:50:21 -070068 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000069
joshualitt249af152014-09-15 11:41:13 -070070 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000071};
72
73#endif