Reland x3 "Drawing YUVA images does not flatten for bicubic."
Fixes:
Workaround GL_ALPHA texture issue in GM.
Don't crash in GM on null image.
Snap both coords in 1D bicubic (restores old behavior).
This reverts commit 97c98f95962aa6d053bbbd69b97944ea158acb35.
Change-Id: I14bf0f8c6acf87cac0a13b9166fac73a2f3520b0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278862
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp
index 5a4f7e7..71c2d26 100644
--- a/src/gpu/GrImageTextureMaker.cpp
+++ b/src/gpu/GrImageTextureMaker.cpp
@@ -11,6 +11,7 @@
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SkGr.h"
+#include "src/gpu/effects/GrBicubicEffect.h"
#include "src/gpu/effects/GrYUVtoRGBEffect.h"
#include "src/image/SkImage_GpuYUVA.h"
#include "src/image/SkImage_Lazy.h"
@@ -65,17 +66,18 @@
GrSamplerState::WrapMode wrapX,
GrSamplerState::WrapMode wrapY,
const GrSamplerState::Filter* filterOrNullForBicubic) {
- // Check simple cases to see if we need to fall back to flattening the image (or whether it's
- // already been flattened.)
- if (!filterOrNullForBicubic || fImage->fRGBView.proxy()) {
+ // Check whether it's already been flattened.
+ if (fImage->fRGBView.proxy()) {
return this->INHERITED::createFragmentProcessor(
textureMatrix, constraintRect, filterConstraint, coordsLimitedToConstraintRect,
wrapX, wrapY, filterOrNullForBicubic);
}
+ GrSamplerState::Filter filter =
+ filterOrNullForBicubic ? *filterOrNullForBicubic : GrSamplerState::Filter::kNearest;
+
// Check to see if the client has given us pre-mipped textures or we can generate them
// If not, fall back to bilerp. Also fall back to bilerp when a domain is requested
- GrSamplerState::Filter filter = *filterOrNullForBicubic;
if (GrSamplerState::Filter::kMipMap == filter &&
(filterConstraint == GrTextureProducer::kYes_FilterConstraint ||
!fImage->setupMipmapsForPlanes(this->context()))) {
@@ -91,8 +93,13 @@
}
const auto& caps = *fImage->context()->priv().caps();
+ const SkMatrix& m = filterOrNullForBicubic ? textureMatrix : SkMatrix::I();
auto fp = GrYUVtoRGBEffect::Make(fImage->fViews, fImage->fYUVAIndices, fImage->fYUVColorSpace,
- filter, caps, textureMatrix, domain);
+ filter, caps, m, domain);
+ if (!filterOrNullForBicubic) {
+ fp = GrBicubicEffect::Make(std::move(fp), fImage->alphaType(), textureMatrix,
+ GrBicubicEffect::Direction::kXY);
+ }
if (fImage->fFromColorSpace) {
fp = GrColorSpaceXformEffect::Make(std::move(fp), fImage->fFromColorSpace.get(),
fImage->alphaType(), fImage->colorSpace());