1 /*
2 * Copyright 2010 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "src/gpu/SkGr.h"
9
10 #include "include/core/SkCanvas.h"
11 #include "include/core/SkColorFilter.h"
12 #include "include/core/SkData.h"
13 #include "include/core/SkPixelRef.h"
14 #include "include/effects/SkRuntimeEffect.h"
15 #include "include/gpu/GrContext.h"
16 #include "include/gpu/GrTypes.h"
17 #include "include/private/GrRecordingContext.h"
18 #include "include/private/SkImageInfoPriv.h"
19 #include "include/private/SkTemplates.h"
20 #include "src/core/SkAutoMalloc.h"
21 #include "src/core/SkBlendModePriv.h"
22 #include "src/core/SkColorSpacePriv.h"
23 #include "src/core/SkImagePriv.h"
24 #include "src/core/SkMaskFilterBase.h"
25 #include "src/core/SkMessageBus.h"
26 #include "src/core/SkMipMap.h"
27 #include "src/core/SkPaintPriv.h"
28 #include "src/core/SkResourceCache.h"
29 #include "src/core/SkTraceEvent.h"
30 #include "src/gpu/GrBitmapTextureMaker.h"
31 #include "src/gpu/GrCaps.h"
32 #include "src/gpu/GrColorSpaceXform.h"
33 #include "src/gpu/GrContextPriv.h"
34 #include "src/gpu/GrGpuResourcePriv.h"
35 #include "src/gpu/GrPaint.h"
36 #include "src/gpu/GrProxyProvider.h"
37 #include "src/gpu/GrRecordingContextPriv.h"
38 #include "src/gpu/GrTextureProxy.h"
39 #include "src/gpu/GrXferProcessor.h"
40 #include "src/gpu/effects/GrBicubicEffect.h"
41 #include "src/gpu/effects/GrPorterDuffXferProcessor.h"
42 #include "src/gpu/effects/GrSkSLFP.h"
43 #include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
44 #include "src/gpu/effects/generated/GrClampFragmentProcessor.h"
45 #include "src/gpu/effects/generated/GrConstColorProcessor.h"
46 #include "src/image/SkImage_Base.h"
47 #include "src/shaders/SkShaderBase.h"
48
49 GR_FP_SRC_STRING SKSL_DITHER_SRC = R"(
50 // This controls the range of values added to color channels
51 in int rangeType;
52
53 void main(float2 p, inout half4 color) {
54 half value;
55 half range;
56 @switch (rangeType) {
57 case 0:
58 range = 1.0 / 255.0;
59 break;
60 case 1:
61 range = 1.0 / 63.0;
62 break;
63 default:
64 // Experimentally this looks better than the expected value of 1/15.
65 range = 1.0 / 15.0;
66 break;
67 }
68 @if (sk_Caps.integerSupport) {
69 // This ordered-dither code is lifted from the cpu backend.
70 uint x = uint(p.x);
71 uint y = uint(p.y);
72 uint m = (y & 1) << 5 | (x & 1) << 4 |
73 (y & 2) << 2 | (x & 2) << 1 |
74 (y & 4) >> 1 | (x & 4) >> 2;
75 value = half(m) * 1.0 / 64.0 - 63.0 / 128.0;
76 } else {
77 // Simulate the integer effect used above using step/mod. For speed, simulates a 4x4
78 // dither pattern rather than an 8x8 one.
79 half4 modValues = mod(half4(half(p.x), half(p.y), half(p.x), half(p.y)), half4(2.0, 2.0, 4.0, 4.0));
80 half4 stepValues = step(modValues, half4(1.0, 1.0, 2.0, 2.0));
81 value = dot(stepValues, half4(8.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0)) - 15.0 / 32.0;
82 }
83 // For each color channel, add the random offset to the channel value and then clamp
84 // between 0 and alpha to keep the color premultiplied.
85 color = half4(clamp(color.rgb + value * range, 0.0, color.a), color.a);
86 }
87 )";
88
GrMakeKeyFromImageID(GrUniqueKey * key,uint32_t imageID,const SkIRect & imageBounds)89 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& imageBounds) {
90 SkASSERT(key);
91 SkASSERT(imageID);
92 SkASSERT(!imageBounds.isEmpty());
93 static const GrUniqueKey::Domain kImageIDDomain = GrUniqueKey::GenerateDomain();
94 GrUniqueKey::Builder builder(key, kImageIDDomain, 5, "Image");
95 builder[0] = imageID;
96 builder[1] = imageBounds.fLeft;
97 builder[2] = imageBounds.fTop;
98 builder[3] = imageBounds.fRight;
99 builder[4] = imageBounds.fBottom;
100 }
101
102 ////////////////////////////////////////////////////////////////////////////////
103
GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey & key,uint32_t contextUniqueID,SkPixelRef * pixelRef)104 void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, uint32_t contextUniqueID,
105 SkPixelRef* pixelRef) {
106 class Invalidator : public SkPixelRef::GenIDChangeListener {
107 public:
108 explicit Invalidator(const GrUniqueKey& key, uint32_t contextUniqueID)
109 : fMsg(key, contextUniqueID) {}
110
111 private:
112 GrUniqueKeyInvalidatedMessage fMsg;
113
114 void onChange() override { SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(fMsg); }
115 };
116
117 pixelRef->addGenIDChangeListener(new Invalidator(key, contextUniqueID));
118 }
119
GrCopyBaseMipMapToTextureProxy(GrRecordingContext * ctx,GrSurfaceProxy * baseProxy,GrSurfaceOrigin origin,GrColorType srcColorType)120 GrSurfaceProxyView GrCopyBaseMipMapToTextureProxy(GrRecordingContext* ctx,
121 GrSurfaceProxy* baseProxy,
122 GrSurfaceOrigin origin,
123 GrColorType srcColorType) {
124 SkASSERT(baseProxy);
125
126 if (!ctx->priv().caps()->isFormatCopyable(baseProxy->backendFormat())) {
127 return {};
128 }
129 GrSurfaceProxyView view = GrSurfaceProxy::Copy(ctx, baseProxy, origin, srcColorType,
130 GrMipMapped::kYes, SkBackingFit::kExact,
131 SkBudgeted::kYes);
132 SkASSERT(!view.proxy() || view.asTextureProxy());
133 return view;
134 }
135
GrRefCachedBitmapView(GrRecordingContext * ctx,const SkBitmap & bitmap,GrSamplerState params,SkScalar scaleAdjust[2])136 GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext* ctx, const SkBitmap& bitmap,
137 GrSamplerState params, SkScalar scaleAdjust[2]) {
138 GrBitmapTextureMaker maker(ctx, bitmap, GrBitmapTextureMaker::Cached::kYes);
139 return maker.viewForParams(params, scaleAdjust);
140 }
141
GrMakeCachedBitmapProxyView(GrRecordingContext * context,const SkBitmap & bitmap,SkBackingFit fit)142 GrSurfaceProxyView GrMakeCachedBitmapProxyView(GrRecordingContext* context, const SkBitmap& bitmap,
143 SkBackingFit fit) {
144 if (!bitmap.peekPixels(nullptr)) {
145 return {};
146 }
147
148 GrBitmapTextureMaker maker(context, bitmap, GrBitmapTextureMaker::Cached::kYes, fit);
149 auto[view, grCT] = maker.view(GrMipMapped::kNo);
150 return view;
151 }
152
153 ///////////////////////////////////////////////////////////////////////////////
154
SkColorToPMColor4f(SkColor c,const GrColorInfo & colorInfo)155 SkPMColor4f SkColorToPMColor4f(SkColor c, const GrColorInfo& colorInfo) {
156 SkColor4f color = SkColor4f::FromColor(c);
157 if (auto* xform = colorInfo.colorSpaceXformFromSRGB()) {
158 color = xform->apply(color);
159 }
160 return color.premul();
161 }
162
SkColor4fPrepForDst(SkColor4f color,const GrColorInfo & colorInfo)163 SkColor4f SkColor4fPrepForDst(SkColor4f color, const GrColorInfo& colorInfo) {
164 if (auto* xform = colorInfo.colorSpaceXformFromSRGB()) {
165 color = xform->apply(color);
166 }
167 return color;
168 }
169
170 ///////////////////////////////////////////////////////////////////////////////
171
blend_requires_shader(const SkBlendMode mode)172 static inline bool blend_requires_shader(const SkBlendMode mode) {
173 return SkBlendMode::kDst != mode;
174 }
175
176 #ifndef SK_IGNORE_GPU_DITHER
dither_range_type_for_config(GrColorType dstColorType)177 static inline int32_t dither_range_type_for_config(GrColorType dstColorType) {
178 switch (dstColorType) {
179 case GrColorType::kUnknown:
180 case GrColorType::kGray_8:
181 case GrColorType::kRGBA_8888:
182 case GrColorType::kRGB_888x:
183 case GrColorType::kRG_88:
184 case GrColorType::kBGRA_8888:
185 case GrColorType::kRG_1616:
186 case GrColorType::kRGBA_16161616:
187 case GrColorType::kRG_F16:
188 case GrColorType::kRGBA_8888_SRGB:
189 case GrColorType::kRGBA_1010102:
190 case GrColorType::kAlpha_F16:
191 case GrColorType::kRGBA_F32:
192 case GrColorType::kRGBA_F16:
193 case GrColorType::kRGBA_F16_Clamped:
194 case GrColorType::kAlpha_8:
195 case GrColorType::kAlpha_8xxx:
196 case GrColorType::kAlpha_16:
197 case GrColorType::kAlpha_F32xxx:
198 case GrColorType::kGray_8xxx:
199 case GrColorType::kRGB_888:
200 case GrColorType::kR_8:
201 case GrColorType::kR_16:
202 case GrColorType::kR_F16:
203 case GrColorType::kGray_F16:
204 return 0;
205 case GrColorType::kBGR_565:
206 return 1;
207 case GrColorType::kABGR_4444:
208 return 2;
209 }
210 SkUNREACHABLE;
211 }
212 #endif
213
skpaint_to_grpaint_impl(GrRecordingContext * context,const GrColorInfo & dstColorInfo,const SkPaint & skPaint,const SkMatrix & viewM,std::unique_ptr<GrFragmentProcessor> * shaderProcessor,SkBlendMode * primColorMode,GrPaint * grPaint)214 static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
215 const GrColorInfo& dstColorInfo,
216 const SkPaint& skPaint,
217 const SkMatrix& viewM,
218 std::unique_ptr<GrFragmentProcessor>* shaderProcessor,
219 SkBlendMode* primColorMode,
220 GrPaint* grPaint) {
221 // Convert SkPaint color to 4f format in the destination color space
222 SkColor4f origColor = SkColor4fPrepForDst(skPaint.getColor4f(), dstColorInfo);
223
224 GrFPArgs fpArgs(context, &viewM, skPaint.getFilterQuality(), &dstColorInfo);
225
226 // Setup the initial color considering the shader, the SkPaint color, and the presence or not
227 // of per-vertex colors.
228 std::unique_ptr<GrFragmentProcessor> shaderFP;
229 if (!primColorMode || blend_requires_shader(*primColorMode)) {
230 fpArgs.fInputColorIsOpaque = origColor.isOpaque();
231 if (shaderProcessor) {
232 shaderFP = std::move(*shaderProcessor);
233 } else if (const auto* shader = as_SB(skPaint.getShader())) {
234 shaderFP = shader->asFragmentProcessor(fpArgs);
235 if (!shaderFP) {
236 return false;
237 }
238 }
239 }
240
241 // Set this in below cases if the output of the shader/paint-color/paint-alpha/primXfermode is
242 // a known constant value. In that case we can simply apply a color filter during this
243 // conversion without converting the color filter to a GrFragmentProcessor.
244 bool applyColorFilterToPaintColor = false;
245 if (shaderFP) {
246 if (primColorMode) {
247 // There is a blend between the primitive color and the shader color. The shader sees
248 // the opaque paint color. The shader's output is blended using the provided mode by
249 // the primitive color. The blended color is then modulated by the paint's alpha.
250
251 // The geometry processor will insert the primitive color to start the color chain, so
252 // the GrPaint color will be ignored.
253
254 SkPMColor4f shaderInput = origColor.makeOpaque().premul();
255 shaderFP = GrFragmentProcessor::OverrideInput(std::move(shaderFP), shaderInput);
256 shaderFP = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(shaderFP),
257 *primColorMode);
258
259 // The above may return null if compose results in a pass through of the prim color.
260 if (shaderFP) {
261 grPaint->addColorFragmentProcessor(std::move(shaderFP));
262 }
263
264 // We can ignore origColor here - alpha is unchanged by gamma
265 float paintAlpha = skPaint.getColor4f().fA;
266 if (1.0f != paintAlpha) {
267 // No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
268 // color channels. It's value should be treated as the same in ANY color space.
269 grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
270 { paintAlpha, paintAlpha, paintAlpha, paintAlpha },
271 GrConstColorProcessor::InputMode::kModulateRGBA));
272 }
273 } else {
274 // The shader's FP sees the paint *unpremul* color
275 SkPMColor4f origColorAsPM = { origColor.fR, origColor.fG, origColor.fB, origColor.fA };
276 grPaint->setColor4f(origColorAsPM);
277 grPaint->addColorFragmentProcessor(std::move(shaderFP));
278 }
279 } else {
280 if (primColorMode) {
281 // There is a blend between the primitive color and the paint color. The blend considers
282 // the opaque paint color. The paint's alpha is applied to the post-blended color.
283 SkPMColor4f opaqueColor = origColor.makeOpaque().premul();
284 auto processor = GrConstColorProcessor::Make(opaqueColor,
285 GrConstColorProcessor::InputMode::kIgnore);
286 processor = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(processor),
287 *primColorMode);
288 if (processor) {
289 grPaint->addColorFragmentProcessor(std::move(processor));
290 }
291
292 grPaint->setColor4f(opaqueColor);
293
294 // We can ignore origColor here - alpha is unchanged by gamma
295 float paintAlpha = skPaint.getColor4f().fA;
296 if (1.0f != paintAlpha) {
297 // No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
298 // color channels. It's value should be treated as the same in ANY color space.
299 grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
300 { paintAlpha, paintAlpha, paintAlpha, paintAlpha },
301 GrConstColorProcessor::InputMode::kModulateRGBA));
302 }
303 } else {
304 // No shader, no primitive color.
305 grPaint->setColor4f(origColor.premul());
306 applyColorFilterToPaintColor = true;
307 }
308 }
309
310 SkColorFilter* colorFilter = skPaint.getColorFilter();
311 if (colorFilter) {
312 if (applyColorFilterToPaintColor) {
313 SkColorSpace* dstCS = dstColorInfo.colorSpace();
314 grPaint->setColor4f(colorFilter->filterColor4f(origColor, dstCS, dstCS).premul());
315 } else {
316 auto cfFP = colorFilter->asFragmentProcessor(context, dstColorInfo);
317 if (cfFP) {
318 grPaint->addColorFragmentProcessor(std::move(cfFP));
319 } else {
320 return false;
321 }
322 }
323 }
324
325 SkMaskFilterBase* maskFilter = as_MFB(skPaint.getMaskFilter());
326 if (maskFilter) {
327 // We may have set this before passing to the SkShader.
328 fpArgs.fInputColorIsOpaque = false;
329 if (auto mfFP = maskFilter->asFragmentProcessor(fpArgs)) {
330 grPaint->addCoverageFragmentProcessor(std::move(mfFP));
331 }
332 }
333
334 // When the xfermode is null on the SkPaint (meaning kSrcOver) we need the XPFactory field on
335 // the GrPaint to also be null (also kSrcOver).
336 SkASSERT(!grPaint->getXPFactory());
337 if (!skPaint.isSrcOver()) {
338 grPaint->setXPFactory(SkBlendMode_AsXPFactory(skPaint.getBlendMode()));
339 }
340
341 #ifndef SK_IGNORE_GPU_DITHER
342 GrColorType ct = dstColorInfo.colorType();
343 if (SkPaintPriv::ShouldDither(skPaint, GrColorTypeToSkColorType(ct)) &&
344 grPaint->numColorFragmentProcessors() > 0) {
345 int32_t ditherRange = dither_range_type_for_config(ct);
346 if (ditherRange >= 0) {
347 static auto effect = std::get<0>(SkRuntimeEffect::Make(SkString(SKSL_DITHER_SRC)));
348 auto ditherFP = GrSkSLFP::Make(context, effect, "Dither",
349 SkData::MakeWithCopy(&ditherRange, sizeof(ditherRange)));
350 if (ditherFP) {
351 grPaint->addColorFragmentProcessor(std::move(ditherFP));
352 }
353 }
354 }
355 #endif
356 if (GrColorTypeClampType(dstColorInfo.colorType()) == GrClampType::kManual) {
357 if (grPaint->numColorFragmentProcessors()) {
358 grPaint->addColorFragmentProcessor(GrClampFragmentProcessor::Make(false));
359 } else {
360 auto color = grPaint->getColor4f();
361 grPaint->setColor4f({SkTPin(color.fR, 0.f, 1.f),
362 SkTPin(color.fG, 0.f, 1.f),
363 SkTPin(color.fB, 0.f, 1.f),
364 SkTPin(color.fA, 0.f, 1.f)});
365 }
366 }
367 return true;
368 }
369
SkPaintToGrPaint(GrRecordingContext * context,const GrColorInfo & dstColorInfo,const SkPaint & skPaint,const SkMatrix & viewM,GrPaint * grPaint)370 bool SkPaintToGrPaint(GrRecordingContext* context, const GrColorInfo& dstColorInfo,
371 const SkPaint& skPaint, const SkMatrix& viewM, GrPaint* grPaint) {
372 return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, viewM, nullptr, nullptr,
373 grPaint);
374 }
375
376 /** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProcessor. */
SkPaintToGrPaintReplaceShader(GrRecordingContext * context,const GrColorInfo & dstColorInfo,const SkPaint & skPaint,std::unique_ptr<GrFragmentProcessor> shaderFP,GrPaint * grPaint)377 bool SkPaintToGrPaintReplaceShader(GrRecordingContext* context,
378 const GrColorInfo& dstColorInfo,
379 const SkPaint& skPaint,
380 std::unique_ptr<GrFragmentProcessor> shaderFP,
381 GrPaint* grPaint) {
382 if (!shaderFP) {
383 return false;
384 }
385 return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, SkMatrix::I(), &shaderFP,
386 nullptr, grPaint);
387 }
388
389 /** Ignores the SkShader (if any) on skPaint. */
SkPaintToGrPaintNoShader(GrRecordingContext * context,const GrColorInfo & dstColorInfo,const SkPaint & skPaint,GrPaint * grPaint)390 bool SkPaintToGrPaintNoShader(GrRecordingContext* context,
391 const GrColorInfo& dstColorInfo,
392 const SkPaint& skPaint,
393 GrPaint* grPaint) {
394 // Use a ptr to a nullptr to to indicate that the SkShader is ignored and not replaced.
395 std::unique_ptr<GrFragmentProcessor> nullShaderFP(nullptr);
396 return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, SkMatrix::I(), &nullShaderFP,
397 nullptr, grPaint);
398 }
399
400 /** Blends the SkPaint's shader (or color if no shader) with a per-primitive color which must
401 be setup as a vertex attribute using the specified SkBlendMode. */
SkPaintToGrPaintWithXfermode(GrRecordingContext * context,const GrColorInfo & dstColorInfo,const SkPaint & skPaint,const SkMatrix & viewM,SkBlendMode primColorMode,GrPaint * grPaint)402 bool SkPaintToGrPaintWithXfermode(GrRecordingContext* context,
403 const GrColorInfo& dstColorInfo,
404 const SkPaint& skPaint,
405 const SkMatrix& viewM,
406 SkBlendMode primColorMode,
407 GrPaint* grPaint) {
408 return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, viewM, nullptr, &primColorMode,
409 grPaint);
410 }
411
SkPaintToGrPaintWithTexture(GrRecordingContext * context,const GrColorInfo & dstColorInfo,const SkPaint & paint,const SkMatrix & viewM,std::unique_ptr<GrFragmentProcessor> fp,bool textureIsAlphaOnly,GrPaint * grPaint)412 bool SkPaintToGrPaintWithTexture(GrRecordingContext* context,
413 const GrColorInfo& dstColorInfo,
414 const SkPaint& paint,
415 const SkMatrix& viewM,
416 std::unique_ptr<GrFragmentProcessor> fp,
417 bool textureIsAlphaOnly,
418 GrPaint* grPaint) {
419 std::unique_ptr<GrFragmentProcessor> shaderFP;
420 if (textureIsAlphaOnly) {
421 if (const auto* shader = as_SB(paint.getShader())) {
422 shaderFP = shader->asFragmentProcessor(
423 GrFPArgs(context, &viewM, paint.getFilterQuality(), &dstColorInfo));
424 if (!shaderFP) {
425 return false;
426 }
427 std::unique_ptr<GrFragmentProcessor> fpSeries[] = { std::move(shaderFP), std::move(fp) };
428 shaderFP = GrFragmentProcessor::RunInSeries(fpSeries, 2);
429 } else {
430 shaderFP = GrFragmentProcessor::MakeInputPremulAndMulByOutput(std::move(fp));
431 }
432 } else {
433 if (paint.getColor4f().isOpaque()) {
434 shaderFP = GrFragmentProcessor::OverrideInput(std::move(fp), SK_PMColor4fWHITE, false);
435 } else {
436 shaderFP = GrFragmentProcessor::MulChildByInputAlpha(std::move(fp));
437 }
438 }
439
440 return SkPaintToGrPaintReplaceShader(context, dstColorInfo, paint, std::move(shaderFP),
441 grPaint);
442 }
443
444 ////////////////////////////////////////////////////////////////////////////////////////////////
445
GrSkFilterQualityToGrFilterMode(int imageWidth,int imageHeight,SkFilterQuality paintFilterQuality,const SkMatrix & viewM,const SkMatrix & localM,bool sharpenMipmappedTextures,bool * doBicubic)446 GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(int imageWidth, int imageHeight,
447 SkFilterQuality paintFilterQuality,
448 const SkMatrix& viewM,
449 const SkMatrix& localM,
450 bool sharpenMipmappedTextures,
451 bool* doBicubic) {
452 *doBicubic = false;
453 if (imageWidth <= 1 && imageHeight <= 1) {
454 return GrSamplerState::Filter::kNearest;
455 }
456 switch (paintFilterQuality) {
457 case kNone_SkFilterQuality:
458 return GrSamplerState::Filter::kNearest;
459 case kLow_SkFilterQuality:
460 return GrSamplerState::Filter::kBilerp;
461 case kMedium_SkFilterQuality: {
462 SkMatrix matrix;
463 matrix.setConcat(viewM, localM);
464 // With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until the
465 // computed LOD is >= 0.5. At what scale factor does a texture get an LOD of 0.5?
466 //
467 // Want: 0 = log2(1/s) - 0.5
468 // 0.5 = log2(1/s)
469 // 2^0.5 = 1/s
470 // 1/2^0.5 = s
471 // 2^0.5/2 = s
472 SkScalar mipScale = sharpenMipmappedTextures ? SK_ScalarRoot2Over2 : SK_Scalar1;
473 if (matrix.getMinScale() < mipScale) {
474 return GrSamplerState::Filter::kMipMap;
475 } else {
476 // Don't trigger MIP level generation unnecessarily.
477 return GrSamplerState::Filter::kBilerp;
478 }
479 }
480 case kHigh_SkFilterQuality: {
481 SkMatrix matrix;
482 matrix.setConcat(viewM, localM);
483 GrSamplerState::Filter textureFilterMode;
484 *doBicubic = GrBicubicEffect::ShouldUseBicubic(matrix, &textureFilterMode);
485 return textureFilterMode;
486 }
487 }
488 SkUNREACHABLE;
489 }
490