Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: chrome/browser/browser_theme_provider_gtk.cc

Issue 272033: Misc. cleanup for theme provider code, including:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_theme_provider.cc ('k') | chrome/browser/browser_theme_provider_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browser_theme_provider.h" 5 #include "chrome/browser/browser_theme_provider.h"
6 6
7 #include "app/gfx/gtk_util.h" 7 #include "app/gfx/gtk_util.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
11 11
12 GdkPixbuf* BrowserThemeProvider::GetPixbufNamed(int id) { 12 GdkPixbuf* BrowserThemeProvider::GetPixbufNamed(int id) {
13 return GetPixbufImpl(id, false); 13 return GetPixbufImpl(id, false);
14 } 14 }
15 15
16 GdkPixbuf* BrowserThemeProvider::GetRTLEnabledPixbufNamed(int id) { 16 GdkPixbuf* BrowserThemeProvider::GetRTLEnabledPixbufNamed(int id) {
17 return GetPixbufImpl(id, true); 17 return GetPixbufImpl(id, true);
18 } 18 }
19 19
20 GdkPixbuf* BrowserThemeProvider::GetPixbufImpl(int id, bool rtl_enabled) { 20 GdkPixbuf* BrowserThemeProvider::GetPixbufImpl(int id, bool rtl_enabled) {
21 DCHECK(CalledOnValidThread()); 21 DCHECK(CalledOnValidThread());
22 // Use the negative |resource_id| for the key for BIDI-aware images. 22 // Use the negative |resource_id| for the key for BIDI-aware images.
23 int key = rtl_enabled ? -id : id; 23 int key = rtl_enabled ? -id : id;
24 24
25 // Check to see if we already have the pixbuf in the cache. 25 // Check to see if we already have the pixbuf in the cache.
26 GdkPixbufMap::const_iterator found = gdk_pixbufs_.find(key); 26 GdkPixbufMap::const_iterator pixbufs_iter = gdk_pixbufs_.find(key);
27 if (found != gdk_pixbufs_.end()) 27 if (pixbufs_iter != gdk_pixbufs_.end())
28 return found->second; 28 return pixbufs_iter->second;
29 29
30 SkBitmap* bitmap = GetBitmapNamed(id); 30 SkBitmap* bitmap = GetBitmapNamed(id);
31 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap); 31 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap);
32 32
33 // We loaded successfully. Cache the pixbuf. 33 // We loaded successfully. Cache the pixbuf.
34 if (pixbuf) { 34 if (pixbuf) {
35 if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && 35 if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) &&
36 rtl_enabled) { 36 rtl_enabled) {
37 GdkPixbuf* original_pixbuf = pixbuf; 37 GdkPixbuf* original_pixbuf = pixbuf;
38 pixbuf = gdk_pixbuf_flip(pixbuf, TRUE); 38 pixbuf = gdk_pixbuf_flip(pixbuf, TRUE);
(...skipping 24 matching lines...) Expand all
63 void BrowserThemeProvider::FreePlatformCaches() { 63 void BrowserThemeProvider::FreePlatformCaches() {
64 DCHECK(CalledOnValidThread()); 64 DCHECK(CalledOnValidThread());
65 65
66 // Free GdkPixbufs. 66 // Free GdkPixbufs.
67 for (GdkPixbufMap::iterator i = gdk_pixbufs_.begin(); 67 for (GdkPixbufMap::iterator i = gdk_pixbufs_.begin();
68 i != gdk_pixbufs_.end(); i++) { 68 i != gdk_pixbufs_.end(); i++) {
69 g_object_unref(i->second); 69 g_object_unref(i->second);
70 } 70 }
71 gdk_pixbufs_.clear(); 71 gdk_pixbufs_.clear();
72 } 72 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_theme_provider.cc ('k') | chrome/browser/browser_theme_provider_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698