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

Side by Side Diff: ui/base/resource/resource_bundle_linux.cc

Issue 7977025: aura: Make 'ui' buildable without gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 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 | « ui/base/resource/resource_bundle.h ('k') | ui/gfx/canvas_skia.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <gtk/gtk.h>
8
9 #include "base/base_paths.h" 7 #include "base/base_paths.h"
10 #include "base/file_path.h" 8 #include "base/file_path.h"
11 #include "base/file_util.h" 9 #include "base/file_util.h"
12 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
13 #include "base/logging.h" 11 #include "base/logging.h"
14 #include "base/path_service.h" 12 #include "base/path_service.h"
15 #include "base/string_piece.h" 13 #include "base/string_piece.h"
16 #include "base/string_util.h" 14 #include "base/string_util.h"
17 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/base/ui_base_paths.h" 17 #include "ui/base/ui_base_paths.h"
20 #include "ui/gfx/font.h" 18 #include "ui/gfx/font.h"
21 #include "ui/gfx/gtk_util.h" 19 #include "ui/gfx/gtk_util.h"
22 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
23 21
22 #if defined(TOOLKIT_USES_GTK)
23 #include <gtk/gtk.h>
24 #endif
25
24 namespace ui { 26 namespace ui {
25 27
28 #if defined(TOOLKIT_USES_GTK)
26 namespace { 29 namespace {
27 30
28 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned 31 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned
29 // has a ref count of 1 so the caller must call g_object_unref to free the 32 // has a ref count of 1 so the caller must call g_object_unref to free the
30 // memory. 33 // memory.
31 GdkPixbuf* LoadPixbuf(RefCountedStaticMemory* data, bool rtl_enabled) { 34 GdkPixbuf* LoadPixbuf(RefCountedStaticMemory* data, bool rtl_enabled) {
32 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); 35 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new());
33 bool ok = data && gdk_pixbuf_loader_write(loader.get(), 36 bool ok = data && gdk_pixbuf_loader_write(loader.get(),
34 reinterpret_cast<const guint8*>(data->front()), data->size(), NULL); 37 reinterpret_cast<const guint8*>(data->front()), data->size(), NULL);
35 if (!ok) 38 if (!ok)
(...skipping 14 matching lines...) Expand all
50 } else { 53 } else {
51 // The pixbuf is owned by the loader, so add a ref so when we delete the 54 // The pixbuf is owned by the loader, so add a ref so when we delete the
52 // loader (when the ScopedGObject goes out of scope), the pixbuf still 55 // loader (when the ScopedGObject goes out of scope), the pixbuf still
53 // exists. 56 // exists.
54 g_object_ref(pixbuf); 57 g_object_ref(pixbuf);
55 return pixbuf; 58 return pixbuf;
56 } 59 }
57 } 60 }
58 61
59 } // namespace 62 } // namespace
63 #endif // defined(TOOLKIT_USES_GTK)
60 64
61 // static 65 // static
62 FilePath ResourceBundle::GetResourcesFilePath() { 66 FilePath ResourceBundle::GetResourcesFilePath() {
63 FilePath resources_file_path; 67 FilePath resources_file_path;
64 PathService::Get(ui::FILE_RESOURCES_PAK, &resources_file_path); 68 PathService::Get(ui::FILE_RESOURCES_PAK, &resources_file_path);
65 return resources_file_path; 69 return resources_file_path;
66 } 70 }
67 71
68 // static 72 // static
69 FilePath ResourceBundle::GetLargeIconResourcesFilePath() { 73 FilePath ResourceBundle::GetLargeIconResourcesFilePath() {
70 // Not supported. 74 // Not supported.
71 return FilePath(); 75 return FilePath();
72 } 76 }
73 77
74 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) { 78 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
79 #if defined(TOOLKIT_USES_GTK)
75 return *GetPixbufImpl(resource_id, false); 80 return *GetPixbufImpl(resource_id, false);
81 #else
82 static gfx::Image image(NULL);
83 return image;
84 #endif
76 } 85 }
77 86
87 #if defined(TOOLKIT_USES_GTK)
78 gfx::Image* ResourceBundle::GetPixbufImpl(int resource_id, bool rtl_enabled) { 88 gfx::Image* ResourceBundle::GetPixbufImpl(int resource_id, bool rtl_enabled) {
79 // Use the negative |resource_id| for the key for BIDI-aware images. 89 // Use the negative |resource_id| for the key for BIDI-aware images.
80 int key = rtl_enabled ? -resource_id : resource_id; 90 int key = rtl_enabled ? -resource_id : resource_id;
81 91
82 // Check to see if the image is already in the cache. 92 // Check to see if the image is already in the cache.
83 { 93 {
84 base::AutoLock lock_scope(*lock_); 94 base::AutoLock lock_scope(*lock_);
85 ImageMap::const_iterator found = images_.find(key); 95 ImageMap::const_iterator found = images_.find(key);
86 if (found != images_.end()) 96 if (found != images_.end())
87 return found->second; 97 return found->second;
(...skipping 19 matching lines...) Expand all
107 } 117 }
108 118
109 LOG(WARNING) << "Unable to pixbuf with id " << resource_id; 119 LOG(WARNING) << "Unable to pixbuf with id " << resource_id;
110 NOTREACHED(); // Want to assert in debug mode. 120 NOTREACHED(); // Want to assert in debug mode.
111 return GetEmptyImage(); 121 return GetEmptyImage();
112 } 122 }
113 123
114 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) { 124 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) {
115 return *GetPixbufImpl(resource_id, true); 125 return *GetPixbufImpl(resource_id, true);
116 } 126 }
127 #endif // defined(TOOLKIT_USES_GTK)
117 128
118 } // namespace ui 129 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.h ('k') | ui/gfx/canvas_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698