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

Side by Side Diff: content/child/image_decoder.cc

Issue 17704002: Move image_decoder.cc/.h from webkit\glue to content\child. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 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 "webkit/glue/image_decoder.h" 5 #include "content/child/image_decoder.h"
6 6
7 #include "content/public/child/image_decoder_utils.h"
7 #include "third_party/WebKit/public/platform/WebData.h" 8 #include "third_party/WebKit/public/platform/WebData.h"
8 #include "third_party/WebKit/public/platform/WebImage.h" 9 #include "third_party/WebKit/public/platform/WebImage.h"
9 #include "third_party/WebKit/public/platform/WebSize.h" 10 #include "third_party/WebKit/public/platform/WebSize.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
11 12
12 using WebKit::WebData; 13 using WebKit::WebData;
13 using WebKit::WebImage; 14 using WebKit::WebImage;
14 15
15 namespace webkit_glue { 16 namespace content {
17
18 SkBitmap DecodeImage(const unsigned char* data,
19 const gfx::Size& desired_image_size,
20 size_t size) {
21 ImageDecoder decoder(desired_image_size);
22 return decoder.Decode(data, size);
23 }
16 24
17 ImageDecoder::ImageDecoder() : desired_icon_size_(0, 0) { 25 ImageDecoder::ImageDecoder() : desired_icon_size_(0, 0) {
18 } 26 }
19 27
20 ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size) 28 ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size)
21 : desired_icon_size_(desired_icon_size) { 29 : desired_icon_size_(desired_icon_size) {
22 } 30 }
23 31
24 ImageDecoder::~ImageDecoder() { 32 ImageDecoder::~ImageDecoder() {
25 } 33 }
26 34
27 SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const { 35 SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const {
28 const WebImage& image = WebImage::fromData( 36 const WebImage& image = WebImage::fromData(
29 WebData(reinterpret_cast<const char*>(data), size), desired_icon_size_); 37 WebData(reinterpret_cast<const char*>(data), size), desired_icon_size_);
30 return image.getSkBitmap(); 38 return image.getSkBitmap();
31 } 39 }
32 40
33 // static 41 // static
34 std::vector<SkBitmap> ImageDecoder::DecodeAll( 42 std::vector<SkBitmap> ImageDecoder::DecodeAll(
35 const unsigned char* data, size_t size) { 43 const unsigned char* data, size_t size) {
36 const WebKit::WebVector<WebImage>& images = WebImage::framesFromData( 44 const WebKit::WebVector<WebImage>& images = WebImage::framesFromData(
37 WebData(reinterpret_cast<const char*>(data), size)); 45 WebData(reinterpret_cast<const char*>(data), size));
38 std::vector<SkBitmap> result; 46 std::vector<SkBitmap> result;
39 for (size_t i = 0; i < images.size(); ++i) 47 for (size_t i = 0; i < images.size(); ++i)
40 result.push_back(images[i].getSkBitmap()); 48 result.push_back(images[i].getSkBitmap());
41 return result; 49 return result;
42 } 50 }
43 51
44 } // namespace webkit_glue 52 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698