- add sources.
[platform/framework/web/crosswalk.git] / src / ozone / impl / ipc / gpu_process_dispatcher_delegate.cc
1 // Copyright 2013 Intel Corporation. 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 #include "ozone/impl/ipc/gpu_process_dispatcher_delegate.h"
6
7 #include "base/bind.h"
8 #include "content/child/child_process.h"
9 #include "content/child/child_thread.h"
10 #include "ozone/impl/ipc/messages.h"
11
12 namespace {
13
14 content::ChildThread* GetProcessMainThread() {
15   content::ChildProcess* process = content::ChildProcess::current();
16   DCHECK(process);
17   DCHECK(process->main_thread());
18   return process ? process->main_thread() : NULL;
19 }
20
21 }
22
23 namespace ozonewayland {
24
25 GpuProcessDispatcherDelegate::GpuProcessDispatcherDelegate()
26     : WaylandDispatcherDelegate() {
27 }
28
29 GpuProcessDispatcherDelegate::~GpuProcessDispatcherDelegate() {
30 }
31
32 void GpuProcessDispatcherDelegate::MotionNotify(float x, float y) {
33   PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendMotionNotify,
34                                 x,
35                                 y));
36 }
37
38 void GpuProcessDispatcherDelegate::ButtonNotify(unsigned handle,
39                                                 int state,
40                                                 int flags,
41                                                 float x,
42                                                 float y) {
43   PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendButtonNotify,
44                                 handle,
45                                 state,
46                                 flags,
47                                 x,
48                                 y));
49 }
50
51 void GpuProcessDispatcherDelegate::AxisNotify(float x,
52                                               float y,
53                                               float xoffset,
54                                               float yoffset) {
55   PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendAxisNotify,
56                                 x,
57                                 y,
58                                 xoffset,
59                                 yoffset));
60 }
61
62 void GpuProcessDispatcherDelegate::PointerEnter(unsigned handle,
63                                                 float x,
64                                                 float y) {
65   PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendPointerEnter,
66                                 handle,
67                                 x,
68                                 y));
69 }
70
71 void GpuProcessDispatcherDelegate::PointerLeave(unsigned handle,
72                                                 float x,
73                                                 float y) {
74   PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendPointerLeave,
75                                 handle,
76                                 x,
77                                 y));
78 }
79
80 void GpuProcessDispatcherDelegate::KeyNotify(unsigned state,
81                                              unsigned code,
82                                              unsigned modifiers) {
83   PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendKeyNotify,
84                                 state,
85                                 code,
86                                 modifiers));
87 }
88
89 void GpuProcessDispatcherDelegate::OutputSizeChanged(unsigned width,
90                                                      unsigned height) {
91   PostTaskOnMainLoop(base::Bind(
92       &GpuProcessDispatcherDelegate::SendOutputSizeChanged, width, height));
93 }
94
95 void GpuProcessDispatcherDelegate::SendMotionNotify(float x, float y) {
96   content::ChildThread* thread = GetProcessMainThread();
97   thread->Send(new WaylandInput_MotionNotify(x, y));
98 }
99
100 void GpuProcessDispatcherDelegate::SendButtonNotify(unsigned handle,
101                                                     int state,
102                                                     int flags,
103                                                     float x,
104                                                     float y) {
105   content::ChildThread* thread = GetProcessMainThread();
106   thread->Send(new WaylandInput_ButtonNotify(handle, state, flags, x, y));
107 }
108
109 void GpuProcessDispatcherDelegate::SendAxisNotify(float x,
110                                                   float y,
111                                                   float xoffset,
112                                                   float yoffset) {
113   content::ChildThread* thread = GetProcessMainThread();
114   thread->Send(new WaylandInput_AxisNotify(x, y, xoffset, yoffset));
115 }
116
117 void GpuProcessDispatcherDelegate::SendPointerEnter(unsigned handle,
118                                                     float x,
119                                                     float y) {
120   content::ChildThread* thread = GetProcessMainThread();
121   thread->Send(new WaylandInput_PointerEnter(handle, x, y));
122 }
123
124 void GpuProcessDispatcherDelegate::SendPointerLeave(unsigned handle,
125                                                     float x,
126                                                     float y) {
127   content::ChildThread* thread = GetProcessMainThread();
128   thread->Send(new WaylandInput_PointerLeave(handle, x, y));
129 }
130
131 void GpuProcessDispatcherDelegate::SendKeyNotify(unsigned type,
132                                                  unsigned code,
133                                                  unsigned modifiers) {
134   content::ChildThread* thread = GetProcessMainThread();
135   thread->Send(new WaylandInput_KeyNotify(type, code, modifiers));
136 }
137
138 void GpuProcessDispatcherDelegate::SendOutputSizeChanged(unsigned width,
139                                                          unsigned height) {
140   content::ChildThread* thread = GetProcessMainThread();
141   thread->Send(new WaylandInput_OutputSize(width, height));
142 }
143
144 }  // namespace ozonewayland