skia2/include/gpu/GrTextureAccess.h
cdalton a6b92ad1f7 Infer sampler precision from pixel config
Adds a "samplerPrecision" method to GrGLSLCaps and updates
GrGLSLProgramBuilder to infer a sampler's precision based on its
config and visibility.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1846963004

Review URL: https://codereview.chromium.org/1846963004
2016-04-11 12:03:08 -07:00

72 lines
2.2 KiB
C++

/*
* 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
#include "GrGpuResourceRef.h"
#include "GrTexture.h"
#include "GrTextureParams.h"
#include "SkRefCnt.h"
#include "SkShader.h"
/**
* Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with
* an associated GrTextureParams
*/
class GrTextureAccess : public SkNoncopyable {
public:
/**
* Must be initialized before adding to a GrProcessor's texture access list.
*/
GrTextureAccess();
GrTextureAccess(GrTexture*, const GrTextureParams&);
explicit GrTextureAccess(GrTexture*,
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
GrShaderFlags visibility = kFragment_GrShaderFlag);
void reset(GrTexture*, const GrTextureParams&,
GrShaderFlags visibility = kFragment_GrShaderFlag);
void reset(GrTexture*,
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
GrShaderFlags visibility = kFragment_GrShaderFlag);
bool operator==(const GrTextureAccess& that) const {
return this->getTexture() == that.getTexture() &&
fParams == that.fParams &&
fVisibility == that.fVisibility;
}
bool operator!=(const GrTextureAccess& other) const { return !(*this == other); }
GrTexture* getTexture() const { return fTexture.get(); }
GrShaderFlags getVisibility() const { return fVisibility; }
/**
* For internal use by GrProcessor.
*/
const GrGpuResourceRef* getProgramTexture() const { return &fTexture; }
const GrTextureParams& getParams() const { return fParams; }
private:
typedef GrTGpuResourceRef<GrTexture> ProgramTexture;
ProgramTexture fTexture;
GrTextureParams fParams;
GrShaderFlags fVisibility;
typedef SkNoncopyable INHERITED;
};
#endif