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

Unified Diff: services/ui/demo/mus_demo.cc

Issue 2688123002: Mus Demo: Reorganize functions in mus_demo.cc (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/demo/mus_demo.cc
diff --git a/services/ui/demo/mus_demo.cc b/services/ui/demo/mus_demo.cc
index f80c64fbaae611af6df9d0e7f61c3168bbb5d628..6295e83b5dfad815ac6f014c163efd196e5de7fa 100644
--- a/services/ui/demo/mus_demo.cc
+++ b/services/ui/demo/mus_demo.cc
@@ -70,10 +70,15 @@ void DrawSquare(const gfx::Rect& bounds, double angle, SkCanvas* canvas) {
class MusDemo::WindowTreeData {
public:
explicit WindowTreeData(
- std::unique_ptr<aura::WindowTreeHostMus> window_tree_host);
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
+ Init(std::move(window_tree_host));
+ }
~WindowTreeData();
private:
+ // Initializes the window tree host and start drawing frames.
+ void Init(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host);
+
// Draws one frame, incrementing the rotation angle.
void DrawFrame();
@@ -99,6 +104,36 @@ class MusDemo::WindowTreeData {
base::TimeTicks last_draw_frame_time_;
};
+MusDemo::WindowTreeData::~WindowTreeData() {
+ timer_.Stop();
+ root_window_->RemoveChild(bitmap_window_.get());
+ bitmap_window_.reset();
+}
+
+void MusDemo::WindowTreeData::Init(
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
+ window_tree_host->InitHost();
+ window_tree_host->Show();
+ root_window_ = window_tree_host->window();
+ // Take ownership of the WTH.
+ window_tree_host_ = std::move(window_tree_host);
+
+ // Initialize the window for the bitmap.
+ window_delegate_ = new aura_extra::ImageWindowDelegate();
+ bitmap_window_ = base::MakeUnique<aura::Window>(window_delegate_);
+ bitmap_window_->Init(LAYER_TEXTURED);
+ bitmap_window_->SetBounds(root_window_->bounds());
+ bitmap_window_->Show();
+ bitmap_window_->SetName("Bitmap");
+
+ root_window_->AddChild(bitmap_window_.get());
+
+ // Draw initial frame and start the timer to regularly draw frames.
+ DrawFrame();
+ timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay),
+ base::Bind(&WindowTreeData::DrawFrame, base::Unretained(this)));
+}
+
MusDemo::MusDemo() {}
MusDemo::~MusDemo() {
@@ -193,40 +228,10 @@ void MusDemo::OnWmNewDisplay(
base::MakeUnique<WindowTreeData>(std::move(window_tree_host));
}
-MusDemo::WindowTreeData::WindowTreeData(
- std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
- window_tree_host->InitHost();
- window_tree_host->Show();
- root_window_ = window_tree_host->window();
- // Take ownership of the WTH.
- window_tree_host_ = std::move(window_tree_host);
-
- // Initialize the window for the bitmap.
- window_delegate_ = new aura_extra::ImageWindowDelegate();
- bitmap_window_ = base::MakeUnique<aura::Window>(window_delegate_);
- bitmap_window_->Init(LAYER_TEXTURED);
- bitmap_window_->SetBounds(root_window_->bounds());
- bitmap_window_->Show();
- bitmap_window_->SetName("Bitmap");
-
- root_window_->AddChild(bitmap_window_.get());
-
- // Draw initial frame and start the timer to regularly draw frames.
- DrawFrame();
- timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay),
- base::Bind(&WindowTreeData::DrawFrame, base::Unretained(this)));
-}
-
void MusDemo::OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) {
window_tree_data_.reset();
}
-MusDemo::WindowTreeData::~WindowTreeData() {
- timer_.Stop();
- root_window_->RemoveChild(bitmap_window_.get());
- bitmap_window_.reset();
-}
-
void MusDemo::OnWmDisplayModified(const display::Display& display) {}
mojom::EventResult MusDemo::OnAccelerator(uint32_t id, const Event& event) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698