blob: 124a75aabc065da64c9360592fb5cfeaaf8ca994 [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,
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000032 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
33
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000034 void reset(GrTexture*, const GrTextureParams&);
35 void reset(GrTexture*,
humper@google.comb86add12013-07-25 18:49:07 +000036 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000037 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
bsalomon@google.com047696c2012-09-11 13:29:29 +000038
bsalomoncdee0092016-01-08 13:20:12 -080039 bool operator==(const GrTextureAccess& that) const {
40 return this->getTexture() == that.getTexture() && fParams == that.fParams;
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000041 }
42
bsalomoncdee0092016-01-08 13:20:12 -080043 bool operator!=(const GrTextureAccess& other) const { return !(*this == other); }
bsalomon@google.com6d003d12012-09-11 15:45:20 +000044
bsalomonc4923342014-09-16 13:54:53 -070045 GrTexture* getTexture() const { return fTexture.get(); }
bsalomon2a9ca782014-09-05 14:27:43 -070046
47 /**
joshualittb0a8a372014-09-23 09:50:21 -070048 * For internal use by GrProcessor.
bsalomon2a9ca782014-09-05 14:27:43 -070049 */
bsalomonf96ba022014-09-17 08:05:40 -070050 const GrGpuResourceRef* getProgramTexture() const { return &fTexture; }
bsalomon@google.com6d003d12012-09-11 15:45:20 +000051
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000052 const GrTextureParams& getParams() const { return fParams; }
53
bsalomon@google.com047696c2012-09-11 13:29:29 +000054private:
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000055
bsalomonf96ba022014-09-17 08:05:40 -070056 typedef GrTGpuResourceRef<GrTexture> ProgramTexture;
bsalomonc4923342014-09-16 13:54:53 -070057
58 ProgramTexture fTexture;
bsalomon2a9ca782014-09-05 14:27:43 -070059 GrTextureParams fParams;
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +000060
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +000061 typedef SkNoncopyable INHERITED;
bsalomon@google.com047696c2012-09-11 13:29:29 +000062};
63
64#endif