diff options
Diffstat (limited to 'src/gpu/GrTextureProducer.cpp')
-rw-r--r-- | src/gpu/GrTextureProducer.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp index d9fffbc410..1e9c3acd16 100644 --- a/src/gpu/GrTextureProducer.cpp +++ b/src/gpu/GrTextureProducer.cpp @@ -10,6 +10,7 @@ #include "GrProxyProvider.h" #include "GrRenderTargetContext.h" #include "GrTextureProxy.h" +#include "SkGr.h" #include "SkRectPriv.h" #include "effects/GrBicubicEffect.h" #include "effects/GrSimpleTextureEffect.h" @@ -24,6 +25,24 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context, const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight); GrMipMapped mipMapped = dstWillRequireMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo; + SkRect localRect = SkRect::MakeWH(inputProxy->width(), inputProxy->height()); + + bool needsDomain = false; + bool resizing = false; + if (copyParams.fFilter != GrSamplerState::Filter::kNearest) { + bool resizing = localRect.width() != dstRect.width() || + localRect.height() != dstRect.height(); + needsDomain = resizing && !GrProxyProvider::IsFunctionallyExact(inputProxy.get()); + } + + if (copyParams.fFilter == GrSamplerState::Filter::kNearest && !needsDomain && !resizing && + dstWillRequireMipMaps) { + sk_sp<GrTextureProxy> proxy = GrCopyBaseMipMapToTextureProxy(context, inputProxy.get()); + if (proxy) { + return proxy; + } + } + sk_sp<GrRenderTargetContext> copyRTC = context->contextPriv().makeDeferredRenderTargetContextWithFallback( SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), @@ -33,14 +52,6 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context, } GrPaint paint; - SkRect localRect = SkRect::MakeWH(inputProxy->width(), inputProxy->height()); - - bool needsDomain = false; - if (copyParams.fFilter != GrSamplerState::Filter::kNearest) { - bool resizing = localRect.width() != dstRect.width() || - localRect.height() != dstRect.height(); - needsDomain = resizing && !GrProxyProvider::IsFunctionallyExact(inputProxy.get()); - } if (needsDomain) { const SkRect domain = localRect.makeInset(0.5f, 0.5f); |