summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/wm/image_grid_unittest.cc4
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc2
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc2
-rw-r--r--chrome/browser/history/expire_history_backend_unittest.cc3
-rw-r--r--chrome/browser/history/history_backend_unittest.cc11
-rw-r--r--chrome/browser/history/history_tab_helper.cc2
-rw-r--r--chrome/browser/history/top_sites_unittest.cc10
-rw-r--r--chrome/browser/icon_loader_chromeos.cc16
-rw-r--r--chrome/browser/icon_loader_linux.cc12
-rw-r--r--chrome/browser/icon_loader_win.cc6
-rw-r--r--chrome/browser/profiles/gaia_info_update_service.cc2
-rw-r--r--chrome/browser/tab_contents/thumbnail_generator.cc2
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service.cc28
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service.h12
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.cc4
-rw-r--r--chrome/tools/profiles/generate_profile.cc6
-rw-r--r--ui/base/resource/resource_bundle.cc8
-rw-r--r--ui/gfx/image/image.cc7
-rw-r--r--ui/gfx/image/image.h4
-rw-r--r--ui/gfx/image/image_unittest.cc18
-rw-r--r--ui/gfx/image/image_unittest_util.cc36
-rw-r--r--ui/gfx/image/image_unittest_util.h8
-rw-r--r--ui/gfx/image/image_util.cc6
24 files changed, 98 insertions, 113 deletions
diff --git a/ash/wm/image_grid_unittest.cc b/ash/wm/image_grid_unittest.cc
index cf533b5..715ddb9 100644
--- a/ash/wm/image_grid_unittest.cc
+++ b/ash/wm/image_grid_unittest.cc
@@ -17,8 +17,8 @@ namespace {
// Creates a gfx::Image with the requested dimensions.
gfx::Image* CreateImage(const gfx::Size& size) {
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
+ SkBitmap* bitmap = new SkBitmap();
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
return new gfx::Image(bitmap);
}
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 9d1df2c..54ac187 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -519,7 +519,7 @@ void ExtensionInstallUI::ShowConfirmation() {
case INLINE_INSTALL_PROMPT:
case INSTALL_PROMPT: {
prompt_.set_extension(extension_);
- prompt_.set_icon(gfx::Image(icon_));
+ prompt_.set_icon(gfx::Image(new SkBitmap(icon_)));
ShowExtensionInstallDialog(profile_, delegate_, prompt_);
break;
}
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc
index 3aac80f..2d7cda3 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -186,7 +186,7 @@ void FaviconTabHelper::OnDidDownloadFavicon(int id,
const GURL& image_url,
bool errored,
const SkBitmap& image) {
- gfx::Image favicon(image);
+ gfx::Image favicon(new SkBitmap(image));
favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon);
if (touch_icon_handler_.get())
touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon);
diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc
index 40562e1..fffc7f1 100644
--- a/chrome/browser/history/expire_history_backend_unittest.cc
+++ b/chrome/browser/history/expire_history_backend_unittest.cc
@@ -230,9 +230,8 @@ void ExpireHistoryTest::AddExampleData(URLID url_ids[3], Time visit_times[4]) {
thumb_db_->AddIconMapping(url_row3.url(), favicon2);
// Thumbnails for each URL. |thumbnail| takes ownership of decoded SkBitmap.
- scoped_ptr<SkBitmap> thumbnail_bitmap(
+ gfx::Image thumbnail(
gfx::JPEGCodec::Decode(kGoogleThumbnail, sizeof(kGoogleThumbnail)));
- gfx::Image thumbnail(*thumbnail_bitmap);
ThumbnailScore score(0.25, true, true, Time::Now());
Time time;
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index c3e0884..d3f6f0b 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -346,19 +346,16 @@ TEST_F(HistoryBackendTest, DeleteAll) {
// Add thumbnails for each page. The |Images| take ownership of SkBitmap
// created from decoding the images.
ThumbnailScore score(0.25, true, true);
- scoped_ptr<SkBitmap> google_bitmap(
+ gfx::Image google_bitmap(
gfx::JPEGCodec::Decode(kGoogleThumbnail, sizeof(kGoogleThumbnail)));
- gfx::Image google_image(*google_bitmap);
-
Time time;
GURL gurl;
- backend_->thumbnail_db_->SetPageThumbnail(gurl, row1_id, &google_image,
+ backend_->thumbnail_db_->SetPageThumbnail(gurl, row1_id, &google_bitmap,
score, time);
- scoped_ptr<SkBitmap> weewar_bitmap(
+ gfx::Image weewar_bitmap(
gfx::JPEGCodec::Decode(kWeewarThumbnail, sizeof(kWeewarThumbnail)));
- gfx::Image weewar_image(*weewar_bitmap);
- backend_->thumbnail_db_->SetPageThumbnail(gurl, row2_id, &weewar_image,
+ backend_->thumbnail_db_->SetPageThumbnail(gurl, row2_id, &weewar_bitmap,
score, time);
// Star row1.
diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/history/history_tab_helper.cc
index a9eb13c..2da50d0 100644
--- a/chrome/browser/history/history_tab_helper.cc
+++ b/chrome/browser/history/history_tab_helper.cc
@@ -158,7 +158,7 @@ void HistoryTabHelper::OnThumbnail(const GURL& url,
// Tell History about this thumbnail.
history::TopSites* ts = profile->GetTopSites();
if (ts) {
- gfx::Image thumbnail(bitmap);
+ gfx::Image thumbnail(new SkBitmap(bitmap));
ts->SetPageThumbnail(url, &thumbnail, score);
}
}
diff --git a/chrome/browser/history/top_sites_unittest.cc b/chrome/browser/history/top_sites_unittest.cc
index 863bfc6..bdfd045 100644
--- a/chrome/browser/history/top_sites_unittest.cc
+++ b/chrome/browser/history/top_sites_unittest.cc
@@ -166,11 +166,11 @@ class TopSitesTest : public HistoryUnitTestBase {
// Creates a bitmap of the specified color. Caller takes ownership.
gfx::Image CreateBitmap(SkColor color) {
- SkBitmap thumbnail;
- thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4);
- thumbnail.allocPixels();
- thumbnail.eraseColor(color);
- return gfx::Image(thumbnail); // adds ref.
+ SkBitmap* thumbnail = new SkBitmap;
+ thumbnail->setConfig(SkBitmap::kARGB_8888_Config, 4, 4);
+ thumbnail->allocPixels();
+ thumbnail->eraseColor(color);
+ return gfx::Image(thumbnail); // takes ownership.
}
// Forces top sites to load top sites from history, then recreates top sites.
diff --git a/chrome/browser/icon_loader_chromeos.cc b/chrome/browser/icon_loader_chromeos.cc
index cc4739f..14692be 100644
--- a/chrome/browser/icon_loader_chromeos.cc
+++ b/chrome/browser/icon_loader_chromeos.cc
@@ -164,15 +164,15 @@ int IconMapper::Lookup(const std::string& extension,
// Returns a copy of |source| that is |pixel_size| in width and height. If
// |pixel_size| is |kDoNotResize|, returns an unmodified copy of |source|.
// |source| must be a square image (width == height).
-SkBitmap GenerateBitmapWithSize(const SkBitmap& source, int pixel_size) {
- DCHECK(!source.isNull());
- DCHECK(source.width() == source.height());
+SkBitmap* GenerateBitmapWithSize(SkBitmap* source, int pixel_size) {
+ DCHECK(source);
+ DCHECK(source->width() == source->height());
- if (pixel_size == kDoNotResize || source.width() == pixel_size)
- return source;
+ if (pixel_size == kDoNotResize || source->width() == pixel_size)
+ return new SkBitmap(*source);
- return skia::ImageOperations::Resize(
- source, skia::ImageOperations::RESIZE_BEST, pixel_size, pixel_size);
+ return new SkBitmap(skia::ImageOperations::Resize(
+ *source, skia::ImageOperations::RESIZE_BEST, pixel_size, pixel_size));
}
int IconSizeToPixelSize(IconLoader::IconSize size) {
@@ -203,7 +203,7 @@ void IconLoader::ReadIcon() {
if (!gfx::PNGCodec::Decode(bytes->front(), bytes->size(), &bitmap))
NOTREACHED();
image_.reset(new gfx::Image(
- GenerateBitmapWithSize(bitmap, IconSizeToPixelSize(icon_size_))));
+ GenerateBitmapWithSize(&bitmap, IconSizeToPixelSize(icon_size_))));
target_message_loop_->PostTask(
FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this));
}
diff --git a/chrome/browser/icon_loader_linux.cc b/chrome/browser/icon_loader_linux.cc
index f0bb1e6..b70dfd8 100644
--- a/chrome/browser/icon_loader_linux.cc
+++ b/chrome/browser/icon_loader_linux.cc
@@ -40,14 +40,14 @@ void IconLoader::ReadIcon() {
file_util::ReadFileToString(filename, &icon_data);
webkit_glue::ImageDecoder decoder;
- SkBitmap bitmap;
- bitmap = decoder.Decode(
+ scoped_ptr<SkBitmap> bitmap(new SkBitmap());
+ *bitmap = decoder.Decode(
reinterpret_cast<const unsigned char*>(icon_data.data()),
icon_data.length());
- if (!bitmap.empty()) {
- DCHECK_EQ(size_pixels, bitmap.width());
- DCHECK_EQ(size_pixels, bitmap.height());
- image_.reset(new gfx::Image(bitmap));
+ if (!bitmap->empty()) {
+ DCHECK_EQ(size_pixels, bitmap->width());
+ DCHECK_EQ(size_pixels, bitmap->height());
+ image_.reset(new gfx::Image(bitmap.release()));
} else {
LOG(WARNING) << "Unsupported file type or load error: "
<< filename.value();
diff --git a/chrome/browser/icon_loader_win.cc b/chrome/browser/icon_loader_win.cc
index c217bff..f51c064 100644
--- a/chrome/browser/icon_loader_win.cc
+++ b/chrome/browser/icon_loader_win.cc
@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/threading/thread.h"
-#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/icon_util.h"
#include "ui/gfx/size.h"
@@ -35,9 +34,8 @@ void IconLoader::ReadIcon() {
SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES))
return;
- scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(
- file_info.hIcon));
- image_.reset(new gfx::Image(*bitmap));
+ image_.reset(new gfx::Image(
+ IconUtil::CreateSkBitmapFromHICON(file_info.hIcon)));
DestroyIcon(file_info.hIcon);
target_message_loop_->PostTask(FROM_HERE,
base::Bind(&IconLoader::NotifyDelegate, this));
diff --git a/chrome/browser/profiles/gaia_info_update_service.cc b/chrome/browser/profiles/gaia_info_update_service.cc
index 32ce7cd..f7ada7e 100644
--- a/chrome/browser/profiles/gaia_info_update_service.cc
+++ b/chrome/browser/profiles/gaia_info_update_service.cc
@@ -129,7 +129,7 @@ void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
if (picture_status == ProfileDownloader::PICTURE_SUCCESS) {
profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL,
picture_url);
- gfx::Image gfx_image(bitmap);
+ gfx::Image gfx_image(new SkBitmap(bitmap));
cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image);
} else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) {
cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL);
diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc
index 1834ae7..c8678d1 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -471,7 +471,7 @@ void ThumbnailGenerator::UpdateThumbnail(
clip_result == ThumbnailGenerator::kNotClipped);
score.load_completed = (!load_interrupted_ && !web_contents->IsLoading());
- gfx::Image image(thumbnail);
+ gfx::Image image(new SkBitmap(thumbnail));
const GURL& url = web_contents->GetURL();
top_sites->SetPageThumbnail(url, &image, score);
VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString();
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm
index 2daa7f1..4c01975 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm
@@ -48,7 +48,7 @@ public:
SkBitmap bitmap = decoder.Decode(
reinterpret_cast<const unsigned char*>(file_contents.c_str()),
file_contents.length());
- icon_ = gfx::Image(bitmap);
+ icon_ = gfx::Image(new SkBitmap(bitmap));
}
void LoadExtension() {
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc
index 30d92ef..cd6b0ab 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.cc
+++ b/chrome/browser/ui/gtk/gtk_theme_service.cc
@@ -939,16 +939,16 @@ void GtkThemeService::FreeIconSets() {
}
}
-SkBitmap GtkThemeService::GenerateGtkThemeBitmap(int id) const {
+SkBitmap* GtkThemeService::GenerateGtkThemeBitmap(int id) const {
switch (id) {
case IDR_THEME_TOOLBAR: {
GtkStyle* style = gtk_rc_get_style(fake_window_);
GdkColor* color = &style->bg[GTK_STATE_NORMAL];
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- kToolbarImageWidth, kToolbarImageHeight);
- bitmap.allocPixels();
- bitmap.eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8);
+ SkBitmap* bitmap = new SkBitmap;
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config,
+ kToolbarImageWidth, kToolbarImageHeight);
+ bitmap->allocPixels();
+ bitmap->eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8);
return bitmap;
}
case IDR_THEME_TAB_BACKGROUND:
@@ -1001,7 +1001,7 @@ SkBitmap GtkThemeService::GenerateGtkThemeBitmap(int id) const {
}
}
-SkBitmap GtkThemeService::GenerateFrameImage(
+SkBitmap* GtkThemeService::GenerateFrameImage(
int color_id,
const char* gradient_name) const {
// We use two colors: the main color (passed in) and a lightened version of
@@ -1038,23 +1038,23 @@ SkBitmap GtkThemeService::GenerateFrameImage(
canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth,
kToolbarImageHeight - gradient_size), base);
- return canvas.ExtractBitmap();
+ return new SkBitmap(canvas.ExtractBitmap());
}
-SkBitmap GtkThemeService::GenerateTabImage(int base_id) const {
+SkBitmap* GtkThemeService::GenerateTabImage(int base_id) const {
SkBitmap* base_image = GetBitmapNamed(base_id);
SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap(
*base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB));
- return SkBitmapOperations::CreateTiledBitmap(
- bg_tint, 0, 0, bg_tint.width(), bg_tint.height());
+ return new SkBitmap(SkBitmapOperations::CreateTiledBitmap(
+ bg_tint, 0, 0, bg_tint.width(), bg_tint.height()));
}
-SkBitmap GtkThemeService::GenerateTintedIcon(
+SkBitmap* GtkThemeService::GenerateTintedIcon(
int base_id,
const color_utils::HSL& tint) const {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- return SkBitmapOperations::CreateHSLShiftedBitmap(
- *rb.GetBitmapNamed(base_id), tint);
+ return new SkBitmap(SkBitmapOperations::CreateHSLShiftedBitmap(
+ *rb.GetBitmapNamed(base_id), tint));
}
void GtkThemeService::GetNormalButtonTintHSL(
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.h b/chrome/browser/ui/gtk/gtk_theme_service.h
index d421ffb..0228c56 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.h
+++ b/chrome/browser/ui/gtk/gtk_theme_service.h
@@ -196,21 +196,21 @@ class GtkThemeService : public ThemeService {
void FreeIconSets();
// Lazily generates each bitmap used in the gtk theme.
- SkBitmap GenerateGtkThemeBitmap(int id) const;
+ SkBitmap* GenerateGtkThemeBitmap(int id) const;
// Creates a GTK+ version of IDR_THEME_FRAME. Instead of tinting, this
// creates a theme configurable gradient ending with |color_id| at the
// bottom, and |gradient_name| at the top if that color is specified in the
// theme.
- SkBitmap GenerateFrameImage(int color_id,
- const char* gradient_name) const;
+ SkBitmap* GenerateFrameImage(int color_id,
+ const char* gradient_name) const;
// Takes the base frame image |base_id| and tints it with |tint_id|.
- SkBitmap GenerateTabImage(int base_id) const;
+ SkBitmap* GenerateTabImage(int base_id) const;
// Tints an icon based on tint.
- SkBitmap GenerateTintedIcon(int base_id,
- const color_utils::HSL& tint) const;
+ SkBitmap* GenerateTintedIcon(int base_id,
+ const color_utils::HSL& tint) const;
// Returns the tint for buttons that contrasts with the normal window
// background color.
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc
index 1802c56..924f984 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc
@@ -529,7 +529,7 @@ void WebIntentPickerController::OnFaviconDataAvailable(
if (gfx::PNGCodec::Decode(favicon_data.image_data->front(),
favicon_data.image_data->size(),
&icon_bitmap)) {
- gfx::Image icon_image(icon_bitmap);
+ gfx::Image icon_image(new SkBitmap(icon_bitmap));
picker_model_->UpdateFaviconAt(index, icon_image);
return;
}
@@ -633,7 +633,7 @@ void WebIntentPickerController::DecodeExtensionIconAndResize(
icon_bitmap,
skia::ImageOperations::RESIZE_BEST,
gfx::kFaviconSize, gfx::kFaviconSize);
- gfx::Image icon_image(resized_icon);
+ gfx::Image icon_image(new SkBitmap(resized_icon));
content::BrowserThread::PostTask(
content::BrowserThread::UI,
diff --git a/chrome/tools/profiles/generate_profile.cc b/chrome/tools/profiles/generate_profile.cc
index c310879..940b27d 100644
--- a/chrome/tools/profiles/generate_profile.cc
+++ b/chrome/tools/profiles/generate_profile.cc
@@ -181,9 +181,9 @@ void InsertURLBatch(Profile* profile,
if (types & FULL_TEXT)
history_service->SetPageContents(url, ConstructRandomPage());
if (types & TOP_SITES && top_sites) {
- const SkBitmap& bitmap = (RandomInt(0, 2) == 0) ? *google_bitmap :
- *weewar_bitmap;
- gfx::Image image(bitmap);
+ SkBitmap* bitmap = (RandomInt(0, 2) == 0) ? google_bitmap.get() :
+ weewar_bitmap.get();
+ gfx::Image image(new SkBitmap(*bitmap));
top_sites->SetPageThumbnail(url, &image, score);
}
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 693677c..bb011ab 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -465,10 +465,10 @@ gfx::Image& ResourceBundle::GetEmptyImage() {
if (empty_image_.IsEmpty()) {
// The placeholder bitmap is bright red so people notice the problem.
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
- bitmap.allocPixels();
- bitmap.eraseARGB(255, 255, 0, 0);
+ SkBitmap* bitmap = new SkBitmap();
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
+ bitmap->allocPixels();
+ bitmap->eraseARGB(255, 255, 0, 0);
empty_image_ = gfx::Image(bitmap);
}
return empty_image_;
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index 66fb97c..e748dd9 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -224,6 +224,13 @@ Image::Image() {
// |storage_| is NULL for empty Images.
}
+Image::Image(const SkBitmap* bitmap)
+ : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
+ internal::ImageRepSkia* rep = new internal::ImageRepSkia(
+ new ImageSkia(bitmap));
+ AddRepresentation(rep);
+}
+
Image::Image(const SkBitmap& bitmap)
: storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
internal::ImageRepSkia* rep =
diff --git a/ui/gfx/image/image.h b/ui/gfx/image/image.h
index 71c3e17..9c0e6eb 100644
--- a/ui/gfx/image/image.h
+++ b/ui/gfx/image/image.h
@@ -62,6 +62,10 @@ class UI_EXPORT Image {
// Creates an empty image with no representations.
Image();
+ // Creates a new image with the default representation. The object will take
+ // ownership of the image.
+ explicit Image(const SkBitmap* bitmap);
+
// Creates a new image by copying the bitmap for use as the default
// representation.
explicit Image(const SkBitmap& bitmap);
diff --git a/ui/gfx/image/image_unittest.cc b/ui/gfx/image/image_unittest.cc
index 732f69f..8793562 100644
--- a/ui/gfx/image/image_unittest.cc
+++ b/ui/gfx/image/image_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image/image.h"
@@ -67,8 +68,8 @@ TEST_F(ImageTest, SkiaToSkia) {
}
TEST_F(ImageTest, SkiaRefToSkia) {
- SkBitmap originalBitmap(gt::CreateBitmap(25, 25));
- gfx::Image image(originalBitmap);
+ scoped_ptr<SkBitmap> originalBitmap(gt::CreateBitmap(25, 25));
+ gfx::Image image(*originalBitmap.get());
const SkBitmap* bitmap = image.ToSkBitmap();
EXPECT_TRUE(bitmap);
EXPECT_FALSE(bitmap->isNull());
@@ -103,7 +104,7 @@ TEST_F(ImageTest, SkiaToPlatform) {
if (!kUsesSkiaNatively)
EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
- EXPECT_TRUE(gt::IsPlatformImageValid(gt::ToPlatformType(image)));
+ EXPECT_TRUE(gt::ToPlatformType(image));
EXPECT_EQ(kRepCount, image.RepresentationCount());
const SkBitmap* bitmap = image.ToSkBitmap();
@@ -127,7 +128,7 @@ TEST_F(ImageTest, PlatformToSkia) {
EXPECT_FALSE(bitmap->isNull());
EXPECT_EQ(kRepCount, image.RepresentationCount());
- EXPECT_TRUE(gt::IsPlatformImageValid(gt::ToPlatformType(image)));
+ EXPECT_TRUE(gt::ToPlatformType(image));
EXPECT_EQ(kRepCount, image.RepresentationCount());
EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia));
@@ -135,11 +136,11 @@ TEST_F(ImageTest, PlatformToSkia) {
TEST_F(ImageTest, PlatformToPlatform) {
gfx::Image image(gt::CreatePlatformImage());
- EXPECT_TRUE(gt::IsPlatformImageValid(gt::ToPlatformType(image)));
+ EXPECT_TRUE(gt::ToPlatformType(image));
EXPECT_EQ(1U, image.RepresentationCount());
// Make sure double conversion doesn't happen.
- EXPECT_TRUE(gt::IsPlatformImageValid(gt::ToPlatformType(image)));
+ EXPECT_TRUE(gt::ToPlatformType(image));
EXPECT_EQ(1U, image.RepresentationCount());
EXPECT_TRUE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
@@ -220,8 +221,7 @@ TEST_F(ImageTest, SwapRepresentations) {
image1.SwapRepresentations(&image2);
EXPECT_EQ(bitmap2, image1.ToSkBitmap());
- EXPECT_TRUE(gt::PlatformImagesEqual(platform_image,
- gt::ToPlatformType(image1)));
+ EXPECT_EQ(platform_image, gt::ToPlatformType(image1));
EXPECT_EQ(bitmap1, image2.ToSkBitmap());
EXPECT_EQ(kRepCount, image1.RepresentationCount());
EXPECT_EQ(1U, image2.RepresentationCount());
@@ -237,7 +237,7 @@ TEST_F(ImageTest, Copy) {
EXPECT_EQ(1U, image2.RepresentationCount());
EXPECT_EQ(image1.ToSkBitmap(), image2.ToSkBitmap());
- EXPECT_TRUE(gt::IsPlatformImageValid(gt::ToPlatformType(image2)));
+ EXPECT_TRUE(gt::ToPlatformType(image2));
EXPECT_EQ(kRepCount, image2.RepresentationCount());
EXPECT_EQ(kRepCount, image1.RepresentationCount());
}
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc
index 141db84..6a72869 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 {
-const SkBitmap CreateBitmap(int width, int height) {
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap.allocPixels();
- bitmap.eraseRGB(255, 0, 0);
+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);
return bitmap;
}
@@ -65,15 +65,15 @@ bool IsEmpty(const gfx::Image& image) {
}
PlatformImage CreatePlatformImage() {
- const SkBitmap bitmap(CreateBitmap(25, 25));
+ scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25));
#if defined(OS_MACOSX)
- NSImage* image = gfx::SkBitmapToNSImage(bitmap);
+ NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get()));
base::mac::NSObjectRetain(image);
return image;
#elif defined(TOOLKIT_GTK)
- return gfx::GdkPixbufFromSkBitmap(&bitmap);
+ return gfx::GdkPixbufFromSkBitmap(bitmap.get());
#else
- return bitmap;
+ return bitmap.release();
#endif
}
@@ -93,23 +93,7 @@ PlatformImage ToPlatformType(const gfx::Image& image) {
#elif defined(TOOLKIT_GTK)
return image.ToGdkPixbuf();
#else
- 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();
+ return image.ToSkBitmap();
#endif
}
diff --git a/ui/gfx/image/image_unittest_util.h b/ui/gfx/image/image_unittest_util.h
index e617f26..fb471b9 100644
--- a/ui/gfx/image/image_unittest_util.h
+++ b/ui/gfx/image/image_unittest_util.h
@@ -18,10 +18,10 @@ typedef NSImage* PlatformImage;
#elif defined(TOOLKIT_GTK)
typedef GdkPixbuf* PlatformImage;
#else
-typedef const SkBitmap PlatformImage;
+typedef const SkBitmap* PlatformImage;
#endif
-const SkBitmap CreateBitmap(int width, int height);
+SkBitmap* CreateBitmap(int width, int height);
gfx::Image CreateImage();
@@ -35,10 +35,6 @@ gfx::Image::RepresentationType GetPlatformRepresentationType();
PlatformImage ToPlatformType(const gfx::Image& image);
-bool IsPlatformImageValid(PlatformImage image);
-
-bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2);
-
} // namespace test
} // namespace gfx
diff --git a/ui/gfx/image/image_util.cc b/ui/gfx/image/image_util.cc
index ea870c0..4216629 100644
--- a/ui/gfx/image/image_util.cc
+++ b/ui/gfx/image/image_util.cc
@@ -13,9 +13,9 @@
namespace gfx {
Image* ImageFromPNGEncodedData(const unsigned char* input, size_t input_size) {
- SkBitmap favicon_bitmap;
- if (gfx::PNGCodec::Decode(input, input_size, &favicon_bitmap))
- return new Image(favicon_bitmap);
+ scoped_ptr<SkBitmap> favicon_bitmap(new SkBitmap());
+ if (gfx::PNGCodec::Decode(input, input_size, favicon_bitmap.get()))
+ return new Image(favicon_bitmap.release());
return NULL;
}