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