| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/child/image_decoder.h" | 5 #include "content/child/image_decoder.h" |
| 6 | 6 |
| 7 #include "content/public/child/image_decoder_utils.h" | 7 #include "content/public/child/image_decoder_utils.h" |
| 8 #include "third_party/WebKit/public/platform/WebData.h" | 8 #include "third_party/WebKit/public/platform/WebData.h" |
| 9 #include "third_party/WebKit/public/platform/WebImage.h" | 9 #include "third_party/WebKit/public/platform/WebImage.h" |
| 10 #include "third_party/WebKit/public/platform/WebSize.h" | 10 #include "third_party/WebKit/public/platform/WebSize.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 | 12 |
| 13 using WebKit::WebData; | 13 using blink::WebData; |
| 14 using WebKit::WebImage; | 14 using blink::WebImage; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 SkBitmap DecodeImage(const unsigned char* data, | 18 SkBitmap DecodeImage(const unsigned char* data, |
| 19 const gfx::Size& desired_image_size, | 19 const gfx::Size& desired_image_size, |
| 20 size_t size) { | 20 size_t size) { |
| 21 ImageDecoder decoder(desired_image_size); | 21 ImageDecoder decoder(desired_image_size); |
| 22 return decoder.Decode(data, size); | 22 return decoder.Decode(data, size); |
| 23 } | 23 } |
| 24 | 24 |
| 25 ImageDecoder::ImageDecoder() : desired_icon_size_(0, 0) { | 25 ImageDecoder::ImageDecoder() : desired_icon_size_(0, 0) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size) | 28 ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size) |
| 29 : desired_icon_size_(desired_icon_size) { | 29 : desired_icon_size_(desired_icon_size) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 ImageDecoder::~ImageDecoder() { | 32 ImageDecoder::~ImageDecoder() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const { | 35 SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const { |
| 36 const WebImage& image = WebImage::fromData( | 36 const WebImage& image = WebImage::fromData( |
| 37 WebData(reinterpret_cast<const char*>(data), size), desired_icon_size_); | 37 WebData(reinterpret_cast<const char*>(data), size), desired_icon_size_); |
| 38 return image.getSkBitmap(); | 38 return image.getSkBitmap(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // static | 41 // static |
| 42 std::vector<SkBitmap> ImageDecoder::DecodeAll( | 42 std::vector<SkBitmap> ImageDecoder::DecodeAll( |
| 43 const unsigned char* data, size_t size) { | 43 const unsigned char* data, size_t size) { |
| 44 const WebKit::WebVector<WebImage>& images = WebImage::framesFromData( | 44 const blink::WebVector<WebImage>& images = WebImage::framesFromData( |
| 45 WebData(reinterpret_cast<const char*>(data), size)); | 45 WebData(reinterpret_cast<const char*>(data), size)); |
| 46 std::vector<SkBitmap> result; | 46 std::vector<SkBitmap> result; |
| 47 for (size_t i = 0; i < images.size(); ++i) | 47 for (size_t i = 0; i < images.size(); ++i) |
| 48 result.push_back(images[i].getSkBitmap()); | 48 result.push_back(images[i].getSkBitmap()); |
| 49 return result; | 49 return result; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace content | 52 } // namespace content |
| OLD | NEW |