Simplify view getters on GrTextureProducer.
The only thing that affects the view returned is whether it ought to
be MIP mapped or not. So don't take a whole GrSamplerState.
The view() function won't ever change the colortype so just query
GrTextureProducer rather than having view() return a tuple.
The rest is transitively reaching through callers and callees of
GrTextureProducer::view() to only pass filter or GrMipMapped instead of
GrSamplerState. Also, some params that indicate whether MIPs are
requested are changed from bool to GrMipMapped. And some minor style
stuff (mainly de-yoda-ifying GrMipMapped checks, using
GrSurfaceProxyView operator bool()).
Change-Id: Ia184aa793cf51d42642ea3bb0521ce06da2efb10
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274205
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/gm/fpcoordinateoverride.cpp b/gm/fpcoordinateoverride.cpp
index d6425b7..facd44e 100644
--- a/gm/fpcoordinateoverride.cpp
+++ b/gm/fpcoordinateoverride.cpp
@@ -83,7 +83,7 @@
SkBitmap bmp;
GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
GrBitmapTextureMaker maker(ctx, bmp);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
std::unique_ptr<GrFragmentProcessor> imgFP =
GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
auto fp = std::unique_ptr<GrFragmentProcessor>(new SampleCoordEffect(std::move(imgFP)));
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index ee610f3..36adfbf 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -184,8 +184,7 @@
}
protected:
GrSurfaceProxyView onGenerateTexture(GrRecordingContext* ctx, const SkImageInfo& info,
- const SkIPoint& origin,
- bool willBeMipped) override {
+ const SkIPoint& origin, GrMipMapped mipMapped) override {
SkASSERT(ctx);
SkASSERT(ctx == fCtx.get());
@@ -197,8 +196,6 @@
return fView;
}
- GrMipMapped mipMapped = willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo;
-
// TODO: When we update this function to return a view instead of just a proxy then we can
// remove the extra ref that happens when we call asTextureProxyRef.
return GrSurfaceProxy::Copy(
@@ -273,8 +270,7 @@
}
static void draw_as_tex(SkCanvas* canvas, SkImage* image, SkScalar x, SkScalar y) {
- GrSurfaceProxyView view =
- as_IB(image)->refView(canvas->getGrContext(), GrSamplerState::Filter::kBilerp);
+ GrSurfaceProxyView view = as_IB(image)->refView(canvas->getGrContext(), GrMipMapped::kNo);
if (!view) {
// show placeholder if we have no texture
SkPaint paint;
diff --git a/gm/texelsubset.cpp b/gm/texelsubset.cpp
index b788bd6..121b103 100644
--- a/gm/texelsubset.cpp
+++ b/gm/texelsubset.cpp
@@ -81,8 +81,8 @@
context->priv().caps()->mipMapSupport()
? GrMipMapped::kYes : GrMipMapped::kNo;
GrBitmapTextureMaker maker(context, fBitmap);
- auto[view, grCT] = maker.view(mipMapped);
- if (!view.proxy()) {
+ auto view = maker.view(mipMapped);
+ if (!view) {
*errorMsg = "Failed to create proxy.";
return DrawResult::kFail;
}
@@ -115,7 +115,7 @@
fBitmap.extractSubset(&subsetBmp, texelSubset);
subsetBmp.setImmutable();
GrBitmapTextureMaker subsetMaker(context, subsetBmp);
- auto[subsetView, subsetCT] = subsetMaker.view(mipMapped);
+ auto subsetView = subsetMaker.view(mipMapped);
SkRect localRect = SkRect::Make(fBitmap.bounds()).makeOutset(kDrawPad, kDrawPad);
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 2ed22db..6e8f197 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -99,7 +99,7 @@
for (int i = 0; i < 3; ++i) {
GrBitmapTextureMaker maker(context, fBitmaps[i]);
- std::tie(views[i], std::ignore) = maker.view(GrMipMapped::kNo);
+ views[i] = maker.view(GrMipMapped::kNo);
if (!views[i]) {
*errorMsg = "Failed to create proxy";
return DrawResult::kFail;
@@ -215,7 +215,7 @@
for (int i = 0; i < 2; ++i) {
GrBitmapTextureMaker maker(context, fBitmaps[i]);
- std::tie(views[i], std::ignore) = maker.view(GrMipMapped::kNo);
+ views[i] = maker.view(GrMipMapped::kNo);
if (!views[i]) {
*errorMsg = "Failed to create proxy";
return DrawResult::kFail;
@@ -311,7 +311,7 @@
for (int i = 0; i < 3; ++i) {
GrBitmapTextureMaker maker(context, fBitmaps[i]);
- std::tie(views[i], std::ignore) = maker.view(GrMipMapped::kNo);
+ views[i] = maker.view(GrMipMapped::kNo);
if (!views[i]) {
*errorMsg = "Failed to create proxy";
return DrawResult::kFail;
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 1637f59..0409761 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -140,7 +140,7 @@
* overhead in later allocating mips and copying of the base layer.
*/
GrSurfaceProxyView generateTexture(GrRecordingContext*, const SkImageInfo& info,
- const SkIPoint& origin, bool willNeedMipMaps);
+ const SkIPoint& origin, GrMipMapped);
bool texturesAreCacheable() const { return this->onTexturesAreCacheable(); }
#endif
@@ -183,8 +183,7 @@
};
virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
- const SkIPoint&,
- bool willNeedMipMaps); // returns nullptr
+ const SkIPoint&, GrMipMapped); // returns nullptr
virtual bool onTexturesAreCacheable() const { return true; }
#endif
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index 42bc721..66e1e4c 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -64,18 +64,18 @@
GrSurfaceProxyView SkImageGenerator::generateTexture(GrRecordingContext* ctx,
const SkImageInfo& info,
const SkIPoint& origin,
- bool willNeedMipMaps) {
+ GrMipMapped mipMapped) {
SkIRect srcRect = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height());
if (!SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(srcRect)) {
return {};
}
- return this->onGenerateTexture(ctx, info, origin, willNeedMipMaps);
+ return this->onGenerateTexture(ctx, info, origin, mipMapped);
}
GrSurfaceProxyView SkImageGenerator::onGenerateTexture(GrRecordingContext*,
const SkImageInfo&,
const SkIPoint&,
- bool willNeedMipMaps) {
+ GrMipMapped) {
return {};
}
#endif
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index c5917cc..7344d60 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -24,8 +24,8 @@
override;
#if SK_SUPPORT_GPU
- GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
- const SkIPoint&, bool willNeedMipMaps) override;
+ GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&, const SkIPoint&,
+ GrMipMapped) override;
#endif
private:
@@ -93,18 +93,18 @@
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrRecordingContextPriv.h"
-GrSurfaceProxyView SkPictureImageGenerator::onGenerateTexture(
- GrRecordingContext* ctx, const SkImageInfo& info,
- const SkIPoint& origin, bool willNeedMipMaps) {
+GrSurfaceProxyView SkPictureImageGenerator::onGenerateTexture(GrRecordingContext* ctx,
+ const SkImageInfo& info,
+ const SkIPoint& origin,
+ GrMipMapped mipMapped) {
SkASSERT(ctx);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
// CONTEXT TODO: remove this use of 'backdoor' to create an SkSkSurface
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx->priv().backdoor(),
- SkBudgeted::kYes, info, 0,
- kTopLeft_GrSurfaceOrigin, &props,
- willNeedMipMaps));
+ auto surface = SkSurface::MakeRenderTarget(ctx->priv().backdoor(), SkBudgeted::kYes, info, 0,
+ kTopLeft_GrSurfaceOrigin, &props,
+ mipMapped == GrMipMapped::kYes);
if (!surface) {
return {};
}
@@ -119,7 +119,8 @@
}
const GrSurfaceProxyView* view = as_IB(image)->view(ctx);
SkASSERT(view);
- SkASSERT(!willNeedMipMaps || GrMipMapped::kYes == view->asTextureProxy()->mipMapped());
+ SkASSERT(mipMapped == GrMipMapped::kNo ||
+ view->asTextureProxy()->mipMapped() == GrMipMapped::kYes);
return *view;
}
#endif
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 936c6a9..f393c45 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -186,9 +186,10 @@
return GrSurfaceProxyView(std::move(texProxy), fSurfaceOrigin, readSwizzle);
}
-GrSurfaceProxyView GrAHardwareBufferImageGenerator::onGenerateTexture(
- GrRecordingContext* context, const SkImageInfo& info,
- const SkIPoint& origin, bool willNeedMipMaps) {
+GrSurfaceProxyView GrAHardwareBufferImageGenerator::onGenerateTexture(GrRecordingContext* context,
+ const SkImageInfo& info,
+ const SkIPoint& origin,
+ GrMipMapped mipMapped) {
GrSurfaceProxyView texProxyView = this->makeView(context);
if (!texProxyView.proxy()) {
return {};
@@ -204,8 +205,6 @@
// Otherwise, make a copy for the requested subset.
SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height());
- GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
-
GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType());
return GrSurfaceProxy::Copy(context, texProxyView.proxy(), texProxyView.origin(), grColorType,
mipMapped, subset, SkBackingFit::kExact,
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.h b/src/gpu/GrAHardwareBufferImageGenerator.h
index 44d33f2..aa3803c 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.h
+++ b/src/gpu/GrAHardwareBufferImageGenerator.h
@@ -42,8 +42,8 @@
bool onIsValid(GrContext*) const override;
- GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
- const SkIPoint&, bool willNeedMipMaps) override;
+ GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&, const SkIPoint&,
+ GrMipMapped) override;
private:
GrAHardwareBufferImageGenerator(const SkImageInfo&, AHardwareBuffer*, SkAlphaType,
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 096a17d..2a807d6 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -93,9 +93,10 @@
refHelper->unref();
}
-GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(
- GrRecordingContext* context, const SkImageInfo& info,
- const SkIPoint& origin, bool willNeedMipMaps) {
+GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(GrRecordingContext* context,
+ const SkImageInfo& info,
+ const SkIPoint& origin,
+ GrMipMapped mipMapped) {
SkASSERT(context);
if (context->backend() != fBackendTexture.backend()) {
@@ -144,7 +145,8 @@
GrColorType grColorType = SkColorTypeToGrColorType(info.colorType());
- GrMipMapped mipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
+ GrMipMapped textureIsMipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes
+ : GrMipMapped::kNo;
// Ganesh assumes that, when wrapping a mipmapped backend texture from a client, that its
// mipmaps are fully fleshed out.
@@ -155,12 +157,11 @@
// Must make copies of member variables to capture in the lambda since this image generator may
// be deleted before we actually execute the lambda.
- sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- [
- refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
- grColorType
- ](GrResourceProvider * resourceProvider)
- ->GrSurfaceProxy::LazyCallbackResult {
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createLazyProxy(
+ [refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
+ grColorType](GrResourceProvider* resourceProvider)
+ -> GrSurfaceProxy::LazyCallbackResult {
if (refHelper->fSemaphore) {
resourceProvider->priv().gpu()->waitSemaphore(
refHelper->fSemaphore.get());
@@ -201,22 +202,22 @@
return {std::move(tex), true,
GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
},
- backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
- mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
- SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
+ backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
+ textureIsMipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly,
+ SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
+ GrSurfaceProxy::UseAllocator::kYes);
if (!proxy) {
return {};
}
if (origin.isZero() && info.dimensions() == fBackendTexture.dimensions() &&
- (!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped())) {
+ (mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes)) {
// If the caller wants the entire texture and we have the correct mip support, we're done
return GrSurfaceProxyView(std::move(proxy), fSurfaceOrigin, readSwizzle);
} else {
// Otherwise, make a copy of the requested subset. Make sure our temporary is renderable,
// because Vulkan will want to do the copy as a draw. All other copies would require a
// layout change in Vulkan and we do not change the layout of borrowed images.
- GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height());
return GrSurfaceProxy::Copy(
diff --git a/src/gpu/GrBackendTextureImageGenerator.h b/src/gpu/GrBackendTextureImageGenerator.h
index cef161c..283fa39 100644
--- a/src/gpu/GrBackendTextureImageGenerator.h
+++ b/src/gpu/GrBackendTextureImageGenerator.h
@@ -39,8 +39,8 @@
// do that safely (we might be on another thread). So assume everything is fine.
bool onIsValid(GrContext*) const override { return true; }
- GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
- const SkIPoint&, bool willNeedMipMaps) override;
+ GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&, const SkIPoint&,
+ GrMipMapped mipMapped) override;
bool onTexturesAreCacheable() const override { return false; }
private:
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index baff879..a32ec21 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -39,7 +39,7 @@
}
}
-GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
+GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(GrMipMapped mipMapped) {
GrProxyProvider* proxyProvider = this->context()->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy;
GrSwizzle swizzle;
@@ -50,7 +50,7 @@
if (proxy) {
swizzle = this->context()->priv().caps()->getReadSwizzle(proxy->backendFormat(),
this->colorType());
- if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
+ if (mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes) {
return GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle);
}
}
@@ -65,16 +65,14 @@
return {};
}
copy8888.setImmutable();
- proxy = proxyProvider->createProxyFromBitmap(
- copy8888, willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo, fFit);
+ proxy = proxyProvider->createProxyFromBitmap(copy8888, mipMapped, fFit);
} else {
- proxy = proxyProvider->createProxyFromBitmap(
- fBitmap, willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo, fFit);
+ proxy = proxyProvider->createProxyFromBitmap(fBitmap, mipMapped, fFit);
}
if (proxy) {
swizzle = this->context()->priv().caps()->getReadSwizzle(proxy->backendFormat(),
this->colorType());
- SkASSERT(!willBeMipped || GrMipMapped::kYes == proxy->mipMapped());
+ SkASSERT(mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes);
if (fOriginalKey.isValid()) {
proxyProvider->assignUniqueKeyToProxy(fOriginalKey, proxy.get());
GrInstallBitmapUniqueKeyInvalidator(
@@ -85,8 +83,8 @@
}
if (proxy) {
- SkASSERT(willBeMipped);
- SkASSERT(GrMipMapped::kNo == proxy->mipMapped());
+ SkASSERT(mipMapped == GrMipMapped::kYes);
+ SkASSERT(proxy->mipMapped() == GrMipMapped::kNo);
SkASSERT(fOriginalKey.isValid());
// We need a mipped proxy, but we found a proxy earlier that wasn't mipped. Thus we generate
// a new mipped surface and copy the original proxy into the base layer. We will then let
diff --git a/src/gpu/GrBitmapTextureMaker.h b/src/gpu/GrBitmapTextureMaker.h
index 311bacb..59217d0 100644
--- a/src/gpu/GrBitmapTextureMaker.h
+++ b/src/gpu/GrBitmapTextureMaker.h
@@ -23,7 +23,7 @@
bool useDecal = false);
private:
- GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
+ GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
const SkBitmap fBitmap;
const SkBackingFit fFit;
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 1ce1e82..cfd9657 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -153,7 +153,7 @@
GrBitmapTextureMaker maker(context, bm, GrBitmapTextureMaker::Cached::kNo,
SkBackingFit::kApprox);
- std::tie(filteredMaskView, std::ignore) = maker.view(GrMipMapped::kNo);
+ filteredMaskView = maker.view(GrMipMapped::kNo);
if (!filteredMaskView.proxy()) {
return false;
}
diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp
index 892140f..97793e9 100644
--- a/src/gpu/GrImageTextureMaker.cpp
+++ b/src/gpu/GrImageTextureMaker.cpp
@@ -33,8 +33,8 @@
GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
}
-GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
- return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, willBeMipped);
+GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(GrMipMapped mipMapped) {
+ return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, mipMapped);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
@@ -47,8 +47,8 @@
GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
}
-GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
- if (willBeMipped) {
+GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(GrMipMapped mipMapped) {
+ if (mipMapped == GrMipMapped::kYes) {
return fImage->refMippedView(this->context());
} else {
if (const GrSurfaceProxyView* view = fImage->view(this->context())) {
diff --git a/src/gpu/GrImageTextureMaker.h b/src/gpu/GrImageTextureMaker.h
index 908e232..bd1aee7 100644
--- a/src/gpu/GrImageTextureMaker.h
+++ b/src/gpu/GrImageTextureMaker.h
@@ -22,7 +22,7 @@
SkImage::CachingHint chint, bool useDecal = false);
private:
- GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
+ GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
const SkImage_Lazy* fImage;
GrUniqueKey fOriginalKey;
@@ -48,7 +48,7 @@
bool hasMixedResolutions() const override { return true; }
private:
- GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
+ GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
const SkImage_GpuYUVA* fImage;
GrUniqueKey fOriginalKey;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index e7916c6..38bed95 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -104,6 +104,5 @@
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap, GrBitmapTextureMaker::Cached::kNo, fit);
- auto[textureView, ct] = maker.view(GrMipMapped::kNo);
- return textureView;
+ return maker.view(GrMipMapped::kNo);
}
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index 1653e66..07c080e 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -52,8 +52,7 @@
return copyView;
}
-GrSurfaceProxyView GrTextureAdjuster::onRefTextureProxyViewForParams(GrSamplerState params,
- bool willBeMipped) {
+GrSurfaceProxyView GrTextureAdjuster::onView(GrMipMapped mipMapped) {
if (this->context()->priv().abandoned()) {
// The texture was abandoned.
return {};
@@ -64,7 +63,7 @@
GrTextureProxy* texProxy = fOriginal.asTextureProxy();
SkASSERT(texProxy);
- if (!GrGpu::IsACopyNeededForMips(this->context()->priv().caps(), texProxy, params.filter())) {
+ if (mipMapped == GrMipMapped::kNo || texProxy->mipMapped() == GrMipMapped::kYes) {
return fOriginal;
}
@@ -85,7 +84,12 @@
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrSamplerState::Filter* filterOrNullForBicubic) {
- GrSurfaceProxyView view = this->viewForParams(filterOrNullForBicubic);
+ GrSurfaceProxyView view;
+ if (filterOrNullForBicubic) {
+ view = this->view(*filterOrNullForBicubic);
+ } else {
+ view = this->view(GrMipMapped::kNo);
+ }
if (!view) {
return nullptr;
}
diff --git a/src/gpu/GrTextureAdjuster.h b/src/gpu/GrTextureAdjuster.h
index 08ce030..61a2742 100644
--- a/src/gpu/GrTextureAdjuster.h
+++ b/src/gpu/GrTextureAdjuster.h
@@ -31,7 +31,7 @@
const GrSamplerState::Filter* filterOrNullForBicubic) override;
private:
- GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState, bool willBeMipped) override;
+ GrSurfaceProxyView onView(GrMipMapped) override;
GrSurfaceProxyView makeMippedCopy();
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index de73479..34383e1 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -14,13 +14,12 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SkGr.h"
-GrSurfaceProxyView GrTextureMaker::onRefTextureProxyViewForParams(GrSamplerState params,
- bool willBeMipped) {
+GrSurfaceProxyView GrTextureMaker::onView(GrMipMapped mipMapped) {
if (this->width() > this->context()->priv().caps()->maxTextureSize() ||
this->height() > this->context()->priv().caps()->maxTextureSize()) {
return {};
}
- return this->refOriginalTextureProxyView(willBeMipped);
+ return this->refOriginalTextureProxyView(mipMapped);
}
std::unique_ptr<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
@@ -41,7 +40,12 @@
fmForDetermineDomain = &kBilerp;
}
- GrSurfaceProxyView view = this->viewForParams(filterOrNullForBicubic);
+ GrSurfaceProxyView view;
+ if (filterOrNullForBicubic) {
+ view = this->view(*filterOrNullForBicubic);
+ } else {
+ view = this->view(GrMipMapped::kNo);
+ }
if (!view) {
return nullptr;
}
diff --git a/src/gpu/GrTextureMaker.h b/src/gpu/GrTextureMaker.h
index 20352f6..872a5d4 100644
--- a/src/gpu/GrTextureMaker.h
+++ b/src/gpu/GrTextureMaker.h
@@ -31,13 +31,10 @@
/**
* Return the maker's "original" texture. It is the responsibility of the maker to handle any
* caching of the original if desired.
- * If "genType" argument equals AllowedTexGenType::kCheap and the texture is not trivial to
- * construct then refOriginalTextureProxy should return nullptr (for example if texture is made
- * by drawing into a render target).
*/
- virtual GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) = 0;
+ virtual GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) = 0;
- GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState, bool willBeMipped) final;
+ GrSurfaceProxyView onView(GrMipMapped) final;
typedef GrTextureProducer INHERITED;
};
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index c40a142..62c4e9c 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -167,62 +167,25 @@
}
}
-GrSurfaceProxyView GrTextureProducer::viewForParams(
- const GrSamplerState::Filter* filterOrNullForBicubic) {
- GrSamplerState sampler; // Default is nearest + clamp
- if (filterOrNullForBicubic) {
- sampler.setFilterMode(*filterOrNullForBicubic);
- }
- if (fDomainNeedsDecal) {
- // Assuming hardware support, switch to clamp-to-border instead of clamp
- if (fContext->priv().caps()->clampToBorderSupport()) {
- sampler.setWrapModeX(GrSamplerState::WrapMode::kClampToBorder);
- sampler.setWrapModeY(GrSamplerState::WrapMode::kClampToBorder);
+GrSurfaceProxyView GrTextureProducer::view(GrMipMapped mipMapped) {
+ const GrCaps* caps = this->context()->priv().caps();
+ // Sanitize the MIP map request.
+ if (mipMapped == GrMipMapped::kYes) {
+ if ((this->width() == 1 && this->height() == 1) || !caps->mipMapSupport()) {
+ mipMapped = GrMipMapped::kNo;
}
}
- return this->viewForParams(sampler);
-}
-
-GrSurfaceProxyView GrTextureProducer::viewForParams(GrSamplerState sampler) {
- const GrCaps* caps = this->context()->priv().caps();
-
- int mipCount = SkMipMap::ComputeLevelCount(this->width(), this->height());
- bool willBeMipped = GrSamplerState::Filter::kMipMap == sampler.filter() && mipCount &&
- caps->mipMapSupport();
-
- auto result = this->onRefTextureProxyViewForParams(sampler, willBeMipped);
- if (!result) {
- return {};
- }
-
- SkASSERT(result.asTextureProxy());
-
- // Check to make sure that if we say the texture willBeMipped that the returned texture has mip
- // maps, unless the config is not copyable.
- SkASSERT(!willBeMipped || result.asTextureProxy()->mipMapped() == GrMipMapped::kYes ||
+ auto result = this->onView(mipMapped);
+ // Check to make sure if we requested MIPs that the returned texture has MIP maps or the format
+ // is not copyable.
+ SkASSERT(!result || mipMapped == GrMipMapped::kNo ||
+ result.asTextureProxy()->mipMapped() == GrMipMapped::kYes ||
!caps->isFormatCopyable(result.proxy()->backendFormat()));
-
- SkASSERT(result.proxy()->dimensions() == this->dimensions());
-
return result;
}
-std::pair<GrSurfaceProxyView, GrColorType> GrTextureProducer::view(GrMipMapped willNeedMips) {
- GrSamplerState::Filter filter =
- GrMipMapped::kNo == willNeedMips ? GrSamplerState::Filter::kNearest
- : GrSamplerState::Filter::kMipMap;
- GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, filter);
-
- auto result = this->viewForParams(sampler);
-
-#ifdef SK_DEBUG
- const GrCaps* caps = this->context()->priv().caps();
- // Check that the resulting proxy format is compatible with the GrColorType of this producer
- SkASSERT(!result.proxy() ||
- result.proxy()->isFormatCompressed(caps) ||
- caps->areColorTypeAndFormatCompatible(this->colorType(),
- result.proxy()->backendFormat()));
-#endif
-
- return {result, this->colorType()};
+GrSurfaceProxyView GrTextureProducer::view(GrSamplerState::Filter filter) {
+ auto mipMapped = filter == GrSamplerState::Filter::kMipMap ? GrMipMapped::kYes
+ : GrMipMapped::kNo;
+ return this->view(mipMapped);
}
diff --git a/src/gpu/GrTextureProducer.h b/src/gpu/GrTextureProducer.h
index 0d05a30..a3c5744 100644
--- a/src/gpu/GrTextureProducer.h
+++ b/src/gpu/GrTextureProducer.h
@@ -32,6 +32,8 @@
*/
class GrTextureProducer : public SkNoncopyable {
public:
+ virtual ~GrTextureProducer() {}
+
enum FilterConstraint {
kYes_FilterConstraint,
kNo_FilterConstraint,
@@ -65,28 +67,19 @@
const GrSamplerState::Filter* filterOrNullForBicubic) = 0;
/**
- * Returns a texture that is safe for use with the params.
+ * Returns a texture view, possibly with MIP maps. The request for MIP maps may not be honored
+ * base on caps, format, and whether the texture is 1x1. A non-MIP mapped request may still
+ * receive a MIP mapped texture (if that is what is available in the cache).
*/
- GrSurfaceProxyView viewForParams(GrSamplerState);
+ GrSurfaceProxyView view(GrMipMapped);
- GrSurfaceProxyView viewForParams(const GrSamplerState::Filter* filterOrNullForBicubic);
-
- /**
- * Returns a texture. If willNeedMips is true then the returned texture is guaranteed to have
- * allocated mip map levels. This can be a performance win if future draws with the texture
- * require mip maps.
- */
- // TODO: Once we remove support for npot textures, we should add a flag for must support repeat
- // wrap mode. To support that flag now would require us to support scaleAdjust array like in
- // refTextureProxyForParams, however the current public API that uses this call does not expose
- // that array.
- std::pair<GrSurfaceProxyView, GrColorType> view(GrMipMapped willNeedMips);
-
- virtual ~GrTextureProducer() {}
+ /** Helper version of above that determines MIP mapping requirement from Filter. */
+ GrSurfaceProxyView view(GrSamplerState::Filter);
int width() const { return fImageInfo.width(); }
int height() const { return fImageInfo.height(); }
SkISize dimensions() const { return fImageInfo.dimensions(); }
+ GrColorType colorType() const { return fImageInfo.colorType(); }
SkAlphaType alphaType() const { return fImageInfo.alphaType(); }
SkColorSpace* colorSpace() const { return fImageInfo.colorSpace(); }
bool isAlphaOnly() const { return GrColorTypeIsAlphaOnly(fImageInfo.colorType()); }
@@ -102,8 +95,6 @@
bool domainNeedsDecal)
: fContext(context), fImageInfo(imageInfo), fDomainNeedsDecal(domainNeedsDecal) {}
- GrColorType colorType() const { return fImageInfo.colorType(); }
-
enum DomainMode {
kNoDomain_DomainMode,
kDomain_DomainMode,
@@ -127,8 +118,7 @@
GrRecordingContext* context() const { return fContext; }
private:
- virtual GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState,
- bool willBeMipped) = 0;
+ virtual GrSurfaceProxyView onView(GrMipMapped) = 0;
GrRecordingContext* fContext;
const GrImageInfo fImageInfo;
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 470bf2a..905bbd1 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -153,7 +153,7 @@
bitmap.setImmutable();
GrBitmapTextureMaker maker(ctx, bitmap, GrBitmapTextureMaker::Cached::kNo, fit);
- std::tie(yuvViews[i], std::ignore) = maker.view(GrMipMapped::kNo);
+ yuvViews[i] = maker.view(GrMipMapped::kNo);
if (!yuvViews[i]) {
return {};
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9deaff9..e98bc8e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -699,7 +699,6 @@
const SkIRect& imageRect,
const SkMatrix& viewMatrix,
const SkMatrix& srcToDstRect,
- GrSamplerState params,
const SkRect* srcRectPtr,
int maxTileSize,
int* tileSize,
@@ -754,7 +753,6 @@
// If image is explicitly texture backed then we shouldn't get here.
SkASSERT(!image->isTextureBacked());
- GrSamplerState samplerState;
bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
image->width(), image->height(), quality, viewMatrix, srcToDstRect,
@@ -768,7 +766,6 @@
} else {
tileFilterPad = 1;
}
- samplerState.setFilterMode(textureFilterMode);
int maxTileSize = this->caps()->maxTileSize() - 2 * tileFilterPad;
@@ -777,8 +774,7 @@
SkIRect outClippedSrcRect;
return this->shouldTileImageID(image->unique(), image->bounds(), viewMatrix, srcToDstRect,
- samplerState, srcRectPtr, maxTileSize, &outTileSize,
- &outClippedSrcRect);
+ srcRectPtr, maxTileSize, &outTileSize, &outClippedSrcRect);
}
// This method outsets 'iRect' by 'outset' all around and then clamps its extents to
@@ -821,7 +817,7 @@
const SkMatrix& dstMatrix,
const SkRect& srcRect,
const SkIRect& clippedSrcIRect,
- GrSamplerState params,
+ GrSamplerState::Filter filter,
const SkPaint& origPaint,
SkCanvas::SrcRectConstraint constraint,
int tileSize,
@@ -864,7 +860,7 @@
SkIntToScalar(iTileR.fTop));
SkRect rectToDraw = tileR;
dstMatrix.mapRect(&rectToDraw);
- if (GrSamplerState::Filter::kNearest != params.filter() || bicubic) {
+ if (filter != GrSamplerState::Filter::kNearest || bicubic) {
SkIRect iClampRect;
if (SkCanvas::kFast_SrcRectConstraint == constraint) {
@@ -891,7 +887,7 @@
viewMatrix,
rectToDraw,
tileR,
- params,
+ filter,
*paint,
constraint,
bicubic,
@@ -905,7 +901,7 @@
const SkMatrix& viewMatrix,
const SkRect& dstRect,
const SkRect& srcRect,
- GrSamplerState samplerState,
+ GrSamplerState::Filter filter,
const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint,
bool bicubic,
@@ -916,9 +912,10 @@
// We should be respecting the max tile size by the time we get here.
SkASSERT(bitmap.width() <= this->caps()->maxTileSize() &&
bitmap.height() <= this->caps()->maxTileSize());
- SkASSERT(!samplerState.isRepeated());
- GrSurfaceProxyView view = GrRefCachedBitmapView(fContext.get(), bitmap, samplerState);
+ GrMipMapped mipMapped = filter == GrSamplerState::Filter::kMipMap ? GrMipMapped::kYes
+ : GrMipMapped::kNo;
+ GrSurfaceProxyView view = GrRefCachedBitmapView(fContext.get(), bitmap, mipMapped);
if (!view) {
return;
}
@@ -937,19 +934,18 @@
if (bicubic) {
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
fp = GrBicubicEffect::MakeSubset(std::move(view), srcAlphaType, texMatrix,
- samplerState.wrapModeX(), samplerState.wrapModeY(),
- srcRect, kDir, caps);
+ GrSamplerState::WrapMode::kClamp,
+ GrSamplerState::WrapMode::kClamp, srcRect, kDir, caps);
} else {
- fp = GrTextureEffect::MakeSubset(std::move(view), srcAlphaType, texMatrix,
- samplerState, srcRect, caps);
+ fp = GrTextureEffect::MakeSubset(std::move(view), srcAlphaType, texMatrix, filter,
+ srcRect, caps);
}
} else if (bicubic) {
- SkASSERT(GrSamplerState::Filter::kNearest == samplerState.filter());
+ SkASSERT(GrSamplerState::Filter::kNearest == filter);
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
- fp = GrBicubicEffect::Make(std::move(view), srcAlphaType, texMatrix,
- samplerState.wrapModeX(), samplerState.wrapModeY(), kDir, caps);
+ fp = GrBicubicEffect::Make(std::move(view), srcAlphaType, texMatrix, kDir);
} else {
- fp = GrTextureEffect::Make(std::move(view), srcAlphaType, texMatrix, samplerState, caps);
+ fp = GrTextureEffect::Make(std::move(view), srcAlphaType, texMatrix, filter);
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(),
@@ -1043,14 +1039,7 @@
SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(left, top, subset.width(), subset.height()));
SkRect srcRect = SkRect::Make(subset);
if (clipImage) {
- // Add the image as a simple texture effect applied to coverage. Accessing content outside
- // 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.
- auto filter = paint.getFilterQuality() > kNone_SkFilterQuality
- ? GrSamplerState::Filter::kBilerp
- : GrSamplerState::Filter::kNearest;
- GrSurfaceProxyView clipView = as_IB(clipImage)->refView(this->context(), filter);
+ GrSurfaceProxyView clipView = as_IB(clipImage)->refView(this->context(), GrMipMapped::kNo);
// Fold clip matrix into ctm
ctm.preConcat(clipMatrix);
SkMatrix inverseClipMatrix;
@@ -1060,7 +1049,7 @@
GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
cfp = GrTextureEffect::Make(std::move(clipView), clipImage->alphaType(),
- inverseClipMatrix, filter);
+ inverseClipMatrix);
if (srcColorType != GrColorType::kAlpha_8) {
cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
}
@@ -1142,7 +1131,6 @@
int tileSize;
SkIRect clippedSrcRect;
- GrSamplerState sampleState;
bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
bitmap.width(), bitmap.height(), paint.getFilterQuality(), this->localToDevice(),
@@ -1157,14 +1145,14 @@
} else {
tileFilterPad = 1;
}
- sampleState.setFilterMode(textureFilterMode);
int maxTileSizeForFilter = this->caps()->maxTileSize() - 2 * tileFilterPad;
if (this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(),
- this->localToDevice(), srcToDstMatrix, sampleState, src,
+ this->localToDevice(), srcToDstMatrix, src,
maxTileSizeForFilter, &tileSize, &clippedSrcRect)) {
- this->drawTiledBitmap(bitmap, this->localToDevice(), srcToDstMatrix, *src, clippedSrcRect,
- sampleState, paint, constraint, tileSize, doBicubic);
+ this->drawTiledBitmap(bitmap, this->localToDevice(), srcToDstMatrix, *src,
+ clippedSrcRect, textureFilterMode, paint, constraint, tileSize,
+ doBicubic);
return;
}
}
@@ -1343,7 +1331,7 @@
auto dstColorSpace = fRenderTargetContext->colorInfo().colorSpace();
const GrSamplerState::Filter filter = compute_lattice_filter_mode(*paint);
- auto view = producer->viewForParams(&filter);
+ auto view = producer->view(filter);
if (!view) {
return;
}
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 7baf339..4919ad5 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -170,7 +170,6 @@
const SkIRect& imageRect,
const SkMatrix& viewMatrix,
const SkMatrix& srcToDstRectMatrix,
- GrSamplerState params,
const SkRect* srcRectPtr,
int maxTileSize,
int* tileSize,
@@ -192,7 +191,7 @@
const SkMatrix& srcToDstMatrix,
const SkRect& srcRect,
const SkIRect& clippedSrcRect,
- GrSamplerState params,
+ GrSamplerState::Filter,
const SkPaint& paint,
SkCanvas::SrcRectConstraint,
int tileSize,
@@ -203,7 +202,7 @@
const SkMatrix& viewMatrix,
const SkRect& dstRect,
const SkRect& srcRect,
- GrSamplerState samplerState,
+ GrSamplerState::Filter,
const SkPaint& paint,
SkCanvas::SrcRectConstraint,
bool bicubic,
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 7b2b1a9..2eb7788 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -241,14 +241,14 @@
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[view, ct] = producer->view(GrMipMapped::kNo);
+ auto view = producer->view(GrMipMapped::kNo);
if (!view) {
return;
}
- draw_texture(rtc, clip, ctm, paint, src, dst, dstClip, aa, aaFlags, constraint,
- std::move(view),
- {ct, producer->alphaType(), sk_ref_sp(producer->colorSpace())});
+ draw_texture(
+ rtc, clip, ctm, paint, src, dst, dstClip, aa, aaFlags, constraint, std::move(view),
+ {producer->colorType(), producer->alphaType(), sk_ref_sp(producer->colorSpace())});
return;
}
@@ -537,7 +537,7 @@
uint32_t uniqueID;
view = image->refPinnedView(this->context(), &uniqueID);
if (!view) {
- view = image->refView(this->context(), GrSamplerState::Filter::kBilerp);
+ view = image->refView(this->context(), GrMipMapped::kNo);
}
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 0b20bb7..7222dcf 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -134,9 +134,9 @@
}
GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext* ctx, const SkBitmap& bitmap,
- GrSamplerState params) {
+ GrMipMapped mipMapped) {
GrBitmapTextureMaker maker(ctx, bitmap, GrBitmapTextureMaker::Cached::kYes);
- return maker.viewForParams(params);
+ return maker.view(mipMapped);
}
GrSurfaceProxyView GrMakeCachedBitmapProxyView(GrRecordingContext* context, const SkBitmap& bitmap,
@@ -146,8 +146,7 @@
}
GrBitmapTextureMaker maker(context, bitmap, GrBitmapTextureMaker::Cached::kYes, fit);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
- return view;
+ return maker.view(GrMipMapped::kNo);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h
index 36daae1..bdfb31a 100644
--- a/src/gpu/SkGr.h
+++ b/src/gpu/SkGr.h
@@ -164,11 +164,12 @@
// Texture management
/**
- * Returns a view that wraps a texture representing the bitmap that is compatible with the
- * GrSamplerState. The texture is inserted into the cache (unless the bitmap is marked volatile)
- * and can be retrieved again via this function.
+ * Returns a view that wraps a texture representing the bitmap. The texture is inserted into the
+ * cache (unless the bitmap is marked volatile and can be retrieved again via this function.
+ * A MIP mapped texture may be returned even when GrMipMapped is kNo. The function will succeed
+ * with a non-MIP mapped texture if GrMipMapped is kYes but MIP mapping is not supported.
*/
-GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext*, const SkBitmap&, GrSamplerState);
+GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext*, const SkBitmap&, GrMipMapped);
/**
* Creates a new texture with mipmap levels and copies the baseProxy into the base layer.
diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
index eefb3f5..5582538 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
@@ -257,7 +257,7 @@
bm.setImmutable();
GrBitmapTextureMaker maker(context, bm);
- auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
+ auto blurView = maker.view(GrMipMapped::kNo);
if (!blurView) {
return {};
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index 1ac027f..f3932f5 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -60,9 +60,8 @@
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto [dataView, ct] = maker.view(GrMipMapped::kNo);
-
- if (!dataView.proxy()) {
+ auto dataView = maker.view(GrMipMapped::kNo);
+ if (!dataView) {
return false;
}
diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp
index 1cabeb8..667d92b 100644
--- a/src/gpu/effects/GrRectBlurEffect.fp
+++ b/src/gpu/effects/GrRectBlurEffect.fp
@@ -85,7 +85,7 @@
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
if (!view) {
return {};
}
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
index bb6767f..d53339f 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
@@ -234,7 +234,7 @@
bm.setImmutable();
GrBitmapTextureMaker maker(context, bm);
- auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
+ auto blurView = maker.view(GrMipMapped::kNo);
if (!blurView) {
return {};
}
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h
index 5e4b3ce..f6bbd62 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -69,9 +69,8 @@
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[dataView, ct] = maker.view(GrMipMapped::kNo);
-
- if (!dataView.proxy()) {
+ auto dataView = maker.view(GrMipMapped::kNo);
+ if (!dataView) {
return false;
}
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.h b/src/gpu/effects/generated/GrRectBlurEffect.h
index 6a56d9d..f7331fe 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRectBlurEffect.h
@@ -68,7 +68,7 @@
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
if (!view) {
return {};
}
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 6d1a36b..71fe840 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -668,7 +668,7 @@
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
if (view) {
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 9dfcc7c..aa8df40 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -64,7 +64,7 @@
// this call will flatten a SkImage_GpuYUV to a single texture.
virtual const GrSurfaceProxyView* view(GrRecordingContext*) const { return nullptr; }
- virtual GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState) const = 0;
+ virtual GrSurfaceProxyView refView(GrRecordingContext*, GrMipMapped) const = 0;
virtual GrSurfaceProxyView refPinnedView(GrRecordingContext*, uint32_t* uniqueID) const {
return {};
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index fcb882c..f3986eb 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -409,12 +409,12 @@
static sk_sp<SkImage> create_image_from_producer(GrContext* context, GrTextureProducer* producer,
uint32_t id, GrMipMapped mipMapped) {
- auto[view, colorType] = producer->view(mipMapped);
- if (!view.proxy()) {
+ auto view = producer->view(mipMapped);
+ if (!view) {
return nullptr;
}
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), id, std::move(view),
- GrColorTypeToSkColorType(colorType),
+ GrColorTypeToSkColorType(producer->colorType()),
producer->alphaType(), sk_ref_sp(producer->colorSpace()));
}
@@ -547,8 +547,8 @@
bmp.installPixels(*pixmap);
GrBitmapTextureMaker bitmapMaker(context, bmp);
GrMipMapped mipMapped = buildMips ? GrMipMapped::kYes : GrMipMapped::kNo;
- auto[view, grCT] = bitmapMaker.view(mipMapped);
- if (!view.proxy()) {
+ auto view = bitmapMaker.view(mipMapped);
+ if (!view) {
return SkImage::MakeRasterCopy(*pixmap);
}
@@ -560,7 +560,7 @@
std::unique_ptr<GrSemaphore> sema = gpu->prepareTextureForCrossContextUsage(texture.get());
- SkColorType skCT = GrColorTypeToSkColorType(grCT);
+ SkColorType skCT = GrColorTypeToSkColorType(bitmapMaker.colorType());
auto gen = GrBackendTextureImageGenerator::Make(std::move(texture), view.origin(),
std::move(sema), skCT,
pixmap->alphaType(),
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 7bd05ba..51a0e01 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -187,7 +187,7 @@
}
GrSurfaceProxyView SkImage_GpuBase::refView(GrRecordingContext* context,
- GrSamplerState params) const {
+ GrMipMapped mipMapped) const {
if (!context || !fContext->priv().matches(context)) {
SkASSERT(0);
return {};
@@ -195,7 +195,7 @@
GrTextureAdjuster adjuster(fContext.get(), *this->view(context), this->imageInfo().colorInfo(),
this->uniqueID());
- return adjuster.viewForParams(params);
+ return adjuster.view(mipMapped);
}
GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContextIO,
diff --git a/src/image/SkImage_GpuBase.h b/src/image/SkImage_GpuBase.h
index 3f4fa52..f1f6690 100644
--- a/src/image/SkImage_GpuBase.h
+++ b/src/image/SkImage_GpuBase.h
@@ -28,7 +28,7 @@
bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
int srcX, int srcY, CachingHint) const override;
- GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState) const final;
+ GrSurfaceProxyView refView(GrRecordingContext*, GrMipMapped) const final;
GrSurfaceProxyView refPinnedView(GrRecordingContext* context, uint32_t* uniqueID) const final {
*uniqueID = this->uniqueID();
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 43ab458..2cfe5c2 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -169,7 +169,7 @@
GrSurfaceProxyView SkImage_GpuYUVA::refMippedView(GrRecordingContext* context) const {
// if invalid or already has miplevels
this->flattenToRGB(context);
- if (!fRGBView.proxy() || GrMipMapped::kYes == fRGBView.asTextureProxy()->mipMapped()) {
+ if (!fRGBView || fRGBView.asTextureProxy()->mipMapped() == GrMipMapped::kYes) {
return fRGBView;
}
@@ -177,7 +177,7 @@
GrColorType srcColorType = SkColorTypeToGrColorType(this->colorType());
GrSurfaceProxyView mippedView = GrCopyBaseMipMapToTextureProxy(context, fRGBView.proxy(),
fRGBView.origin(), srcColorType);
- if (mippedView.proxy()) {
+ if (mippedView) {
fRGBView = std::move(mippedView);
return fRGBView;
}
@@ -294,10 +294,11 @@
GrBitmapTextureMaker bitmapMaker(context, bmp);
GrMipMapped mipMapped = buildMips ? GrMipMapped::kYes : GrMipMapped::kNo;
GrSurfaceProxyView view;
- std::tie(tempViews[i], proxyColorTypes[i]) = bitmapMaker.view(mipMapped);
+ tempViews[i] = bitmapMaker.view(mipMapped);
if (!tempViews[i]) {
return nullptr;
}
+ proxyColorTypes[i] = bitmapMaker.colorType();
}
return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(context), imageSize, kNeedNewImageUniqueID,
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index e80e4b5..55f25cb 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -238,13 +238,13 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-GrSurfaceProxyView SkImage_Lazy::refView(GrRecordingContext* context, GrSamplerState params) const {
+GrSurfaceProxyView SkImage_Lazy::refView(GrRecordingContext* context, GrMipMapped mipMapped) const {
if (!context) {
return {};
}
GrImageTextureMaker textureMaker(context, this, kAllow_CachingHint);
- return textureMaker.viewForParams(params);
+ return textureMaker.view(mipMapped);
}
#endif
@@ -422,7 +422,7 @@
GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(GrRecordingContext* ctx,
const GrUniqueKey& origKey,
SkImage::CachingHint chint,
- bool willBeMipped) const {
+ GrMipMapped mipMapped) const {
// Values representing the various texture lock paths we can take. Used for logging the path
// taken to a histogram.
enum LockTexturePath {
@@ -436,6 +436,11 @@
enum { kLockTexturePathCount = kRGBA_LockTexturePath + 1 };
+ auto satisfiesMipMapRequest = [&](const GrSurfaceProxyView& view) {
+ SkASSERT(view);
+ return mipMapped == GrMipMapped::kNo ||
+ view.asTextureProxy()->mipMapped() == GrMipMapped::kYes;
+ };
// Build our texture key.
// Even though some proxies created here may have a specific origin and use that origin, we do
// not include that in the key. Since SkImages are meant to be immutable, a given SkImage will
@@ -458,7 +463,7 @@
kLockTexturePathCount);
GrSwizzle swizzle = caps->getReadSwizzle(proxy->backendFormat(), ct);
view = GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle);
- if (!willBeMipped || GrMipMapped::kYes == view.asTextureProxy()->mipMapped()) {
+ if (satisfiesMipMapRequest(view)) {
return view;
}
}
@@ -467,14 +472,14 @@
// 2. Ask the generator to natively create one
if (!view.proxy()) {
ScopedGenerator generator(fSharedGenerator);
- view = generator->generateTexture(ctx, this->imageInfo(), fOrigin, willBeMipped);
+ view = generator->generateTexture(ctx, this->imageInfo(), fOrigin, mipMapped);
if (view.proxy()) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath,
kLockTexturePathCount);
GrTextureProxy* proxy = view.asTextureProxy();
SkASSERT(proxy);
set_key_on_proxy(proxyProvider, proxy, nullptr, key);
- if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
+ if (satisfiesMipMapRequest(view)) {
if (generator->texturesAreCacheable()) {
*fUniqueKeyInvalidatedMessages.append() =
new GrUniqueKeyInvalidatedMessage(key, ctx->priv().contextID());
@@ -486,7 +491,8 @@
// 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping
// the texture we fall through here and have the CPU generate the mip maps for us.
- if (!view.proxy() && !willBeMipped && !ctx->priv().options().fDisableGpuYUVConversion) {
+ if (!view.proxy() && mipMapped == GrMipMapped::kNo &&
+ !ctx->priv().options().fDisableGpuYUVConversion) {
SkColorType colorType = this->colorType();
ScopedGenerator generator(fSharedGenerator);
@@ -520,10 +526,9 @@
SkBitmap bitmap;
if (!view.proxy() && this->getROPixels(&bitmap, chint)) {
GrBitmapTextureMaker bitmapMaker(ctx, bitmap);
- std::tie(view, std::ignore) =
- bitmapMaker.view(willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo);
+ view = bitmapMaker.view(mipMapped);
GrTextureProxy* proxy = view.asTextureProxy();
- if (proxy && (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped())) {
+ if (proxy && satisfiesMipMapRequest(view)) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath,
kLockTexturePathCount);
SkASSERT(proxy);
@@ -534,32 +539,32 @@
}
}
- if (view.proxy()) {
- // We need a mipped proxy, but we either found a proxy earlier that wasn't mipped, generated
- // a native non mipped proxy, or generated a non-mipped yuv proxy. Thus we generate a new
- // mipped surface and copy the original proxy into the base layer. We will then let the gpu
- // generate the rest of the mips.
- SkASSERT(willBeMipped);
- SkASSERT(GrMipMapped::kNo == view.asTextureProxy()->mipMapped());
- *fUniqueKeyInvalidatedMessages.append() =
- new GrUniqueKeyInvalidatedMessage(key, ctx->priv().contextID());
- GrColorType srcColorType = SkColorTypeToGrColorType(this->colorType());
- GrSurfaceProxyView mippedView = GrCopyBaseMipMapToTextureProxy(
- ctx, view.proxy(), kTopLeft_GrSurfaceOrigin, srcColorType);
- auto mippedProxy = mippedView.asTextureProxy();
- if (mippedProxy) {
- set_key_on_proxy(proxyProvider, mippedProxy, view.asTextureProxy(), key);
- return mippedView;
- }
- // We failed to make a mipped proxy with the base copied into it. This could have
- // been from failure to make the proxy or failure to do the copy. Thus we will fall
- // back to just using the non mipped proxy; See skbug.com/7094.
- return view;
+ if (!view) {
+ SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
+ kLockTexturePathCount);
+ return {};
}
- SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
- kLockTexturePathCount);
- return {};
+ // We need a mipped proxy, but we either found a proxy earlier that wasn't mipped, generated
+ // a native non mipped proxy, or generated a non-mipped yuv proxy. Thus we generate a new
+ // mipped surface and copy the original proxy into the base layer. We will then let the gpu
+ // generate the rest of the mips.
+ SkASSERT(mipMapped == GrMipMapped::kYes);
+ SkASSERT(view.asTextureProxy()->mipMapped() == GrMipMapped::kNo);
+ *fUniqueKeyInvalidatedMessages.append() =
+ new GrUniqueKeyInvalidatedMessage(key, ctx->priv().contextID());
+ GrColorType srcColorType = SkColorTypeToGrColorType(this->colorType());
+ GrSurfaceProxyView mippedView = GrCopyBaseMipMapToTextureProxy(
+ ctx, view.proxy(), kTopLeft_GrSurfaceOrigin, srcColorType);
+ auto mippedProxy = mippedView.asTextureProxy();
+ if (mippedProxy) {
+ set_key_on_proxy(proxyProvider, mippedProxy, view.asTextureProxy(), key);
+ return mippedView;
+ }
+ // We failed to make a mipped proxy with the base copied into it. This could have
+ // been from failure to make the proxy or failure to do the copy. Thus we will fall
+ // back to just using the non mipped proxy; See skbug.com/7094.
+ return view;
}
GrColorType SkImage_Lazy::colorTypeOfLockTextureProxy(const GrCaps* caps) const {
diff --git a/src/image/SkImage_Lazy.h b/src/image/SkImage_Lazy.h
index 01e5466..08e0410 100644
--- a/src/image/SkImage_Lazy.h
+++ b/src/image/SkImage_Lazy.h
@@ -42,7 +42,7 @@
bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY,
CachingHint) const override;
#if SK_SUPPORT_GPU
- GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState) const override;
+ GrSurfaceProxyView refView(GrRecordingContext*, GrMipMapped) const override;
sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4],
SkYUVColorSpace*, const void* planes[4]) override;
#endif
@@ -58,12 +58,11 @@
#if SK_SUPPORT_GPU
// Returns the texture proxy. If we're going to generate and cache the texture, we should use
- // the passed in key (if the key is valid). If genType is AllowedTexGenType::kCheap and the
- // texture is not trivial to construct, returns nullptr.
+ // the passed in key (if the key is valid).
GrSurfaceProxyView lockTextureProxyView(GrRecordingContext*,
const GrUniqueKey& key,
SkImage::CachingHint,
- bool willBeMipped) const;
+ GrMipMapped) const;
// Returns the GrColorType to use with the GrTextureProxy returned from lockTextureProxy. This
// may be different from the color type on the image in the case where we need up upload CPU
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index e1e8b4c..bec8e0b 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -85,7 +85,7 @@
const SkBitmap* onPeekBitmap() const override { return &fBitmap; }
#if SK_SUPPORT_GPU
- GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState) const override;
+ GrSurfaceProxyView refView(GrRecordingContext*, GrMipMapped) const override;
#endif
bool getROPixels(SkBitmap*, CachingHint) const override;
@@ -174,7 +174,7 @@
#if SK_SUPPORT_GPU
GrSurfaceProxyView SkImage_Raster::refView(GrRecordingContext* context,
- GrSamplerState params) const {
+ GrMipMapped mipMapped) const {
if (!context) {
return {};
}
@@ -183,10 +183,10 @@
if (GrSurfaceProxyView view = this->refPinnedView(context, &uniqueID)) {
GrTextureAdjuster adjuster(context, std::move(view), fBitmap.info().colorInfo(),
fPinnedUniqueID);
- return adjuster.viewForParams(params);
+ return adjuster.view(mipMapped);
}
- return GrRefCachedBitmapView(context, fBitmap, params);
+ return GrRefCachedBitmapView(context, fBitmap, mipMapped);
}
#endif
@@ -209,7 +209,7 @@
} else {
SkASSERT(fPinnedCount == 0);
SkASSERT(fPinnedUniqueID == 0);
- fPinnedView = GrRefCachedBitmapView(ctx, fBitmap, GrSamplerState::Filter::kNearest);
+ fPinnedView = GrRefCachedBitmapView(ctx, fBitmap, GrMipMapped::kNo);
if (!fPinnedView) {
return false;
}
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 9c31223..3b2e520 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -201,8 +201,8 @@
return nullptr;
}
- GrSamplerState::WrapMode wm[] = {tile_mode_to_wrap_mode(fTileModeX),
- tile_mode_to_wrap_mode(fTileModeY)};
+ GrSamplerState::WrapMode wmX = tile_mode_to_wrap_mode(fTileModeX),
+ wmY = tile_mode_to_wrap_mode(fTileModeY);
// Must set wrap and filter on the sampler before requesting a texture. In two places below
// we check the matrix scale factors to determine how to interpret the filter quality setting.
@@ -212,8 +212,11 @@
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
fImage->width(), fImage->height(), args.fFilterQuality, *args.fViewMatrix, *lm,
args.fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
- GrSamplerState samplerState(wm, textureFilterMode);
- GrSurfaceProxyView view = as_IB(fImage)->refView(args.fContext, samplerState);
+ GrMipMapped mipMapped = GrMipMapped::kNo;
+ if (textureFilterMode == GrSamplerState::Filter::kMipMap) {
+ mipMapped = GrMipMapped::kYes;
+ }
+ GrSurfaceProxyView view = as_IB(fImage)->refView(args.fContext, mipMapped);
if (!view) {
return nullptr;
}
@@ -225,9 +228,10 @@
std::unique_ptr<GrFragmentProcessor> inner;
if (doBicubic) {
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
- inner = GrBicubicEffect::Make(std::move(view), srcAlphaType, lmInverse, wm[0], wm[1], kDir,
+ inner = GrBicubicEffect::Make(std::move(view), srcAlphaType, lmInverse, wmX, wmY, kDir,
caps);
} else {
+ GrSamplerState samplerState(wmX, wmY, textureFilterMode);
inner = GrTextureEffect::Make(std::move(view), srcAlphaType, lmInverse, samplerState, caps);
}
inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(), srcAlphaType,
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index 1005d7b..ff71aa7 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -112,11 +112,11 @@
return;
}
- for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
- for (auto willUseMips : {false, true}) {
+ for (auto betMipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
+ for (auto requestMipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
GrBackendTexture backendTex = context->createBackendTexture(
- kSize, kSize, kRGBA_8888_SkColorType,
- SkColors::kTransparent, mipMapped, GrRenderable::kNo, GrProtected::kNo);
+ kSize, kSize, kRGBA_8888_SkColorType, SkColors::kTransparent, betMipMapped,
+ GrRenderable::kNo, GrProtected::kNo);
sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex,
kTopLeft_GrSurfaceOrigin,
@@ -152,8 +152,8 @@
SkIPoint origin = SkIPoint::Make(0,0);
SkImageInfo imageInfo = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- GrSurfaceProxyView genView = imageGen->generateTexture(context, imageInfo, origin,
- willUseMips);
+ GrSurfaceProxyView genView =
+ imageGen->generateTexture(context, imageInfo, origin, requestMipMapped);
GrSurfaceProxy* genProxy = genView.proxy();
REPORTER_ASSERT(reporter, genProxy);
@@ -188,7 +188,7 @@
GrGLTextureInfo origTexInfo;
if (genBackendTex.getGLTextureInfo(&genTexInfo) &&
backendTex.getGLTextureInfo(&origTexInfo)) {
- if (willUseMips && GrMipMapped::kNo == mipMapped) {
+ if (requestMipMapped == GrMipMapped::kYes && betMipMapped == GrMipMapped::kNo) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origTexInfo.fID != genTexInfo.fID);
} else {
@@ -203,7 +203,7 @@
GrVkImageInfo origImageInfo;
if (genBackendTex.getVkImageInfo(&genImageInfo) &&
backendTex.getVkImageInfo(&origImageInfo)) {
- if (willUseMips && GrMipMapped::kNo == mipMapped) {
+ if (requestMipMapped == GrMipMapped::kYes && betMipMapped == GrMipMapped::kNo) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origImageInfo.fImage != genImageInfo.fImage);
} else {
@@ -219,7 +219,7 @@
GrMtlTextureInfo origImageInfo;
if (genBackendTex.getMtlTextureInfo(&genImageInfo) &&
backendTex.getMtlTextureInfo(&origImageInfo)) {
- if (willUseMips && GrMipMapped::kNo == mipMapped) {
+ if (requestMipMapped == GrMipMapped::kYes && betMipMapped == GrMipMapped::kNo) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origImageInfo.fTexture != genImageInfo.fTexture);
} else {
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 65288c4..b14a04b 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -407,7 +407,7 @@
copySrcBitmap.setImmutable();
GrBitmapTextureMaker maker(context, copySrcBitmap);
- auto[copySrc, grCT] = maker.view(GrMipMapped::kNo);
+ auto copySrc = maker.view(GrMipMapped::kNo);
REPORTER_ASSERT(reporter, copySrc.proxy());
auto copyResult = surfContext->testCopy(copySrc.proxy(), copySrc.origin());
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index 5033e25..cdd2b9b 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -210,8 +210,7 @@
static GrSurfaceProxyView create_proxy_view(GrRecordingContext* context) {
SkBitmap srcBM = create_bm();
GrBitmapTextureMaker maker(context, srcBM);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
- return view;
+ return maker.view(GrMipMapped::kNo);
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 1a1969a..f2bfdad 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -970,19 +970,17 @@
sk_sp<SkImage> refImg(imageMaker(ctx));
// Any context should be able to borrow the texture at this point
- GrSurfaceProxyView view = as_IB(refImg)->refView(ctx, GrSamplerState::Filter::kNearest);
+ GrSurfaceProxyView view = as_IB(refImg)->refView(ctx, GrMipMapped::kNo);
REPORTER_ASSERT(reporter, view);
// But once it's borrowed, no other context should be able to borrow
otherTestContext->makeCurrent();
- GrSurfaceProxyView otherView =
- as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest);
+ GrSurfaceProxyView otherView = as_IB(refImg)->refView(otherCtx, GrMipMapped::kNo);
REPORTER_ASSERT(reporter, !otherView);
// Original context (that's already borrowing) should be okay
testContext->makeCurrent();
- GrSurfaceProxyView viewSecondRef =
- as_IB(refImg)->refView(ctx, GrSamplerState::Filter::kNearest);
+ GrSurfaceProxyView viewSecondRef = as_IB(refImg)->refView(ctx, GrMipMapped::kNo);
REPORTER_ASSERT(reporter, viewSecondRef);
// Release first ref from the original context
@@ -991,7 +989,7 @@
// 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();
- otherView = as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest);
+ otherView = as_IB(refImg)->refView(otherCtx, GrMipMapped::kNo);
REPORTER_ASSERT(reporter, !otherView);
// Release second ref from the original context
@@ -1000,7 +998,7 @@
// Now we should be able to borrow the texture from the other context
otherTestContext->makeCurrent();
- otherView = as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest);
+ otherView = as_IB(refImg)->refView(otherCtx, GrMipMapped::kNo);
REPORTER_ASSERT(reporter, otherView);
// Release everything
@@ -1041,7 +1039,7 @@
sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false);
REPORTER_ASSERT(reporter, image);
- GrSurfaceProxyView view = as_IB(image)->refView(ctx, GrSamplerState::Filter::kNearest);
+ GrSurfaceProxyView view = as_IB(image)->refView(ctx, GrMipMapped::kNo);
REPORTER_ASSERT(reporter, view);
bool expectAlpha = kAlpha_8_SkColorType == ct;
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index c89a750..bee6739 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -281,7 +281,7 @@
[](void* addr, void* context) { delete[] (GrColor*)addr; }, nullptr);
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
if (!view.proxy() || !view.proxy()->instantiate(resourceProvider)) {
return false;
}
@@ -304,7 +304,7 @@
[](void* addr, void* context) { delete[] (uint8_t*)addr; }, nullptr);
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
if (!view.proxy() || !view.proxy()->instantiate(resourceProvider)) {
return false;
}
@@ -331,8 +331,7 @@
[](void* addr, void* context) { delete[] (GrColor*)addr; }, nullptr);
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
- return view;
+ return maker.view(GrMipMapped::kNo);
}
// We tag logged data as unpremul to avoid conversion when encoding as PNG. The input texture
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 6435742..b4ddf88 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -67,14 +67,14 @@
bitmap.installPixels(ii, alphaDataCopy, ii.minRowBytes());
bitmap.setImmutable();
GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
if (!view.proxy()) {
ERRORF(reporter, "Could not create alpha texture.");
return;
}
- auto sContext = GrSurfaceContext::Make(context, std::move(view), grCT, kPremul_SkAlphaType,
- nullptr);
+ auto sContext = GrSurfaceContext::Make(context, std::move(view), maker.colorType(),
+ kPremul_SkAlphaType, nullptr);
sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii));
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 026d0fd..74523e7 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -224,18 +224,18 @@
{
// gpu
GrBitmapTextureMaker maker(context, bm);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
- if (!view.proxy()) {
+ auto view = maker.view(GrMipMapped::kNo);
+ if (!view) {
return;
}
- sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeDeferredFromGpu(
- context,
- SkIRect::MakeWH(kFullSize, kFullSize),
- kNeedNewImageUniqueID_SpecialImage,
- std::move(view),
- grCT,
- nullptr));
+ sk_sp<SkSpecialImage> gpuImage(
+ SkSpecialImage::MakeDeferredFromGpu(context,
+ SkIRect::MakeWH(kFullSize, kFullSize),
+ kNeedNewImageUniqueID_SpecialImage,
+ std::move(view),
+ maker.colorType(),
+ nullptr));
{
sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context));
@@ -255,28 +255,29 @@
GrContext* context = ctxInfo.grContext();
SkBitmap bm = create_bm();
GrBitmapTextureMaker maker(context, bm);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ auto view = maker.view(GrMipMapped::kNo);
if (!view.proxy()) {
return;
}
- sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeDeferredFromGpu(
- context,
- SkIRect::MakeWH(kFullSize, kFullSize),
- kNeedNewImageUniqueID_SpecialImage,
- view,
- grCT,
- nullptr));
+ sk_sp<SkSpecialImage> fullSImg(
+ SkSpecialImage::MakeDeferredFromGpu(context,
+ SkIRect::MakeWH(kFullSize, kFullSize),
+ kNeedNewImageUniqueID_SpecialImage,
+ view,
+ maker.colorType(),
+ nullptr));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu(
- context, subset,
- kNeedNewImageUniqueID_SpecialImage,
- std::move(view),
- grCT,
- nullptr));
+ context,
+ subset,
+ kNeedNewImageUniqueID_SpecialImage,
+ std::move(view),
+ maker.colorType(),
+ nullptr));
test_image(subSImg1, reporter, context, true);
}