Separate MIP filtering from min/mag filtering.
Does not add kNearest as a mip map mode yet.
Bug: skia:10344
Change-Id: Ida80cbf19e2b1eed5209d0680837fb45e54b4261
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303481
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/tests/BulkRectTest.cpp b/tests/BulkRectTest.cpp
index 776625c..e3cc413 100644
--- a/tests/BulkRectTest.cpp
+++ b/tests/BulkRectTest.cpp
@@ -110,14 +110,20 @@
set[i].fAAFlags = perQuadAA(i);
}
- GrTextureOp::AddTextureSetOps(rtc.get(), nullptr, dContext, set, requestedTotNumQuads,
- requestedTotNumQuads, // We alternate so proxyCnt == cnt
+ GrTextureOp::AddTextureSetOps(rtc.get(),
+ nullptr,
+ dContext,
+ set,
+ requestedTotNumQuads,
+ requestedTotNumQuads, // We alternate so proxyCnt == cnt
GrSamplerState::Filter::kNearest,
+ GrSamplerState::MipmapMode::kNone,
GrTextureOp::Saturate::kYes,
blendMode,
overallAA,
SkCanvas::kStrict_SrcRectConstraint,
- SkMatrix::I(), nullptr);
+ SkMatrix::I(),
+ nullptr);
GrOpsTask* opsTask = rtc->testingOnly_PeekLastOpsTask();
int actualNumOps = opsTask->numOpChains();
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index a83fdaa..a327f68 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -349,19 +349,42 @@
// Create a new render target and draw 'mipmapView' into it using the provided 'filter'.
static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target(
- GrRecordingContext* context, GrProxyProvider* proxyProvider, GrColorType colorType,
- SkAlphaType alphaType, GrSurfaceProxyView mipmapView, GrSamplerState::Filter filter) {
- sk_sp<GrSurfaceProxy> renderTarget = proxyProvider->createProxy(
- mipmapView.proxy()->backendFormat(), {1, 1}, GrRenderable::kYes, 1, GrMipmapped::kNo,
- SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
+ GrRecordingContext* context,
+ GrProxyProvider* proxyProvider,
+ GrColorType colorType,
+ SkAlphaType alphaType,
+ GrSurfaceProxyView mipmapView,
+ GrSamplerState::MipmapMode mm) {
+ sk_sp<GrSurfaceProxy> renderTarget =
+ proxyProvider->createProxy(mipmapView.proxy()->backendFormat(),
+ {1, 1},
+ GrRenderable::kYes,
+ 1,
+ GrMipmapped::kNo,
+ SkBackingFit::kApprox,
+ SkBudgeted::kYes,
+ GrProtected::kNo);
- auto rtc = GrRenderTargetContext::Make(
- context, colorType, nullptr, std::move(renderTarget), kTopLeft_GrSurfaceOrigin,
- nullptr);
+ auto rtc = GrRenderTargetContext::Make(context,
+ colorType,
+ nullptr,
+ std::move(renderTarget),
+ kTopLeft_GrSurfaceOrigin,
+ nullptr);
- rtc->drawTexture(nullptr, std::move(mipmapView), alphaType, filter, SkBlendMode::kSrcOver,
- {1,1,1,1}, SkRect::MakeWH(4, 4), SkRect::MakeWH(1,1), GrAA::kYes,
- GrQuadAAFlags::kAll, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(),
+ rtc->drawTexture(nullptr,
+ std::move(mipmapView),
+ alphaType,
+ GrSamplerState::Filter::kLinear,
+ mm,
+ SkBlendMode::kSrcOver,
+ {1, 1, 1, 1},
+ SkRect::MakeWH(4, 4),
+ SkRect::MakeWH(1, 1),
+ GrAA::kYes,
+ GrQuadAAFlags::kAll,
+ SkCanvas::kFast_SrcRectConstraint,
+ SkMatrix::I(),
nullptr);
return rtc;
}
@@ -369,7 +392,7 @@
// Test that two opsTasks using the same mipmaps both depend on the same GrTextureResolveRenderTask.
DEF_GPUTEST(GrManyDependentsMipMappedTest, reporter, /* options */) {
using Enable = GrContextOptions::Enable;
- using Filter = GrSamplerState::Filter;
+ using MipmapMode = GrSamplerState::MipmapMode;
for (auto enableSortingAndReduction : {Enable::kYes, Enable::kNo}) {
GrMockOptions mockOptions;
@@ -421,7 +444,7 @@
// Draw the dirty mipmap texture into a render target.
auto rtc1 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
- alphaType, mipmapView, Filter::kMipMap);
+ alphaType, mipmapView, MipmapMode::kLinear);
auto rtc1Task = sk_ref_sp(rtc1->testingOnly_PeekLastOpsTask());
// Mipmaps should have gotten marked dirty during makeClosed, then marked clean again as
@@ -436,7 +459,7 @@
// Draw the now-clean mipmap texture into a second target.
auto rtc2 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
- alphaType, mipmapView, Filter::kMipMap);
+ alphaType, mipmapView, MipmapMode::kLinear);
auto rtc2Task = sk_ref_sp(rtc2->testingOnly_PeekLastOpsTask());
// Make sure the mipmap texture still has the same regen task.
@@ -465,7 +488,7 @@
// Draw the dirty mipmap texture into a render target, but don't do mipmap filtering.
rtc1 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
- alphaType, mipmapView, Filter::kLinear);
+ alphaType, mipmapView, MipmapMode::kNone);
// Mipmaps should have gotten marked dirty during makeClosed() when adding the dependency.
// Since the last draw did not use mips, they will not have been regenerated and should
@@ -479,7 +502,7 @@
// Draw the stil-dirty mipmap texture into a second target with mipmap filtering.
rtc2 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
alphaType, std::move(mipmapView),
- Filter::kMipMap);
+ MipmapMode::kLinear);
rtc2Task = sk_ref_sp(rtc2->testingOnly_PeekLastOpsTask());
// Make sure the mipmap texture now has a new last render task that regenerates the mips,
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 08f5697..0dedcc6 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -575,11 +575,20 @@
GrSwizzle readSwizzle = dContext->priv().caps()->getReadSwizzle(
backendFormat, GrColorType::kRGBA_8888);
GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin, readSwizzle);
- rtc->drawTexture(nullptr, view, kPremul_SkAlphaType,
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
- SkPMColor4f(), SkRect::MakeWH(w, h), SkRect::MakeWH(w, h),
- GrAA::kNo, GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
- SkMatrix::I(), nullptr);
+ rtc->drawTexture(nullptr,
+ view,
+ kPremul_SkAlphaType,
+ GrSamplerState::Filter::kNearest,
+ GrSamplerState::MipmapMode::kNone,
+ SkBlendMode::kSrcOver,
+ SkPMColor4f(),
+ SkRect::MakeWH(w, h),
+ SkRect::MakeWH(w, h),
+ GrAA::kNo,
+ GrQuadAAFlags::kNone,
+ SkCanvas::kFast_SrcRectConstraint,
+ SkMatrix::I(),
+ nullptr);
// We still have the proxy, which should remain instantiated, thereby keeping the
// texture not purgeable.
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
@@ -589,11 +598,20 @@
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
// This time we move the proxy into the draw.
- rtc->drawTexture(nullptr, std::move(view), kPremul_SkAlphaType,
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
- SkPMColor4f(), SkRect::MakeWH(w, h), SkRect::MakeWH(w, h),
- GrAA::kNo, GrQuadAAFlags::kNone,
- SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
+ rtc->drawTexture(nullptr,
+ std::move(view),
+ kPremul_SkAlphaType,
+ GrSamplerState::Filter::kNearest,
+ GrSamplerState::MipmapMode::kNone,
+ SkBlendMode::kSrcOver,
+ SkPMColor4f(),
+ SkRect::MakeWH(w, h),
+ SkRect::MakeWH(w, h),
+ GrAA::kNo,
+ GrQuadAAFlags::kNone,
+ SkCanvas::kFast_SrcRectConstraint,
+ SkMatrix::I(),
+ nullptr);
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
dContext->flushAndSubmit();
dContext->priv().getGpu()->testingOnly_flushGpuAndSync();
@@ -640,12 +658,20 @@
proxy->backendFormat(), GrColorType::kRGBA_8888);
GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin,
swizzle);
- rtc->drawTexture(
- nullptr, std::move(view), kPremul_SkAlphaType,
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
- SkPMColor4f(), SkRect::MakeWH(w, h), SkRect::MakeWH(w, h),
- GrAA::kNo, GrQuadAAFlags::kNone,
- SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
+ rtc->drawTexture(nullptr,
+ std::move(view),
+ kPremul_SkAlphaType,
+ GrSamplerState::Filter::kNearest,
+ GrSamplerState::MipmapMode::kNone,
+ SkBlendMode::kSrcOver,
+ SkPMColor4f(),
+ SkRect::MakeWH(w, h),
+ SkRect::MakeWH(w, h),
+ GrAA::kNo,
+ GrQuadAAFlags::kNone,
+ SkCanvas::kFast_SrcRectConstraint,
+ SkMatrix::I(),
+ nullptr);
if (drawType == DrawType::kDrawAndFlush) {
dContext->flushAndSubmit();
}
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 6798b81..6510573 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -28,17 +28,17 @@
SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
auto rtContext = GrRenderTargetContext::Make(
context, colorType, nullptr, SkBackingFit::kExact, rectView.proxy()->dimensions());
- for (auto filter : {GrSamplerState::Filter::kNearest,
- GrSamplerState::Filter::kLinear,
- GrSamplerState::Filter::kMipMap}) {
- rtContext->clear(SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA));
- auto fp = GrTextureEffect::Make(rectView, alphaType, SkMatrix::I(), filter);
- GrPaint paint;
- paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- paint.setColorFragmentProcessor(std::move(fp));
- rtContext->drawPaint(nullptr, std::move(paint), SkMatrix::I());
- TestReadPixels(reporter, rtContext.get(), expectedPixelValues,
- "RectangleTexture-basic-draw");
+ for (auto filter : {GrSamplerState::Filter::kNearest, GrSamplerState::Filter::kLinear}) {
+ for (auto mm : {GrSamplerState::MipmapMode::kNone, GrSamplerState::MipmapMode::kLinear}) {
+ rtContext->clear(SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA));
+ auto fp = GrTextureEffect::Make(rectView, alphaType, SkMatrix::I(), filter, mm);
+ GrPaint paint;
+ paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
+ paint.setColorFragmentProcessor(std::move(fp));
+ rtContext->drawPaint(nullptr, std::move(paint), SkMatrix::I());
+ TestReadPixels(reporter, rtContext.get(), expectedPixelValues,
+ "RectangleTexture-basic-draw");
+ }
}
}