summaryrefslogtreecommitdiffstats
path: root/ash/frame/frame_util.cc
blob: bfa8c33548608c76c900bdc7d24a2a27690924b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2014 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 "ash/frame/frame_util.h"

#include "ash/session_state_delegate.h"
#include "ash/shell.h"
#include "grit/ash_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"

namespace ash {

gfx::Image GetAvatarImageForContext(content::BrowserContext* context) {
  static const gfx::ImageSkia* holder =
      ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
          IDR_AVATAR_HOLDER);
  static const gfx::ImageSkia* holder_mask =
      ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
          IDR_AVATAR_HOLDER_MASK);
  gfx::ImageSkia user_image =
      Shell::GetInstance()->session_state_delegate()->GetUserImage(context);
  gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage(
      user_image, skia::ImageOperations::RESIZE_BEST, holder->size());
  gfx::ImageSkia masked =
      gfx::ImageSkiaOperations::CreateMaskedImage(resized, *holder_mask);
  gfx::ImageSkia result =
      gfx::ImageSkiaOperations::CreateSuperimposedImage(*holder, masked);
  return gfx::Image(result);
}

}  // namespace ash