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

Side by Side Diff: apps/moterm/moterm_view.h

Issue 1556683004: Port Moterm to Mozart. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-16
Patch Set: fix nits Created 4 years, 11 months 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 | « apps/moterm/moterm_main.cc ('k') | apps/moterm/moterm_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 APPS_MOTERM_MOTERM_VIEW_H_ 5 #ifndef APPS_MOTERM_MOTERM_VIEW_H_
6 #define APPS_MOTERM_MOTERM_VIEW_H_ 6 #define APPS_MOTERM_MOTERM_VIEW_H_
7 7
8 #include "apps/moterm/gl_helper.h" 8 #include <memory>
9
9 #include "apps/moterm/moterm_driver.h" 10 #include "apps/moterm/moterm_driver.h"
10 #include "apps/moterm/moterm_model.h" 11 #include "apps/moterm/moterm_model.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "mojo/common/binding_set.h" 14 #include "mojo/common/binding_set.h"
14 #include "mojo/public/cpp/application/interface_factory.h" 15 #include "mojo/public/cpp/application/interface_factory.h"
15 #include "mojo/public/cpp/application/service_provider_impl.h" 16 #include "mojo/public/cpp/application/service_provider_impl.h"
16 #include "mojo/public/cpp/bindings/callback.h" 17 #include "mojo/public/cpp/bindings/callback.h"
17 #include "mojo/public/cpp/bindings/interface_request.h" 18 #include "mojo/public/cpp/bindings/interface_request.h"
18 #include "mojo/services/surfaces/interfaces/surface_id.mojom.h" 19 #include "mojo/services/input_events/interfaces/input_event_constants.mojom.h"
20 #include "mojo/services/input_events/interfaces/input_events.mojom.h"
19 #include "mojo/services/terminal/interfaces/terminal.mojom.h" 21 #include "mojo/services/terminal/interfaces/terminal.mojom.h"
20 #include "mojo/services/view_manager/cpp/view_observer.h" 22 #include "mojo/ui/choreographer.h"
21 #include "skia/ext/refptr.h" 23 #include "mojo/ui/ganesh_view.h"
24 #include "mojo/ui/input_handler.h"
22 #include "third_party/skia/include/core/SkBitmapDevice.h" 25 #include "third_party/skia/include/core/SkBitmapDevice.h"
23 #include "third_party/skia/include/core/SkTypeface.h" 26 #include "third_party/skia/include/core/SkTypeface.h"
24 27
25 namespace mojo { 28 class MotermView : public mojo::ui::GaneshView,
26 class Shell; 29 public mojo::ui::ChoreographerDelegate,
27 } 30 public mojo::ui::InputListener,
28
29 class MotermView : public mojo::ViewObserver,
30 public GlHelper::Client,
31 public MotermModel::Delegate, 31 public MotermModel::Delegate,
32 public MotermDriver::Client, 32 public MotermDriver::Client,
33 public mojo::InterfaceFactory<mojo::terminal::Terminal>, 33 public mojo::InterfaceFactory<mojo::terminal::Terminal>,
34 public mojo::terminal::Terminal { 34 public mojo::terminal::Terminal {
35 public: 35 public:
36 MotermView( 36 MotermView(
37 mojo::Shell* shell, 37 mojo::ApplicationImpl* app_impl,
38 mojo::View* view, 38 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request,
39 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request); 39 const mojo::ui::ViewProvider::CreateViewCallback& create_view_callback);
40 ~MotermView() override; 40 ~MotermView() override;
41 41
42 private: 42 private:
43 // |mojo::ViewObserver|: 43 // |mojo::ui::GaneshView|:
44 void OnViewDestroyed(mojo::View* view) override; 44 void OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params,
45 void OnViewBoundsChanged(mojo::View* view, 45 mojo::Array<uint32_t> children_needing_layout,
46 const mojo::Rect& old_bounds, 46 const OnLayoutCallback& callback) override;
47 const mojo::Rect& new_bounds) override;
48 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override;
49 47
50 // |GlHelper::Client|: 48 // |mojo::ui::ChoreographerDelegate|:
51 void OnSurfaceIdChanged(mojo::SurfaceIdPtr surface_id) override; 49 void OnDraw(const mojo::gfx::composition::FrameInfo& frame_info,
52 void OnContextLost() override; 50 const base::TimeDelta& time_delta) override;
53 void OnFrameDisplayed(uint32_t frame_id) override; 51
52 // |mojo::ui::InputListener|:
53 void OnEvent(mojo::EventPtr event, const OnEventCallback& callback) override;
54 54
55 // |MotermModel::Delegate|: 55 // |MotermModel::Delegate|:
56 void OnResponse(const void* buf, size_t size) override; 56 void OnResponse(const void* buf, size_t size) override;
57 void OnSetKeypadMode(bool application_mode) override; 57 void OnSetKeypadMode(bool application_mode) override;
58 58
59 // |MotermDriver::Client|: 59 // |MotermDriver::Client|:
60 void OnDataReceived(const void* bytes, size_t num_bytes) override; 60 void OnDataReceived(const void* bytes, size_t num_bytes) override;
61 void OnClosed() override; 61 void OnClosed() override;
62 void OnDestroyed() override; 62 void OnDestroyed() override;
63 63
(...skipping 10 matching lines...) Expand all
74 bool force, 74 bool force,
75 const ConnectToClientCallback& callback) override; 75 const ConnectToClientCallback& callback) override;
76 void GetSize(const GetSizeCallback& callback) override; 76 void GetSize(const GetSizeCallback& callback) override;
77 void SetSize(uint32_t rows, 77 void SetSize(uint32_t rows,
78 uint32_t columns, 78 uint32_t columns,
79 bool reset, 79 bool reset,
80 const SetSizeCallback& callback) override; 80 const SetSizeCallback& callback) override;
81 81
82 // If |force| is true, it will draw everything. Otherwise it will draw only if 82 // If |force| is true, it will draw everything. Otherwise it will draw only if
83 // |model_state_changes_| is dirty. 83 // |model_state_changes_| is dirty.
84 void Draw(bool force); 84 void ScheduleDraw(bool force);
85 void DrawContent(SkCanvas* canvas);
85 86
86 void OnKeyPressed(const mojo::EventPtr& key_event); 87 void OnKeyPressed(mojo::EventPtr key_event);
87 88
88 mojo::View* const view_; 89 mojo::Size view_size_;
89 GlHelper gl_helper_; 90 mojo::ui::Choreographer choreographer_;
91 mojo::ui::InputHandler input_handler_;
90 92
91 // TODO(vtl): Consider the structure of this app. Do we really want the "view" 93 // TODO(vtl): Consider the structure of this app. Do we really want the "view"
92 // owning the model? 94 // owning the model?
93 // The terminal model. 95 // The terminal model.
94 MotermModel model_; 96 MotermModel model_;
95 // State changes to the model since last draw. 97 // State changes to the model since last draw.
96 MotermModel::StateChanges model_state_changes_; 98 MotermModel::StateChanges model_state_changes_;
97 99
98 base::WeakPtr<MotermDriver> driver_; 100 base::WeakPtr<MotermDriver> driver_;
99 // If set, called when we get |OnClosed()| or |OnDestroyed()| from the driver. 101 // If set, called when we get |OnClosed()| or |OnDestroyed()| from the driver.
100 mojo::Closure on_closed_callback_; 102 mojo::Closure on_closed_callback_;
101 103
102 mojo::ServiceProviderImpl service_provider_impl_; 104 mojo::ServiceProviderImpl service_provider_impl_;
103 mojo::BindingSet<mojo::terminal::Terminal> terminal_bindings_; 105 mojo::BindingSet<mojo::terminal::Terminal> terminal_bindings_;
104 106
105 // TODO(vtl): For some reason, drawing while a frame is already pending (i.e.,
106 // we've submitted it but haven't gotten a callback) interacts badly with
107 // resizing -- sometimes this results in us losing all future
108 // |OnViewBoundsChanged()| messages. So, for now, don't submit frames in that
109 // case.
110 bool frame_pending_;
111 // If we skip drawing despite being forced to, we should force the next draw. 107 // If we skip drawing despite being forced to, we should force the next draw.
112 bool force_next_draw_; 108 bool force_next_draw_;
113 109
114 skia::RefPtr<SkTypeface> regular_typeface_; 110 skia::RefPtr<SkTypeface> regular_typeface_;
115 111
116 int ascent_; 112 int ascent_;
117 int line_height_; 113 int line_height_;
118 int advance_width_; 114 int advance_width_;
119 115
120 skia::RefPtr<SkBitmapDevice> bitmap_device_;
121
122 // Keyboard state. 116 // Keyboard state.
123 bool keypad_application_mode_; 117 bool keypad_application_mode_;
124 118
125 DISALLOW_COPY_AND_ASSIGN(MotermView); 119 DISALLOW_COPY_AND_ASSIGN(MotermView);
126 }; 120 };
127 121
128 #endif // APPS_MOTERM_MOTERM_VIEW_H_ 122 #endif // APPS_MOTERM_MOTERM_VIEW_H_
OLDNEW
« no previous file with comments | « apps/moterm/moterm_main.cc ('k') | apps/moterm/moterm_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698