diff options
author | hubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-15 16:01:39 +0000 |
---|---|---|
committer | hubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-15 16:01:39 +0000 |
commit | a63306e826880313ae22383a9bd3b6995fb5f743 (patch) | |
tree | 6cc9bc9862fcedd33110a2ac4a4970b412e66bc2 | |
parent | c93916b640465d75cb41b9fc32600ec8279b9756 (diff) | |
download | chromium_src-a63306e826880313ae22383a9bd3b6995fb5f743.zip chromium_src-a63306e826880313ae22383a9bd3b6995fb5f743.tar.gz chromium_src-a63306e826880313ae22383a9bd3b6995fb5f743.tar.bz2 |
Make sure skia doesn't try to scale images with less than 32 bits per pixel.
The previous attempt to commit this was reverted because ui_unittests stopped working on windows. Since I don't have a windows box, I can't fix the test, so in this CL I am disabling the tests and notifying the people who can fix it.
This log shows what happened when the test was not disabled:
http://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%28dbg%29%281%29/builds/36957/steps/ui_unittests/logs/stdio
BUG=247081
Review URL: https://chromiumcodereview.appspot.com/17100002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206599 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | skia/ext/image_operations.cc | 4 | ||||
-rw-r--r-- | skia/ext/image_operations_unittest.cc | 11 | ||||
-rw-r--r-- | ui/gfx/icon_util.cc | 8 |
3 files changed, 16 insertions, 7 deletions
diff --git a/skia/ext/image_operations.cc b/skia/ext/image_operations.cc index b1cdade..f30a85d 100644 --- a/skia/ext/image_operations.cc +++ b/skia/ext/image_operations.cc @@ -496,8 +496,8 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source, (method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD)); SkAutoLockPixels locker(source); - if (!source.readyToDraw()) - return SkBitmap(); + if (!source.readyToDraw() || source.config() != SkBitmap::kARGB_8888_Config) + return SkBitmap(); ResizeFilter filter(method, source.width(), source.height(), dest_width, dest_height, dest_subset); diff --git a/skia/ext/image_operations_unittest.cc b/skia/ext/image_operations_unittest.cc index 9fce74b..c7069e2 100644 --- a/skia/ext/image_operations_unittest.cc +++ b/skia/ext/image_operations_unittest.cc @@ -461,6 +461,17 @@ TEST(ImageOperations, HalveSubset) { } } +TEST(ImageOperations, InvalidParams) { + // Make our source bitmap. + SkBitmap src; + src.setConfig(SkBitmap::kA8_Config, 16, 34); + src.allocPixels(); + + // Scale it, don't die. + SkBitmap full_results = skia::ImageOperations::Resize( + src, skia::ImageOperations::RESIZE_BOX, 10, 20); +} + // Resamples an image to the same image, it should give the same result. TEST(ImageOperations, ResampleToSameHamming1) { CheckResampleToSame(skia::ImageOperations::RESIZE_HAMMING1); diff --git a/ui/gfx/icon_util.cc b/ui/gfx/icon_util.cc index cc6cc90..22361860 100644 --- a/ui/gfx/icon_util.cc +++ b/ui/gfx/icon_util.cc @@ -75,11 +75,9 @@ bool BuildResizedImageFamily(const gfx::ImageFamily& image_family, // There is no |dimension|x|dimension| source image. // Resize this one to the desired size, and insert it. SkBitmap best_bitmap = best->AsBitmap(); - // If a gfx::Image was created from a SkBitmap with no allocated pixels, - // AsBitmap will return a null bitmap instead. This bitmap will have no - // config and a size of 0x0. Check this and fail early, to avoid having - // 0x0-sized bitmaps in our resized image family. - if (best_bitmap.config() == SkBitmap::kNo_Config) + // Only kARGB_8888 images are supported. + // This will also filter out images with no pixels. + if (best_bitmap.config() != SkBitmap::kARGB_8888_Config) return false; SkBitmap resized_bitmap = skia::ImageOperations::Resize( best_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, |