summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/nine_box.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-20 20:21:13 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-20 20:21:13 +0000
commit8fcc39da6cd2a6ea148886e2d8333fc02bd62a21 (patch)
tree09dbcbaa42b748b54c923461a951d10df79327b6 /chrome/browser/gtk/nine_box.cc
parent9f50a2f07eb717f613b7cada7e25bfa6e3c79de2 (diff)
downloadchromium_src-8fcc39da6cd2a6ea148886e2d8333fc02bd62a21.zip
chromium_src-8fcc39da6cd2a6ea148886e2d8333fc02bd62a21.tar.gz
chromium_src-8fcc39da6cd2a6ea148886e2d8333fc02bd62a21.tar.bz2
Add GetPixbufNamed to ThemeProvider. GetPixbufNamed converts a loaded theme bitmap to a GdkPixbuf and caches the image so ThemeProvider users don't need to release them ala ResourceBundle::GetPixbufNamed.
Review URL: http://codereview.chromium.org/113626 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/nine_box.cc')
-rw-r--r--chrome/browser/gtk/nine_box.cc34
1 files changed, 11 insertions, 23 deletions
diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc
index 9fb6a52..e1f3aa6 100644
--- a/chrome/browser/gtk/nine_box.cc
+++ b/chrome/browser/gtk/nine_box.cc
@@ -28,15 +28,10 @@ void TileImage(cairo_t* cr, GdkPixbuf* src,
cairo_fill(cr);
}
-GdkPixbuf* GetPixbufNamed(ThemeProvider* theme_provider, int name) {
- return gfx::GdkPixbufFromSkBitmap(theme_provider->GetBitmapNamed(name));
-}
-
} // namespace
NineBox::NineBox(int top_left, int top, int top_right, int left, int center,
- int right, int bottom_left, int bottom, int bottom_right)
- : ninebox_owns_images_(false) {
+ int right, int bottom_left, int bottom, int bottom_right) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
images_[0] = top_left ? rb.GetPixbufNamed(top_left) : NULL;
images_[1] = top ? rb.GetPixbufNamed(top) : NULL;
@@ -51,35 +46,28 @@ NineBox::NineBox(int top_left, int top, int top_right, int left, int center,
NineBox::NineBox(ThemeProvider* theme_provider,
int top_left, int top, int top_right, int left, int center,
- int right, int bottom_left, int bottom, int bottom_right)
- : ninebox_owns_images_(true) {
+ int right, int bottom_left, int bottom, int bottom_right) {
images_[0] = top_left ?
- GetPixbufNamed(theme_provider, top_left) : NULL;
+ theme_provider->GetPixbufNamed(top_left) : NULL;
images_[1] = top ?
- GetPixbufNamed(theme_provider, top) : NULL;
+ theme_provider->GetPixbufNamed(top) : NULL;
images_[2] = top_right ?
- GetPixbufNamed(theme_provider, top_right) : NULL;
+ theme_provider->GetPixbufNamed(top_right) : NULL;
images_[3] = left ?
- GetPixbufNamed(theme_provider, left) : NULL;
+ theme_provider->GetPixbufNamed(left) : NULL;
images_[4] = center ?
- GetPixbufNamed(theme_provider, center) : NULL;
+ theme_provider->GetPixbufNamed(center) : NULL;
images_[5] = right ?
- GetPixbufNamed(theme_provider, right) : NULL;
+ theme_provider->GetPixbufNamed(right) : NULL;
images_[6] = bottom_left ?
- GetPixbufNamed(theme_provider, bottom_left) : NULL;
+ theme_provider->GetPixbufNamed(bottom_left) : NULL;
images_[7] = bottom ?
- GetPixbufNamed(theme_provider, bottom) : NULL;
+ theme_provider->GetPixbufNamed(bottom) : NULL;
images_[8] = bottom_right ?
- GetPixbufNamed(theme_provider, bottom_right) : NULL;
+ theme_provider->GetPixbufNamed(bottom_right) : NULL;
}
NineBox::~NineBox() {
- if (ninebox_owns_images_) {
- for (size_t i = 0; i < 9; i++) {
- if (images_[i])
- g_object_unref(images_[i]);
- }
- }
}
void NineBox::RenderToWidget(GtkWidget* dst) const {