Roll src/third_party/WebKit 9301d6f:4619053 (svn 201058:201059)
[chromium-blink-merge.git] / content / child / image_decoder.h
blob535c4231c9043a2f2d89fb3ae43b90c4d9cfe136
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
3 // found in the LICENSE file.
5 #include <vector>
7 #include "base/basictypes.h"
8 #include "ui/gfx/geometry/size.h"
10 class SkBitmap;
12 namespace content {
14 // Provides an interface to WebKit's image decoders.
16 // Note to future: This class should be deleted. We should have our own nice
17 // image decoders in base/gfx, and our port should use those. Currently, it's
18 // the other way around.
19 class ImageDecoder {
20 public:
21 // Use the constructor with desired_size when you think you may have an .ico
22 // format and care about which size you get back. Otherwise, use the 0-arg
23 // constructor.
24 ImageDecoder();
25 ImageDecoder(const gfx::Size& desired_icon_size);
26 ~ImageDecoder();
28 // Call this function to decode the image. If successful, the decoded image
29 // will be returned. Otherwise, an empty bitmap will be returned.
30 SkBitmap Decode(const unsigned char* data, size_t size) const;
32 // Returns all frames found in the image represented by data. If there are
33 // multiple frames at the same size, only the first one is returned.
34 static std::vector<SkBitmap> DecodeAll(
35 const unsigned char* data, size_t size);
37 private:
38 // Size will be empty to get the largest possible size.
39 gfx::Size desired_icon_size_;
41 DISALLOW_COPY_AND_ASSIGN(ImageDecoder);
44 } // namespace content