Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: Source/platform/graphics/skia/NativeImageSkia.cpp

Issue 201513003: Implement InterpolationMedium to filter animated images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: only ode change Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/skia/NativeImageSkia.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/skia/NativeImageSkia.cpp
diff --git a/Source/platform/graphics/skia/NativeImageSkia.cpp b/Source/platform/graphics/skia/NativeImageSkia.cpp
index a963e3e14b50cdf6b0063eddd972d4914828345a..f7e70af0ad4d05d15b9903954a24f59e89866f85 100644
--- a/Source/platform/graphics/skia/NativeImageSkia.cpp
+++ b/Source/platform/graphics/skia/NativeImageSkia.cpp
@@ -144,19 +144,38 @@ static ResamplingMode limitResamplingMode(GraphicsContext* context, ResamplingMo
case InterpolationNone:
return NoResampling;
case InterpolationMedium:
- // For now we treat InterpolationMedium and InterpolationLow the same.
- case InterpolationLow:
if (resampling == AwesomeResampling)
+ return LinearWithMipmapsResampling;
+ break;
+ case InterpolationLow:
+ if (resampling == AwesomeResampling || resampling == LinearWithMipmapsResampling)
return LinearResampling;
break;
case InterpolationHigh:
- case InterpolationDefault:
break;
}
return resampling;
}
+static SkPaint::FilterLevel convertToSkiaFilterLevel(bool useBicubicFilter, ResamplingMode resampling)
+{
+ if (useBicubicFilter)
+ return SkPaint::kHigh_FilterLevel;
+
+ switch (resampling) {
+ case LinearWithMipmapsResampling:
+ return SkPaint::kMedium_FilterLevel;
+ case LinearResampling:
+ return SkPaint::kLow_FilterLevel;
+ // AwesomeResampling if useBicubicFilter is false means that we do
+ // a manual high quality resampling before drawing to Skia.
+ case AwesomeResampling:
+ default:
+ return SkPaint::kNone_FilterLevel;
+ }
+}
+
// This function is used to scale an image and extract a scaled fragment.
//
// ALGORITHM
@@ -353,7 +372,6 @@ void NativeImageSkia::draw(GraphicsContext* context, const SkRect& srcRect, cons
resampling = LinearResampling;
}
resampling = limitResamplingMode(context, resampling);
- paint.setFilterBitmap(resampling == LinearResampling);
bool isLazyDecoded = DeferredImageDecoder::isLazyDecoded(bitmap());
// FIXME: Bicubic filtering in Skia is only applied to defer-decoded images
@@ -361,8 +379,7 @@ void NativeImageSkia::draw(GraphicsContext* context, const SkRect& srcRect, cons
// turn this on for all cases, including non-defer-decoded images.
bool useBicubicFilter = resampling == AwesomeResampling && isLazyDecoded;
- if (useBicubicFilter)
- paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
+ paint.setFilterLevel(convertToSkiaFilterLevel(useBicubicFilter, resampling));
if (resampling == AwesomeResampling && !useBicubicFilter) {
// Resample the image and then draw the result to canvas with bilinear
@@ -496,10 +513,8 @@ void NativeImageSkia::drawPattern(
paint.setShader(shader.get());
paint.setXfermode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode).get());
paint.setColorFilter(context->colorFilter());
+ paint.setFilterLevel(convertToSkiaFilterLevel(useBicubicFilter, resampling));
- paint.setFilterBitmap(resampling == LinearResampling);
- if (useBicubicFilter)
- paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
if (isLazyDecoded)
PlatformInstrumentation::didDrawLazyPixelRef(bitmap().getGenerationID());
« no previous file with comments | « Source/platform/graphics/skia/NativeImageSkia.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698