| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/mus/demo/mus_demo.h" | 5 #include "components/mus/demo/mus_demo.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "components/bitmap_uploader/bitmap_uploader.h" | 8 #include "components/bitmap_uploader/bitmap_uploader.h" |
| 9 #include "components/mus/public/cpp/window_tree_host_factory.h" | 9 #include "components/mus/public/cpp/window_tree_host_factory.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 void MusDemo::SetWindowManagerClient(mus::WindowManagerClient* client) {} | 93 void MusDemo::SetWindowManagerClient(mus::WindowManagerClient* client) {} |
| 94 | 94 |
| 95 bool MusDemo::OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) { | 95 bool MusDemo::OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) { |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool MusDemo::OnWmSetProperty(mus::Window* window, | 99 bool MusDemo::OnWmSetProperty(mus::Window* window, |
| 100 const std::string& name, | 100 const std::string& name, |
| 101 scoped_ptr<std::vector<uint8_t>>* new_data) { | 101 std::unique_ptr<std::vector<uint8_t>>* new_data) { |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 mus::Window* MusDemo::OnWmCreateTopLevelWindow( | 105 mus::Window* MusDemo::OnWmCreateTopLevelWindow( |
| 106 std::map<std::string, std::vector<uint8_t>>* properties) { | 106 std::map<std::string, std::vector<uint8_t>>* properties) { |
| 107 // TODO(kylechar): Check if this should return something useful. | 107 // TODO(kylechar): Check if this should return something useful. |
| 108 return nullptr; | 108 return nullptr; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void MusDemo::OnAccelerator(uint32_t id, const ui::Event& event) {} | 111 void MusDemo::OnAccelerator(uint32_t id, const ui::Event& event) {} |
| (...skipping 28 matching lines...) Expand all Loading... |
| 140 DrawSquare(bounds, angle_, &canvas); | 140 DrawSquare(bounds, angle_, &canvas); |
| 141 canvas.flush(); | 141 canvas.flush(); |
| 142 | 142 |
| 143 // Copy pixels data into vector that will be passed to BitmapUploader. | 143 // Copy pixels data into vector that will be passed to BitmapUploader. |
| 144 // TODO(rjkroege): Make a 1/0-copy bitmap uploader for the contents of a | 144 // TODO(rjkroege): Make a 1/0-copy bitmap uploader for the contents of a |
| 145 // SkBitmap. | 145 // SkBitmap. |
| 146 bitmap_.lockPixels(); | 146 bitmap_.lockPixels(); |
| 147 const unsigned char* addr = | 147 const unsigned char* addr = |
| 148 static_cast<const unsigned char*>(bitmap_.getPixels()); | 148 static_cast<const unsigned char*>(bitmap_.getPixels()); |
| 149 const int bytes = bounds.width() * bounds.height() * 4; | 149 const int bytes = bounds.width() * bounds.height() * 4; |
| 150 scoped_ptr<std::vector<unsigned char>> data( | 150 std::unique_ptr<std::vector<unsigned char>> data( |
| 151 new std::vector<unsigned char>(addr, addr + bytes)); | 151 new std::vector<unsigned char>(addr, addr + bytes)); |
| 152 bitmap_.unlockPixels(); | 152 bitmap_.unlockPixels(); |
| 153 | 153 |
| 154 // Send frame to MUS via BitmapUploader. | 154 // Send frame to MUS via BitmapUploader. |
| 155 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data), | 155 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data), |
| 156 bitmap_uploader::BitmapUploader::BGRA); | 156 bitmap_uploader::BitmapUploader::BGRA); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace mus_demo | 159 } // namespace mus_demo |
| OLD | NEW |