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 11#include "GrGpuResourceRef.h" 12#include "GrTexture.h" 13#include "GrTextureParams.h" 14#include "SkRefCnt.h" 15#include "SkShader.h" 16 17/** 18 * Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with 19 * an associated GrTextureParams 20 */ 21class GrTextureAccess : public SkNoncopyable { 22public: 23 /** 24 * Must be initialized before adding to a GrProcessor's texture access list. 25 */ 26 GrTextureAccess(); 27 28 GrTextureAccess(GrTexture*, const GrTextureParams&); 29 30 explicit GrTextureAccess(GrTexture*, 31 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, 32 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); 33 34 void reset(GrTexture*, const GrTextureParams&); 35 void reset(GrTexture*, 36 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, 37 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); 38 39 bool operator==(const GrTextureAccess& that) const { 40 return this->getTexture() == that.getTexture() && fParams == that.fParams; 41 } 42 43 bool operator!=(const GrTextureAccess& other) const { return !(*this == other); } 44 45 GrTexture* getTexture() const { return fTexture.get(); } 46 47 /** 48 * For internal use by GrProcessor. 49 */ 50 const GrGpuResourceRef* getProgramTexture() const { return &fTexture; } 51 52 const GrTextureParams& getParams() const { return fParams; } 53 54private: 55 56 typedef GrTGpuResourceRef<GrTexture> ProgramTexture; 57 58 ProgramTexture fTexture; 59 GrTextureParams fParams; 60 61 typedef SkNoncopyable INHERITED; 62}; 63 64#endif 65