OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/frame/frame_util.h" |
| 6 |
| 7 #include "ash/session_state_delegate.h" |
| 8 #include "ash/shell.h" |
| 9 #include "grit/ash_resources.h" |
| 10 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/gfx/image/image_skia.h" |
| 12 #include "ui/gfx/image/image_skia_operations.h" |
| 13 |
| 14 namespace ash { |
| 15 |
| 16 gfx::Image GetAvatarImageForContext(content::BrowserContext* context) { |
| 17 static const gfx::ImageSkia* holder = |
| 18 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 19 IDR_AVATAR_HOLDER); |
| 20 static const gfx::ImageSkia* holder_mask = |
| 21 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 22 IDR_AVATAR_HOLDER_MASK); |
| 23 gfx::ImageSkia user_image = |
| 24 Shell::GetInstance()->session_state_delegate()->GetUserImage(context); |
| 25 gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage( |
| 26 user_image, skia::ImageOperations::RESIZE_BEST, holder->size()); |
| 27 gfx::ImageSkia masked = |
| 28 gfx::ImageSkiaOperations::CreateMaskedImage(resized, *holder_mask); |
| 29 gfx::ImageSkia result = |
| 30 gfx::ImageSkiaOperations::CreateSuperimposedImage(*holder, masked); |
| 31 return gfx::Image(result); |
| 32 } |
| 33 |
| 34 } // namespace ash |
| 35 |
OLD | NEW |