Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 11 #include "ui/gfx/image/image_skia.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 | 14 |
| 15 // Wrapper class storing a still image and it's raw representation. Could be | 15 // Wrapper class storing a still image and it's raw representation. Could be |
| 16 // used for storing profile images (including animated profile images) and user | 16 // used for storing profile images (including animated profile images) and user |
| 17 // wallpapers. | 17 // wallpapers. |
| 18 class UserImage { | 18 class UserImage { |
| 19 public: | 19 public: |
| 20 // TODO(ivankr): replace with RefCountedMemory to prevent copying. | 20 // TODO(ivankr): replace with RefCountedMemory to prevent copying. |
| 21 typedef std::vector<unsigned char> RawImage; | 21 typedef std::vector<unsigned char> RawImage; |
| 22 | 22 |
| 23 // Creates a new instance from a given still frame and tries to encode raw | |
| 24 // representation for it. | |
| 25 static UserImage CreateAndEncode(const gfx::ImageSkia& image); | |
|
Nikita (slow)
2012/08/01 03:56:18
const UserImage&
| |
| 26 | |
| 23 // Create instance with an empty still frame and no raw data. | 27 // Create instance with an empty still frame and no raw data. |
| 24 UserImage(); | 28 UserImage(); |
| 25 | 29 |
| 26 // Creates a new instance from a given still frame without any raw data. | 30 // creates a new instance from a given still frame without any raw data. |
|
Nikita (slow)
2012/08/01 03:56:18
nit: capitalize
Ivan Korotkov
2012/08/01 21:51:28
Done.
| |
| 27 explicit UserImage(const gfx::ImageSkia& image); | 31 explicit UserImage(const gfx::ImageSkia& image); |
| 28 | 32 |
| 29 // Creates a new instance from a given still frame and raw representation. | 33 // Creates a new instance from a given still frame and raw representation. |
| 30 // |raw_image| can be animated, in which case animated_image() will return the | 34 // |raw_image| can be animated, in which case animated_image() will return the |
| 31 // original |raw_image| and raw_image() will return the encoded representation | 35 // original |raw_image| and raw_image() will return the encoded representation |
| 32 // of |image|. | 36 // of |image|. |
| 33 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); | 37 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); |
| 34 | 38 |
| 35 virtual ~UserImage(); | 39 virtual ~UserImage(); |
| 36 | 40 |
| 37 const gfx::ImageSkia& image() const { return image_; } | 41 const gfx::ImageSkia& image() const { return image_; } |
| 38 | 42 |
| 39 // Optional raw representation of the still image. | 43 // Optional raw representation of the still image. |
| 40 bool has_raw_image() const { return has_raw_image_; } | 44 bool has_raw_image() const { return has_raw_image_; } |
| 41 const RawImage& raw_image() const { return raw_image_; } | 45 const RawImage& raw_image() const { return raw_image_; } |
| 42 | 46 |
| 47 // Discards the stored raw image, freeing used memory. | |
| 48 void DiscardRawImage(); | |
| 49 | |
| 43 // Optional raw representation of the animated image. | 50 // Optional raw representation of the animated image. |
| 44 bool has_animated_image() const { return has_animated_image_; } | 51 bool has_animated_image() const { return has_animated_image_; } |
| 45 const RawImage& animated_image() const { return animated_image_; } | 52 const RawImage& animated_image() const { return animated_image_; } |
| 46 | 53 |
| 47 // URL from which this image was originally downloaded, if any. | 54 // URL from which this image was originally downloaded, if any. |
| 48 void set_url(const GURL& url) { url_ = url; } | 55 void set_url(const GURL& url) { url_ = url; } |
| 49 GURL url() const { return url_; } | 56 GURL url() const { return url_; } |
| 50 | 57 |
| 51 private: | 58 private: |
| 52 gfx::ImageSkia image_; | 59 gfx::ImageSkia image_; |
| 53 bool has_raw_image_; | 60 bool has_raw_image_; |
| 54 RawImage raw_image_; | 61 RawImage raw_image_; |
| 55 bool has_animated_image_; | 62 bool has_animated_image_; |
| 56 RawImage animated_image_; | 63 RawImage animated_image_; |
| 57 GURL url_; | 64 GURL url_; |
| 58 }; | 65 }; |
| 59 | 66 |
| 60 } // namespace chromeos | 67 } // namespace chromeos |
| 61 | 68 |
| 62 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_ | 69 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_ |
| OLD | NEW |