summaryrefslogtreecommitdiffstats
path: root/webkit/glue/image_decoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/image_decoder.cc')
-rw-r--r--webkit/glue/image_decoder.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/webkit/glue/image_decoder.cc b/webkit/glue/image_decoder.cc
new file mode 100644
index 0000000..6850909
--- /dev/null
+++ b/webkit/glue/image_decoder.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/glue/image_decoder.h"
+
+#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebImage.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+#if WEBKIT_USING_CG
+#include "skia/ext/skia_utils_mac.h"
+#endif
+
+using WebKit::WebData;
+using WebKit::WebImage;
+
+namespace webkit_glue {
+
+ImageDecoder::ImageDecoder() : desired_icon_size_(0, 0) {
+}
+
+ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size)
+ : desired_icon_size_(desired_icon_size) {
+}
+
+ImageDecoder::~ImageDecoder() {
+}
+
+SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const {
+ const WebImage& image = WebImage::fromData(
+ WebData(reinterpret_cast<const char*>(data), size), desired_icon_size_);
+#if WEBKIT_USING_SKIA
+ return image.getSkBitmap();
+#elif WEBKIT_USING_CG
+ return gfx::CGImageToSkBitmap(image.getCGImageRef());
+#endif
+}
+
+} // namespace webkit_glue