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

Unified Diff: chrome/browser/chromeos/login/user_image.cc

Issue 10454044: Added support for animated/nonanimated user image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Deleted useless inclusions. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/login/user_image.h ('k') | chrome/browser/chromeos/login/user_image_loader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/user_image.cc
diff --git a/chrome/browser/chromeos/login/user_image.cc b/chrome/browser/chromeos/login/user_image.cc
new file mode 100644
index 0000000000000000000000000000000000000000..daa33a0a25b221d9ddc6f86b00955e52d663d9bb
--- /dev/null
+++ b/chrome/browser/chromeos/login/user_image.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/user_image.h"
+
+namespace chromeos {
+
+namespace {
+
+bool IsAnimatedImage(const UserImage::RawImage& data) {
+ const char kGIFStamp[] = "GIF";
+ const size_t kGIFStampLength = sizeof(kGIFStamp) - 1;
+
+ if (data.size() >= kGIFStampLength &&
+ memcmp(&data[0], kGIFStamp, kGIFStampLength) == 0) {
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
+UserImage::UserImage(const SkBitmap& image)
+ : image_(image),
+ has_raw_image_(false),
+ has_animated_image_(false) {
+}
+
+UserImage::UserImage(const SkBitmap& image,
+ const RawImage& raw_image)
+ : image_(image),
+ has_raw_image_(true),
+ has_animated_image_(IsAnimatedImage(raw_image)),
+ raw_image_(raw_image) {
+}
+
+UserImage::~UserImage() {}
+
+void UserImage::SetImage(const SkBitmap& image) {
+ image_ = image;
+ has_raw_image_ = false;
+ has_animated_image_ = false;
+ RawImage().swap(raw_image_);
Ivan Korotkov 2012/05/30 13:06:51 As discussed offline, this idiom is OK but please
ygorshenin1 2012/05/30 13:19:14 Done.
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/user_image.h ('k') | chrome/browser/chromeos/login/user_image_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698