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

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

Issue 2058004: Move non-linux specific code from base/linux_util to app/gtk_util... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 7 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
« app/gtk_util.h ('K') | « base/linux_util.cc ('k') | no next file » | 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/icon_loader.h" 5 #include "chrome/browser/icon_loader.h"
6 6
7 #include <gdk-pixbuf/gdk-pixbuf.h> 7 #include <gdk-pixbuf/gdk-pixbuf.h>
8 #include <gio/gio.h> 8 #include <gio/gio.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/linux_util.h" 13 #include "app/gtk_util.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/mime_util.h" 15 #include "base/mime_util.h"
16 #include "base/thread.h" 16 #include "base/thread.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "gfx/codec/png_codec.h" 18 #include "gfx/codec/png_codec.h"
19 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkBitmap.h"
20 20
21 static int SizeToInt(IconLoader::IconSize size) { 21 static int SizeToInt(IconLoader::IconSize size) {
22 int pixels = 48; 22 int pixels = 48;
23 if (size == IconLoader::NORMAL) 23 if (size == IconLoader::NORMAL)
(...skipping 29 matching lines...) Expand all
53 guchar* pixels = gdk_pixbuf_get_pixels(pixbuf); 53 guchar* pixels = gdk_pixbuf_get_pixels(pixbuf);
54 int width = gdk_pixbuf_get_width(pixbuf); 54 int width = gdk_pixbuf_get_width(pixbuf);
55 int height = gdk_pixbuf_get_height(pixbuf); 55 int height = gdk_pixbuf_get_height(pixbuf);
56 DCHECK_EQ(width, size); 56 DCHECK_EQ(width, size);
57 DCHECK_EQ(height, size); 57 DCHECK_EQ(height, size);
58 int stride = gdk_pixbuf_get_rowstride(pixbuf); 58 int stride = gdk_pixbuf_get_rowstride(pixbuf);
59 59
60 if (!gdk_pixbuf_get_has_alpha(pixbuf)) { 60 if (!gdk_pixbuf_get_has_alpha(pixbuf)) {
61 LOG(WARNING) << "Got an image with no alpha channel, aborting load."; 61 LOG(WARNING) << "Got an image with no alpha channel, aborting load.";
62 } else { 62 } else {
63 uint8_t* BGRA_pixels = base::BGRAToRGBA(pixels, width, height, stride); 63 uint8_t* BGRA_pixels =
64 gtk_util::BGRAToRGBA(pixels, width, height, stride);
64 std::vector<unsigned char> pixel_vector; 65 std::vector<unsigned char> pixel_vector;
65 pixel_vector.resize(height * stride); 66 pixel_vector.resize(height * stride);
66 memcpy(const_cast<unsigned char*>(pixel_vector.data()), BGRA_pixels, 67 memcpy(const_cast<unsigned char*>(pixel_vector.data()), BGRA_pixels,
67 height * stride); 68 height * stride);
68 bitmap_ = gfx::PNGCodec::CreateSkBitmapFromBGRAFormat(pixel_vector, 69 bitmap_ = gfx::PNGCodec::CreateSkBitmapFromBGRAFormat(pixel_vector,
69 width, height); 70 width, height);
70 free(BGRA_pixels); 71 free(BGRA_pixels);
71 } 72 }
72 } else { 73 } else {
73 LOG(WARNING) << "Unsupported file type or load error: " << 74 LOG(WARNING) << "Unsupported file type or load error: " <<
74 filename_.value(); 75 filename_.value();
75 } 76 }
76 77
77 g_object_unref(loader); 78 g_object_unref(loader);
78 79
79 NotifyDelegate(); 80 NotifyDelegate();
80 } 81 }
OLDNEW
« app/gtk_util.h ('K') | « base/linux_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698