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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: athena/screen/background_controller.cc
diff --git a/athena/screen/background_controller.cc b/athena/screen/background_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c9c80f42c563ab5666aa8212777e42a6d7e5c2fa
--- /dev/null
+++ b/athena/screen/background_controller.cc
@@ -0,0 +1,59 @@
+// 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 "athena/screen/background_controller.h"
+
+#include "ui/aura/window.h"
+#include "ui/compositor/layer.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
+
+namespace athena {
+
+class BackgroundView : public views::View {
+ public:
+ BackgroundView() {}
+ virtual ~BackgroundView() {}
+
+ void SetImage(const gfx::ImageSkia& image) { image_ = image; }
+
+ // views::View
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
+ canvas->DrawImageInt(image_,
+ 0,
+ 0,
+ image_.width(),
+ image_.height(),
+ 0,
+ 0,
+ width(),
+ height(),
+ true);
+ }
+
+ private:
+ gfx::ImageSkia image_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundView);
+};
+
+BackgroundController::BackgroundController(aura::Window* container) {
+ views::Widget* desktop_widget = new views::Widget;
+ views::Widget::InitParams params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params.parent = container;
+ desktop_widget->Init(params);
+ desktop_widget->GetNativeWindow()->layer()->SetMasksToBounds(true);
+ background_view_ = new BackgroundView;
+ desktop_widget->SetContentsView(background_view_);
+ desktop_widget->Show();
+}
+
+void BackgroundController::SetImage(const gfx::ImageSkia& image) {
+ background_view_->SetImage(image);
+}
+
+} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698