OLD | NEW |
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/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/gfx/gtk_util.h" | 8 #include "base/gfx/gtk_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Check to see if we already have the pixbuf in the cache. | 24 // Check to see if we already have the pixbuf in the cache. |
25 GdkPixbufMap::const_iterator found = gdk_pixbufs_.find(key); | 25 GdkPixbufMap::const_iterator found = gdk_pixbufs_.find(key); |
26 if (found != gdk_pixbufs_.end()) | 26 if (found != gdk_pixbufs_.end()) |
27 return found->second; | 27 return found->second; |
28 | 28 |
29 SkBitmap* bitmap = GetBitmapNamed(id); | 29 SkBitmap* bitmap = GetBitmapNamed(id); |
30 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap); | 30 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap); |
31 | 31 |
32 // We loaded successfully. Cache the pixbuf. | 32 // We loaded successfully. Cache the pixbuf. |
33 if (pixbuf) { | 33 if (pixbuf) { |
| 34 // TODO(benl): reinstate this when the GDK port is upgraded. |
| 35 #if !defined(OS_FREEBSD) |
34 if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && | 36 if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && |
35 rtl_enabled) { | 37 rtl_enabled) { |
36 GdkPixbuf* original_pixbuf = pixbuf; | 38 GdkPixbuf* original_pixbuf = pixbuf; |
37 pixbuf = gdk_pixbuf_flip(pixbuf, TRUE); | 39 pixbuf = gdk_pixbuf_flip(pixbuf, TRUE); |
38 g_object_unref(original_pixbuf); | 40 g_object_unref(original_pixbuf); |
39 } | 41 } |
| 42 #endif |
40 | 43 |
41 gdk_pixbufs_[key] = pixbuf; | 44 gdk_pixbufs_[key] = pixbuf; |
42 return pixbuf; | 45 return pixbuf; |
43 } | 46 } |
44 | 47 |
45 // We failed to retrieve the bitmap, show a debugging red square. | 48 // We failed to retrieve the bitmap, show a debugging red square. |
46 LOG(WARNING) << "Unable to load GdkPixbuf with id " << id; | 49 LOG(WARNING) << "Unable to load GdkPixbuf with id " << id; |
47 NOTREACHED(); // Want to assert in debug mode. | 50 NOTREACHED(); // Want to assert in debug mode. |
48 | 51 |
49 static GdkPixbuf* empty_bitmap = NULL; | 52 static GdkPixbuf* empty_bitmap = NULL; |
(...skipping 12 matching lines...) Expand all Loading... |
62 void BrowserThemeProvider::FreePlatformCaches() { | 65 void BrowserThemeProvider::FreePlatformCaches() { |
63 DCHECK(CalledOnValidThread()); | 66 DCHECK(CalledOnValidThread()); |
64 | 67 |
65 // Free GdkPixbufs. | 68 // Free GdkPixbufs. |
66 for (GdkPixbufMap::iterator i = gdk_pixbufs_.begin(); | 69 for (GdkPixbufMap::iterator i = gdk_pixbufs_.begin(); |
67 i != gdk_pixbufs_.end(); i++) { | 70 i != gdk_pixbufs_.end(); i++) { |
68 g_object_unref(i->second); | 71 g_object_unref(i->second); |
69 } | 72 } |
70 gdk_pixbufs_.clear(); | 73 gdk_pixbufs_.clear(); |
71 } | 74 } |
OLD | NEW |