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

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

Issue 286933002: [cros login] Split login related classes into subfolders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix includes in new tests Created 6 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
deleted file mode 100644
index 347c1fbd758c32fc4dc70b08abaad945c5bda65c..0000000000000000000000000000000000000000
--- a/chrome/browser/chromeos/login/user_image.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-// 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"
-
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/codec/jpeg_codec.h"
-
-#include "base/debug/trace_event.h"
-
-namespace chromeos {
-
-namespace {
-
-// Default quality for encoding user images.
-const int kDefaultEncodingQuality = 90;
-
-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;
-}
-
-bool EncodeImageSkia(const gfx::ImageSkia& image,
- std::vector<unsigned char>* output) {
- TRACE_EVENT2("oobe", "EncodeImageSkia",
- "width", image.width(), "height", image.height());
- if (image.isNull())
- return false;
- const SkBitmap& bitmap = *image.bitmap();
- SkAutoLockPixels lock_image(bitmap);
- return gfx::JPEGCodec::Encode(
- reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
- gfx::JPEGCodec::FORMAT_SkBitmap,
- bitmap.width(),
- bitmap.height(),
- bitmap.width() * bitmap.bytesPerPixel(),
- kDefaultEncodingQuality, output);
-}
-
-} // namespace
-
-// static
-UserImage UserImage::CreateAndEncode(const gfx::ImageSkia& image) {
- RawImage raw_image;
- if (EncodeImageSkia(image, &raw_image)) {
- UserImage result(image, raw_image);
- result.MarkAsSafe();
- return result;
- }
- return UserImage(image);
-}
-
-UserImage::UserImage()
- : has_raw_image_(false),
- has_animated_image_(false),
- is_safe_format_(false) {
-}
-
-UserImage::UserImage(const gfx::ImageSkia& image)
- : image_(image),
- has_raw_image_(false),
- has_animated_image_(false),
- is_safe_format_(false) {
-}
-
-UserImage::UserImage(const gfx::ImageSkia& image,
- const RawImage& raw_image)
- : image_(image),
- has_raw_image_(false),
- has_animated_image_(false),
- is_safe_format_(false) {
- if (IsAnimatedImage(raw_image)) {
- has_animated_image_ = true;
- animated_image_ = raw_image;
- if (EncodeImageSkia(image_, &raw_image_)) {
- has_raw_image_ = true;
- MarkAsSafe();
- }
- } else {
- has_raw_image_ = true;
- raw_image_ = raw_image;
- }
-}
-
-UserImage::~UserImage() {}
-
-void UserImage::DiscardRawImage() {
- RawImage().swap(raw_image_); // Clear |raw_image_|.
-}
-
-void UserImage::MarkAsSafe() {
- is_safe_format_ = true;
-}
-
-} // 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