Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: examples/ui/tile/tile_view.h

Issue 1425543002: mozart: Add a simple tiling view manager. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « examples/ui/tile/tile_app.cc ('k') | examples/ui/tile/tile_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 #ifndef EXAMPLES_UI_SPINNING_CUBE_SPINNING_CUBE_VIEW_H_ 5 #ifndef EXAMPLES_UI_TILE_TILE_VIEW_H_
6 #define EXAMPLES_UI_SPINNING_CUBE_SPINNING_CUBE_VIEW_H_ 6 #define EXAMPLES_UI_TILE_TILE_VIEW_H_
7 7
8 #include <map>
8 #include <memory> 9 #include <memory>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/memory/weak_ptr.h" 12 #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" 13 #include "mojo/public/cpp/application/application_impl.h"
19 #include "mojo/public/cpp/bindings/strong_binding.h" 14 #include "mojo/public/cpp/bindings/strong_binding.h"
20 #include "mojo/public/cpp/environment/environment.h" 15 #include "mojo/public/cpp/environment/environment.h"
21 #include "mojo/public/cpp/system/core.h" 16 #include "mojo/public/cpp/system/core.h"
22 #include "mojo/public/cpp/system/macros.h" 17 #include "mojo/public/cpp/system/macros.h"
23 #include "mojo/services/surfaces/interfaces/quads.mojom.h" 18 #include "mojo/services/geometry/interfaces/geometry.mojom.h"
24 #include "mojo/services/surfaces/interfaces/surfaces.mojom.h" 19 #include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
25 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h" 20 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h"
26 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" 21 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h"
27 #include "mojo/services/ui/views/interfaces/views.mojom.h" 22 #include "mojo/services/ui/views/interfaces/views.mojom.h"
28 23
29 namespace examples { 24 namespace examples {
30 25
31 class SpinningCubeView : public mojo::ui::View { 26 class TileView : public mojo::ui::View {
32 public: 27 public:
33 SpinningCubeView(mojo::ApplicationImpl* app, 28 TileView(mojo::ApplicationImpl* app_impl_,
34 const mojo::ui::ViewProvider::CreateViewCallback& callback); 29 const std::vector<std::string>& view_urls,
30 const mojo::ui::ViewProvider::CreateViewCallback& callback);
35 31
36 ~SpinningCubeView() override; 32 ~TileView() override;
37 33
38 private: 34 private:
35 struct ViewData {
36 explicit ViewData(const std::string& url);
37 ~ViewData();
38
39 const std::string url;
40
41 bool layout_pending;
42 mojo::ui::ViewLayoutParamsPtr layout_params;
43 mojo::ui::ViewLayoutInfoPtr layout_info;
44 mojo::Rect layout_bounds;
45 };
46
39 // |View|: 47 // |View|:
40 void OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params, 48 void OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params,
41 mojo::Array<uint32_t> children_needing_layout, 49 mojo::Array<uint32_t> children_needing_layout,
42 const OnLayoutCallback& callback) override; 50 const OnLayoutCallback& callback) override;
43 void OnChildUnavailable(uint32_t child_key, 51 void OnChildUnavailable(uint32_t child_key,
44 const OnChildUnavailableCallback& callback) override; 52 const OnChildUnavailableCallback& callback) override;
45 53
46 void OnSurfaceIdNamespaceAvailable(uint32_t id_namespace); 54 void OnSurfaceIdNamespaceAvailable(uint32_t id_namespace);
47 55
48 void InitView(); 56 void InitView();
57 void OnChildConnectionError(uint32_t child_key, const std::string& url);
58 void OnChildCreated(uint32_t child_key,
59 const std::string& url,
60 mojo::ui::ViewProviderPtr provider,
61 mojo::ui::ViewTokenPtr token);
62 void OnChildLayoutFinished(uint32_t child_key,
63 mojo::ui::ViewLayoutInfoPtr child_layout_info);
64 void FinishLayout();
49 65
50 void InitCube(); 66 void OnFrameSubmitted();
51 void DrawCube();
52 void OnSurfaceSubmitted();
53 void ScheduleDraw();
54 67
68 mojo::ApplicationImpl* app_impl_;
69 std::vector<std::string> view_urls_;
55 mojo::ui::ViewProvider::CreateViewCallback callback_; 70 mojo::ui::ViewProvider::CreateViewCallback callback_;
56 mojo::StrongBinding<mojo::ui::View> binding_; 71 mojo::StrongBinding<mojo::ui::View> binding_;
57 72
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_; 73 mojo::SurfacePtr surfaces_;
63 mojo::SurfaceIdPtr surface_id_; 74 mojo::SurfaceIdPtr surface_id_;
64 uint32_t surface_id_namespace_; 75 uint32_t surface_id_namespace_;
65 76
66 mojo::ui::ViewManagerPtr view_manager_; 77 mojo::ui::ViewManagerPtr view_manager_;
67 mojo::ui::ViewHostPtr view_host_; 78 mojo::ui::ViewHostPtr view_host_;
68 mojo::ServiceProviderPtr view_service_provider_; 79
80 std::map<uint32_t, std::unique_ptr<ViewData>> views_;
69 81
70 mojo::Size size_; 82 mojo::Size size_;
83 OnLayoutCallback pending_layout_callback_;
84 uint32_t pending_child_layout_count_;
85 bool frame_pending_;
71 86
72 SpinningCube cube_; 87 base::WeakPtrFactory<TileView> weak_ptr_factory_;
73 MojoTimeTicks last_draw_;
74 bool draw_scheduled_;
75 88
76 base::WeakPtrFactory<SpinningCubeView> weak_ptr_factory_; 89 DISALLOW_COPY_AND_ASSIGN(TileView);
77
78 DISALLOW_COPY_AND_ASSIGN(SpinningCubeView);
79 }; 90 };
80 91
81 } // namespace examples 92 } // namespace examples
82 93
83 #endif // EXAMPLES_UI_SPINNING_CUBE_SPINNING_CUBE_VIEW_H_ 94 #endif // EXAMPLES_UI_TILE_TILE_VIEW_H_
OLDNEW
« no previous file with comments | « examples/ui/tile/tile_app.cc ('k') | examples/ui/tile/tile_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698