summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 03:57:29 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 03:57:29 +0000
commit76708644af7947c3e0f9fa8e6c528d6dfedab961 (patch)
tree54e731014f925718fd01d8495e029f04942a3953 /chrome
parentd791018e637fe65c72448b55e1e786bfb0154eab (diff)
downloadchromium_src-76708644af7947c3e0f9fa8e6c528d6dfedab961.zip
chromium_src-76708644af7947c3e0f9fa8e6c528d6dfedab961.tar.gz
chromium_src-76708644af7947c3e0f9fa8e6c528d6dfedab961.tar.bz2
Revert 137075 - Get rid of Image::Image(SkBitmap*)
Bug=124566 Test=Compiles on CrOS,Mac Review URL: https://chromiumcodereview.appspot.com/10378009 TBR=pkotwicz@chromium.org Review URL: https://chromiumcodereview.appspot.com/10332163 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-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
16 files changed, 57 insertions, 63 deletions
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);
}