Allow implicit conversion from GrSamplerState::Filter to GrSamplerState
constexprify GrSamplerState pass/return GrSamplerState by value (it's 3 bytes). Remove unused function from GrTexturePriv Change-Id: Iffecd941500acf5653f01cc88b42ff1d45678b54 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263346 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
a88cab1ad9
commit
ccb6142956
@ -268,7 +268,7 @@ protected:
|
||||
|
||||
static void draw_as_tex(SkCanvas* canvas, SkImage* image, SkScalar x, SkScalar y) {
|
||||
sk_sp<GrTextureProxy> proxy(as_IB(image)->asTextureProxyRef(
|
||||
canvas->getGrContext(), GrSamplerState::ClampBilerp(), nullptr));
|
||||
canvas->getGrContext(), GrSamplerState::Filter::kBilerp, nullptr));
|
||||
if (!proxy) {
|
||||
// show placeholder if we have no texture
|
||||
SkPaint paint;
|
||||
|
@ -32,7 +32,6 @@ class GrPath;
|
||||
class GrRenderTargetContext;
|
||||
class GrResourceCache;
|
||||
class GrResourceProvider;
|
||||
class GrSamplerState;
|
||||
class GrSurfaceProxy;
|
||||
class GrSwizzle;
|
||||
class GrTextContext;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "include/gpu/GrDriverBugWorkarounds.h"
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
#include "src/gpu/GrBlend.h"
|
||||
#include "src/gpu/GrSamplerState.h"
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
#include "src/gpu/GrSurfaceProxy.h"
|
||||
|
||||
@ -25,7 +26,6 @@ class GrProcessorKeyBuilder;
|
||||
class GrProgramDesc;
|
||||
class GrProgramInfo;
|
||||
class GrRenderTargetProxy;
|
||||
class GrSamplerState;
|
||||
class GrSurface;
|
||||
class SkJSONWriter;
|
||||
|
||||
@ -455,7 +455,7 @@ public:
|
||||
* with immutable samplers.
|
||||
*/
|
||||
virtual void addExtraSamplerKey(GrProcessorKeyBuilder*,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
const GrBackendFormat&) const {}
|
||||
|
||||
virtual GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const = 0;
|
||||
|
@ -413,9 +413,8 @@ GrFragmentProcessor::CIter::CIter(const GrPipeline& pipeline) {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrFragmentProcessor::TextureSampler::TextureSampler(GrSurfaceProxyView view,
|
||||
const GrSamplerState& samplerState)
|
||||
: fView(std::move(view))
|
||||
, fSamplerState(samplerState) {
|
||||
GrSamplerState samplerState)
|
||||
: fView(std::move(view)), fSamplerState(samplerState) {
|
||||
GrSurfaceProxy* proxy = this->proxy();
|
||||
fSamplerState.setFilterMode(
|
||||
SkTMin(samplerState.filter(),
|
||||
@ -423,7 +422,7 @@ GrFragmentProcessor::TextureSampler::TextureSampler(GrSurfaceProxyView view,
|
||||
}
|
||||
|
||||
GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrSurfaceProxy> proxy,
|
||||
const GrSamplerState& samplerState) {
|
||||
GrSamplerState samplerState) {
|
||||
SkASSERT(proxy->asTextureProxy());
|
||||
GrSurfaceOrigin origin = proxy->origin();
|
||||
GrSwizzle swizzle = proxy->textureSwizzle();
|
||||
@ -438,7 +437,7 @@ GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrSurfaceProxy> proxy,
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
void GrFragmentProcessor::TextureSampler::set(GrSurfaceProxyView view,
|
||||
const GrSamplerState& samplerState) {
|
||||
GrSamplerState samplerState) {
|
||||
SkASSERT(view.proxy()->asTextureProxy());
|
||||
fView = std::move(view);
|
||||
fSamplerState = samplerState;
|
||||
|
@ -475,13 +475,11 @@ public:
|
||||
/**
|
||||
* This copy constructor is used by GrFragmentProcessor::clone() implementations.
|
||||
*/
|
||||
explicit TextureSampler(const TextureSampler& that)
|
||||
: fView(that.fView)
|
||||
, fSamplerState(that.fSamplerState) {}
|
||||
explicit TextureSampler(const TextureSampler&) = default;
|
||||
|
||||
TextureSampler(GrSurfaceProxyView, const GrSamplerState& = GrSamplerState::ClampNearest());
|
||||
TextureSampler(GrSurfaceProxyView, GrSamplerState = {});
|
||||
// TODO: Remove this ctor once all uses have been updated to pass in a GrSurfaceProxyView
|
||||
TextureSampler(sk_sp<GrSurfaceProxy>, const GrSamplerState& = GrSamplerState::ClampNearest());
|
||||
TextureSampler(sk_sp<GrSurfaceProxy>, GrSamplerState = {});
|
||||
|
||||
TextureSampler& operator=(const TextureSampler&) = delete;
|
||||
|
||||
@ -500,12 +498,12 @@ public:
|
||||
}
|
||||
|
||||
const GrSurfaceProxyView& view() const { return fView; }
|
||||
const GrSamplerState& samplerState() const { return fSamplerState; }
|
||||
GrSamplerState samplerState() const { return fSamplerState; }
|
||||
|
||||
bool isInitialized() const { return SkToBool(this->proxy()); }
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
void set(GrSurfaceProxyView, const GrSamplerState&);
|
||||
void set(GrSurfaceProxyView, GrSamplerState);
|
||||
#endif
|
||||
private:
|
||||
GrSurfaceProxy* proxy() const { return fView.proxy(); }
|
||||
|
@ -36,7 +36,7 @@ void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCovera
|
||||
}
|
||||
|
||||
void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, SkAlphaType alphaType,
|
||||
const SkMatrix& matrix, const GrSamplerState& samplerState) {
|
||||
const SkMatrix& matrix, GrSamplerState samplerState) {
|
||||
this->addColorFragmentProcessor(
|
||||
GrTextureEffect::Make(std::move(proxy), alphaType, matrix, samplerState));
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
* to the src space position to compute texture coordinates.
|
||||
*/
|
||||
void addColorTextureProcessor(sk_sp<GrTextureProxy>, SkAlphaType, const SkMatrix&,
|
||||
const GrSamplerState& = GrSamplerState::ClampBilerp());
|
||||
GrSamplerState = GrSamplerState::Filter::kBilerp);
|
||||
|
||||
int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
|
||||
int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
|
||||
|
@ -60,13 +60,13 @@ static inline GrSamplerState::Filter clamp_filter(GrTextureType type,
|
||||
return requestedFilter;
|
||||
}
|
||||
|
||||
GrPrimitiveProcessor::TextureSampler::TextureSampler(const GrSamplerState& samplerState,
|
||||
GrPrimitiveProcessor::TextureSampler::TextureSampler(GrSamplerState samplerState,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSwizzle& swizzle) {
|
||||
this->reset(samplerState, backendFormat, swizzle);
|
||||
}
|
||||
|
||||
void GrPrimitiveProcessor::TextureSampler::reset(const GrSamplerState& samplerState,
|
||||
void GrPrimitiveProcessor::TextureSampler::reset(GrSamplerState samplerState,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSwizzle& swizzle) {
|
||||
fSamplerState = samplerState;
|
||||
@ -75,4 +75,3 @@ void GrPrimitiveProcessor::TextureSampler::reset(const GrSamplerState& samplerSt
|
||||
fSwizzle = swizzle;
|
||||
fIsInitialized = true;
|
||||
}
|
||||
|
||||
|
@ -273,17 +273,17 @@ class GrPrimitiveProcessor::TextureSampler {
|
||||
public:
|
||||
TextureSampler() = default;
|
||||
|
||||
TextureSampler(const GrSamplerState&, const GrBackendFormat&, const GrSwizzle&);
|
||||
TextureSampler(GrSamplerState, const GrBackendFormat&, const GrSwizzle&);
|
||||
|
||||
TextureSampler(const TextureSampler&) = delete;
|
||||
TextureSampler& operator=(const TextureSampler&) = delete;
|
||||
|
||||
void reset(const GrSamplerState&, const GrBackendFormat&, const GrSwizzle&);
|
||||
void reset(GrSamplerState, const GrBackendFormat&, const GrSwizzle&);
|
||||
|
||||
const GrBackendFormat& backendFormat() const { return fBackendFormat; }
|
||||
GrTextureType textureType() const { return fBackendFormat.textureType(); }
|
||||
|
||||
const GrSamplerState& samplerState() const { return fSamplerState; }
|
||||
GrSamplerState samplerState() const { return fSamplerState; }
|
||||
const GrSwizzle& swizzle() const { return fSwizzle; }
|
||||
|
||||
bool isInitialized() const { return fIsInitialized; }
|
||||
|
@ -84,8 +84,7 @@ void GrProgramInfo::checkAllInstantiated() const {
|
||||
}
|
||||
|
||||
void GrProgramInfo::checkMSAAAndMIPSAreResolved() const {
|
||||
|
||||
auto assertResolved = [](GrTexture* tex, const GrSamplerState& sampler) {
|
||||
auto assertResolved = [](GrTexture* tex, GrSamplerState sampler) {
|
||||
SkASSERT(tex);
|
||||
|
||||
// Ensure mipmaps were all resolved ahead of time by the DAG.
|
||||
|
@ -2040,7 +2040,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
|
||||
std::copy_n(baseM + 5, 5, uM + 15);
|
||||
GrPaint uPaint;
|
||||
uPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix,
|
||||
GrSamplerState::ClampBilerp());
|
||||
GrSamplerState::Filter::kBilerp);
|
||||
auto uFP = GrColorMatrixFragmentProcessor::Make(uM, false, true, false);
|
||||
uPaint.addColorFragmentProcessor(std::move(uFP));
|
||||
uPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
@ -2059,7 +2059,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
|
||||
std::copy_n(baseM + 10, 5, vM + 15);
|
||||
GrPaint vPaint;
|
||||
vPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix,
|
||||
GrSamplerState::ClampBilerp());
|
||||
GrSamplerState::Filter::kBilerp);
|
||||
auto vFP = GrColorMatrixFragmentProcessor::Make(vM, false, true, false);
|
||||
vPaint.addColorFragmentProcessor(std::move(vFP));
|
||||
vPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
@ -19,15 +19,10 @@ public:
|
||||
enum class WrapMode : uint8_t { kClamp, kRepeat, kMirrorRepeat, kClampToBorder,
|
||||
kLast = kClampToBorder };
|
||||
|
||||
static const int kFilterCount = static_cast<int>(Filter::kLast) + 1;
|
||||
static const int kWrapModeCount = static_cast<int>(WrapMode::kLast) + 1;
|
||||
static constexpr int kFilterCount = static_cast<int>(Filter::kLast) + 1;
|
||||
static constexpr int kWrapModeCount = static_cast<int>(WrapMode::kLast) + 1;
|
||||
|
||||
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() = default;
|
||||
|
||||
constexpr GrSamplerState(WrapMode wrapXAndY, Filter filter)
|
||||
: fWrapModes{wrapXAndY, wrapXAndY}, fFilter(filter) {}
|
||||
@ -35,38 +30,35 @@ public:
|
||||
constexpr GrSamplerState(const WrapMode wrapModes[2], Filter filter)
|
||||
: fWrapModes{wrapModes[0], wrapModes[1]}, fFilter(filter) {}
|
||||
|
||||
constexpr /*explicit*/ GrSamplerState(Filter filter) : 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;
|
||||
}
|
||||
constexpr GrSamplerState& operator=(const GrSamplerState&) = default;
|
||||
|
||||
Filter filter() const { return fFilter; }
|
||||
constexpr Filter filter() const { return fFilter; }
|
||||
|
||||
void setFilterMode(Filter filterMode) { fFilter = filterMode; }
|
||||
constexpr void setFilterMode(Filter filterMode) { fFilter = filterMode; }
|
||||
|
||||
void setWrapModeX(const WrapMode wrap) { fWrapModes[0] = wrap; }
|
||||
void setWrapModeY(const WrapMode wrap) { fWrapModes[1] = wrap; }
|
||||
constexpr void setWrapModeX(const WrapMode wrap) { fWrapModes[0] = wrap; }
|
||||
constexpr void setWrapModeY(const WrapMode wrap) { fWrapModes[1] = wrap; }
|
||||
|
||||
WrapMode wrapModeX() const { return fWrapModes[0]; }
|
||||
WrapMode wrapModeY() const { return fWrapModes[1]; }
|
||||
constexpr WrapMode wrapModeX() const { return fWrapModes[0]; }
|
||||
constexpr WrapMode wrapModeY() const { return fWrapModes[1]; }
|
||||
|
||||
bool isRepeated() const {
|
||||
constexpr bool isRepeated() const {
|
||||
return (WrapMode::kClamp != fWrapModes[0] && WrapMode::kClampToBorder != fWrapModes[0]) ||
|
||||
(WrapMode::kClamp != fWrapModes[1] && WrapMode::kClampToBorder != fWrapModes[1]);
|
||||
}
|
||||
|
||||
bool operator==(const GrSamplerState& that) const {
|
||||
constexpr bool operator==(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); }
|
||||
constexpr bool operator!=(const GrSamplerState& that) const { return !(*this == that); }
|
||||
|
||||
static uint8_t GenerateKey(const GrSamplerState& samplerState) {
|
||||
constexpr static uint8_t GenerateKey(GrSamplerState samplerState) {
|
||||
const int kTileModeXShift = 2;
|
||||
const int kTileModeYShift = 4;
|
||||
|
||||
@ -83,8 +75,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
WrapMode fWrapModes[2];
|
||||
Filter fFilter;
|
||||
WrapMode fWrapModes[2] = {WrapMode::kClamp, WrapMode::kClamp};
|
||||
Filter fFilter = GrSamplerState::Filter::kNearest;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -71,10 +71,9 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
|
||||
return copy;
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> GrTextureAdjuster::onRefTextureProxyForParams(
|
||||
const GrSamplerState& params,
|
||||
bool willBeMipped,
|
||||
SkScalar scaleAdjust[2]) {
|
||||
sk_sp<GrTextureProxy> GrTextureAdjuster::onRefTextureProxyForParams(GrSamplerState params,
|
||||
bool willBeMipped,
|
||||
SkScalar scaleAdjust[2]) {
|
||||
sk_sp<GrTextureProxy> proxy = this->originalProxyRef();
|
||||
CopyParams copyParams;
|
||||
|
||||
|
@ -40,7 +40,7 @@ protected:
|
||||
sk_sp<GrTextureProxy> originalProxyRef() const { return fOriginal; }
|
||||
|
||||
private:
|
||||
sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&,
|
||||
sk_sp<GrTextureProxy> onRefTextureProxyForParams(GrSamplerState,
|
||||
bool willBeMipped,
|
||||
SkScalar scaleAdjust[2]) override;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
|
||||
sk_sp<GrTextureProxy> GrTextureMaker::onRefTextureProxyForParams(const GrSamplerState& params,
|
||||
sk_sp<GrTextureProxy> GrTextureMaker::onRefTextureProxyForParams(GrSamplerState params,
|
||||
bool willBeMipped,
|
||||
SkScalar scaleAdjust[2]) {
|
||||
if (this->width() > this->context()->priv().caps()->maxTextureSize() ||
|
||||
|
@ -40,7 +40,7 @@ protected:
|
||||
AllowedTexGenType genType) = 0;
|
||||
|
||||
private:
|
||||
sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&,
|
||||
sk_sp<GrTextureProxy> onRefTextureProxyForParams(GrSamplerState,
|
||||
bool willBeMipped,
|
||||
SkScalar scaleAdjust[2]) override;
|
||||
|
||||
|
@ -47,11 +47,6 @@ public:
|
||||
bool hasRestrictedSampling() const {
|
||||
return GrTextureTypeHasRestrictedSampling(this->textureType());
|
||||
}
|
||||
/** Filtering is clamped to this value. */
|
||||
GrSamplerState::Filter highestFilterMode() const {
|
||||
return this->hasRestrictedSampling() ? GrSamplerState::Filter::kBilerp
|
||||
: GrSamplerState::Filter::kMipMap;
|
||||
}
|
||||
|
||||
static void ComputeScratchKey(GrPixelConfig config,
|
||||
SkISize dimensions,
|
||||
|
@ -252,9 +252,8 @@ sk_sp<GrTextureProxy> GrTextureProducer::refTextureProxyForParams(
|
||||
return this->refTextureProxyForParams(sampler, scaleAdjust);
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> GrTextureProducer::refTextureProxyForParams(
|
||||
const GrSamplerState& sampler,
|
||||
SkScalar scaleAdjust[2]) {
|
||||
sk_sp<GrTextureProxy> GrTextureProducer::refTextureProxyForParams(GrSamplerState sampler,
|
||||
SkScalar scaleAdjust[2]) {
|
||||
// Check that the caller pre-initialized scaleAdjust
|
||||
SkASSERT(!scaleAdjust || (scaleAdjust[0] == 1 && scaleAdjust[1] == 1));
|
||||
// Check that if the caller passed nullptr for scaleAdjust that we're in the case where there
|
||||
|
@ -82,8 +82,7 @@ public:
|
||||
* contract that if scaleAdjust is not null it must be initialized to {1, 1} before calling
|
||||
* this method. (TODO: Fix this and make this function always initialize scaleAdjust).
|
||||
*/
|
||||
sk_sp<GrTextureProxy> refTextureProxyForParams(const GrSamplerState&,
|
||||
SkScalar scaleAdjust[2]);
|
||||
sk_sp<GrTextureProxy> refTextureProxyForParams(GrSamplerState, SkScalar scaleAdjust[2]);
|
||||
|
||||
sk_sp<GrTextureProxy> refTextureProxyForParams(
|
||||
const GrSamplerState::Filter* filterOrNullForBicubic, SkScalar scaleAdjust[2]);
|
||||
@ -182,7 +181,7 @@ protected:
|
||||
GrRecordingContext* context() const { return fContext; }
|
||||
|
||||
private:
|
||||
virtual sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&,
|
||||
virtual sk_sp<GrTextureProxy> onRefTextureProxyForParams(GrSamplerState,
|
||||
bool willBeMipped,
|
||||
SkScalar scaleAdjust[2]) = 0;
|
||||
|
||||
|
@ -700,7 +700,7 @@ bool SkGpuDevice::shouldTileImageID(uint32_t imageID,
|
||||
const SkIRect& imageRect,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& srcToDstRect,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
const SkRect* srcRectPtr,
|
||||
int maxTileSize,
|
||||
int* tileSize,
|
||||
@ -822,7 +822,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
|
||||
const SkMatrix& dstMatrix,
|
||||
const SkRect& srcRect,
|
||||
const SkIRect& clippedSrcIRect,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
const SkPaint& origPaint,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
int tileSize,
|
||||
@ -906,7 +906,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& dstRect,
|
||||
const SkRect& srcRect,
|
||||
const GrSamplerState& samplerState,
|
||||
GrSamplerState samplerState,
|
||||
const SkPaint& paint,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
bool bicubic,
|
||||
@ -1063,10 +1063,11 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
|
||||
// of the clip image should behave as if it were a decal (i.e. zero coverage). However, to
|
||||
// limit pixels touched and hardware checks, we draw the clip image geometry to get the
|
||||
// decal effect.
|
||||
GrSamplerState sampler = paint.getFilterQuality() > kNone_SkFilterQuality ?
|
||||
GrSamplerState::ClampBilerp() : GrSamplerState::ClampNearest();
|
||||
sk_sp<GrTextureProxy> clipProxy = as_IB(clipImage)->asTextureProxyRef(this->context(),
|
||||
sampler, nullptr);
|
||||
auto filter = paint.getFilterQuality() > kNone_SkFilterQuality
|
||||
? GrSamplerState::Filter::kBilerp
|
||||
: GrSamplerState::Filter::kNearest;
|
||||
sk_sp<GrTextureProxy> clipProxy =
|
||||
as_IB(clipImage)->asTextureProxyRef(this->context(), filter, nullptr);
|
||||
// Fold clip matrix into ctm
|
||||
ctm.preConcat(clipMatrix);
|
||||
SkMatrix inverseClipMatrix;
|
||||
@ -1075,7 +1076,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
|
||||
if (clipProxy && ctm.invert(&inverseClipMatrix)) {
|
||||
GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
|
||||
cfp = GrTextureEffect::Make(std::move(clipProxy), clipImage->alphaType(),
|
||||
inverseClipMatrix, sampler);
|
||||
inverseClipMatrix, filter);
|
||||
if (srcColorType != GrColorType::kAlpha_8) {
|
||||
cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ private:
|
||||
const SkIRect& imageRect,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& srcToDstRectMatrix,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
const SkRect* srcRectPtr,
|
||||
int maxTileSize,
|
||||
int* tileSize,
|
||||
@ -191,7 +191,7 @@ private:
|
||||
const SkMatrix& srcToDstMatrix,
|
||||
const SkRect& srcRect,
|
||||
const SkIRect& clippedSrcRect,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
const SkPaint& paint,
|
||||
SkCanvas::SrcRectConstraint,
|
||||
int tileSize,
|
||||
@ -202,7 +202,7 @@ private:
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& dstRect,
|
||||
const SkRect& srcRect,
|
||||
const GrSamplerState& samplerState,
|
||||
GrSamplerState samplerState,
|
||||
const SkPaint& paint,
|
||||
SkCanvas::SrcRectConstraint,
|
||||
bool bicubic,
|
||||
|
@ -241,7 +241,7 @@ static void draw_texture_producer(GrContext* context, GrRenderTargetContext* rtc
|
||||
if (attemptDrawTexture && can_use_draw_texture(paint)) {
|
||||
// We've done enough checks above to allow us to pass ClampNearest() and not check for
|
||||
// scaling adjustments.
|
||||
auto proxy = producer->refTextureProxyForParams(GrSamplerState::ClampNearest(), nullptr);
|
||||
auto proxy = producer->refTextureProxyForParams(GrSamplerState::Filter::kNearest, nullptr);
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
@ -529,7 +529,7 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
|
||||
uint32_t uniqueID;
|
||||
proxy = image->refPinnedTextureProxy(this->context(), &uniqueID);
|
||||
if (!proxy) {
|
||||
proxy = image->asTextureProxyRef(this->context(), GrSamplerState::ClampBilerp(),
|
||||
proxy = image->asTextureProxyRef(this->context(), GrSamplerState::Filter::kBilerp,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrRecordingContext* ctx,
|
||||
|
||||
sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrRecordingContext* ctx,
|
||||
const SkBitmap& bitmap,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) {
|
||||
return GrBitmapTextureMaker(ctx, bitmap).refTextureProxyForParams(params, scaleAdjust);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ static_assert((int)kIDA_GrBlendCoeff == (int)SkBlendModeCoeff::kIDA);
|
||||
*/
|
||||
sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrRecordingContext*,
|
||||
const SkBitmap&,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
SkScalar scaleAdjust[2]);
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ GrCCPathProcessor::GrCCPathProcessor(CoverageMode coverageMode, const GrTexture*
|
||||
const SkMatrix& viewMatrixIfUsingLocalCoords)
|
||||
: INHERITED(kGrCCPathProcessor_ClassID)
|
||||
, fCoverageMode(coverageMode)
|
||||
, fAtlasAccess(GrSamplerState::ClampNearest(), atlasTexture->backendFormat(), swizzle)
|
||||
, fAtlasAccess(GrSamplerState::Filter::kNearest, atlasTexture->backendFormat(), swizzle)
|
||||
, fAtlasDimensions(atlasTexture->dimensions())
|
||||
, fAtlasOrigin(atlasOrigin) {
|
||||
// TODO: Can we just assert that atlas has GrCCAtlas::kTextureOrigin and remove fAtlasOrigin?
|
||||
|
@ -622,7 +622,7 @@ sk_sp<GrDawnProgram> GrDawnGpu::getOrCreateRenderPipeline(
|
||||
return program;
|
||||
}
|
||||
|
||||
wgpu::Sampler GrDawnGpu::getOrCreateSampler(const GrSamplerState& samplerState) {
|
||||
wgpu::Sampler GrDawnGpu::getOrCreateSampler(GrSamplerState samplerState) {
|
||||
auto i = fSamplers.find(samplerState);
|
||||
if (i != fSamplers.end()) {
|
||||
return i->second;
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
|
||||
sk_sp<GrDawnProgram> getOrCreateRenderPipeline(GrRenderTarget*, const GrProgramInfo&);
|
||||
|
||||
wgpu::Sampler getOrCreateSampler(const GrSamplerState& samplerState);
|
||||
wgpu::Sampler getOrCreateSampler(GrSamplerState samplerState);
|
||||
|
||||
GrDawnRingBuffer::Slice allocateUniformRingBufferSlice(int size);
|
||||
GrDawnStagingBuffer* getStagingBuffer(size_t size);
|
||||
@ -183,7 +183,7 @@ private:
|
||||
};
|
||||
|
||||
struct SamplerHash {
|
||||
size_t operator()(const GrSamplerState& samplerState) const {
|
||||
size_t operator()(GrSamplerState samplerState) const {
|
||||
return SkOpts::hash_fn(&samplerState, sizeof(samplerState), 0);
|
||||
}
|
||||
};
|
||||
|
@ -493,8 +493,8 @@ void GrDawnProgram::setRenderTargetState(const GrRenderTarget* rt, GrSurfaceOrig
|
||||
}
|
||||
}
|
||||
|
||||
static void set_texture(GrDawnGpu* gpu, const GrSamplerState& state, GrTexture* texture,
|
||||
std::vector<wgpu::BindGroupBinding> *bindings, int* binding) {
|
||||
static void set_texture(GrDawnGpu* gpu, GrSamplerState state, GrTexture* texture,
|
||||
std::vector<wgpu::BindGroupBinding>* bindings, int* binding) {
|
||||
// FIXME: could probably cache samplers in GrDawnProgram
|
||||
wgpu::Sampler sampler = gpu->getOrCreateSampler(state);
|
||||
bindings->push_back(make_bind_group_binding((*binding)++, sampler));
|
||||
@ -560,7 +560,7 @@ wgpu::BindGroup GrDawnProgram::setTextures(GrDawnGpu* gpu,
|
||||
}
|
||||
SkIPoint offset;
|
||||
if (GrTexture* dstTexture = pipeline.peekDstTexture(&offset)) {
|
||||
set_texture(gpu, GrSamplerState::ClampNearest(), dstTexture, &bindings, &binding);
|
||||
set_texture(gpu, GrSamplerState::Filter::kNearest, dstTexture, &bindings, &binding);
|
||||
}
|
||||
wgpu::BindGroupDescriptor descriptor;
|
||||
descriptor.layout = fBindGroupLayouts[1];
|
||||
|
@ -232,7 +232,7 @@ void GrDawnUniformHandler::updateUniformVisibility(UniformHandle u, uint32_t vis
|
||||
}
|
||||
|
||||
GrGLSLUniformHandler::SamplerHandle GrDawnUniformHandler::addSampler(const GrSurfaceProxy*,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
const char* name,
|
||||
const GrShaderCaps* caps) {
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
private:
|
||||
explicit GrDawnUniformHandler(GrGLSLProgramBuilder* program);
|
||||
|
||||
SamplerHandle addSampler(const GrSurfaceProxy*, const GrSamplerState&, const GrSwizzle&,
|
||||
SamplerHandle addSampler(const GrSurfaceProxy*, GrSamplerState, const GrSwizzle&,
|
||||
const char* name, const GrShaderCaps*) override;
|
||||
const char* samplerVariable(SamplerHandle handle) const override;
|
||||
GrSwizzle samplerSwizzle(SamplerHandle handle) const override;
|
||||
|
@ -123,8 +123,10 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(const GrShaderCaps& caps,
|
||||
bool wideColor,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& params, GrMaskFormat format,
|
||||
const SkMatrix& localMatrix, bool usesW)
|
||||
GrSamplerState params,
|
||||
GrMaskFormat format,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesW)
|
||||
: INHERITED(kGrBitmapTextGeoProc_ClassID)
|
||||
, fColor(color)
|
||||
, fLocalMatrix(localMatrix)
|
||||
@ -162,7 +164,7 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(const GrShaderCaps& caps,
|
||||
|
||||
void GrBitmapTextGeoProc::addNewViews(const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& params) {
|
||||
GrSamplerState params) {
|
||||
SkASSERT(numActiveViews <= kMaxTextures);
|
||||
// Just to make sure we don't try to add too many proxies
|
||||
numActiveViews = SkTMin(numActiveViews, kMaxTextures);
|
||||
|
@ -27,11 +27,14 @@ public:
|
||||
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const SkPMColor4f& color, bool wideColor,
|
||||
const SkPMColor4f& color,
|
||||
bool wideColor,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& p, GrMaskFormat format,
|
||||
const SkMatrix& localMatrix, bool usesW) {
|
||||
GrSamplerState p,
|
||||
GrMaskFormat format,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesW) {
|
||||
return arena->make<GrBitmapTextGeoProc>(caps, color, wideColor, views, numActiveViews,
|
||||
p, format, localMatrix, usesW);
|
||||
}
|
||||
@ -50,7 +53,7 @@ public:
|
||||
bool usesW() const { return fUsesW; }
|
||||
const SkISize& atlasDimensions() const { return fAtlasDimensions; }
|
||||
|
||||
void addNewViews(const GrSurfaceProxyView*, int numActiveViews, const GrSamplerState&);
|
||||
void addNewViews(const GrSurfaceProxyView*, int numActiveViews, GrSamplerState);
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
@ -60,9 +63,8 @@ private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrBitmapTextGeoProc(const GrShaderCaps&, const SkPMColor4f&, bool wideColor,
|
||||
const GrSurfaceProxyView* views, int numViews,
|
||||
const GrSamplerState& params, GrMaskFormat format,
|
||||
const SkMatrix& localMatrix, bool usesW);
|
||||
const GrSurfaceProxyView* views, int numViews, GrSamplerState params,
|
||||
GrMaskFormat format, const SkMatrix& localMatrix, bool usesW);
|
||||
|
||||
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
||||
|
||||
|
@ -211,7 +211,7 @@ private:
|
||||
GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const GrShaderCaps& caps,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numViews,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
float distanceAdjust,
|
||||
#endif
|
||||
@ -251,7 +251,7 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const GrShaderCaps& c
|
||||
|
||||
void GrDistanceFieldA8TextGeoProc::addNewViews(const GrSurfaceProxyView* views,
|
||||
int numViews,
|
||||
const GrSamplerState& params) {
|
||||
GrSamplerState params) {
|
||||
SkASSERT(numViews <= kMaxTextures);
|
||||
// Just to make sure we don't try to add too many proxies
|
||||
numViews = SkTMin(numViews, kMaxTextures);
|
||||
@ -515,7 +515,7 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
|
||||
bool wideColor,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numViews,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
uint32_t flags)
|
||||
: INHERITED(kGrDistanceFieldPathGeoProc_ClassID)
|
||||
, fMatrix(matrix)
|
||||
@ -544,7 +544,7 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
|
||||
|
||||
void GrDistanceFieldPathGeoProc::addNewViews(const GrSurfaceProxyView* views,
|
||||
int numViews,
|
||||
const GrSamplerState& params) {
|
||||
GrSamplerState params) {
|
||||
SkASSERT(numViews <= kMaxTextures);
|
||||
// Just to make sure we don't try to add too many proxies
|
||||
numViews = SkTMin(numViews, kMaxTextures);
|
||||
@ -831,7 +831,7 @@ private:
|
||||
GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& caps,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numViews,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
DistanceAdjust distanceAdjust,
|
||||
uint32_t flags,
|
||||
const SkMatrix& localMatrix)
|
||||
@ -867,7 +867,7 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const GrShaderCaps&
|
||||
|
||||
void GrDistanceFieldLCDTextGeoProc::addNewViews(const GrSurfaceProxyView* views,
|
||||
int numViews,
|
||||
const GrSamplerState& params) {
|
||||
GrSamplerState params) {
|
||||
SkASSERT(numViews <= kMaxTextures);
|
||||
// Just to make sure we don't try to add too many proxies
|
||||
numViews = SkTMin(numViews, kMaxTextures);
|
||||
|
@ -62,7 +62,9 @@ public:
|
||||
const GrShaderCaps& caps,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& params, float lum, uint32_t flags,
|
||||
GrSamplerState params,
|
||||
float lum,
|
||||
uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return arena->make<GrDistanceFieldA8TextGeoProc>(
|
||||
caps, views, numActiveViews, params, lum, flags, localMatrixIfUsesLocalCoords);
|
||||
@ -72,7 +74,8 @@ public:
|
||||
const GrShaderCaps& caps,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& params, uint32_t flags,
|
||||
GrSamplerState params,
|
||||
uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return arena->make<GrDistanceFieldA8TextGeoProc>(
|
||||
caps, views, numActiveViews, params, flags, localMatrixIfUsesLocalCoords);
|
||||
@ -93,7 +96,7 @@ public:
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
const SkISize& atlasDimensions() const { return fAtlasDimensions; }
|
||||
|
||||
void addNewViews(const GrSurfaceProxyView* views, int numViews, const GrSamplerState&);
|
||||
void addNewViews(const GrSurfaceProxyView* views, int numViews, GrSamplerState);
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
@ -105,11 +108,12 @@ private:
|
||||
GrDistanceFieldA8TextGeoProc(const GrShaderCaps& caps,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
float distanceAdjust,
|
||||
#endif
|
||||
uint32_t flags, const SkMatrix& localMatrix);
|
||||
uint32_t flags,
|
||||
const SkMatrix& localMatrix);
|
||||
|
||||
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
||||
|
||||
@ -140,13 +144,10 @@ public:
|
||||
static constexpr int kMaxTextures = 4;
|
||||
|
||||
/** The local matrix should be identity if local coords are not required by the GrPipeline. */
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const SkMatrix& matrix,
|
||||
bool wideColor,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& params, uint32_t flags) {
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, const GrShaderCaps& caps,
|
||||
const SkMatrix& matrix, bool wideColor,
|
||||
const GrSurfaceProxyView* views, int numActiveViews,
|
||||
GrSamplerState params, uint32_t flags) {
|
||||
return arena->make<GrDistanceFieldPathGeoProc>(caps, matrix, wideColor, views,
|
||||
numActiveViews, params, flags);
|
||||
}
|
||||
@ -162,7 +163,7 @@ public:
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
const SkISize& atlasDimensions() const { return fAtlasDimensions; }
|
||||
|
||||
void addNewViews(const GrSurfaceProxyView*, int numActiveViews, const GrSamplerState&);
|
||||
void addNewViews(const GrSurfaceProxyView*, int numActiveViews, GrSamplerState);
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
@ -176,7 +177,8 @@ private:
|
||||
bool wideColor,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState&, uint32_t flags);
|
||||
GrSamplerState,
|
||||
uint32_t flags);
|
||||
|
||||
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
||||
|
||||
@ -222,7 +224,7 @@ public:
|
||||
const GrShaderCaps& caps,
|
||||
const GrSurfaceProxyView* views,
|
||||
int numActiveViews,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
DistanceAdjust distanceAdjust,
|
||||
uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
@ -243,7 +245,7 @@ public:
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
const SkISize& atlasDimensions() const { return fAtlasDimensions; }
|
||||
|
||||
void addNewViews(const GrSurfaceProxyView*, int numActiveViews, const GrSamplerState&);
|
||||
void addNewViews(const GrSurfaceProxyView*, int numActiveViews, GrSamplerState);
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
@ -253,8 +255,8 @@ private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& caps, const GrSurfaceProxyView* views,
|
||||
int numActiveViews, const GrSamplerState& params,
|
||||
DistanceAdjust wa, uint32_t flags, const SkMatrix& localMatrix);
|
||||
int numActiveViews, GrSamplerState params, DistanceAdjust wa,
|
||||
uint32_t flags, const SkMatrix& localMatrix);
|
||||
|
||||
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
||||
|
||||
|
@ -126,7 +126,7 @@ static sk_sp<GrTextureProxy> CreateIntegralTexture(GrProxyProvider* proxyProvide
|
||||
// normalized texture coords from frag coord distances.
|
||||
float invSixSigma = 1.f / sixSigma;
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrRectBlurEffect(insetRect,
|
||||
std::move(integral), invSixSigma, isFast, GrSamplerState::ClampBilerp()));
|
||||
std::move(integral), invSixSigma, isFast, GrSamplerState::Filter::kBilerp));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ GrRRectShadowGeoProc::GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView)
|
||||
this->setVertexAttributes(&fInPosition, 3);
|
||||
|
||||
SkASSERT(lutView.proxy());
|
||||
fLUTTextureSampler.reset(GrSamplerState::ClampBilerp(), lutView.proxy()->backendFormat(),
|
||||
fLUTTextureSampler.reset(GrSamplerState::Filter::kBilerp, lutView.proxy()->backendFormat(),
|
||||
lutView.swizzle());
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ void GrTextureDomain::GLDomain::sample(GrGLSLShaderBuilder* builder,
|
||||
void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrTextureDomain& textureDomain,
|
||||
const GrSurfaceProxyView& view,
|
||||
const GrSamplerState& state) {
|
||||
GrSamplerState state) {
|
||||
// We want a hard transition from texture content to trans-black in nearest mode.
|
||||
bool filterDecal = state.filter() != GrSamplerState::Filter::kNearest;
|
||||
this->setData(pdman, textureDomain, view.proxy(), view.origin(), filterDecal);
|
||||
@ -514,7 +514,7 @@ GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentPro
|
||||
sk_sp<GrSurfaceProxy> proxy, const SkIRect& subset, const SkIPoint& deviceSpaceOffset)
|
||||
: INHERITED(kGrDeviceSpaceTextureDecalFragmentProcessor_ClassID,
|
||||
kCompatibleWithCoverageAsAlpha_OptimizationFlag)
|
||||
, fTextureSampler(proxy, GrSamplerState::ClampNearest())
|
||||
, fTextureSampler(proxy, GrSamplerState::Filter::kNearest)
|
||||
, fTextureDomain(proxy.get(),
|
||||
GrTextureDomain::MakeTexelDomain(subset, GrTextureDomain::kDecal_Mode),
|
||||
GrTextureDomain::kDecal_Mode, GrTextureDomain::kDecal_Mode) {
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
return IsDecalSampled(wraps[0], wraps[1], modeX, modeY);
|
||||
}
|
||||
|
||||
static bool IsDecalSampled(const GrSamplerState& sampler, Mode modeX, Mode modeY) {
|
||||
static bool IsDecalSampled(GrSamplerState sampler, Mode modeX, Mode modeY) {
|
||||
return IsDecalSampled(sampler.wrapModeX(), sampler.wrapModeY(), modeX, modeY);
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ public:
|
||||
* the GrSamplerState's filter mode.
|
||||
*/
|
||||
void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&,
|
||||
const GrSurfaceProxyView&, const GrSamplerState& state);
|
||||
const GrSurfaceProxyView&, GrSamplerState state);
|
||||
/** Same as above but with direct control over decal filtering. */
|
||||
void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, const GrSurfaceProxy*,
|
||||
GrSurfaceOrigin, bool filterIfDecal);
|
||||
|
@ -14,15 +14,6 @@
|
||||
#include "src/sksl/SkSLCPP.h"
|
||||
#include "src/sksl/SkSLUtil.h"
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
|
||||
SkAlphaType alphaType,
|
||||
const SkMatrix& matrix,
|
||||
GrSamplerState::Filter filter) {
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(proxy), alphaType, matrix,
|
||||
GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
|
||||
SkAlphaType alphaType,
|
||||
const SkMatrix& matrix,
|
||||
|
@ -15,18 +15,12 @@
|
||||
|
||||
class GrTextureEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
/** Uses kClamp wrap mode in both dimensions. */
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(
|
||||
sk_sp<GrSurfaceProxy>,
|
||||
SkAlphaType,
|
||||
const SkMatrix&,
|
||||
GrSamplerState::Filter = GrSamplerState::Filter::kNearest);
|
||||
GrSamplerState = {GrSamplerState::Filter::kNearest});
|
||||
|
||||
/** Allows full specification of the sampling parameters. */
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy>,
|
||||
SkAlphaType,
|
||||
const SkMatrix&,
|
||||
GrSamplerState);
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
float invSixSigma = 1.f / sixSigma;
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrRectBlurEffect(insetRect, std::move(integral), invSixSigma, isFast,
|
||||
GrSamplerState::ClampBilerp()));
|
||||
GrSamplerState::Filter::kBilerp));
|
||||
}
|
||||
GrRectBlurEffect(const GrRectBlurEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
|
@ -283,7 +283,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void bindSampler(int unitIdx, const GrSamplerState& state) {
|
||||
void bindSampler(int unitIdx, GrSamplerState state) {
|
||||
int index = StateToIndex(state);
|
||||
if (!fSamplers[index]) {
|
||||
GrGLuint s;
|
||||
@ -332,7 +332,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static int StateToIndex(const GrSamplerState& state) {
|
||||
static int StateToIndex(GrSamplerState state) {
|
||||
int filter = static_cast<int>(state.filter());
|
||||
SkASSERT(filter >= 0 && filter < 3);
|
||||
int wrapX = static_cast<int>(state.wrapModeX());
|
||||
@ -3491,7 +3491,7 @@ bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurface* src, const SkIRect& s
|
||||
int w = srcRect.width();
|
||||
int h = srcRect.height();
|
||||
// We don't swizzle at all in our copies.
|
||||
this->bindTexture(0, GrSamplerState::ClampNearest(), GrSwizzle::RGBA(), srcTex);
|
||||
this->bindTexture(0, GrSamplerState::Filter::kNearest, GrSwizzle::RGBA(), srcTex);
|
||||
this->bindSurfaceFBOForPixelOps(dst, 0, GR_GL_FRAMEBUFFER, kDst_TempFBOTarget);
|
||||
this->flushViewport(dst->width(), dst->height());
|
||||
fHWBoundRenderTargetUniqueID.makeInvalid();
|
||||
@ -3636,7 +3636,7 @@ bool GrGLGpu::onRegenerateMipMapLevels(GrTexture* texture) {
|
||||
// We'll be changing our base level further below:
|
||||
this->setTextureUnit(0);
|
||||
// The mipmap program does not do any swizzling.
|
||||
this->bindTexture(0, GrSamplerState::ClampBilerp(), GrSwizzle::RGBA(), glTex);
|
||||
this->bindTexture(0, GrSamplerState::Filter::kBilerp, GrSwizzle::RGBA(), glTex);
|
||||
|
||||
// Vertex data:
|
||||
if (!fMipmapProgramArrayBuffer) {
|
||||
|
@ -100,7 +100,7 @@ void GrGLProgram::updateUniformsAndTextureBindings(const GrRenderTarget* renderT
|
||||
|
||||
fXferProcessor->setData(fProgramDataManager, xp, dstTexture, offset);
|
||||
if (dstTexture) {
|
||||
fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerState::ClampNearest(),
|
||||
fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerState::Filter::kNearest,
|
||||
programInfo.pipeline().dstProxyView().swizzle(),
|
||||
static_cast<GrGLTexture*>(dstTexture));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
||||
}
|
||||
|
||||
GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(const GrSurfaceProxy* texture,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
const char* name,
|
||||
const GrShaderCaps* shaderCaps) {
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
fUniforms[u.toIndex()].fVisibility |= visibility;
|
||||
}
|
||||
|
||||
SamplerHandle addSampler(const GrSurfaceProxy*, const GrSamplerState&, const GrSwizzle&,
|
||||
SamplerHandle addSampler(const GrSurfaceProxy*, GrSamplerState, const GrSwizzle&,
|
||||
const char* name, const GrShaderCaps*) override;
|
||||
|
||||
const char* samplerVariable(SamplerHandle handle) const override {
|
||||
|
@ -277,7 +277,7 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
|
||||
}
|
||||
|
||||
GrGLSLProgramBuilder::SamplerHandle GrGLSLProgramBuilder::emitSampler(const GrSurfaceProxy* texture,
|
||||
const GrSamplerState& state,
|
||||
GrSamplerState state,
|
||||
const GrSwizzle& swizzle,
|
||||
const char* name) {
|
||||
++fNumFragmentSamplers;
|
||||
|
@ -161,7 +161,7 @@ private:
|
||||
SkString output,
|
||||
SkTArray<std::unique_ptr<GrGLSLFragmentProcessor>>*);
|
||||
void emitAndInstallXferProc(const SkString& colorIn, const SkString& coverageIn);
|
||||
SamplerHandle emitSampler(const GrSurfaceProxy*, const GrSamplerState&, const GrSwizzle&,
|
||||
SamplerHandle emitSampler(const GrSurfaceProxy*, GrSamplerState, const GrSwizzle&,
|
||||
const char* name);
|
||||
bool checkSamplerCounts();
|
||||
|
||||
|
@ -84,7 +84,7 @@ private:
|
||||
// Only called if GrShaderCaps(:textureSwizzleAppliedInShader() == true.
|
||||
virtual GrSwizzle samplerSwizzle(SamplerHandle) const = 0;
|
||||
|
||||
virtual SamplerHandle addSampler(const GrSurfaceProxy*, const GrSamplerState&, const GrSwizzle&,
|
||||
virtual SamplerHandle addSampler(const GrSurfaceProxy*, GrSamplerState, const GrSwizzle&,
|
||||
const char* name, const GrShaderCaps*) = 0;
|
||||
|
||||
virtual UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
|
@ -9,7 +9,7 @@
|
||||
in uniform sampler2D gradient;
|
||||
|
||||
@samplerParams(gradient) {
|
||||
GrSamplerState::ClampBilerp()
|
||||
GrSamplerState::Filter::kBilerp
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
private:
|
||||
GrTextureGradientColorizer(sk_sp<GrSurfaceProxy> gradient)
|
||||
: INHERITED(kGrTextureGradientColorizer_ClassID, kNone_OptimizationFlags)
|
||||
, gradient(std::move(gradient), GrSamplerState::ClampBilerp()) {
|
||||
, gradient(std::move(gradient), GrSamplerState::Filter::kBilerp) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
@ -111,7 +111,7 @@ private:
|
||||
GrMtlSampler* fSampler;
|
||||
id<MTLTexture> fTexture;
|
||||
|
||||
SamplerBindings(const GrSamplerState& state, GrTexture* texture, GrMtlGpu*);
|
||||
SamplerBindings(GrSamplerState state, GrTexture* texture, GrMtlGpu*);
|
||||
};
|
||||
|
||||
GrMtlGpu* fGpu;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#error This file must be compiled with Arc. Use -fobjc-arc flag
|
||||
#endif
|
||||
|
||||
GrMtlPipelineState::SamplerBindings::SamplerBindings(const GrSamplerState& state,
|
||||
GrMtlPipelineState::SamplerBindings::SamplerBindings(GrSamplerState state,
|
||||
GrTexture* texture,
|
||||
GrMtlGpu* gpu)
|
||||
: fTexture(static_cast<GrMtlTexture*>(texture)->mtlTexture()) {
|
||||
@ -109,9 +109,8 @@ void GrMtlPipelineState::setTextures(const GrProgramInfo& programInfo,
|
||||
}
|
||||
|
||||
if (GrTextureProxy* dstTextureProxy = programInfo.pipeline().dstProxyView().asTextureProxy()) {
|
||||
fSamplerBindings.emplace_back(GrSamplerState::ClampNearest(),
|
||||
dstTextureProxy->peekTexture(),
|
||||
fGpu);
|
||||
fSamplerBindings.emplace_back(
|
||||
GrSamplerState::Filter::kNearest, dstTextureProxy->peekTexture(), fGpu);
|
||||
}
|
||||
|
||||
SkASSERT(fNumSamplers == fSamplerBindings.count());
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
GrSurfaceOrigin);
|
||||
|
||||
// Finds or creates a compatible MTLSamplerState based on the GrSamplerState.
|
||||
GrMtlSampler* findOrCreateCompatibleSampler(const GrSamplerState&);
|
||||
GrMtlSampler* findOrCreateCompatibleSampler(GrSamplerState);
|
||||
|
||||
id<MTLBuffer> getDynamicBuffer(size_t size, size_t* offset);
|
||||
void addBufferCompletionHandler(GrMtlCommandBuffer* cmdBuffer);
|
||||
|
@ -58,7 +58,7 @@ GrMtlDepthStencil* GrMtlResourceProvider::findOrCreateCompatibleDepthStencilStat
|
||||
return depthStencilState;
|
||||
}
|
||||
|
||||
GrMtlSampler* GrMtlResourceProvider::findOrCreateCompatibleSampler(const GrSamplerState& params) {
|
||||
GrMtlSampler* GrMtlResourceProvider::findOrCreateCompatibleSampler(GrSamplerState params) {
|
||||
GrMtlSampler* sampler;
|
||||
sampler = fSamplers.find(GrMtlSampler::GenerateKey(params));
|
||||
if (!sampler) {
|
||||
|
@ -19,7 +19,7 @@ class GrMtlGpu;
|
||||
// A wrapper for a MTLSamplerState object with caching support.
|
||||
class GrMtlSampler : public SkRefCnt {
|
||||
public:
|
||||
static GrMtlSampler* Create(const GrMtlGpu* gpu, const GrSamplerState&);
|
||||
static GrMtlSampler* Create(const GrMtlGpu* gpu, GrSamplerState);
|
||||
~GrMtlSampler() { fMtlSamplerState = nil; }
|
||||
|
||||
id<MTLSamplerState> mtlSampler() const { return fMtlSamplerState; }
|
||||
@ -27,7 +27,7 @@ public:
|
||||
typedef uint32_t Key;
|
||||
|
||||
// Helpers for hashing GrMtlSampler
|
||||
static Key GenerateKey(const GrSamplerState&);
|
||||
static Key GenerateKey(GrSamplerState);
|
||||
|
||||
static const Key& GetKey(const GrMtlSampler& sampler) { return sampler.fKey; }
|
||||
static uint32_t Hash(const Key& key) {
|
||||
|
@ -40,7 +40,7 @@ static inline MTLSamplerAddressMode wrap_mode_to_mtl_sampler_address(
|
||||
SK_ABORT("Unknown wrap mode.");
|
||||
}
|
||||
|
||||
GrMtlSampler* GrMtlSampler::Create(const GrMtlGpu* gpu, const GrSamplerState& samplerState) {
|
||||
GrMtlSampler* GrMtlSampler::Create(const GrMtlGpu* gpu, GrSamplerState samplerState) {
|
||||
static MTLSamplerMinMagFilter mtlMinMagFilterModes[] = {
|
||||
MTLSamplerMinMagFilterNearest,
|
||||
MTLSamplerMinMagFilterLinear,
|
||||
@ -73,6 +73,6 @@ GrMtlSampler* GrMtlSampler::Create(const GrMtlGpu* gpu, const GrSamplerState& sa
|
||||
GenerateKey(samplerState));
|
||||
}
|
||||
|
||||
GrMtlSampler::Key GrMtlSampler::GenerateKey(const GrSamplerState& samplerState) {
|
||||
GrMtlSampler::Key GrMtlSampler::GenerateKey(GrSamplerState samplerState) {
|
||||
return GrSamplerState::GenerateKey(samplerState);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ private:
|
||||
}
|
||||
|
||||
SamplerHandle addSampler(const GrSurfaceProxy*,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
const GrSwizzle&,
|
||||
const char* name,
|
||||
const GrShaderCaps*) override;
|
||||
|
@ -243,7 +243,7 @@ GrGLSLUniformHandler::UniformHandle GrMtlUniformHandler::internalAddUniformArray
|
||||
}
|
||||
|
||||
GrGLSLUniformHandler::SamplerHandle GrMtlUniformHandler::addSampler(const GrSurfaceProxy* texture,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
const char* name,
|
||||
const GrShaderCaps* caps) {
|
||||
|
@ -319,11 +319,11 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
|
||||
*target->caps().shaderCaps(),
|
||||
views, numActiveViews);
|
||||
} else {
|
||||
GrSamplerState samplerState = fNeedsGlyphTransform ? GrSamplerState::ClampBilerp()
|
||||
: GrSamplerState::ClampNearest();
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(target->allocator(),
|
||||
*target->caps().shaderCaps(), this->color(), false, views, numActiveViews,
|
||||
samplerState, maskFormat, localMatrix, vmPerspective);
|
||||
auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kBilerp
|
||||
: GrSamplerState::Filter::kNearest;
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
||||
target->allocator(), *target->caps().shaderCaps(), this->color(), false, views,
|
||||
numActiveViews, filter, maskFormat, localMatrix, vmPerspective);
|
||||
}
|
||||
|
||||
size_t vertexStride = flushInfo.fGeometryProcessor->vertexStride();
|
||||
@ -454,16 +454,15 @@ void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) co
|
||||
if (this->usesDistanceFields()) {
|
||||
if (this->isLCD()) {
|
||||
reinterpret_cast<GrDistanceFieldLCDTextGeoProc*>(gp)->addNewViews(
|
||||
views, numActiveViews, GrSamplerState::ClampBilerp());
|
||||
views, numActiveViews, GrSamplerState::Filter::kBilerp);
|
||||
} else {
|
||||
reinterpret_cast<GrDistanceFieldA8TextGeoProc*>(gp)->addNewViews(
|
||||
views, numActiveViews, GrSamplerState::ClampBilerp());
|
||||
views, numActiveViews, GrSamplerState::Filter::kBilerp);
|
||||
}
|
||||
} else {
|
||||
GrSamplerState samplerState = fNeedsGlyphTransform ? GrSamplerState::ClampBilerp()
|
||||
: GrSamplerState::ClampNearest();
|
||||
reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewViews(views, numActiveViews,
|
||||
samplerState);
|
||||
auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kBilerp
|
||||
: GrSamplerState::Filter::kNearest;
|
||||
reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewViews(views, numActiveViews, filter);
|
||||
}
|
||||
}
|
||||
int maxGlyphsPerDraw = static_cast<int>(flushInfo->fIndexBuffer->size() / sizeof(uint16_t) / 6);
|
||||
@ -578,7 +577,7 @@ GrGeometryProcessor* GrAtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
|
||||
GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(
|
||||
redCorrection, greenCorrection, blueCorrection);
|
||||
return GrDistanceFieldLCDTextGeoProc::Make(arena, caps, views, numActiveViews,
|
||||
GrSamplerState::ClampBilerp(), widthAdjust,
|
||||
GrSamplerState::Filter::kBilerp, widthAdjust,
|
||||
fDFGPFlags, localMatrix);
|
||||
} else {
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
@ -590,11 +589,11 @@ GrGeometryProcessor* GrAtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
|
||||
fUseGammaCorrectDistanceTable);
|
||||
}
|
||||
return GrDistanceFieldA8TextGeoProc::Make(arena, caps, views, numActiveViews,
|
||||
GrSamplerState::ClampBilerp(),
|
||||
correction, fDFGPFlags, localMatrix);
|
||||
GrSamplerState::Filter::kBilerp, correction,
|
||||
fDFGPFlags, localMatrix);
|
||||
#else
|
||||
return GrDistanceFieldA8TextGeoProc::Make(arena, caps, views, numActiveViews,
|
||||
GrSamplerState::ClampBilerp(),
|
||||
GrSamplerState::Filter::kBilerp,
|
||||
fDFGPFlags, localMatrix);
|
||||
#endif
|
||||
}
|
||||
|
@ -529,10 +529,11 @@ public:
|
||||
return arena->make<QuadPerEdgeAAGeometryProcessor>(spec);
|
||||
}
|
||||
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, const VertexSpec& vertexSpec,
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const VertexSpec& vertexSpec,
|
||||
const GrShaderCaps& caps,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSamplerState& samplerState,
|
||||
GrSamplerState samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate saturate) {
|
||||
@ -741,7 +742,7 @@ private:
|
||||
QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec,
|
||||
const GrShaderCaps& caps,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSamplerState& samplerState,
|
||||
GrSamplerState samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate saturate)
|
||||
@ -826,13 +827,14 @@ GrGeometryProcessor* MakeProcessor(SkArenaAlloc* arena, const VertexSpec& spec)
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(arena, spec);
|
||||
}
|
||||
|
||||
GrGeometryProcessor* MakeTexturedProcessor(SkArenaAlloc* arena, const VertexSpec& spec,
|
||||
GrGeometryProcessor* MakeTexturedProcessor(SkArenaAlloc* arena,
|
||||
const VertexSpec& spec,
|
||||
const GrShaderCaps& caps,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSamplerState& samplerState,
|
||||
GrSamplerState samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate saturate) {
|
||||
Saturate saturate) {
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(arena, spec, caps, backendFormat, samplerState,
|
||||
swizzle, std::move(textureColorSpaceXform),
|
||||
saturate);
|
||||
|
@ -166,10 +166,14 @@ namespace GrQuadPerEdgeAA {
|
||||
|
||||
GrGeometryProcessor* MakeProcessor(SkArenaAlloc*, const VertexSpec&);
|
||||
|
||||
GrGeometryProcessor* MakeTexturedProcessor(
|
||||
SkArenaAlloc*, const VertexSpec&, const GrShaderCaps&, const GrBackendFormat&,
|
||||
const GrSamplerState&, const GrSwizzle&,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform, Saturate);
|
||||
GrGeometryProcessor* MakeTexturedProcessor(SkArenaAlloc*,
|
||||
const VertexSpec&,
|
||||
const GrShaderCaps&,
|
||||
const GrBackendFormat&,
|
||||
GrSamplerState,
|
||||
const GrSwizzle&,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate);
|
||||
|
||||
// This method will return the correct index buffer for the specified indexBufferOption.
|
||||
// It will, correctly, return nullptr if the indexBufferOption is kTriStrips.
|
||||
|
@ -353,9 +353,10 @@ private:
|
||||
} else {
|
||||
matrix = &SkMatrix::I();
|
||||
}
|
||||
flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(target->allocator(),
|
||||
*target->caps().shaderCaps(), *matrix, fWideColor, fAtlas->getViews(),
|
||||
fAtlas->numActivePages(), GrSamplerState::ClampBilerp(), flags);
|
||||
flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(
|
||||
target->allocator(), *target->caps().shaderCaps(), *matrix, fWideColor,
|
||||
fAtlas->getViews(), fAtlas->numActivePages(), GrSamplerState::Filter::kBilerp,
|
||||
flags);
|
||||
} else {
|
||||
SkMatrix invert;
|
||||
if (fHelper.usesLocalCoords()) {
|
||||
@ -364,10 +365,10 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(target->allocator(),
|
||||
*target->caps().shaderCaps(), this->color(), fWideColor, fAtlas->getViews(),
|
||||
fAtlas->numActivePages(), GrSamplerState::ClampNearest(), kA8_GrMaskFormat,
|
||||
invert, false);
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
||||
target->allocator(), *target->caps().shaderCaps(), this->color(), fWideColor,
|
||||
fAtlas->getViews(), fAtlas->numActivePages(), GrSamplerState::Filter::kNearest,
|
||||
kA8_GrMaskFormat, invert, false);
|
||||
}
|
||||
|
||||
// allocate vertices
|
||||
@ -784,10 +785,12 @@ private:
|
||||
// Update the proxies used in the GP to match.
|
||||
if (fUsesDistanceField) {
|
||||
reinterpret_cast<GrDistanceFieldPathGeoProc*>(gp)->addNewViews(
|
||||
fAtlas->getViews(), fAtlas->numActivePages(), GrSamplerState::ClampBilerp());
|
||||
fAtlas->getViews(), fAtlas->numActivePages(),
|
||||
GrSamplerState::Filter::kBilerp);
|
||||
} else {
|
||||
reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewViews(
|
||||
fAtlas->getViews(), fAtlas->numActivePages(), GrSamplerState::ClampNearest());
|
||||
fAtlas->getViews(), fAtlas->numActivePages(),
|
||||
GrSamplerState::Filter::kNearest);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1774,7 +1774,7 @@ int GrVkCaps::getFragmentUniformSet() const {
|
||||
}
|
||||
|
||||
void GrVkCaps::addExtraSamplerKey(GrProcessorKeyBuilder* b,
|
||||
const GrSamplerState& samplerState,
|
||||
GrSamplerState samplerState,
|
||||
const GrBackendFormat& format) const {
|
||||
const GrVkYcbcrConversionInfo* ycbcrInfo = format.getVkYcbcrConversionInfo();
|
||||
if (!ycbcrInfo) {
|
||||
|
@ -184,7 +184,7 @@ public:
|
||||
int getFragmentUniformSet() const;
|
||||
|
||||
void addExtraSamplerKey(GrProcessorKeyBuilder*,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
const GrBackendFormat&) const override;
|
||||
|
||||
GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const override;
|
||||
|
@ -160,7 +160,7 @@ bool GrVkPipelineState::setAndBindTextures(GrVkGpu* gpu,
|
||||
|
||||
if (GrTexture* dstTexture = pipeline.peekDstTexture()) {
|
||||
samplerBindings[currTextureBinding++] = {
|
||||
GrSamplerState::ClampNearest(), static_cast<GrVkTexture*>(dstTexture)};
|
||||
GrSamplerState::Filter::kNearest, static_cast<GrVkTexture*>(dstTexture)};
|
||||
}
|
||||
|
||||
// Get new descriptor set
|
||||
@ -189,7 +189,7 @@ bool GrVkPipelineState::setAndBindTextures(GrVkGpu* gpu,
|
||||
}
|
||||
|
||||
for (int i = 0; i < fNumSamplers; ++i) {
|
||||
const GrSamplerState& state = samplerBindings[i].fState;
|
||||
GrSamplerState state = samplerBindings[i].fState;
|
||||
GrVkTexture* texture = samplerBindings[i].fTexture;
|
||||
|
||||
const GrVkImageView* textureView = texture->textureView();
|
||||
@ -231,7 +231,7 @@ bool GrVkPipelineState::setAndBindTextures(GrVkGpu* gpu,
|
||||
commandBuffer->addResource(samplerBindings[i].fTexture->resource());
|
||||
}
|
||||
if (fNumSamplers == 1) {
|
||||
const GrSamplerState& state = samplerBindings[0].fState;
|
||||
GrSamplerState state = samplerBindings[0].fState;
|
||||
GrVkTexture* texture = samplerBindings[0].fTexture;
|
||||
texture->addDescriptorSetToCache(descriptorSet, state);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool(
|
||||
}
|
||||
|
||||
GrVkSampler* GrVkResourceProvider::findOrCreateCompatibleSampler(
|
||||
const GrSamplerState& params, const GrVkYcbcrConversionInfo& ycbcrInfo) {
|
||||
GrSamplerState params, const GrVkYcbcrConversionInfo& ycbcrInfo) {
|
||||
GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params, ycbcrInfo));
|
||||
if (!sampler) {
|
||||
sampler = GrVkSampler::Create(fGpu, params, ycbcrInfo);
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
|
||||
// Finds or creates a compatible GrVkSampler based on the GrSamplerState and
|
||||
// GrVkYcbcrConversionInfo. The refcount is incremented and a pointer returned.
|
||||
GrVkSampler* findOrCreateCompatibleSampler(const GrSamplerState&,
|
||||
GrVkSampler* findOrCreateCompatibleSampler(GrSamplerState,
|
||||
const GrVkYcbcrConversionInfo& ycbcrInfo);
|
||||
|
||||
// Finds or creates a compatible GrVkSamplerYcbcrConversion based on the GrSamplerState and
|
||||
|
@ -25,7 +25,7 @@ static inline VkSamplerAddressMode wrap_mode_to_vk_sampler_address(
|
||||
SK_ABORT("Unknown wrap mode.");
|
||||
}
|
||||
|
||||
GrVkSampler* GrVkSampler::Create(GrVkGpu* gpu, const GrSamplerState& samplerState,
|
||||
GrVkSampler* GrVkSampler::Create(GrVkGpu* gpu, GrSamplerState samplerState,
|
||||
const GrVkYcbcrConversionInfo& ycbcrInfo) {
|
||||
static VkFilter vkMinFilterModes[] = {
|
||||
VK_FILTER_NEAREST,
|
||||
@ -120,9 +120,8 @@ void GrVkSampler::freeGPUData(GrVkGpu* gpu) const {
|
||||
}
|
||||
}
|
||||
|
||||
GrVkSampler::Key GrVkSampler::GenerateKey(const GrSamplerState& samplerState,
|
||||
GrVkSampler::Key GrVkSampler::GenerateKey(GrSamplerState samplerState,
|
||||
const GrVkYcbcrConversionInfo& ycbcrInfo) {
|
||||
return { GrSamplerState::GenerateKey(samplerState),
|
||||
GrVkSamplerYcbcrConversion::GenerateKey(ycbcrInfo) };
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class GrVkGpu;
|
||||
|
||||
class GrVkSampler : public GrVkResource {
|
||||
public:
|
||||
static GrVkSampler* Create(GrVkGpu* gpu, const GrSamplerState&, const GrVkYcbcrConversionInfo&);
|
||||
static GrVkSampler* Create(GrVkGpu* gpu, GrSamplerState, const GrVkYcbcrConversionInfo&);
|
||||
|
||||
VkSampler sampler() const { return fSampler; }
|
||||
const VkSampler* samplerPtr() const { return &fSampler; }
|
||||
@ -42,7 +42,7 @@ public:
|
||||
};
|
||||
|
||||
// Helpers for hashing GrVkSampler
|
||||
static Key GenerateKey(const GrSamplerState&, const GrVkYcbcrConversionInfo&);
|
||||
static Key GenerateKey(GrSamplerState, const GrVkYcbcrConversionInfo&);
|
||||
|
||||
static const Key& GetKey(const GrVkSampler& sampler) { return sampler.fKey; }
|
||||
static uint32_t Hash(const Key& key) {
|
||||
|
@ -272,19 +272,17 @@ void GrVkTexture::removeFinishIdleProcs() {
|
||||
fIdleProcs = procsToKeep;
|
||||
}
|
||||
|
||||
const GrVkDescriptorSet* GrVkTexture::cachedSingleDescSet(const GrSamplerState& state) {
|
||||
const GrVkDescriptorSet* GrVkTexture::cachedSingleDescSet(GrSamplerState state) {
|
||||
if (std::unique_ptr<DescriptorCacheEntry>* e = fDescSetCache.find(state)) {
|
||||
return (*e)->fDescriptorSet;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GrVkTexture::addDescriptorSetToCache(const GrVkDescriptorSet* descSet,
|
||||
const GrSamplerState& state) {
|
||||
void GrVkTexture::addDescriptorSetToCache(const GrVkDescriptorSet* descSet, GrSamplerState state) {
|
||||
SkASSERT(!fDescSetCache.find(state));
|
||||
descSet->ref();
|
||||
fDescSetCache.insert(state,
|
||||
std::unique_ptr<DescriptorCacheEntry>(
|
||||
new DescriptorCacheEntry(descSet, this->getVkGpu())));
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ public:
|
||||
// GrSamplerState, then a pointer to it is returned. The ref count is not incremented on the
|
||||
// returned pointer, thus the caller must call ref it if they wish to keep ownership of the
|
||||
// GrVkDescriptorSet.
|
||||
const GrVkDescriptorSet* cachedSingleDescSet(const GrSamplerState&);
|
||||
const GrVkDescriptorSet* cachedSingleDescSet(GrSamplerState);
|
||||
|
||||
void addDescriptorSetToCache(const GrVkDescriptorSet*, const GrSamplerState&);
|
||||
void addDescriptorSetToCache(const GrVkDescriptorSet*, GrSamplerState);
|
||||
|
||||
protected:
|
||||
GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>,
|
||||
@ -88,7 +88,7 @@ private:
|
||||
const GrVkImageView* fTextureView;
|
||||
|
||||
struct SamplerHash {
|
||||
uint32_t operator()(const GrSamplerState& state) const {
|
||||
uint32_t operator()(GrSamplerState state) const {
|
||||
return GrSamplerState::GenerateKey(state);
|
||||
}
|
||||
};
|
||||
|
@ -255,7 +255,7 @@ GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
|
||||
}
|
||||
|
||||
GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(const GrSurfaceProxy* texture,
|
||||
const GrSamplerState& state,
|
||||
GrSamplerState state,
|
||||
const GrSwizzle& swizzle,
|
||||
const char* name,
|
||||
const GrShaderCaps* shaderCaps) {
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
}
|
||||
|
||||
SamplerHandle addSampler(const GrSurfaceProxy*,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
const GrSwizzle&,
|
||||
const char* name,
|
||||
const GrShaderCaps*) override;
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
return GrSurfaceProxyView();
|
||||
}
|
||||
|
||||
virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, const GrSamplerState&,
|
||||
virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const = 0;
|
||||
virtual sk_sp<GrTextureProxy> refPinnedTextureProxy(GrRecordingContext*,
|
||||
uint32_t* uniqueID) const {
|
||||
|
@ -190,7 +190,7 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels,
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> SkImage_GpuBase::asTextureProxyRef(GrRecordingContext* context,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
if (!context || !fContext->priv().matches(context)) {
|
||||
SkASSERT(0);
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
virtual const GrSurfaceProxyView& getSurfaceProxyView(GrRecordingContext* context) const = 0;
|
||||
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, const GrSamplerState&,
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const final;
|
||||
|
||||
sk_sp<GrTextureProxy> refPinnedTextureProxy(GrRecordingContext* context,
|
||||
|
@ -238,7 +238,7 @@ bool SkImage_Lazy::onIsValid(GrContext* context) const {
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> SkImage_Lazy::asTextureProxyRef(GrRecordingContext* context,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
CachingHint) const override;
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*,
|
||||
const GrSamplerState&,
|
||||
GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const override;
|
||||
sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4],
|
||||
SkYUVColorSpace*, const void* planes[4]) override;
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
const SkBitmap* onPeekBitmap() const override { return &fBitmap; }
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, const GrSamplerState&,
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const override;
|
||||
#endif
|
||||
|
||||
@ -167,7 +167,7 @@ bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const {
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrRecordingContext* context,
|
||||
const GrSamplerState& params,
|
||||
GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
@ -205,7 +205,7 @@ bool SkImage_Raster::onPinAsTexture(GrContext* ctx) const {
|
||||
} else {
|
||||
SkASSERT(fPinnedCount == 0);
|
||||
SkASSERT(fPinnedUniqueID == 0);
|
||||
fPinnedProxy = GrRefCachedBitmapTextureProxy(ctx, fBitmap, GrSamplerState::ClampNearest(),
|
||||
fPinnedProxy = GrRefCachedBitmapTextureProxy(ctx, fBitmap, GrSamplerState::Filter::kNearest,
|
||||
nullptr);
|
||||
if (!fPinnedProxy) {
|
||||
return false;
|
||||
|
@ -967,19 +967,19 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
|
||||
|
||||
// Any context should be able to borrow the texture at this point
|
||||
sk_sp<GrTextureProxy> proxy = as_IB(refImg)->asTextureProxyRef(
|
||||
ctx, GrSamplerState::ClampNearest(), nullptr);
|
||||
ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
|
||||
// But once it's borrowed, no other context should be able to borrow
|
||||
otherTestContext->makeCurrent();
|
||||
sk_sp<GrTextureProxy> otherProxy = as_IB(refImg)->asTextureProxyRef(
|
||||
otherCtx, GrSamplerState::ClampNearest(), nullptr);
|
||||
otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, !otherProxy);
|
||||
|
||||
// Original context (that's already borrowing) should be okay
|
||||
testContext->makeCurrent();
|
||||
sk_sp<GrTextureProxy> proxySecondRef = as_IB(refImg)->asTextureProxyRef(
|
||||
ctx, GrSamplerState::ClampNearest(), nullptr);
|
||||
ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, proxySecondRef);
|
||||
|
||||
// Release first ref from the original context
|
||||
@ -988,8 +988,8 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
|
||||
// We released one proxy but not the other from the current borrowing context. Make sure
|
||||
// a new context is still not able to borrow the texture.
|
||||
otherTestContext->makeCurrent();
|
||||
otherProxy = as_IB(refImg)->asTextureProxyRef(otherCtx, GrSamplerState::ClampNearest(),
|
||||
nullptr);
|
||||
otherProxy = as_IB(refImg)->asTextureProxyRef(
|
||||
otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, !otherProxy);
|
||||
|
||||
// Release second ref from the original context
|
||||
@ -998,8 +998,8 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
|
||||
|
||||
// Now we should be able to borrow the texture from the other context
|
||||
otherTestContext->makeCurrent();
|
||||
otherProxy = as_IB(refImg)->asTextureProxyRef(otherCtx, GrSamplerState::ClampNearest(),
|
||||
nullptr);
|
||||
otherProxy = as_IB(refImg)->asTextureProxyRef(
|
||||
otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, otherProxy);
|
||||
|
||||
// Release everything
|
||||
@ -1040,8 +1040,8 @@ DEF_GPUTEST(SkImage_CrossContextGrayAlphaConfigs, reporter, options) {
|
||||
sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false);
|
||||
REPORTER_ASSERT(reporter, image);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef(
|
||||
ctx, GrSamplerState::ClampNearest(), nullptr);
|
||||
sk_sp<GrTextureProxy> proxy =
|
||||
as_IB(image)->asTextureProxyRef(ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
|
||||
bool expectAlpha = kAlpha_8_SkColorType == ct;
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
GrSurfaceProxy::UseAllocator::kYes);
|
||||
GrSwizzle swizzle = ctx->priv().caps()->getReadSwizzle(format, kColorType);
|
||||
fAccess.set(GrSurfaceProxyView(fLazyProxy, kOrigin, swizzle),
|
||||
GrSamplerState::ClampNearest());
|
||||
GrSamplerState::Filter::kNearest);
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user