| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "ui/gfx/size.h" | 8 #include "ui/gfx/size.h" |
| 9 #include "webkit/glue/webkit_glue_export.h" | 9 #include "webkit/glue/webkit_glue_export.h" |
| 10 | 10 |
| 11 class SkBitmap; | 11 class SkBitmap; |
| 12 | 12 |
| 13 namespace webkit_glue { | 13 namespace webkit_glue { |
| 14 | 14 |
| 15 // Provides an interface to WebKit's image decoders. | 15 // Provides an interface to WebKit's image decoders. |
| 16 // | 16 // |
| 17 // Note to future: This class should be deleted. We should have our own nice | 17 // Note to future: This class should be deleted. We should have our own nice |
| 18 // image decoders in base/gfx, and our port should use those. Currently, it's | 18 // image decoders in base/gfx, and our port should use those. Currently, it's |
| 19 // the other way around. | 19 // the other way around. |
| 20 class WEBKIT_GLUE_EXPORT ImageDecoder { | 20 class WEBKIT_GLUE_EXPORT ImageDecoder { |
| 21 public: | 21 public: |
| 22 // Use the constructor with desired_size when you think you may have an .ico | 22 // Use the constructor with desired_size when you think you may have an .ico |
| 23 // format and care about which size you get back. Otherwise, use the 0-arg | 23 // format and care about which size you get back. Otherwise, use the 0-arg |
| 24 // constructor. | 24 // constructor. |
| 25 ImageDecoder(); | 25 ImageDecoder(); |
| 26 ImageDecoder(const gfx::Size& desired_icon_size); | 26 explicit ImageDecoder(const gfx::Size& desired_icon_size); |
| 27 ~ImageDecoder(); | 27 ~ImageDecoder(); |
| 28 | 28 |
| 29 // Call this function to decode the image. If successful, the decoded image | 29 // Call this function to decode the image. If successful, the decoded image |
| 30 // will be returned. Otherwise, an empty bitmap will be returned. | 30 // will be returned. Otherwise, an empty bitmap will be returned. |
| 31 SkBitmap Decode(const unsigned char* data, size_t size) const; | 31 SkBitmap Decode(const unsigned char* data, size_t size) const; |
| 32 | 32 |
| 33 // Returns all frames found in the image represented by data. If there are | 33 // Returns all frames found in the image represented by data. If there are |
| 34 // multiple frames at the same size, only the first one is returned. | 34 // multiple frames at the same size, only the first one is returned. |
| 35 static std::vector<SkBitmap> DecodeAll( | 35 static std::vector<SkBitmap> DecodeAll( |
| 36 const unsigned char* data, size_t size); | 36 const unsigned char* data, size_t size); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // Size will be empty to get the largest possible size. | 39 // Size will be empty to get the largest possible size. |
| 40 gfx::Size desired_icon_size_; | 40 gfx::Size desired_icon_size_; |
| 41 | 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 42 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 } // namespace webkit_glue | 45 } // namespace webkit_glue |
| OLD | NEW |