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

Unified Diff: components/mus/demo/mus_demo.h

Issue 1832943002: Add mus_demo mojo app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move from mash/BUILD.gn to BUILD.gn Created 4 years, 9 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
« no previous file with comments | « components/mus/demo/manifest.json ('k') | components/mus/demo/mus_demo.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/demo/mus_demo.h
diff --git a/components/mus/demo/mus_demo.h b/components/mus/demo/mus_demo.h
new file mode 100644
index 0000000000000000000000000000000000000000..a49b8277a56cc0f6faa4fcfe89b4705a0bee67ba
--- /dev/null
+++ b/components/mus/demo/mus_demo.h
@@ -0,0 +1,91 @@
+// Copyright 2016 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.
+
+#ifndef COMPONENTS_MUS_DEMO_MUS_DEMO_H_
+#define COMPONENTS_MUS_DEMO_MUS_DEMO_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/timer/timer.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_manager_delegate.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
+#include "components/mus/public/interfaces/window_tree_host.mojom.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "mojo/shell/public/cpp/connector.h"
+#include "mojo/shell/public/cpp/shell_client.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+namespace bitmap_uploader {
+class BitmapUploader;
+}
+
+namespace mus_demo {
+
+// A simple MUS Demo mojo app. This app connects to the mojo:mus, creates a new
+// window and draws a spinning square in the center of the window. Provides a
+// simple way to demonstrate that the graphic stack works as intended.
+class MusDemo : public mojo::ShellClient,
+ public mus::WindowTreeDelegate,
+ public mus::WindowManagerDelegate {
+ public:
+ MusDemo();
+ ~MusDemo() override;
+
+ private:
+ // mojo::ShellClient:
+ void Initialize(mojo::Connector* connector,
+ const mojo::Identity& identity,
+ uint32_t id) override;
+ bool AcceptConnection(mojo::Connection* connection) override;
+
+ // WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnUnembed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
+
+ // WindowManagerDelegate:
+ void SetWindowManagerClient(mus::WindowManagerClient* client) override;
+ bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override;
+ bool OnWmSetProperty(mus::Window* window,
+ const std::string& name,
+ scoped_ptr<std::vector<uint8_t>>* new_data) override;
+ mus::Window* OnWmCreateTopLevelWindow(
+ std::map<std::string, std::vector<uint8_t>>* properties) override;
+ void OnAccelerator(uint32_t id, const ui::Event& event) override;
+
+ // Allocate a bitmap the same size as the window to draw into.
+ void AllocBitmap();
+
+ // Draws one frame, incrementing the rotation angle.
+ void DrawFrame();
+
+ mojo::Connector* connector_ = nullptr;
+
+ mus::Window* window_ = nullptr;
+ mus::mojom::WindowTreeHostPtr window_tree_host_;
+
+ // Used to send frames to mus.
+ scoped_ptr<bitmap_uploader::BitmapUploader> uploader_;
+
+ // Bitmap that is the same size as our client window area.
+ SkBitmap bitmap_;
+
+ // Timer for calling DrawFrame().
+ base::RepeatingTimer timer_;
+
+ // Current rotation angle for drawing.
+ double angle_ = 0.0;
+
+ DISALLOW_COPY_AND_ASSIGN(MusDemo);
+};
+
+} // namespace mus_demo
+
+#endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_
« no previous file with comments | « components/mus/demo/manifest.json ('k') | components/mus/demo/mus_demo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698