diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 23:46:18 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 23:46:18 +0000 |
commit | 715dfab49198de28a3c8577d63573a668b570f88 (patch) | |
tree | 54d63e3bf1de2291abf12f04ef940342e81f4edb | |
parent | e57ec6f78194e1cd7bb74b47cda1eab065e2d39a (diff) | |
download | chromium_src-715dfab49198de28a3c8577d63573a668b570f88.zip chromium_src-715dfab49198de28a3c8577d63573a668b570f88.tar.gz chromium_src-715dfab49198de28a3c8577d63573a668b570f88.tar.bz2 |
Reverting 16122.
Review URL: http://codereview.chromium.org/113427
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16124 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | app/resource_bundle_linux.cc | 2 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc | 1 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_bar_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 14 | ||||
-rw-r--r-- | chrome/browser/gtk/hung_renderer_dialog_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_container_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/menu_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/chrome.gyp | 6 | ||||
-rw-r--r-- | chrome/common/gtk_util.cc | 29 | ||||
-rw-r--r-- | chrome/common/gtk_util.h | 12 |
11 files changed, 53 insertions, 27 deletions
diff --git a/app/resource_bundle_linux.cc b/app/resource_bundle_linux.cc index 2d47ae5..116ebd9 100644 --- a/app/resource_bundle_linux.cc +++ b/app/resource_bundle_linux.cc @@ -7,7 +7,6 @@ #include <gtk/gtk.h> #include "app/gfx/chrome_font.h" -#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "base/base_paths.h" #include "base/data_pack.h" @@ -19,6 +18,7 @@ #include "base/string_piece.h" #include "base/string_util.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/gtk_util.h" #include "SkBitmap.h" namespace { diff --git a/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc b/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc index 033bc8ee..6787338 100644 --- a/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc +++ b/chrome/browser/bookmarks/bookmark_menu_controller_gtk.cc @@ -6,7 +6,6 @@ #include <gtk/gtk.h> -#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/string_util.h" diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 649c2c64..ebfe567 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -4,7 +4,6 @@ #include "chrome/browser/gtk/bookmark_bar_gtk.h" -#include "app/gfx/gtk_util.h" #include "app/gfx/text_elider.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" @@ -96,7 +95,7 @@ void BookmarkBarGtk::Init(Profile* profile) { static GdkPixbuf* folder_icon = rb.GetPixbufNamed(IDR_BOOKMARK_BAR_FOLDER); bookmark_hbox_ = gtk_hbox_new(FALSE, 0); - container_.Own(gtk_util::CreateGtkBorderBin(bookmark_hbox_, &kBackgroundColor, + container_.Own(gfx::CreateGtkBorderBin(bookmark_hbox_, &kBackgroundColor, kBarPadding, kBarPadding, kBarPadding, kBarPadding)); instructions_ = @@ -274,7 +273,7 @@ void BookmarkBarGtk::SetInstructionState(BookmarkNode* boomarks_bar_node) { } void BookmarkBarGtk::RemoveAllBookmarkButtons() { - gtk_util::RemoveAllChildren(bookmark_toolbar_.get()); + gfx::RemoveAllChildren(bookmark_toolbar_.get()); } int BookmarkBarGtk::GetBookmarkButtonCount() { diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 2a2c27d..30720d2 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -99,7 +99,7 @@ void FindBarGtk::InitWidgets() { // lateral position. We put that fixed in a SlideAnimatorGtk in order to get // the slide effect. GtkWidget* hbox = gtk_hbox_new(false, 0); - container_ = gtk_util::CreateGtkBorderBin(hbox, NULL, + container_ = gfx::CreateGtkBorderBin(hbox, NULL, kBarPaddingTopBottom, kBarPaddingTopBottom, kEntryPaddingLeft, kBarPaddingRight); gtk_widget_set_app_paintable(container_, TRUE); @@ -162,12 +162,12 @@ void FindBarGtk::InitWidgets() { gtk_box_pack_end(GTK_BOX(content_hbox), text_entry_, TRUE, TRUE, 0); // We fake anti-aliasing by having two borders. - GtkWidget* border_bin = gtk_util::CreateGtkBorderBin(content_hbox, - &kTextBorderColor, - 1, 1, 1, 0); - GtkWidget* border_bin_aa = gtk_util::CreateGtkBorderBin(border_bin, - &kTextBorderColorAA, - 1, 1, 1, 0); + GtkWidget* border_bin = gfx::CreateGtkBorderBin(content_hbox, + &kTextBorderColor, + 1, 1, 1, 0); + GtkWidget* border_bin_aa = gfx::CreateGtkBorderBin(border_bin, + &kTextBorderColorAA, + 1, 1, 1, 0); GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(centering_vbox), border_bin_aa, TRUE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, 0); diff --git a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc index 2ca6699..682ab0d 100644 --- a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc +++ b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc @@ -6,11 +6,11 @@ #include <gtk/gtk.h> -#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/process_util.h" #include "chrome/browser/browser_list.h" +#include "chrome/common/gtk_util.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/result_codes.h" #include "grit/chromium_strings.h" diff --git a/chrome/browser/gtk/infobar_container_gtk.cc b/chrome/browser/gtk/infobar_container_gtk.cc index 3623497..f560ca1 100644 --- a/chrome/browser/gtk/infobar_container_gtk.cc +++ b/chrome/browser/gtk/infobar_container_gtk.cc @@ -65,7 +65,7 @@ void InfoBarContainerGtk::ChangeTabContents(TabContents* contents) { Source<TabContents>(tab_contents_)); } - gtk_util::RemoveAllChildren(container_.get()); + gfx::RemoveAllChildren(container_.get()); tab_contents_ = contents; if (tab_contents_) { diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc index e129fa9..fcee318 100644 --- a/chrome/browser/gtk/infobar_gtk.cc +++ b/chrome/browser/gtk/infobar_gtk.cc @@ -6,7 +6,6 @@ #include <gtk/gtk.h> -#include "app/gfx/gtk_util.h" #include "base/gfx/gtk_util.h" #include "base/string_util.h" #include "chrome/browser/gtk/custom_button.h" @@ -50,8 +49,8 @@ InfoBar::InfoBar(InfoBarDelegate* delegate) // Set the top border and background color. gtk_widget_modify_bg(bg_box, GTK_STATE_NORMAL, &kBackgroundColor); - border_bin_.Own(gtk_util::CreateGtkBorderBin(bg_box, &kBorderColor, - 0, 1, 0, 0)); + border_bin_.Own(gfx::CreateGtkBorderBin(bg_box, &kBorderColor, + 0, 1, 0, 0)); gtk_widget_set_size_request(border_bin_.get(), -1, kInfoBarHeight); // Add the icon on the left, if any. diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc index 6279b28..5ffac91 100644 --- a/chrome/browser/gtk/menu_gtk.cc +++ b/chrome/browser/gtk/menu_gtk.cc @@ -4,11 +4,11 @@ #include "chrome/browser/gtk/menu_gtk.h" -#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "base/logging.h" #include "base/stl_util-inl.h" #include "base/string_util.h" +#include "chrome/common/gtk_util.h" #include "third_party/skia/include/core/SkBitmap.h" MenuGtk::MenuGtk(MenuGtk::Delegate* delegate, diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index db5ff38..8ca0259 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -188,8 +188,6 @@ '../app/gfx/color_utils.cc', '../app/gfx/color_utils.h', '../app/gfx/favicon_size.h', - '../app/gfx/gtk_util.cc', - '../app/gfx/gtk_util.h', '../app/gfx/icon_util.cc', '../app/gfx/icon_util.h', '../app/gfx/insets.h', @@ -337,6 +335,8 @@ 'common/gfx/emf.cc', 'common/gfx/emf.h', 'common/gfx/utils.h', + 'common/gtk_util.cc', + 'common/gtk_util.h', 'common/net/cookie_monster_sqlite.cc', 'common/net/cookie_monster_sqlite.h', 'common/net/dns.h', @@ -387,8 +387,6 @@ 'common/file_descriptor_set_posix.h', 'common/filter_policy.h', 'common/gears_api.h', - 'common/gtk_util.cc', - 'common/gtk_util.h', 'common/important_file_writer.cc', 'common/important_file_writer.h', 'common/ipc_channel.h', diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index f0d5ea1..d246ccc 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -16,6 +16,10 @@ void RemoveWidget(GtkWidget* widget, gpointer container) { gtk_container_remove(GTK_CONTAINER(container), widget); } +void FreePixels(guchar* pixels, gpointer data) { + free(data); +} + } // namespace namespace event_utils { @@ -33,7 +37,28 @@ WindowOpenDisposition DispositionFromEventFlags(guint event_flags) { } // namespace event_utils -namespace gtk_util { +namespace gfx { + +GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) { + bitmap->lockPixels(); + int width = bitmap->width(); + int height = bitmap->height(); + int stride = bitmap->rowBytes(); + const guchar* orig_data = static_cast<guchar*>(bitmap->getPixels()); + guchar* data = base::BGRAToRGBA(orig_data, width, height, stride); + + // This pixbuf takes ownership of our malloc()ed data and will + // free it for us when it is destroyed. + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( + data, + GDK_COLORSPACE_RGB, // The only colorspace gtk supports. + true, // There is an alpha channel. + 8, + width, height, stride, &FreePixels, data); + + bitmap->unlockPixels(); + return pixbuf; +} GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, int top, int bottom, int left, int right) { @@ -54,4 +79,4 @@ void RemoveAllChildren(GtkWidget* container) { gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); } -} // namespace gtk_util +} // namespace gfx diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h index 9a94182..ff3dc5c 100644 --- a/chrome/common/gtk_util.h +++ b/chrome/common/gtk_util.h @@ -9,7 +9,9 @@ #include "webkit/glue/window_open_disposition.h" +typedef struct _GdkPixbuf GdkPixbuf; typedef struct _GtkWidget GtkWidget; +class SkBitmap; namespace event_utils { @@ -20,9 +22,13 @@ WindowOpenDisposition DispositionFromEventFlags(guint state); } // namespace event_utils -namespace gtk_util { +namespace gfx { - // Create a GtkBin with |child| as its child widget. This bin will paint a +// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so +// it is an expensive operation. +GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap); + +// Create a GtkBin with |child| as its child widget. This bin will paint a // border of color |color| with the sizes specified in pixels. GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, int top, int bottom, int left, int right); @@ -30,6 +36,6 @@ GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, // Remove all children from this container. void RemoveAllChildren(GtkWidget* container); -} // namespace gtk_util +} // namespace gfx #endif // CHROME_COMMON_GTK_UTIL_H_ |