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

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

Issue 302473005: athena: Add a minimal executable for just the UI. (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 | « no previous file | athena/ui/DEPS » ('j') | athena/ui/athena_ui_main.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "athena/screen/background_controller.h" 5 #include "athena/screen/background_controller.h"
6 6
7 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
8 #include "ui/compositor/layer.h" 8 #include "ui/compositor/layer.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/image/image_skia.h" 10 #include "ui/gfx/image/image_skia.h"
11 #include "ui/views/view.h" 11 #include "ui/views/view.h"
12 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
13 13
14 namespace athena { 14 namespace athena {
15 15
16 class BackgroundView : public views::View { 16 class BackgroundView : public views::View {
17 public: 17 public:
18 BackgroundView() {} 18 BackgroundView() {}
19 virtual ~BackgroundView() {} 19 virtual ~BackgroundView() {}
20 20
21 void SetImage(const gfx::ImageSkia& image) { 21 void SetImage(const gfx::ImageSkia& image) {
22 image_ = image; 22 image_ = image;
23 SchedulePaint(); 23 SchedulePaint();
24 } 24 }
25 25
26 // views::View 26 // views::View
27 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 27 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
28 canvas->DrawImageInt(image_, 28 if (!image_.isNull()) {
oshima 2014/05/27 18:32:14 can you set the background using SetupBackgroundIm
sadrul 2014/05/29 03:03:56 Done.
29 0, 29 canvas->DrawImageInt(image_,
30 0, 30 0,
31 image_.width(), 31 0,
32 image_.height(), 32 image_.width(),
33 0, 33 image_.height(),
34 0, 34 0,
35 width(), 35 0,
36 height(), 36 width(),
37 true); 37 height(),
38 true);
39 } else {
40 canvas->DrawColor(SK_ColorRED);
41 }
38 } 42 }
39 43
40 private: 44 private:
41 gfx::ImageSkia image_; 45 gfx::ImageSkia image_;
42 46
43 DISALLOW_COPY_AND_ASSIGN(BackgroundView); 47 DISALLOW_COPY_AND_ASSIGN(BackgroundView);
44 }; 48 };
45 49
46 BackgroundController::BackgroundController(aura::Window* container) { 50 BackgroundController::BackgroundController(aura::Window* container) {
47 // TODO(oshima): Using widget to just draw an image is probably 51 // TODO(oshima): Using widget to just draw an image is probably
(...skipping 15 matching lines...) Expand all
63 // background_widget is owned by the container and will be deleted 67 // background_widget is owned by the container and will be deleted
64 // when the container is deleted. 68 // when the container is deleted.
65 } 69 }
66 70
67 void BackgroundController::SetImage(const gfx::ImageSkia& image) { 71 void BackgroundController::SetImage(const gfx::ImageSkia& image) {
68 // TODO(oshima): implement cross fede animation. 72 // TODO(oshima): implement cross fede animation.
69 background_view_->SetImage(image); 73 background_view_->SetImage(image);
70 } 74 }
71 75
72 } // namespace athena 76 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | athena/ui/DEPS » ('j') | athena/ui/athena_ui_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698