2012-09-11 13:29:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrTextureAccess_DEFINED
|
|
|
|
#define GrTextureAccess_DEFINED
|
|
|
|
|
2014-09-17 15:05:40 +00:00
|
|
|
#include "GrGpuResourceRef.h"
|
2014-09-16 20:54:53 +00:00
|
|
|
#include "GrTexture.h"
|
2015-10-12 17:39:46 +00:00
|
|
|
#include "GrTextureParams.h"
|
2012-09-11 15:45:20 +00:00
|
|
|
#include "SkRefCnt.h"
|
2012-09-18 14:14:49 +00:00
|
|
|
#include "SkShader.h"
|
2012-09-11 13:29:29 +00:00
|
|
|
|
2016-01-08 21:20:12 +00:00
|
|
|
/**
|
|
|
|
* Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with
|
|
|
|
* an associated GrTextureParams
|
2012-09-11 13:29:29 +00:00
|
|
|
*/
|
2014-09-05 21:27:43 +00:00
|
|
|
class GrTextureAccess : public SkNoncopyable {
|
2012-09-11 13:29:29 +00:00
|
|
|
public:
|
2012-09-11 15:45:20 +00:00
|
|
|
/**
|
2016-01-08 21:20:12 +00:00
|
|
|
* Must be initialized before adding to a GrProcessor's texture access list.
|
2012-09-11 15:45:20 +00:00
|
|
|
*/
|
|
|
|
GrTextureAccess();
|
2012-09-11 13:29:29 +00:00
|
|
|
|
2012-09-18 14:14:49 +00:00
|
|
|
GrTextureAccess(GrTexture*, const GrTextureParams&);
|
2016-01-08 21:20:12 +00:00
|
|
|
|
2012-09-18 14:14:49 +00:00
|
|
|
explicit GrTextureAccess(GrTexture*,
|
2013-07-25 18:49:07 +00:00
|
|
|
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
|
2012-09-18 14:14:49 +00:00
|
|
|
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
|
2012-09-11 13:29:29 +00:00
|
|
|
|
2012-09-18 14:14:49 +00:00
|
|
|
void reset(GrTexture*, const GrTextureParams&);
|
|
|
|
void reset(GrTexture*,
|
2013-07-25 18:49:07 +00:00
|
|
|
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
|
2012-09-18 14:14:49 +00:00
|
|
|
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
|
|
|
|
|
2016-01-08 21:20:12 +00:00
|
|
|
bool operator==(const GrTextureAccess& that) const {
|
|
|
|
return this->getTexture() == that.getTexture() && fParams == that.fParams;
|
2012-09-18 14:14:49 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 21:20:12 +00:00
|
|
|
bool operator!=(const GrTextureAccess& other) const { return !(*this == other); }
|
2012-09-11 15:45:20 +00:00
|
|
|
|
2014-09-16 20:54:53 +00:00
|
|
|
GrTexture* getTexture() const { return fTexture.get(); }
|
2014-09-05 21:27:43 +00:00
|
|
|
|
|
|
|
/**
|
2014-09-23 16:50:21 +00:00
|
|
|
* For internal use by GrProcessor.
|
2014-09-05 21:27:43 +00:00
|
|
|
*/
|
2014-09-17 15:05:40 +00:00
|
|
|
const GrGpuResourceRef* getProgramTexture() const { return &fTexture; }
|
2012-09-11 15:45:20 +00:00
|
|
|
|
2012-09-18 14:14:49 +00:00
|
|
|
const GrTextureParams& getParams() const { return fParams; }
|
|
|
|
|
2012-09-11 13:29:29 +00:00
|
|
|
private:
|
2012-09-18 14:14:49 +00:00
|
|
|
|
2014-09-17 15:05:40 +00:00
|
|
|
typedef GrTGpuResourceRef<GrTexture> ProgramTexture;
|
2014-09-16 20:54:53 +00:00
|
|
|
|
|
|
|
ProgramTexture fTexture;
|
2014-09-05 21:27:43 +00:00
|
|
|
GrTextureParams fParams;
|
2012-09-18 14:14:49 +00:00
|
|
|
|
2013-09-18 13:00:55 +00:00
|
|
|
typedef SkNoncopyable INHERITED;
|
2012-09-11 13:29:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|