| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef EXAMPLES_UI_SPINNING_CUBE_SPINNING_CUBE_VIEW_H_ |
| 6 #define EXAMPLES_UI_SPINNING_CUBE_SPINNING_CUBE_VIEW_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/bind.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "examples/spinning_cube/spinning_cube.h" |
| 13 #include "mojo/gpu/gl_context.h" |
| 14 #include "mojo/gpu/gl_context_owner.h" |
| 15 #include "mojo/gpu/gl_texture.h" |
| 16 #include "mojo/gpu/texture_cache.h" |
| 17 #include "mojo/gpu/texture_uploader.h" |
| 18 #include "mojo/public/cpp/application/application_impl.h" |
| 19 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 20 #include "mojo/public/cpp/environment/environment.h" |
| 21 #include "mojo/public/cpp/system/core.h" |
| 22 #include "mojo/public/cpp/system/macros.h" |
| 23 #include "mojo/services/surfaces/interfaces/quads.mojom.h" |
| 24 #include "mojo/services/surfaces/interfaces/surfaces.mojom.h" |
| 25 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h" |
| 26 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" |
| 27 #include "mojo/services/ui/views/interfaces/views.mojom.h" |
| 28 |
| 29 namespace examples { |
| 30 |
| 31 class SpinningCubeView : public mojo::ui::View { |
| 32 public: |
| 33 SpinningCubeView(mojo::ApplicationImpl* app, |
| 34 const mojo::ui::ViewProvider::CreateViewCallback& callback); |
| 35 |
| 36 ~SpinningCubeView() override; |
| 37 |
| 38 private: |
| 39 // |View|: |
| 40 void OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params, |
| 41 mojo::Array<uint32_t> children_needing_layout, |
| 42 const OnLayoutCallback& callback) override; |
| 43 void OnChildUnavailable(uint32_t child_key, |
| 44 const OnChildUnavailableCallback& callback) override; |
| 45 |
| 46 void OnSurfaceIdNamespaceAvailable(uint32_t id_namespace); |
| 47 |
| 48 void InitView(); |
| 49 |
| 50 void InitCube(); |
| 51 void DrawCube(); |
| 52 void OnSurfaceSubmitted(); |
| 53 void ScheduleDraw(); |
| 54 |
| 55 mojo::ui::ViewProvider::CreateViewCallback callback_; |
| 56 mojo::StrongBinding<mojo::ui::View> binding_; |
| 57 |
| 58 mojo::GLContextOwner context_owner_; |
| 59 mojo::ResourceReturnerPtr resource_returner_; // must be before texture cache |
| 60 mojo::TextureCache texture_cache_; |
| 61 |
| 62 mojo::SurfacePtr surfaces_; |
| 63 mojo::SurfaceIdPtr surface_id_; |
| 64 uint32_t surface_id_namespace_; |
| 65 |
| 66 mojo::ui::ViewManagerPtr view_manager_; |
| 67 mojo::ui::ViewHostPtr view_host_; |
| 68 mojo::ServiceProviderPtr view_service_provider_; |
| 69 |
| 70 mojo::Size size_; |
| 71 |
| 72 SpinningCube cube_; |
| 73 MojoTimeTicks last_draw_; |
| 74 bool draw_scheduled_; |
| 75 |
| 76 base::WeakPtrFactory<SpinningCubeView> weak_ptr_factory_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(SpinningCubeView); |
| 79 }; |
| 80 |
| 81 } // namespace examples |
| 82 |
| 83 #endif // EXAMPLES_UI_SPINNING_CUBE_SPINNING_CUBE_VIEW_H_ |
| OLD | NEW |