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

Unified Diff: ui/gfx/image/image_unittest_util.cc

Issue 10378009: Get rid of Image::Image(SkBitmap*) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 8 years, 7 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
Index: ui/gfx/image/image_unittest_util.cc
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc
index 6a728697af8ae8282f86a71d2ef3af3f256d9887..164a146f7f21e3f10bd17349b58917d9a1fff381 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,24 @@ PlatformImage ToPlatformType(const gfx::Image& image) {
#elif defined(TOOLKIT_GTK)
return image.ToGdkPixbuf();
#else
- return image.ToSkBitmap();
+ return *image.ToSkBitmap();
+#endif
+}
+
+bool PlatformRepresentationIsValid(const gfx::Image& image) {
+ PlatformImage platform_representation = ToPlatformType(image);
+#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+ return platform_representation != NULL;
+#else
+ return !platform_representation.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
}

Powered by Google App Engine
This is Rietveld 408576698