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

Side by Side Diff: athena/screen/background_controller.cc

Issue 287163009: [Athena] minimum impl to add screen/background and test windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « athena/screen/background_controller.h ('k') | athena/screen/public/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "athena/screen/background_controller.h"
6
7 #include "ui/aura/window.h"
8 #include "ui/compositor/layer.h"
9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/image/image_skia.h"
11 #include "ui/views/view.h"
12 #include "ui/views/widget/widget.h"
13
14 namespace athena {
15
16 class BackgroundView : public views::View {
17 public:
18 BackgroundView() {}
19 virtual ~BackgroundView() {}
20
21 void SetImage(const gfx::ImageSkia& image) {
22 image_ = image;
23 SchedulePaint();
24 }
25
26 // views::View
27 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
28 canvas->DrawImageInt(image_,
29 0,
30 0,
31 image_.width(),
32 image_.height(),
33 0,
34 0,
35 width(),
36 height(),
37 true);
38 }
39
40 private:
41 gfx::ImageSkia image_;
42
43 DISALLOW_COPY_AND_ASSIGN(BackgroundView);
44 };
45
46 BackgroundController::BackgroundController(aura::Window* container) {
47 // TODO(oshima): Using widget to just draw an image is probably
48 // overkill. Just use WindowDelegate to draw the background and
49 // remove dependency to ui/views.
50
51 views::Widget* background_widget = new views::Widget;
52 views::Widget::InitParams params(
53 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
54 params.parent = container;
55 background_widget->Init(params);
56 background_widget->GetNativeWindow()->layer()->SetMasksToBounds(true);
57 background_view_ = new BackgroundView;
58 background_widget->SetContentsView(background_view_);
59 background_widget->Show();
60 }
61
62 BackgroundController::~BackgroundController() {
63 // background_widget is owned by the container and will be deleted
64 // when the container is deleted.
65 }
66
67 void BackgroundController::SetImage(const gfx::ImageSkia& image) {
68 // TODO(oshima): implement cross fede animation.
69 background_view_->SetImage(image);
70 }
71
72 } // namespace athena
OLDNEW
« no previous file with comments | « athena/screen/background_controller.h ('k') | athena/screen/public/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698