| 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/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 "app/gfx/codec/png_codec.h" | 
| 11 #include "base/file_util.h" | 12 #include "base/file_util.h" | 
| 12 #include "base/gfx/png_decoder.h" |  | 
| 13 #include "base/logging.h" | 13 #include "base/logging.h" | 
| 14 #include "base/linux_util.h" | 14 #include "base/linux_util.h" | 
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" | 
| 16 #include "base/mime_util.h" | 16 #include "base/mime_util.h" | 
| 17 #include "base/thread.h" | 17 #include "base/thread.h" | 
| 18 #include "base/string_util.h" | 18 #include "base/string_util.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; | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 = base::BGRAToRGBA(pixels, width, height, stride); | 
| 64       std::vector<unsigned char> pixel_vector; | 64       std::vector<unsigned char> pixel_vector; | 
| 65       pixel_vector.resize(height * stride); | 65       pixel_vector.resize(height * stride); | 
| 66       memcpy(const_cast<unsigned char*>(pixel_vector.data()), BGRA_pixels, | 66       memcpy(const_cast<unsigned char*>(pixel_vector.data()), BGRA_pixels, | 
| 67              height * stride); | 67              height * stride); | 
| 68       bitmap_ = PNGDecoder::CreateSkBitmapFromBGRAFormat(pixel_vector, | 68       bitmap_ = gfx::PNGCodec::CreateSkBitmapFromBGRAFormat(pixel_vector, | 
| 69                                                          width, height); | 69                                                             width, height); | 
| 70       free(BGRA_pixels); | 70       free(BGRA_pixels); | 
| 71     } | 71     } | 
| 72   } else { | 72   } else { | 
| 73     LOG(WARNING) << "Unsupported file type or load error: " << | 73     LOG(WARNING) << "Unsupported file type or load error: " << | 
| 74                     filename_.value(); | 74                     filename_.value(); | 
| 75   } | 75   } | 
| 76 | 76 | 
| 77   g_object_unref(loader); | 77   g_object_unref(loader); | 
| 78 | 78 | 
| 79   NotifyDelegate(); | 79   NotifyDelegate(); | 
| 80 } | 80 } | 
| OLD | NEW | 
|---|