From c2c0014636e7af36ee768f4bf684a27ec82ec0ae Mon Sep 17 00:00:00 2001 From: "jdduke@chromium.org" Date: Sun, 1 Sep 2013 23:34:15 +0000 Subject: [PATCH] [Android] Use a simpler downsampling routine when loading resources Resizing Android resources at runtime trades CPU cycles for a reduced memory footprint. By switching to a simpler (box) downsampling filter, we maintain sufficient quality while reducing the resize computation expense. BUG=281476,282411 Review URL: https://chromiumcodereview.appspot.com/23572021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220763 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/gfx/android/java_bitmap.cc | 3 ++- ui/gfx/android/java_bitmap.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/gfx/android/java_bitmap.cc b/ui/gfx/android/java_bitmap.cc index e292b385aa18..83d4a4651820 100644 --- a/ui/gfx/android/java_bitmap.cc +++ b/ui/gfx/android/java_bitmap.cc @@ -100,8 +100,9 @@ SkBitmap CreateSkBitmapFromResource(const char* name, gfx::Size size) { ConvertToSkBitmap(CreateJavaBitmapFromResource(name, size)); if (bitmap.isNull()) return bitmap; + // RESIZE_BOX has sufficient downsampling quality with minimal runtime cost. return skia::ImageOperations::Resize(bitmap, - skia::ImageOperations::RESIZE_GOOD, + skia::ImageOperations::RESIZE_BOX, size.width(), size.height()); } diff --git a/ui/gfx/android/java_bitmap.h b/ui/gfx/android/java_bitmap.h index 9dd49fb8a389..14bfc9909ae3 100644 --- a/ui/gfx/android/java_bitmap.h +++ b/ui/gfx/android/java_bitmap.h @@ -45,6 +45,7 @@ UI_EXPORT base::android::ScopedJavaLocalRef ConvertToJavaBitmap( const SkBitmap* skbitmap); // If the resource loads successfully, it will be resized to |size|. +// Note: If the source resource is smaller than |size|, quality may suffer. UI_EXPORT SkBitmap CreateSkBitmapFromResource(const char* name, gfx::Size size); } // namespace gfx -- 2.11.4.GIT