Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
GrSamplerState Class Reference

#include <GrSamplerState.h>

Public Types

enum class  WrapMode : uint8_t {
  kClamp , kRepeat , kMirrorRepeat , kClampToBorder ,
  kLast = kClampToBorder
}
 
using Filter = SkFilterMode
 
using MipmapMode = SkMipmapMode
 

Public Member Functions

constexpr GrSamplerState ()=default
 
constexpr GrSamplerState (WrapMode wrapXAndY, Filter filter, MipmapMode mm=MipmapMode::kNone)
 
constexpr GrSamplerState (WrapMode wrapX, WrapMode wrapY, Filter filter, MipmapMode mm=MipmapMode::kNone)
 
constexpr GrSamplerState (const WrapMode wrapModes[2], Filter filter, MipmapMode mm=MipmapMode::kNone)
 
constexpr GrSamplerState (Filter filter)
 
constexpr GrSamplerState (Filter filter, MipmapMode mm)
 
constexpr GrSamplerState (const GrSamplerState &)=default
 
constexpr GrSamplerStateoperator= (const GrSamplerState &)=default
 
constexpr WrapMode wrapModeX () const
 
constexpr WrapMode wrapModeY () const
 
constexpr bool isRepeatedX () const
 
constexpr bool isRepeatedY () const
 
constexpr bool isRepeated () const
 
constexpr Filter filter () const
 
constexpr MipmapMode mipmapMode () const
 
constexpr skgpu::Mipmapped mipmapped () const
 
int maxAniso () const
 
bool isAniso () const
 
constexpr bool operator== (GrSamplerState that) const
 
constexpr bool operator!= (const GrSamplerState &that) const
 
uint32_t asKey (bool anisoIsOrthogonal) const
 

Static Public Member Functions

static constexpr GrSamplerState Aniso (WrapMode wrapX, WrapMode wrapY, int maxAniso, skgpu::Mipmapped viewIsMipped)
 

Static Public Attributes

static constexpr int kFilterCount = static_cast<int>(Filter::kLast) + 1
 
static constexpr int kWrapModeCount = static_cast<int>(WrapMode::kLast) + 1
 
static constexpr int kMipmapModeCount = static_cast<int>(MipmapMode::kLast) + 1
 

Detailed Description

Represents the filtering and tile modes used to access a texture.

Definition at line 22 of file GrSamplerState.h.

Member Typedef Documentation

◆ Filter

Definition at line 24 of file GrSamplerState.h.

◆ MipmapMode

Definition at line 25 of file GrSamplerState.h.

Member Enumeration Documentation

◆ WrapMode

enum class GrSamplerState::WrapMode : uint8_t
strong
Enumerator
kClamp 
kRepeat 
kMirrorRepeat 
kClampToBorder 
kLast 

Definition at line 27 of file GrSamplerState.h.

27 : uint8_t {
28 kClamp,
29 kRepeat,
30 kMirrorRepeat,
31 kClampToBorder,
32 kLast = kClampToBorder
33 };

Constructor & Destructor Documentation

◆ GrSamplerState() [1/7]

constexpr GrSamplerState::GrSamplerState ( )
constexprdefault

◆ GrSamplerState() [2/7]

constexpr GrSamplerState::GrSamplerState ( WrapMode  wrapXAndY,
Filter  filter,
MipmapMode  mm = MipmapMode::kNone 
)
inlineconstexpr

Definition at line 41 of file GrSamplerState.h.

42 : fWrapModes{wrapXAndY, wrapXAndY}, fFilter(filter), fMipmapMode(mm) {}
constexpr Filter filter() const

◆ GrSamplerState() [3/7]

constexpr GrSamplerState::GrSamplerState ( WrapMode  wrapX,
WrapMode  wrapY,
Filter  filter,
MipmapMode  mm = MipmapMode::kNone 
)
inlineconstexpr

Definition at line 44 of file GrSamplerState.h.

48 : fWrapModes{wrapX, wrapY}, fFilter(filter), fMipmapMode(mm) {}

◆ GrSamplerState() [4/7]

constexpr GrSamplerState::GrSamplerState ( const WrapMode  wrapModes[2],
Filter  filter,
MipmapMode  mm = MipmapMode::kNone 
)
inlineconstexpr

Definition at line 50 of file GrSamplerState.h.

53 : fWrapModes{wrapModes[0], wrapModes[1]}, fFilter(filter), fMipmapMode(mm) {}

◆ GrSamplerState() [5/7]

constexpr GrSamplerState::GrSamplerState ( Filter  filter)
inlineconstexpr

Definition at line 55 of file GrSamplerState.h.

55: fFilter(filter) {}

◆ GrSamplerState() [6/7]

constexpr GrSamplerState::GrSamplerState ( Filter  filter,
MipmapMode  mm 
)
inlineconstexpr

Definition at line 56 of file GrSamplerState.h.

56: fFilter(filter), fMipmapMode(mm) {}

◆ GrSamplerState() [7/7]

constexpr GrSamplerState::GrSamplerState ( const GrSamplerState )
constexprdefault

Member Function Documentation

◆ Aniso()

static constexpr GrSamplerState GrSamplerState::Aniso ( WrapMode  wrapX,
WrapMode  wrapY,
int  maxAniso,
skgpu::Mipmapped  viewIsMipped 
)
inlinestaticconstexpr

Definition at line 60 of file GrSamplerState.h.

63 {
64 GrSamplerState sampler;
65 sampler.fWrapModes[0] = wrapX;
66 sampler.fWrapModes[1] = wrapY;
67 sampler.fMaxAniso = SkTPin(maxAniso, 1, kMaxMaxAniso);
68 sampler.fFilter = Filter::kLinear;
69 sampler.fMipmapMode = viewIsMipped == skgpu::Mipmapped::kYes ? MipmapMode::kLinear
71 return sampler;
72 }
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
Definition: SkTPin.h:19
int maxAniso() const

◆ asKey()

uint32_t GrSamplerState::asKey ( bool  anisoIsOrthogonal) const
inline

Turn the sampler state into an integer for use as a key. How that works for aniso depends on whether the underlying API defines aniso as orthogonal to other filter settings or as a replacement for them.

Definition at line 117 of file GrSamplerState.h.

117 {
118 constexpr int kNumWrapBits = SkNextLog2_portable(kWrapModeCount);
119 constexpr int kNumMaxAnisoBits = SkNextLog2_portable(kMaxMaxAniso);
120 constexpr int kNumFilterBits = SkNextLog2_portable(kFilterCount);
121 constexpr int kNumMipmapModeBits = SkNextLog2_portable(kMipmapModeCount);
122
123 constexpr int kWrapXShift = 0;
124 constexpr int kWrapYShift = kWrapXShift + kNumWrapBits;
125 constexpr int kMaxAnisoShift = kWrapYShift + kNumWrapBits;
126 constexpr int kFilterShift = kMaxAnisoShift + kNumMaxAnisoBits;
127 constexpr int kMipmapModeShift = kFilterShift + kNumFilterBits;
128
129 static_assert(kMipmapModeShift + kNumMipmapModeBits <= 32);
130
131 uint32_t key = (static_cast<uint32_t>(fWrapModes[0]) << kWrapXShift)
132 | (static_cast<uint32_t>(fWrapModes[1]) << kWrapYShift)
133 | (static_cast<uint32_t>(fMaxAniso) << kMaxAnisoShift);
134 if (fMaxAniso == 1 || anisoIsOrthogonal) {
135 key |= (static_cast<uint32_t>(fFilter) << kFilterShift)
136 | (static_cast<uint32_t>(fMipmapMode) << kMipmapModeShift);
137 }
138 return key;
139 }
constexpr int SkNextLog2_portable(uint32_t value)
Definition: SkMathPriv.h:243
static constexpr int kMipmapModeCount
static constexpr int kFilterCount
static constexpr int kWrapModeCount

◆ filter()

constexpr Filter GrSamplerState::filter ( ) const
inlineconstexpr

Definition at line 94 of file GrSamplerState.h.

94{ return fFilter; }

◆ isAniso()

bool GrSamplerState::isAniso ( ) const
inline

Definition at line 103 of file GrSamplerState.h.

103{ return fMaxAniso > 1; }

◆ isRepeated()

constexpr bool GrSamplerState::isRepeated ( ) const
inlineconstexpr

Definition at line 90 of file GrSamplerState.h.

90 {
91 return this->isRepeatedX() || this->isRepeatedY();
92 }
constexpr bool isRepeatedX() const
constexpr bool isRepeatedY() const

◆ isRepeatedX()

constexpr bool GrSamplerState::isRepeatedX ( ) const
inlineconstexpr

Definition at line 82 of file GrSamplerState.h.

82 {
83 return fWrapModes[0] == WrapMode::kRepeat || fWrapModes[0] == WrapMode::kMirrorRepeat;
84 }

◆ isRepeatedY()

constexpr bool GrSamplerState::isRepeatedY ( ) const
inlineconstexpr

Definition at line 86 of file GrSamplerState.h.

86 {
87 return fWrapModes[1] == WrapMode::kRepeat || fWrapModes[1] == WrapMode::kMirrorRepeat;
88 }

◆ maxAniso()

int GrSamplerState::maxAniso ( ) const
inline

Definition at line 102 of file GrSamplerState.h.

102{ return fMaxAniso; }

◆ mipmapMode()

constexpr MipmapMode GrSamplerState::mipmapMode ( ) const
inlineconstexpr

Definition at line 96 of file GrSamplerState.h.

96{ return fMipmapMode; }

◆ mipmapped()

constexpr skgpu::Mipmapped GrSamplerState::mipmapped ( ) const
inlineconstexpr

Definition at line 98 of file GrSamplerState.h.

98 {
99 return skgpu::Mipmapped(fMipmapMode != MipmapMode::kNone);
100 }
Mipmapped
Definition: GpuTypes.h:53

◆ operator!=()

constexpr bool GrSamplerState::operator!= ( const GrSamplerState that) const
inlineconstexpr

Definition at line 110 of file GrSamplerState.h.

110{ return !(*this == that); }

◆ operator=()

constexpr GrSamplerState & GrSamplerState::operator= ( const GrSamplerState )
constexprdefault

◆ operator==()

constexpr bool GrSamplerState::operator== ( GrSamplerState  that) const
inlineconstexpr

Definition at line 105 of file GrSamplerState.h.

105 {
106 return fWrapModes[0] == that.fWrapModes[0] && fWrapModes[1] == that.fWrapModes[1] &&
107 fFilter == that.fFilter && fMipmapMode == that.fMipmapMode;
108 }

◆ wrapModeX()

constexpr WrapMode GrSamplerState::wrapModeX ( ) const
inlineconstexpr

Definition at line 78 of file GrSamplerState.h.

78{ return fWrapModes[0]; }

◆ wrapModeY()

constexpr WrapMode GrSamplerState::wrapModeY ( ) const
inlineconstexpr

Definition at line 80 of file GrSamplerState.h.

80{ return fWrapModes[1]; }

Member Data Documentation

◆ kFilterCount

constexpr int GrSamplerState::kFilterCount = static_cast<int>(Filter::kLast) + 1
staticconstexpr

Definition at line 35 of file GrSamplerState.h.

◆ kMipmapModeCount

constexpr int GrSamplerState::kMipmapModeCount = static_cast<int>(MipmapMode::kLast) + 1
staticconstexpr

Definition at line 37 of file GrSamplerState.h.

◆ kWrapModeCount

constexpr int GrSamplerState::kWrapModeCount = static_cast<int>(WrapMode::kLast) + 1
staticconstexpr

Definition at line 36 of file GrSamplerState.h.


The documentation for this class was generated from the following file: