| 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 <unistd.h> | 5 #include <unistd.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "mojo/application/application_runner_chromium.h" | 11 #include "mojo/application/application_runner_chromium.h" |
| 12 #include "mojo/public/c/system/main.h" | 12 #include "mojo/public/c/system/main.h" |
| 13 #include "mojo/public/cpp/application/connect.h" |
| 13 #include "mojo/ui/choreographer.h" | 14 #include "mojo/ui/choreographer.h" |
| 14 #include "mojo/ui/ganesh_view.h" | 15 #include "mojo/ui/ganesh_view.h" |
| 15 #include "mojo/ui/input_handler.h" | 16 #include "mojo/ui/input_handler.h" |
| 16 #include "mojo/ui/view_provider_app.h" | 17 #include "mojo/ui/view_provider_app.h" |
| 17 #include "third_party/dejavu-fonts-ttf-2.34/kDejaVuSansMonoRegular.h" | 18 #include "third_party/dejavu-fonts-ttf-2.34/kDejaVuSansMonoRegular.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "third_party/skia/include/core/SkRect.h" | 21 #include "third_party/skia/include/core/SkRect.h" |
| 21 #include "third_party/skia/include/core/SkStream.h" | 22 #include "third_party/skia/include/core/SkStream.h" |
| 22 #include "third_party/skia/include/core/SkTypeface.h" | 23 #include "third_party/skia/include/core/SkTypeface.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 | 47 |
| 47 constexpr SkScalar kButtonWidth = 300; | 48 constexpr SkScalar kButtonWidth = 300; |
| 48 constexpr SkScalar kButtonHeight = 30; | 49 constexpr SkScalar kButtonHeight = 30; |
| 49 constexpr SkScalar kMargin = 15; | 50 constexpr SkScalar kMargin = 15; |
| 50 } // namespace | 51 } // namespace |
| 51 | 52 |
| 52 class JankView : public mojo::ui::GaneshView, | 53 class JankView : public mojo::ui::GaneshView, |
| 53 public mojo::ui::ChoreographerDelegate, | 54 public mojo::ui::ChoreographerDelegate, |
| 54 public mojo::ui::InputListener { | 55 public mojo::ui::InputListener { |
| 55 public: | 56 public: |
| 56 JankView(mojo::ApplicationImpl* app_impl, | 57 JankView(mojo::InterfaceHandle<mojo::ApplicationConnector> app_connector, |
| 57 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) | 58 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) |
| 58 : GaneshView(app_impl, view_owner_request.Pass(), "Jank"), | 59 : GaneshView(app_connector.Pass(), view_owner_request.Pass(), "Jank"), |
| 59 choreographer_(scene(), this), | 60 choreographer_(scene(), this), |
| 60 input_handler_(GetViewServiceProvider(), this), | 61 input_handler_(GetViewServiceProvider(), this), |
| 61 typeface_(skia::AdoptRef(SkTypeface::CreateFromStream( | 62 typeface_(skia::AdoptRef(SkTypeface::CreateFromStream( |
| 62 new SkMemoryStream(font_data::kDejaVuSansMonoRegular.data, | 63 new SkMemoryStream(font_data::kDejaVuSansMonoRegular.data, |
| 63 font_data::kDejaVuSansMonoRegular.size)))) {} | 64 font_data::kDejaVuSansMonoRegular.size)))) {} |
| 64 | 65 |
| 65 ~JankView() override {} | 66 ~JankView() override {} |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 // |GaneshView|: | 69 // |GaneshView|: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 class JankApp : public mojo::ui::ViewProviderApp { | 204 class JankApp : public mojo::ui::ViewProviderApp { |
| 204 public: | 205 public: |
| 205 JankApp() {} | 206 JankApp() {} |
| 206 ~JankApp() override {} | 207 ~JankApp() override {} |
| 207 | 208 |
| 208 void CreateView( | 209 void CreateView( |
| 209 const std::string& connection_url, | 210 const std::string& connection_url, |
| 210 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, | 211 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, |
| 211 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 212 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 212 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override { | 213 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override { |
| 213 new JankView(app_impl(), view_owner_request.Pass()); | 214 new JankView(mojo::CreateApplicationConnector(app_impl()->shell()), |
| 215 view_owner_request.Pass()); |
| 214 } | 216 } |
| 215 | 217 |
| 216 private: | 218 private: |
| 217 DISALLOW_COPY_AND_ASSIGN(JankApp); | 219 DISALLOW_COPY_AND_ASSIGN(JankApp); |
| 218 }; | 220 }; |
| 219 | 221 |
| 220 } // namespace examples | 222 } // namespace examples |
| 221 | 223 |
| 222 MojoResult MojoMain(MojoHandle application_request) { | 224 MojoResult MojoMain(MojoHandle application_request) { |
| 223 mojo::ApplicationRunnerChromium runner(new examples::JankApp()); | 225 mojo::ApplicationRunnerChromium runner(new examples::JankApp()); |
| 224 return runner.Run(application_request); | 226 return runner.Run(application_request); |
| 225 } | 227 } |
| OLD | NEW |