blob: 1b5de0ce99cc1f4e162820c03df288bce6f0f939 [file] [log] [blame]
bsalomon@google.com047696c2012-09-11 13:29:29 +00001/*
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
bsalomonf96ba022014-09-17 08:05:40 -070011#include "GrGpuResourceRef.h"
bsalomonc4923342014-09-16 13:54:53 -070012#include "GrTexture.h"
bsalomonafa95e22015-10-12 10:39:46 -070013#include "GrTextureParams.h"
bsalomon@google.com6d003d12012-09-11 15:45:20 +000014#include "SkRefCnt.h"
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000015#include "SkShader.h"
bsalomon@google.com047696c2012-09-11 13:29:29 +000016
bsalomoncdee0092016-01-08 13:20:12 -080017/**
18 * Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with
19 * an associated GrTextureParams
bsalomon@google.com047696c2012-09-11 13:29:29 +000020 */
bsalomon2a9ca782014-09-05 14:27:43 -070021class GrTextureAccess : public SkNoncopyable {
bsalomon@google.com047696c2012-09-11 13:29:29 +000022public:
bsalomon@google.com6d003d12012-09-11 15:45:20 +000023 /**
bsalomoncdee0092016-01-08 13:20:12 -080024 * Must be initialized before adding to a GrProcessor's texture access list.
bsalomon@google.com6d003d12012-09-11 15:45:20 +000025 */
26 GrTextureAccess();
bsalomon@google.com047696c2012-09-11 13:29:29 +000027
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000028 GrTextureAccess(GrTexture*, const GrTextureParams&);
bsalomoncdee0092016-01-08 13:20:12 -080029
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000030 explicit GrTextureAccess(GrTexture*,
humper@google.comb86add12013-07-25 18:49:07 +000031 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
cdalton9c3f1432016-03-11 10:07:37 -080032 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
cdaltona6b92ad2016-04-11 12:03:08 -070033 GrShaderFlags visibility = kFragment_GrShaderFlag);
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000034
cdalton9c3f1432016-03-11 10:07:37 -080035 void reset(GrTexture*, const GrTextureParams&,
cdaltona6b92ad2016-04-11 12:03:08 -070036 GrShaderFlags visibility = kFragment_GrShaderFlag);
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000037 void reset(GrTexture*,
humper@google.comb86add12013-07-25 18:49:07 +000038 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
cdalton9c3f1432016-03-11 10:07:37 -080039 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
cdaltona6b92ad2016-04-11 12:03:08 -070040 GrShaderFlags visibility = kFragment_GrShaderFlag);
bsalomon@google.com047696c2012-09-11 13:29:29 +000041
bsalomoncdee0092016-01-08 13:20:12 -080042 bool operator==(const GrTextureAccess& that) const {
cdalton9c3f1432016-03-11 10:07:37 -080043 return this->getTexture() == that.getTexture() &&
44 fParams == that.fParams &&
cdaltona6b92ad2016-04-11 12:03:08 -070045 fVisibility == that.fVisibility;
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000046 }
47
bsalomoncdee0092016-01-08 13:20:12 -080048 bool operator!=(const GrTextureAccess& other) const { return !(*this == other); }
bsalomon@google.com6d003d12012-09-11 15:45:20 +000049
bsalomonc4923342014-09-16 13:54:53 -070050 GrTexture* getTexture() const { return fTexture.get(); }
cdalton9c3f1432016-03-11 10:07:37 -080051 GrShaderFlags getVisibility() const { return fVisibility; }
bsalomon2a9ca782014-09-05 14:27:43 -070052
53 /**
joshualittb0a8a372014-09-23 09:50:21 -070054 * For internal use by GrProcessor.
bsalomon2a9ca782014-09-05 14:27:43 -070055 */
bsalomonf96ba022014-09-17 08:05:40 -070056 const GrGpuResourceRef* getProgramTexture() const { return &fTexture; }
bsalomon@google.com6d003d12012-09-11 15:45:20 +000057
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000058 const GrTextureParams& getParams() const { return fParams; }
59
bsalomon@google.com047696c2012-09-11 13:29:29 +000060private:
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000061
bsalomonf96ba022014-09-17 08:05:40 -070062 typedef GrTGpuResourceRef<GrTexture> ProgramTexture;
bsalomonc4923342014-09-16 13:54:53 -070063
64 ProgramTexture fTexture;
bsalomon2a9ca782014-09-05 14:27:43 -070065 GrTextureParams fParams;
cdalton9c3f1432016-03-11 10:07:37 -080066 GrShaderFlags fVisibility;
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000067
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +000068 typedef SkNoncopyable INHERITED;
bsalomon@google.com047696c2012-09-11 13:29:29 +000069};
70
71#endif