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

Side by Side Diff: chrome/gpu/gpu_channel.cc

Issue 3067026: Initial port of accelerated compositor to Mac OS X 10.6. Reused... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome/gpu/gpu_channel.h ('k') | chrome/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "chrome/gpu/gpu_channel.h" 9 #include "chrome/gpu/gpu_channel.h"
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 IPC_MESSAGE_UNHANDLED_ERROR() 93 IPC_MESSAGE_UNHANDLED_ERROR()
94 IPC_END_MESSAGE_MAP() 94 IPC_END_MESSAGE_MAP()
95 } 95 }
96 96
97 int GpuChannel::GenerateRouteID() { 97 int GpuChannel::GenerateRouteID() {
98 static int last_id = 0; 98 static int last_id = 0;
99 return ++last_id; 99 return ++last_id;
100 } 100 }
101 101
102 void GpuChannel::OnCreateViewCommandBuffer(gfx::NativeViewId view_id, 102 void GpuChannel::OnCreateViewCommandBuffer(gfx::NativeViewId view_id,
103 int32 render_view_id,
103 int32* route_id) { 104 int32* route_id) {
104 *route_id = 0; 105 *route_id = 0;
105 106
106 #if defined(ENABLE_GPU) 107 #if defined(ENABLE_GPU)
107 108
108 gfx::PluginWindowHandle handle = gfx::kNullPluginWindow; 109 gfx::PluginWindowHandle handle = gfx::kNullPluginWindow;
109 #if defined(OS_WIN) 110 #if defined(OS_WIN)
110 gfx::NativeView view = gfx::NativeViewFromId(view_id); 111 gfx::NativeView view = gfx::NativeViewFromId(view_id);
111 112
112 // Check that the calling renderer is allowed to render to this window. 113 // Check that the calling renderer is allowed to render to this window.
113 // TODO(apatrick): consider killing the renderer process rather than failing. 114 // TODO(apatrick): consider killing the renderer process rather than failing.
114 int view_renderer_id = reinterpret_cast<int>( 115 int view_renderer_id = reinterpret_cast<int>(
115 GetProp(view, chrome::kChromiumRendererIdProperty)); 116 GetProp(view, chrome::kChromiumRendererIdProperty));
116 if (view_renderer_id != renderer_id_) 117 if (view_renderer_id != renderer_id_)
117 return; 118 return;
118 handle = view; 119 handle = view;
119 #elif defined(OS_LINUX) 120 #elif defined(OS_LINUX)
120 ChildThread* gpu_thread = ChildThread::current(); 121 ChildThread* gpu_thread = ChildThread::current();
121 // Ask the browser for the view's XID. 122 // Ask the browser for the view's XID.
122 // TODO(piman): This assumes that it doesn't change. It can change however 123 // TODO(piman): This assumes that it doesn't change. It can change however
123 // when tearing off tabs. This needs a fix in the browser UI code. A possible 124 // when tearing off tabs. This needs a fix in the browser UI code. A possible
124 // alternative would be to add a socket/plug pair like with plugins but that 125 // alternative would be to add a socket/plug pair like with plugins but that
125 // has issues with events and focus. 126 // has issues with events and focus.
126 gpu_thread->Send(new GpuHostMsg_GetViewXID(view_id, &handle)); 127 gpu_thread->Send(new GpuHostMsg_GetViewXID(view_id, &handle));
128 #elif defined(OS_MACOSX)
129 // On Mac OS X we currently pass a (fake) PluginWindowHandle for the
130 // NativeViewId. We could allocate fake NativeViewIds on the browser
131 // side as well, and map between those and PluginWindowHandles, but
132 // this seems excessive.
133 handle = static_cast<gfx::PluginWindowHandle>(
134 static_cast<intptr_t>(view_id));
127 #else 135 #else
128 // TODO(apatrick): This needs to be something valid for mac and linux. 136 // TODO(apatrick): This needs to be something valid for mac and linux.
129 // Offscreen rendering will work on these platforms but not rendering to the 137 // Offscreen rendering will work on these platforms but not rendering to the
130 // window. 138 // window.
131 DCHECK_EQ(view_id, 0); 139 DCHECK_EQ(view_id, 0);
132 #endif 140 #endif
133 141
134 *route_id = GenerateRouteID(); 142 *route_id = GenerateRouteID();
135 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( 143 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub(
136 this, handle, NULL, gfx::Size(), 0, *route_id)); 144 this, handle, NULL, gfx::Size(), 0, *route_id,
145 renderer_id_, render_view_id));
137 router_.AddRoute(*route_id, stub.get()); 146 router_.AddRoute(*route_id, stub.get());
138 stubs_.AddWithID(stub.release(), *route_id); 147 stubs_.AddWithID(stub.release(), *route_id);
139 #endif // ENABLE_GPU 148 #endif // ENABLE_GPU
140 } 149 }
141 150
142 void GpuChannel::OnCreateOffscreenCommandBuffer(int32 parent_route_id, 151 void GpuChannel::OnCreateOffscreenCommandBuffer(int32 parent_route_id,
143 const gfx::Size& size, 152 const gfx::Size& size,
144 uint32 parent_texture_id, 153 uint32 parent_texture_id,
145 int32* route_id) { 154 int32* route_id) {
146 #if defined(ENABLE_GPU) 155 #if defined(ENABLE_GPU)
147 *route_id = GenerateRouteID(); 156 *route_id = GenerateRouteID();
148 GpuCommandBufferStub* parent_stub = NULL; 157 GpuCommandBufferStub* parent_stub = NULL;
149 if (parent_route_id != 0) 158 if (parent_route_id != 0)
150 parent_stub = stubs_.Lookup(parent_route_id); 159 parent_stub = stubs_.Lookup(parent_route_id);
151 160
152 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( 161 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub(
153 this, 162 this,
154 gfx::kNullPluginWindow, 163 gfx::kNullPluginWindow,
155 parent_stub, 164 parent_stub,
156 size, 165 size,
157 parent_texture_id, 166 parent_texture_id,
158 *route_id)); 167 *route_id,
168 0, 0));
159 router_.AddRoute(*route_id, stub.get()); 169 router_.AddRoute(*route_id, stub.get());
160 stubs_.AddWithID(stub.release(), *route_id); 170 stubs_.AddWithID(stub.release(), *route_id);
161 #else 171 #else
162 *route_id = 0; 172 *route_id = 0;
163 #endif 173 #endif
164 } 174 }
165 175
166 void GpuChannel::OnDestroyCommandBuffer(int32 route_id) { 176 void GpuChannel::OnDestroyCommandBuffer(int32 route_id) {
167 #if defined(ENABLE_GPU) 177 #if defined(ENABLE_GPU)
168 router_.RemoveRoute(route_id); 178 router_.RemoveRoute(route_id);
(...skipping 20 matching lines...) Expand all
189 channel_.reset(new IPC::SyncChannel( 199 channel_.reset(new IPC::SyncChannel(
190 channel_name, IPC::Channel::MODE_SERVER, this, NULL, 200 channel_name, IPC::Channel::MODE_SERVER, this, NULL,
191 ChildProcess::current()->io_message_loop(), false, 201 ChildProcess::current()->io_message_loop(), false,
192 ChildProcess::current()->GetShutDownEvent())); 202 ChildProcess::current()->GetShutDownEvent()));
193 return true; 203 return true;
194 } 204 }
195 205
196 std::string GpuChannel::GetChannelName() { 206 std::string GpuChannel::GetChannelName() {
197 return StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id_); 207 return StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id_);
198 } 208 }
OLDNEW
« no previous file with comments | « chrome/gpu/gpu_channel.h ('k') | chrome/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698