Chromium Code Reviews| Index: services/ui/demo/mus_demo.cc |
| diff --git a/services/ui/demo/mus_demo.cc b/services/ui/demo/mus_demo.cc |
| index 6295e83b5dfad815ac6f014c163efd196e5de7fa..c0cde5a9b49f6d20d53437428fd4ece4e2408652 100644 |
| --- a/services/ui/demo/mus_demo.cc |
| +++ b/services/ui/demo/mus_demo.cc |
| @@ -73,7 +73,6 @@ class MusDemo::WindowTreeData { |
| 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. |
| @@ -82,15 +81,14 @@ class MusDemo::WindowTreeData { |
| // Draws one frame, incrementing the rotation angle. |
| void DrawFrame(); |
| + // Helper function to retrieve the window to which we draw the bitmap. |
| + aura::Window* BitmapWindow() { |
|
sky
2017/02/10 18:48:37
GetBitmapWindow(), or as this is inlined and cheap
fwang
2017/02/11 09:58:48
Done.
|
| + return window_tree_host_->window()->children()[0]; |
|
sky
2017/02/10 18:48:38
DCHECK(!children.empty())
fwang
2017/02/11 09:58:48
Done.
|
| + } |
| + |
| // The Window tree host corresponding to this data. |
| std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_; |
| - // Root window of the window tree host. |
| - aura::Window* root_window_ = nullptr; |
| - |
| - // Window to which we draw the bitmap. |
| - std::unique_ptr<aura::Window> bitmap_window_; |
| - |
| // Destroys itself when the window gets destroyed. |
| aura_extra::ImageWindowDelegate* window_delegate_ = nullptr; |
| @@ -99,34 +97,24 @@ class MusDemo::WindowTreeData { |
| // Current rotation angle for drawing. |
| double angle_ = 0.0; |
| - |
| - // Last time a frame was drawn. |
| - base::TimeTicks last_draw_frame_time_; |
| }; |
|
sky
2017/02/10 18:48:38
DISALLOW...
fwang
2017/02/11 09:58:48
Done.
|
| -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()); |
| + aura::Window* root_window = window_tree_host_->window(); |
| + aura::Window* bitmap_window = new aura::Window(window_delegate_); |
| + bitmap_window->Init(LAYER_TEXTURED); |
| + bitmap_window->SetBounds(root_window->bounds()); |
|
sky
2017/02/10 18:48:38
bitmap_window should have the same size, but an or
fwang
2017/02/11 09:58:48
Done.
|
| + bitmap_window->Show(); |
| + bitmap_window->SetName("Bitmap"); |
| + root_window->AddChild(bitmap_window); |
| // Draw initial frame and start the timer to regularly draw frames. |
| DrawFrame(); |
| @@ -257,17 +245,11 @@ bool MusDemo::IsWindowActive(aura::Window* window) { return false; } |
| void MusDemo::OnWmDeactivateWindow(aura::Window* window) {} |
| void MusDemo::WindowTreeData::DrawFrame() { |
| - base::TimeTicks now = base::TimeTicks::Now(); |
| - |
| - VLOG(1) << (now - last_draw_frame_time_).InMilliseconds() |
| - << "ms since the last frame was drawn."; |
| - last_draw_frame_time_ = now; |
| - |
| angle_ += 2.0; |
| if (angle_ >= 360.0) |
| angle_ = 0.0; |
| - const gfx::Rect& bounds = bitmap_window_->bounds(); |
| + const gfx::Rect& bounds = BitmapWindow()->bounds(); |
| // Allocate a bitmap of correct size. |
| SkBitmap bitmap; |
| @@ -287,7 +269,7 @@ void MusDemo::WindowTreeData::DrawFrame() { |
| gfx::Image image(image_skia); |
| window_delegate_->SetImage(image); |
| - bitmap_window_->SchedulePaintInRect(bitmap_window_->bounds()); |
| + BitmapWindow()->SchedulePaintInRect(BitmapWindow()->bounds()); |
|
sky
2017/02/10 18:48:37
SchedulePaintInRect() takes a rectangle in the coo
fwang
2017/02/11 09:58:48
Done.
|
| } |
| } // namespace demo |