bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 | |
| 8 | #ifndef GrTextureAccess_DEFINED |
| 9 | #define GrTextureAccess_DEFINED |
| 10 | |
bsalomon | f96ba02 | 2014-09-17 08:05:40 -0700 | [diff] [blame] | 11 | #include "GrGpuResourceRef.h" |
bsalomon | c492334 | 2014-09-16 13:54:53 -0700 | [diff] [blame] | 12 | #include "GrTexture.h" |
bsalomon | afa95e2 | 2015-10-12 10:39:46 -0700 | [diff] [blame] | 13 | #include "GrTextureParams.h" |
bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 14 | #include "SkRefCnt.h" |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 15 | #include "SkShader.h" |
bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 16 | |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 17 | /** |
| 18 | * Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with |
| 19 | * an associated GrTextureParams |
bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 20 | */ |
bsalomon | 2a9ca78 | 2014-09-05 14:27:43 -0700 | [diff] [blame] | 21 | class GrTextureAccess : public SkNoncopyable { |
bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 22 | public: |
bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 23 | /** |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 24 | * Must be initialized before adding to a GrProcessor's texture access list. |
bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 25 | */ |
| 26 | GrTextureAccess(); |
bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 27 | |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 28 | GrTextureAccess(GrTexture*, const GrTextureParams&); |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 29 | |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 30 | explicit GrTextureAccess(GrTexture*, |
humper@google.com | b86add1 | 2013-07-25 18:49:07 +0000 | [diff] [blame] | 31 | GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 32 | SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode, |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 33 | GrShaderFlags visibility = kFragment_GrShaderFlag, |
| 34 | GrSLPrecision = kDefault_GrSLPrecision); |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 35 | |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 36 | void reset(GrTexture*, const GrTextureParams&, |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 37 | GrShaderFlags visibility = kFragment_GrShaderFlag, |
| 38 | GrSLPrecision = kDefault_GrSLPrecision); |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 39 | void reset(GrTexture*, |
humper@google.com | b86add1 | 2013-07-25 18:49:07 +0000 | [diff] [blame] | 40 | GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 41 | SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode, |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 42 | GrShaderFlags visibility = kFragment_GrShaderFlag, |
| 43 | GrSLPrecision = kDefault_GrSLPrecision); |
bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 44 | |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 45 | bool operator==(const GrTextureAccess& that) const { |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 46 | return this->getTexture() == that.getTexture() && |
| 47 | fParams == that.fParams && |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 48 | fVisibility == that.fVisibility && |
| 49 | fPrecision == that.fPrecision; |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 50 | } |
| 51 | |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 52 | bool operator!=(const GrTextureAccess& other) const { return !(*this == other); } |
bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 53 | |
bsalomon | c492334 | 2014-09-16 13:54:53 -0700 | [diff] [blame] | 54 | GrTexture* getTexture() const { return fTexture.get(); } |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 55 | GrShaderFlags getVisibility() const { return fVisibility; } |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 56 | GrSLPrecision getPrecision() const { return fPrecision; } |
bsalomon | 2a9ca78 | 2014-09-05 14:27:43 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 59 | * For internal use by GrProcessor. |
bsalomon | 2a9ca78 | 2014-09-05 14:27:43 -0700 | [diff] [blame] | 60 | */ |
bsalomon | f96ba02 | 2014-09-17 08:05:40 -0700 | [diff] [blame] | 61 | const GrGpuResourceRef* getProgramTexture() const { return &fTexture; } |
bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 62 | |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 63 | const GrTextureParams& getParams() const { return fParams; } |
| 64 | |
bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 65 | private: |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 66 | |
bsalomon | f96ba02 | 2014-09-17 08:05:40 -0700 | [diff] [blame] | 67 | typedef GrTGpuResourceRef<GrTexture> ProgramTexture; |
bsalomon | c492334 | 2014-09-16 13:54:53 -0700 | [diff] [blame] | 68 | |
| 69 | ProgramTexture fTexture; |
bsalomon | 2a9ca78 | 2014-09-05 14:27:43 -0700 | [diff] [blame] | 70 | GrTextureParams fParams; |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 71 | GrShaderFlags fVisibility; |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 72 | GrSLPrecision fPrecision; |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 73 | |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 74 | typedef SkNoncopyable INHERITED; |
bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | #endif |