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

Side by Side Diff: ui/ozone/platform/dri/gpu_platform_support_gbm.cc

Issue 479713002: [Ozone-GBM] Adding NativeWindowDelegate to IPC window changes to the GPU (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 #include "ui/ozone/platform/dri/native_window_delegate_impl.h"
11 #include "ui/ozone/platform/dri/native_window_manager.h"
10 12
11 namespace ui { 13 namespace ui {
12 14
13 GpuPlatformSupportGbm::GpuPlatformSupportGbm(DriSurfaceFactory* dri) 15 GpuPlatformSupportGbm::GpuPlatformSupportGbm(
14 : sender_(NULL), dri_(dri) { 16 DriSurfaceFactory* dri,
17 NativeWindowManager* window_manager,
18 ScreenManager* screen_manager)
19 : sender_(NULL),
20 dri_(dri),
21 window_manager_(window_manager),
22 screen_manager_(screen_manager) {
15 } 23 }
16 24
17 GpuPlatformSupportGbm::~GpuPlatformSupportGbm() {} 25 GpuPlatformSupportGbm::~GpuPlatformSupportGbm() {}
18 26
19 void GpuPlatformSupportGbm::AddHandler(scoped_ptr<GpuPlatformSupport> handler) { 27 void GpuPlatformSupportGbm::AddHandler(scoped_ptr<GpuPlatformSupport> handler) {
20 handlers_.push_back(handler.release()); 28 handlers_.push_back(handler.release());
21 } 29 }
22 30
23 void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) { 31 void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) {
24 sender_ = sender; 32 sender_ = sender;
25 33
26 for (size_t i = 0; i < handlers_.size(); ++i) 34 for (size_t i = 0; i < handlers_.size(); ++i)
27 handlers_[i]->OnChannelEstablished(sender); 35 handlers_[i]->OnChannelEstablished(sender);
28 } 36 }
29 37
30 bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) { 38 bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) {
31 bool handled = true; 39 bool handled = true;
32 40
33 IPC_BEGIN_MESSAGE_MAP(GpuPlatformSupportGbm, message) 41 IPC_BEGIN_MESSAGE_MAP(GpuPlatformSupportGbm, message)
42 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CreateNativeWindowDelegate,
43 OnCreateNativeWindowDelegate)
44 IPC_MESSAGE_HANDLER(OzoneGpuMsg_DestoryNativeWindowDelegate,
45 OnDestoryNativeWindowDelegate)
46 IPC_MESSAGE_HANDLER(OzoneGpuMsg_NativeWindowBoundsChanged,
47 OnNativeWindowBoundsChanged)
48
34 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet) 49 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
35 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove) 50 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
36 IPC_MESSAGE_UNHANDLED(handled = false); 51 IPC_MESSAGE_UNHANDLED(handled = false);
37 IPC_END_MESSAGE_MAP() 52 IPC_END_MESSAGE_MAP()
38 53
39 if (!handled) 54 if (!handled)
40 for (size_t i = 0; i < handlers_.size(); ++i) 55 for (size_t i = 0; i < handlers_.size(); ++i)
41 if (handlers_[i]->OnMessageReceived(message)) 56 if (handlers_[i]->OnMessageReceived(message))
42 return true; 57 return true;
43 58
44 return false; 59 return false;
45 } 60 }
46 61
62 void GpuPlatformSupportGbm::OnCreateNativeWindowDelegate(
63 gfx::AcceleratedWidget widget) {
64 // Due to how the GPU process starts up this IPC call may happen after the IPC
65 // to create a surface. Since a surface wants to know the window associated
66 // with it, we create it ahead of time. So when this call happens we do not
67 // create a delegate if it already exists.
68 // Note: NativeWindowDelegateImpl registers itself with |window_manager_| on
69 // allocation, so we don't need to keep track of it further.
70 if (!window_manager_->HasNativeWindowDelegate(widget))
71 new NativeWindowDelegateImpl(widget, window_manager_, screen_manager_);
72 }
73
74 void GpuPlatformSupportGbm::OnDestoryNativeWindowDelegate(
75 gfx::AcceleratedWidget widget) {
76 scoped_ptr<NativeWindowDelegate> delegate(
77 window_manager_->GetNativeWindowDelegate(widget));
78 }
79
80 void GpuPlatformSupportGbm::OnNativeWindowBoundsChanged(
81 gfx::AcceleratedWidget widget, const gfx::Rect& bounds) {
82 window_manager_->GetNativeWindowDelegate(widget)->OnBoundsChanged(bounds);
83 }
84
47 void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget, 85 void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget,
48 const SkBitmap& bitmap, 86 const SkBitmap& bitmap,
49 const gfx::Point& location) { 87 const gfx::Point& location) {
50 dri_->SetHardwareCursor(widget, bitmap, location); 88 dri_->SetHardwareCursor(widget, bitmap, location);
51 } 89 }
52 90
53 void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget, 91 void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget,
54 const gfx::Point& location) { 92 const gfx::Point& location) {
55 dri_->MoveHardwareCursor(widget, location); 93 dri_->MoveHardwareCursor(widget, location);
56 } 94 }
57 95
58 } // namespace ui 96 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698