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

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

Issue 126103003: Changed RefCountedStaticMemory() to accept a void pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 10 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
« no previous file with comments | « ui/base/resource/resource_bundle.cc ('k') | ui/base/resource/resource_data_dll_win.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 10 matching lines...) Expand all
21 namespace ui { 21 namespace ui {
22 22
23 namespace { 23 namespace {
24 24
25 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned 25 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned
26 // has a ref count of 1 so the caller must call g_object_unref to free the 26 // has a ref count of 1 so the caller must call g_object_unref to free the
27 // memory. 27 // memory.
28 GdkPixbuf* LoadPixbuf(base::RefCountedStaticMemory* data, bool rtl_enabled) { 28 GdkPixbuf* LoadPixbuf(base::RefCountedStaticMemory* data, bool rtl_enabled) {
29 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); 29 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new());
30 bool ok = data && gdk_pixbuf_loader_write(loader.get(), 30 bool ok = data && gdk_pixbuf_loader_write(loader.get(),
31 reinterpret_cast<const guint8*>(data->front()), data->size(), NULL); 31 data->front_as<guint8>(), data->size(), NULL);
32 if (!ok) 32 if (!ok)
33 return NULL; 33 return NULL;
34 // Calling gdk_pixbuf_loader_close forces the data to be parsed by the 34 // Calling gdk_pixbuf_loader_close forces the data to be parsed by the
35 // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf. 35 // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf.
36 ok = gdk_pixbuf_loader_close(loader.get(), NULL); 36 ok = gdk_pixbuf_loader_close(loader.get(), NULL);
37 if (!ok) 37 if (!ok)
38 return NULL; 38 return NULL;
39 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get()); 39 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get());
40 if (!pixbuf) 40 if (!pixbuf)
41 return NULL; 41 return NULL;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 // Another thread raced the load and has already cached the image. 104 // Another thread raced the load and has already cached the image.
105 if (images_.count(key)) 105 if (images_.count(key))
106 return images_[key]; 106 return images_[key];
107 107
108 images_[key] = image; 108 images_[key] = image;
109 return images_[key]; 109 return images_[key];
110 } 110 }
111 111
112 } // namespace ui 112 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.cc ('k') | ui/base/resource/resource_data_dll_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698