OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 "webkit/glue/image_decoder.h" | 5 #include "webkit/glue/image_decoder.h" |
6 | 6 |
7 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" | 7 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
11 | 11 |
12 #if WEBKIT_USING_CG | |
13 #include "skia/ext/skia_utils_mac.h" | |
14 #endif | |
15 | |
16 using WebKit::WebData; | 12 using WebKit::WebData; |
17 using WebKit::WebImage; | 13 using WebKit::WebImage; |
18 | 14 |
19 namespace webkit_glue { | 15 namespace webkit_glue { |
20 | 16 |
21 ImageDecoder::ImageDecoder() : desired_icon_size_(0, 0) { | 17 ImageDecoder::ImageDecoder() : desired_icon_size_(0, 0) { |
22 } | 18 } |
23 | 19 |
24 ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size) | 20 ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size) |
25 : desired_icon_size_(desired_icon_size) { | 21 : desired_icon_size_(desired_icon_size) { |
26 } | 22 } |
27 | 23 |
28 ImageDecoder::~ImageDecoder() { | 24 ImageDecoder::~ImageDecoder() { |
29 } | 25 } |
30 | 26 |
31 SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const { | 27 SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const { |
32 const WebImage& image = WebImage::fromData( | 28 const WebImage& image = WebImage::fromData( |
33 WebData(reinterpret_cast<const char*>(data), size), desired_icon_size_); | 29 WebData(reinterpret_cast<const char*>(data), size), desired_icon_size_); |
34 #if WEBKIT_USING_SKIA | |
35 return image.getSkBitmap(); | 30 return image.getSkBitmap(); |
36 #elif WEBKIT_USING_CG | |
37 return gfx::CGImageToSkBitmap(image.getCGImageRef()); | |
38 #endif | |
39 } | 31 } |
40 | 32 |
41 } // namespace webkit_glue | 33 } // namespace webkit_glue |
OLD | NEW |