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

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

Powered by Google App Engine
This is Rietveld 408576698