summaryrefslogtreecommitdiffstats
path: root/ui/gfx/image/image_unittest_util.cc
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 03:28:29 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 03:28:29 +0000
commit12c7da12c76dfdd58e9a5fc2ed77b319dfd2c96d (patch)
treec8b03dacda19d343c7dfc33ad72e4c273f808462 /ui/gfx/image/image_unittest_util.cc
parente7a8cbd4d4d389e666d5d3c372bb5d09a63b829b (diff)
downloadchromium_src-12c7da12c76dfdd58e9a5fc2ed77b319dfd2c96d.zip
chromium_src-12c7da12c76dfdd58e9a5fc2ed77b319dfd2c96d.tar.gz
chromium_src-12c7da12c76dfdd58e9a5fc2ed77b319dfd2c96d.tar.bz2
Revert 136812 - Get rid of Image::Image(SkBitmap*)
Bug=124566 Test=Compiles on CrOS,Mac Review URL: https://chromiumcodereview.appspot.com/10378009 TBR=pkotwicz@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=136813 Review URL: https://chromiumcodereview.appspot.com/10383153 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137068 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/image/image_unittest_util.cc')
-rw-r--r--ui/gfx/image/image_unittest_util.cc36
1 files changed, 26 insertions, 10 deletions
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc
index 6a72869..141db84 100644
--- a/ui/gfx/image/image_unittest_util.cc
+++ b/ui/gfx/image/image_unittest_util.cc
@@ -20,11 +20,11 @@
namespace gfx {
namespace test {
-SkBitmap* CreateBitmap(int width, int height) {
- SkBitmap* bitmap = new SkBitmap();
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap->allocPixels();
- bitmap->eraseRGB(255, 0, 0);
+const SkBitmap CreateBitmap(int width, int height) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.allocPixels();
+ bitmap.eraseRGB(255, 0, 0);
return bitmap;
}
@@ -65,15 +65,15 @@ bool IsEmpty(const gfx::Image& image) {
}
PlatformImage CreatePlatformImage() {
- scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25));
+ const SkBitmap bitmap(CreateBitmap(25, 25));
#if defined(OS_MACOSX)
- NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get()));
+ NSImage* image = gfx::SkBitmapToNSImage(bitmap);
base::mac::NSObjectRetain(image);
return image;
#elif defined(TOOLKIT_GTK)
- return gfx::GdkPixbufFromSkBitmap(bitmap.get());
+ return gfx::GdkPixbufFromSkBitmap(&bitmap);
#else
- return bitmap.release();
+ return bitmap;
#endif
}
@@ -93,7 +93,23 @@ PlatformImage ToPlatformType(const gfx::Image& image) {
#elif defined(TOOLKIT_GTK)
return image.ToGdkPixbuf();
#else
- return image.ToSkBitmap();
+ return *image.ToSkBitmap();
+#endif
+}
+
+bool IsPlatformImageValid(PlatformImage image) {
+#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+ return image != NULL;
+#else
+ return !image.isNull();
+#endif
+}
+
+bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) {
+#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+ return image1 == image2;
+#else
+ return image1.getPixels() == image2.getPixels();
#endif
}