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

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

Issue 10820049: Load 2x resources on demand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For preview Created 8 years, 3 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 #include "chrome/browser/chromeos/login/user_image.h" 5 #include "chrome/browser/chromeos/login/user_image.h"
6 6
7 #include "base/logging.h"
7 #include "ui/gfx/codec/png_codec.h" 8 #include "ui/gfx/codec/png_codec.h"
8 9
9 namespace chromeos { 10 namespace chromeos {
10 11
11 namespace { 12 namespace {
12 13
13 bool IsAnimatedImage(const UserImage::RawImage& data) { 14 bool IsAnimatedImage(const UserImage::RawImage& data) {
14 const char kGIFStamp[] = "GIF"; 15 const char kGIFStamp[] = "GIF";
15 const size_t kGIFStampLength = sizeof(kGIFStamp) - 1; 16 const size_t kGIFStampLength = sizeof(kGIFStamp) - 1;
16 17
(...skipping 24 matching lines...) Expand all
41 42
42 UserImage::UserImage() 43 UserImage::UserImage()
43 : has_raw_image_(false), 44 : has_raw_image_(false),
44 has_animated_image_(false) { 45 has_animated_image_(false) {
45 } 46 }
46 47
47 UserImage::UserImage(const gfx::ImageSkia& image) 48 UserImage::UserImage(const gfx::ImageSkia& image)
48 : image_(image), 49 : image_(image),
49 has_raw_image_(false), 50 has_raw_image_(false),
50 has_animated_image_(false) { 51 has_animated_image_(false) {
52 DCHECK(image.IsReadOnly());
51 } 53 }
52 54
53 UserImage::UserImage(const gfx::ImageSkia& image, 55 UserImage::UserImage(const gfx::ImageSkia& image,
54 const RawImage& raw_image) 56 const RawImage& raw_image)
55 : image_(image), 57 : image_(image),
56 has_raw_image_(false), 58 has_raw_image_(false),
57 has_animated_image_(false) { 59 has_animated_image_(false) {
60 DCHECK(image.IsReadOnly());
58 if (IsAnimatedImage(raw_image)) { 61 if (IsAnimatedImage(raw_image)) {
59 has_animated_image_ = true; 62 has_animated_image_ = true;
60 animated_image_ = raw_image; 63 animated_image_ = raw_image;
61 if (EncodeBGRAImageSkia(image_, false, &raw_image_)) 64 if (EncodeBGRAImageSkia(image_, false, &raw_image_))
62 has_raw_image_ = true; 65 has_raw_image_ = true;
63 } else { 66 } else {
64 has_raw_image_ = true; 67 has_raw_image_ = true;
65 raw_image_ = raw_image; 68 raw_image_ = raw_image;
66 } 69 }
67 } 70 }
68 71
69 UserImage::~UserImage() {} 72 UserImage::~UserImage() {}
70 73
71 void UserImage::DiscardRawImage() { 74 void UserImage::DiscardRawImage() {
72 RawImage().swap(raw_image_); // Clear |raw_image_|. 75 RawImage().swap(raw_image_); // Clear |raw_image_|.
73 } 76 }
74 77
75 } // namespace chromeos 78 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/user_image_loader.cc » ('j') | ui/gfx/image/image_skia.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698