| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/ui/demo/window_tree_data.h" | 5 #include "services/ui/demo/window_tree_data.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 WindowTreeData::WindowTreeData(int square_size) : square_size_(square_size) {} | 60 WindowTreeData::WindowTreeData(int square_size) : square_size_(square_size) {} |
| 61 | 61 |
| 62 WindowTreeData::~WindowTreeData() {} | 62 WindowTreeData::~WindowTreeData() {} |
| 63 | 63 |
| 64 aura::Window* WindowTreeData::bitmap_window() { | 64 aura::Window* WindowTreeData::bitmap_window() { |
| 65 DCHECK(!window_tree_host_->window()->children().empty()); | 65 DCHECK(!window_tree_host_->window()->children().empty()); |
| 66 return window_tree_host_->window()->children()[0]; | 66 return window_tree_host_->window()->children()[0]; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void WindowTreeData::Init( | 69 void WindowTreeData::Init() { |
| 70 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 70 DCHECK(window_tree_host_); |
| 71 if (window_tree_host) { | 71 DCHECK(!IsInitialized()); |
| 72 window_tree_host->InitHost(); | |
| 73 window_tree_host->Show(); | |
| 74 SetWindowTreeHost(std::move(window_tree_host)); | |
| 75 } | |
| 76 | 72 |
| 77 // Initialize the window for the bitmap. | 73 // Initialize the window for the bitmap. |
| 78 window_delegate_ = new aura_extra::ImageWindowDelegate(); | 74 window_delegate_ = new aura_extra::ImageWindowDelegate(); |
| 79 aura::Window* root_window = window_tree_host_->window(); | 75 aura::Window* root_window = window_tree_host_->window(); |
| 80 aura::Window* bitmap_window = new aura::Window(window_delegate_); | 76 aura::Window* bitmap_window = new aura::Window(window_delegate_); |
| 81 bitmap_window->Init(LAYER_TEXTURED); | 77 bitmap_window->Init(LAYER_TEXTURED); |
| 82 bitmap_window->SetBounds(gfx::Rect(root_window->bounds().size())); | 78 bitmap_window->SetBounds(gfx::Rect(root_window->bounds().size())); |
| 83 bitmap_window->Show(); | 79 bitmap_window->Show(); |
| 84 bitmap_window->SetName("Bitmap"); | 80 bitmap_window->SetName("Bitmap"); |
| 85 root_window->AddChild(bitmap_window); | 81 root_window->AddChild(bitmap_window); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 113 gfx::ImageSkiaRep image_skia_rep(bitmap, 1); | 109 gfx::ImageSkiaRep image_skia_rep(bitmap, 1); |
| 114 gfx::ImageSkia image_skia(image_skia_rep); | 110 gfx::ImageSkia image_skia(image_skia_rep); |
| 115 gfx::Image image(image_skia); | 111 gfx::Image image(image_skia); |
| 116 | 112 |
| 117 window_delegate_->SetImage(image); | 113 window_delegate_->SetImage(image); |
| 118 bitmap_window()->SchedulePaintInRect(gfx::Rect(bounds.size())); | 114 bitmap_window()->SchedulePaintInRect(gfx::Rect(bounds.size())); |
| 119 } | 115 } |
| 120 | 116 |
| 121 } // namespace demo | 117 } // namespace demo |
| 122 } // namespace ui | 118 } // namespace ui |
| OLD | NEW |