Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / ozone / platform / dri / gpu_platform_support_gbm.cc
1 // Copyright 2014 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 #include "ui/ozone/platform/dri/gpu_platform_support_gbm.h"
6
7 #include "ipc/ipc_message_macros.h"
8 #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
9 #include "ui/ozone/platform/dri/dri_surface_factory.h"
10
11 namespace ui {
12
13 GpuPlatformSupportGbm::GpuPlatformSupportGbm(DriSurfaceFactory* dri)
14     : sender_(NULL), dri_(dri) {
15 }
16
17 GpuPlatformSupportGbm::~GpuPlatformSupportGbm() {}
18
19 void GpuPlatformSupportGbm::AddHandler(scoped_ptr<GpuPlatformSupport> handler) {
20   handlers_.push_back(handler.release());
21 }
22
23 void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) {
24   sender_ = sender;
25
26   for (size_t i = 0; i < handlers_.size(); ++i)
27     handlers_[i]->OnChannelEstablished(sender);
28 }
29
30 bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) {
31   bool handled = true;
32
33   IPC_BEGIN_MESSAGE_MAP(GpuPlatformSupportGbm, message)
34   IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
35   IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
36   IPC_MESSAGE_UNHANDLED(handled = false);
37   IPC_END_MESSAGE_MAP()
38
39   if (!handled)
40     for (size_t i = 0; i < handlers_.size(); ++i)
41       if (handlers_[i]->OnMessageReceived(message))
42         return true;
43
44   return false;
45 }
46
47 void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget,
48                                         const SkBitmap& bitmap,
49                                         const gfx::Point& location) {
50   dri_->SetHardwareCursor(widget, bitmap, location);
51 }
52
53 void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget,
54                                          const gfx::Point& location) {
55   dri_->MoveHardwareCursor(widget, location);
56 }
57
58 }  // namespace ui