OLD | NEW |
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 SERVICES_KEYBOARD_NATIVE_VIEW_OBSERVER_DELEGATE_H_ | 5 #ifndef SERVICES_KEYBOARD_NATIVE_VIEW_OBSERVER_DELEGATE_H_ |
6 #define SERVICES_KEYBOARD_NATIVE_VIEW_OBSERVER_DELEGATE_H_ | 6 #define SERVICES_KEYBOARD_NATIVE_VIEW_OBSERVER_DELEGATE_H_ |
7 | 7 |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "mojo/gpu/texture_cache.h" | 9 #include "mojo/gpu/texture_cache.h" |
10 #include "mojo/gpu/texture_uploader.h" | 10 #include "mojo/gpu/texture_uploader.h" |
11 #include "mojo/services/view_manager/public/cpp/view_observer.h" | 11 #include "mojo/services/view_manager/public/cpp/view_observer.h" |
12 #include "mojo/skia/ganesh_context.h" | 12 #include "mojo/skia/ganesh_context.h" |
13 #include "services/keyboard_native/key_layout.h" | 13 #include "services/keyboard_native/key_layout.h" |
14 #include "services/keyboard_native/material_splash_animation.h" | 14 #include "services/keyboard_native/material_splash_animation.h" |
15 #include "services/keyboard_native/motion_decay_animation.h" | 15 #include "services/keyboard_native/motion_decay_animation.h" |
16 #include "ui/gfx/geometry/point_f.h" | 16 #include "ui/gfx/geometry/point_f.h" |
17 #include "ui/gfx/geometry/rect_f.h" | 17 #include "ui/gfx/geometry/rect_f.h" |
18 | 18 |
19 namespace keyboard { | 19 namespace keyboard { |
20 | 20 |
21 class KeyboardServiceImpl; | 21 class KeyboardServiceImpl; |
| 22 class Predictor; |
22 | 23 |
23 struct PointerState { | 24 struct PointerState { |
24 KeyLayout::Key* last_key; | 25 KeyLayout::Key* last_key; |
25 gfx::PointF last_point; | 26 gfx::PointF last_point; |
26 bool last_point_valid; | 27 bool last_point_valid; |
27 }; | 28 }; |
28 | 29 |
29 class ViewObserverDelegate : public mojo::ViewObserver { | 30 class ViewObserverDelegate : public mojo::ViewObserver { |
30 public: | 31 public: |
31 ViewObserverDelegate(); | 32 ViewObserverDelegate(); |
32 ~ViewObserverDelegate() override; | 33 ~ViewObserverDelegate() override; |
33 void SetKeyboardServiceImpl(KeyboardServiceImpl* keyboard_service_impl); | 34 void SetKeyboardServiceImpl(KeyboardServiceImpl* keyboard_service_impl); |
34 void OnViewCreated(mojo::View* view, mojo::Shell* shell); | 35 void OnViewCreated(mojo::View* view, mojo::Shell* shell); |
35 | 36 |
36 private: | 37 private: |
37 void SetIdNamespace(uint32_t id_namespace); | 38 void SetIdNamespace(uint32_t id_namespace); |
38 void UpdateSurfaceIds(); | 39 void UpdateSurfaceIds(); |
39 void OnFrameComplete(); | 40 void OnFrameComplete(); |
40 void OnText(const std::string& text); | 41 void OnText(const std::string& text); |
41 void OnDelete(); | 42 void OnDelete(); |
| 43 void OnSuggestText(const std::string& text); |
| 44 void OnUpdateSuggestion(); |
42 void DrawState(); | 45 void DrawState(); |
43 void DrawKeysToCanvas(const gfx::RectF& key_area, SkCanvas* canvas); | 46 void DrawKeysToCanvas(const gfx::RectF& key_area, SkCanvas* canvas); |
44 void DrawAnimations(SkCanvas* canvas, const base::TimeTicks& current_ticks); | 47 void DrawAnimations(SkCanvas* canvas, const base::TimeTicks& current_ticks); |
45 void DrawFloatingKey(SkCanvas* canvas, | 48 void DrawFloatingKey(SkCanvas* canvas, |
46 float floating_key_height, | 49 float floating_key_height, |
47 float floating_key_width); | 50 float floating_key_width); |
48 void UpdateState(int32 pointer_id, | 51 void UpdateState(int32 pointer_id, |
49 int action, | 52 int action, |
50 const gfx::PointF& touch_point); | 53 const gfx::PointF& touch_point); |
51 void IssueDraw(); | 54 void IssueDraw(); |
52 | 55 |
53 // mojo::ViewObserver implementation. | 56 // mojo::ViewObserver implementation. |
54 void OnViewDestroyed(mojo::View* view) override; | 57 void OnViewDestroyed(mojo::View* view) override; |
55 void OnViewBoundsChanged(mojo::View* view, | 58 void OnViewBoundsChanged(mojo::View* view, |
56 const mojo::Rect& old_bounds, | 59 const mojo::Rect& old_bounds, |
57 const mojo::Rect& new_bounds) override; | 60 const mojo::Rect& new_bounds) override; |
58 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; | 61 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; |
59 | 62 |
60 KeyboardServiceImpl* keyboard_service_impl_; | 63 KeyboardServiceImpl* keyboard_service_impl_; |
| 64 Predictor* predictor_; |
61 mojo::View* view_; | 65 mojo::View* view_; |
62 uint32_t id_namespace_; | 66 uint32_t id_namespace_; |
63 uint32_t surface_id_; | 67 uint32_t surface_id_; |
64 base::WeakPtr<mojo::GLContext> gl_context_; | 68 base::WeakPtr<mojo::GLContext> gl_context_; |
65 scoped_ptr<mojo::GaneshContext> gr_context_; | 69 scoped_ptr<mojo::GaneshContext> gr_context_; |
66 scoped_ptr<mojo::TextureCache> texture_cache_; | 70 scoped_ptr<mojo::TextureCache> texture_cache_; |
67 scoped_ptr<Animation> clip_animation_; | 71 scoped_ptr<Animation> clip_animation_; |
68 std::deque<scoped_ptr<Animation>> animations_; | 72 std::deque<scoped_ptr<Animation>> animations_; |
69 KeyLayout key_layout_; | 73 KeyLayout key_layout_; |
70 std::vector<int32> active_pointer_ids_; | 74 std::vector<int32> active_pointer_ids_; |
71 std::map<int32, scoped_ptr<PointerState>> active_pointer_state_; | 75 std::map<int32, scoped_ptr<PointerState>> active_pointer_state_; |
72 bool needs_draw_; | 76 bool needs_draw_; |
73 bool frame_pending_; | 77 bool frame_pending_; |
74 float floating_key_height_; | 78 float floating_key_height_; |
75 float floating_key_width_; | 79 float floating_key_width_; |
76 gfx::RectF key_area_; | 80 gfx::RectF key_area_; |
77 mojo::SurfacePtr surface_; | 81 mojo::SurfacePtr surface_; |
78 base::Closure submit_frame_callback_; | 82 base::Closure submit_frame_callback_; |
79 base::WeakPtrFactory<ViewObserverDelegate> weak_factory_; | 83 base::WeakPtrFactory<ViewObserverDelegate> weak_factory_; |
80 | 84 |
81 DISALLOW_COPY_AND_ASSIGN(ViewObserverDelegate); | 85 DISALLOW_COPY_AND_ASSIGN(ViewObserverDelegate); |
82 }; | 86 }; |
83 | 87 |
84 } // namespace keyboard | 88 } // namespace keyboard |
85 | 89 |
86 #endif // SERVICES_KEYBOARD_NATIVE_VIEW_OBSERVER_DELEGATE_H_ | 90 #endif // SERVICES_KEYBOARD_NATIVE_VIEW_OBSERVER_DELEGATE_H_ |
OLD | NEW |