diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-15 03:52:53 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-15 03:52:53 +0000 |
commit | d791018e637fe65c72448b55e1e786bfb0154eab (patch) | |
tree | 8abf881ab2ba1eb4a8a94231a66e6e955f0e2316 /chrome | |
parent | ea3ee0a8f3e4841e7e27dfc371c98a8b5dd5ca9a (diff) | |
download | chromium_src-d791018e637fe65c72448b55e1e786bfb0154eab.zip chromium_src-d791018e637fe65c72448b55e1e786bfb0154eab.tar.gz chromium_src-d791018e637fe65c72448b55e1e786bfb0154eab.tar.bz2 |
Get rid of Image::Image(SkBitmap*)
Bug=124566
Test=Compiles on CrOS,Mac
Review URL: https://chromiumcodereview.appspot.com/10378009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/favicon/favicon_tab_helper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/history/expire_history_backend_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/history/history_backend_unittest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/history/history_tab_helper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/history/top_sites_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/browser/icon_loader_chromeos.cc | 16 | ||||
-rw-r--r-- | chrome/browser/icon_loader_linux.cc | 12 | ||||
-rw-r--r-- | chrome/browser/icon_loader_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/profiles/gaia_info_update_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/thumbnail_generator.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm | 2 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/gtk_theme_service.cc | 28 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/gtk_theme_service.h | 12 | ||||
-rw-r--r-- | chrome/browser/ui/intents/web_intent_picker_controller.cc | 4 | ||||
-rw-r--r-- | chrome/tools/profiles/generate_profile.cc | 6 |
16 files changed, 63 insertions, 57 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index 54ac187..9d1df2c 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(new SkBitmap(icon_))); + prompt_.set_icon(gfx::Image(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 2d7cda3..3aac80f 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(new SkBitmap(image)); + gfx::Image favicon(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 fffc7f1..40562e1 100644 --- a/chrome/browser/history/expire_history_backend_unittest.cc +++ b/chrome/browser/history/expire_history_backend_unittest.cc @@ -230,8 +230,9 @@ 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. - gfx::Image thumbnail( + scoped_ptr<SkBitmap> thumbnail_bitmap( 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 d3f6f0b..c3e0884 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -346,16 +346,19 @@ 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); - gfx::Image google_bitmap( + scoped_ptr<SkBitmap> 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_bitmap, + backend_->thumbnail_db_->SetPageThumbnail(gurl, row1_id, &google_image, score, time); - gfx::Image weewar_bitmap( + scoped_ptr<SkBitmap> weewar_bitmap( gfx::JPEGCodec::Decode(kWeewarThumbnail, sizeof(kWeewarThumbnail))); - backend_->thumbnail_db_->SetPageThumbnail(gurl, row2_id, &weewar_bitmap, + gfx::Image weewar_image(*weewar_bitmap); + backend_->thumbnail_db_->SetPageThumbnail(gurl, row2_id, &weewar_image, score, time); // Star row1. diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/history/history_tab_helper.cc index 2da50d0..a9eb13c 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(new SkBitmap(bitmap)); + gfx::Image thumbnail(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 bdfd045..863bfc6 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 = new SkBitmap; - thumbnail->setConfig(SkBitmap::kARGB_8888_Config, 4, 4); - thumbnail->allocPixels(); - thumbnail->eraseColor(color); - return gfx::Image(thumbnail); // takes ownership. + SkBitmap thumbnail; + thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); + thumbnail.allocPixels(); + thumbnail.eraseColor(color); + return gfx::Image(thumbnail); // adds ref. } // 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 14692be..cc4739f 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(SkBitmap* source, int pixel_size) { - DCHECK(source); - DCHECK(source->width() == source->height()); +SkBitmap GenerateBitmapWithSize(const SkBitmap& source, int pixel_size) { + DCHECK(!source.isNull()); + DCHECK(source.width() == source.height()); - if (pixel_size == kDoNotResize || source->width() == pixel_size) - return new SkBitmap(*source); + if (pixel_size == kDoNotResize || source.width() == pixel_size) + return source; - return new SkBitmap(skia::ImageOperations::Resize( - *source, skia::ImageOperations::RESIZE_BEST, pixel_size, pixel_size)); + return 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 b70dfd8..f0bb1e6 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; - scoped_ptr<SkBitmap> bitmap(new SkBitmap()); - *bitmap = decoder.Decode( + SkBitmap bitmap; + 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.release())); + if (!bitmap.empty()) { + DCHECK_EQ(size_pixels, bitmap.width()); + DCHECK_EQ(size_pixels, bitmap.height()); + image_.reset(new gfx::Image(bitmap)); } 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 f51c064..c217bff 100644 --- a/chrome/browser/icon_loader_win.cc +++ b/chrome/browser/icon_loader_win.cc @@ -10,6 +10,7 @@ #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" @@ -34,8 +35,9 @@ void IconLoader::ReadIcon() { SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) return; - image_.reset(new gfx::Image( - IconUtil::CreateSkBitmapFromHICON(file_info.hIcon))); + scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON( + file_info.hIcon)); + image_.reset(new gfx::Image(*bitmap)); 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 f7ada7e..32ce7cd 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(new SkBitmap(bitmap)); + gfx::Image gfx_image(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 c8678d1..1834ae7 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(new SkBitmap(thumbnail)); + gfx::Image image(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 4c01975..2daa7f1 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(new SkBitmap(bitmap)); + icon_ = gfx::Image(bitmap); } void LoadExtension() { diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc index cd6b0ab..30d92ef 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 = new SkBitmap; - bitmap->setConfig(SkBitmap::kARGB_8888_Config, - kToolbarImageWidth, kToolbarImageHeight); - bitmap->allocPixels(); - bitmap->eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8); + SkBitmap bitmap; + 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 new SkBitmap(canvas.ExtractBitmap()); + return 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 new SkBitmap(SkBitmapOperations::CreateTiledBitmap( - bg_tint, 0, 0, bg_tint.width(), bg_tint.height())); + return 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 new SkBitmap(SkBitmapOperations::CreateHSLShiftedBitmap( - *rb.GetBitmapNamed(base_id), tint)); + return 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 0228c56..d421ffb 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 924f984..1802c56 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(new SkBitmap(icon_bitmap)); + gfx::Image icon_image(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(new SkBitmap(resized_icon)); + gfx::Image icon_image(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 940b27d..c310879 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) { - SkBitmap* bitmap = (RandomInt(0, 2) == 0) ? google_bitmap.get() : - weewar_bitmap.get(); - gfx::Image image(new SkBitmap(*bitmap)); + const SkBitmap& bitmap = (RandomInt(0, 2) == 0) ? *google_bitmap : + *weewar_bitmap; + gfx::Image image(bitmap); top_sites->SetPageThumbnail(url, &image, score); } |