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

Side by Side Diff: chrome/browser/chromeos/login/user_image.h

Issue 10831064: [cros] Remove redundant PNG enconding in UserImage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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) 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 for bitmaps and raw images when it's necessary. Could 15 // Wrapper class storing a still image and it's raw representation. Could be
16 // be used for storing profile images (including animated profile 16 // used for storing profile images (including animated profile images) and user
17 // images) and user wallpapers. 17 // wallpapers.
18 class UserImage { 18 class UserImage {
19 public: 19 public:
20 // TODO(ivankr): replace with RefCountedMemory to prevent copying.
20 typedef std::vector<unsigned char> RawImage; 21 typedef std::vector<unsigned char> RawImage;
21 22
22 // Constructs UserImage from bitmap. Should be used where only 23 // Create instance with an empty still frame and no raw data.
23 // static image is needed (e.g. wallpapers). 24 UserImage();
25
26 // Creates a new instance from a given still frame without any raw data.
24 explicit UserImage(const gfx::ImageSkia& image); 27 explicit UserImage(const gfx::ImageSkia& image);
25 28
26 // Constructs UserImage from raw image and bitmap that should 29 // Creates a new instance from a given still frame and raw representation.
27 // represent single frame from that one. Can be used for wrapping 30 // |raw_image| can be animated, in which case animated_image() will return the
28 // animated images. 31 // original |raw_image| and raw_image() will return the encoded representation
32 // of |image|.
29 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); 33 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image);
30 34
31 virtual ~UserImage(); 35 virtual ~UserImage();
32 36
33 // Replaces already stored image to new |image|. Note, that
34 // |raw_image| and |animated_image| will be reset after that
35 // operation.
36 void SetImage(const gfx::ImageSkia& image);
37 const gfx::ImageSkia& image() const { return image_; } 37 const gfx::ImageSkia& image() const { return image_; }
38 38
39 // Returns true iff |image| argument of constructors or |SetImage| 39 // Optional raw representation of the still image.
40 // can be encoded as a bitmap.
41 bool has_raw_image() const { return has_raw_image_; } 40 bool has_raw_image() const { return has_raw_image_; }
42 const RawImage& raw_image() const { return raw_image_; } 41 const RawImage& raw_image() const { return raw_image_; }
43 42
44 // Returns true iff UserImage is constructed from animated image. 43 // Optional raw representation of the animated image.
45 bool has_animated_image() const { return has_animated_image_; } 44 bool has_animated_image() const { return has_animated_image_; }
46 const RawImage& animated_image() const { return animated_image_; } 45 const RawImage& animated_image() const { return animated_image_; }
47 46
48 // URL from which this image was originally downloaded, if any. 47 // URL from which this image was originally downloaded, if any.
49 void set_url(const GURL& url) { url_ = url; } 48 void set_url(const GURL& url) { url_ = url; }
50 GURL url() const { return url_; } 49 GURL url() const { return url_; }
51 50
52 private: 51 private:
53 gfx::ImageSkia image_; 52 gfx::ImageSkia image_;
54 bool has_raw_image_; 53 bool has_raw_image_;
55 RawImage raw_image_; 54 RawImage raw_image_;
56 bool has_animated_image_; 55 bool has_animated_image_;
57 RawImage animated_image_; 56 RawImage animated_image_;
58 GURL url_; 57 GURL url_;
59 }; 58 };
60 59
61 } // namespace chromeos 60 } // namespace chromeos
62 61
63 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_ 62 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698