skia2/include/gpu/GrSamplerState.h

71 lines
2.2 KiB
C
Raw Normal View History

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrSamplerState_DEFINED
#define GrSamplerState_DEFINED
#include "include/gpu/GrTypes.h"
/**
* Represents the filtering and tile modes used to access a texture.
*/
class GrSamplerState {
public:
enum class Filter : uint8_t { kNearest, kBilerp, kMipMap };
Reland "Add clamp to border wrap mode to gpu" This reverts commit 8137f3c8622bbcf5e49a3b0fca0ca1257c478ff1. Reason for revert: update GrCaps clampToBorder for iOS and Mac 10.11 Original change's description: > Revert "Add clamp to border wrap mode to gpu" > > This reverts commit f49a5785f324187fc029be9d80ff2d87baf51639. > > Reason for revert: clamp-to-border in metal not available on iOS > > Original change's description: > > Add clamp to border wrap mode to gpu > > > > Bug: skia: > > Change-Id: I286163cdea4fa8f7e6a876baaa11aa3dacd4f2ff > > Reviewed-on: https://skia-review.googlesource.com/c/175244 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,ethannicholas@google.com,michaelludwig@google.com > > Change-Id: I01ef28d9c2fbf6c6dcd82d9aac193ff102d60151 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/175988 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> TBR=egdaniel@google.com,bsalomon@google.com,ethannicholas@google.com,michaelludwig@google.com Change-Id: I37467eb096fec28131587aefe340f0485fca59d4 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/175989 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2018-12-10 16:36:13 +00:00
enum class WrapMode : uint8_t { kClamp, kRepeat, kMirrorRepeat, kClampToBorder };
static constexpr GrSamplerState ClampNearest() { return GrSamplerState(); }
static constexpr GrSamplerState ClampBilerp() {
return GrSamplerState(WrapMode::kClamp, Filter::kBilerp);
}
constexpr GrSamplerState() : GrSamplerState(WrapMode::kClamp, Filter::kNearest) {}
constexpr GrSamplerState(WrapMode wrapXAndY, Filter filter)
: fWrapModes{wrapXAndY, wrapXAndY}, fFilter(filter) {}
constexpr GrSamplerState(const WrapMode wrapModes[2], Filter filter)
: fWrapModes{wrapModes[0], wrapModes[1]}, fFilter(filter) {}
constexpr GrSamplerState(const GrSamplerState&) = default;
GrSamplerState& operator=(const GrSamplerState& that) {
fWrapModes[0] = that.fWrapModes[0];
fWrapModes[1] = that.fWrapModes[1];
fFilter = that.fFilter;
return *this;
}
Filter filter() const { return fFilter; }
void setFilterMode(Filter filterMode) { fFilter = filterMode; }
void setWrapModeX(const WrapMode wrap) { fWrapModes[0] = wrap; }
void setWrapModeY(const WrapMode wrap) { fWrapModes[1] = wrap; }
WrapMode wrapModeX() const { return fWrapModes[0]; }
WrapMode wrapModeY() const { return fWrapModes[1]; }
bool isRepeated() const {
Reland "Add clamp to border wrap mode to gpu" This reverts commit 8137f3c8622bbcf5e49a3b0fca0ca1257c478ff1. Reason for revert: update GrCaps clampToBorder for iOS and Mac 10.11 Original change's description: > Revert "Add clamp to border wrap mode to gpu" > > This reverts commit f49a5785f324187fc029be9d80ff2d87baf51639. > > Reason for revert: clamp-to-border in metal not available on iOS > > Original change's description: > > Add clamp to border wrap mode to gpu > > > > Bug: skia: > > Change-Id: I286163cdea4fa8f7e6a876baaa11aa3dacd4f2ff > > Reviewed-on: https://skia-review.googlesource.com/c/175244 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,ethannicholas@google.com,michaelludwig@google.com > > Change-Id: I01ef28d9c2fbf6c6dcd82d9aac193ff102d60151 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/175988 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> TBR=egdaniel@google.com,bsalomon@google.com,ethannicholas@google.com,michaelludwig@google.com Change-Id: I37467eb096fec28131587aefe340f0485fca59d4 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/175989 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2018-12-10 16:36:13 +00:00
return (WrapMode::kClamp != fWrapModes[0] && WrapMode::kClampToBorder != fWrapModes[0]) ||
(WrapMode::kClamp != fWrapModes[1] && WrapMode::kClampToBorder != fWrapModes[1]);
}
bool operator==(const GrSamplerState& that) const {
return fWrapModes[0] == that.fWrapModes[0] && fWrapModes[1] == that.fWrapModes[1] &&
fFilter == that.fFilter;
}
bool operator!=(const GrSamplerState& that) const { return !(*this == that); }
private:
WrapMode fWrapModes[2];
Filter fFilter;
};
#endif