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

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: Remove WindowManagerClient. 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
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..0f1056a0ee43a67de50fe825c4bd05ac046cdda9
--- /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 {
rjkroege 2016/03/29 18:53:23 I think it would be better to be in a different na
kylechar 2016/03/29 20:43:39 Done.
+
+// 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 the graphic stack works as intended.
rjkroege 2016/03/29 18:53:22 to demonstrate that the
kylechar 2016/03/29 20:43:39 Done.
+class MusDemo : public mojo::ShellClient,
+ public WindowTreeDelegate,
+ public 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(Window* root) override;
+ void OnUnembed(Window* root) override;
+ void OnConnectionLost(WindowTreeConnection* connection) override;
+
+ // WindowManagerDelegate:
+ void SetWindowManagerClient(WindowManagerClient* client) override;
+ bool OnWmSetBounds(Window* window, gfx::Rect* bounds) override;
+ bool OnWmSetProperty(Window* window,
+ const std::string& name,
+ scoped_ptr<std::vector<uint8_t>>* new_data) override;
+ 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 t draw into.
rjkroege 2016/03/29 18:53:23 t -> to
kylechar 2016/03/29 20:43:39 Done.
+ void AllocBitmap();
+
+ // Draws one frame, incrementing the rotation angle.
+ void DrawFrame();
+
+ mojo::Connector* connector_ = nullptr;
rjkroege 2016/03/29 18:53:23 These are owned elsewhere? if so, adding // NOT OW
kylechar 2016/03/29 20:43:39 I believe they're owned elsewhere (based on other
rjkroege 2016/03/29 20:56:54 My understanding is that the mojo owns infrastruct
+
+ mojom::WindowTreeHostPtr host_ = nullptr;
+
+ Window* window_ = nullptr;
+
+ // 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
+#endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_

Powered by Google App Engine
This is Rietveld 408576698