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

Side by Side Diff: chrome/gpu/gpu_command_buffer_stub.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_command_buffer_stub.h ('k') | chrome/renderer/ggl/ggl.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(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 #include "base/shared_memory.h" 8 #include "base/shared_memory.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/common/child_thread.h"
10 #include "chrome/common/gpu_messages.h" 11 #include "chrome/common/gpu_messages.h"
11 #include "chrome/gpu/gpu_channel.h" 12 #include "chrome/gpu/gpu_channel.h"
12 #include "chrome/gpu/gpu_command_buffer_stub.h" 13 #include "chrome/gpu/gpu_command_buffer_stub.h"
13 14
14 using gpu::Buffer; 15 using gpu::Buffer;
15 16
16 GpuCommandBufferStub::GpuCommandBufferStub(GpuChannel* channel, 17 GpuCommandBufferStub::GpuCommandBufferStub(GpuChannel* channel,
17 gfx::PluginWindowHandle handle, 18 gfx::PluginWindowHandle handle,
18 GpuCommandBufferStub* parent, 19 GpuCommandBufferStub* parent,
19 const gfx::Size& size, 20 const gfx::Size& size,
20 uint32 parent_texture_id, 21 uint32 parent_texture_id,
21 int32 route_id) 22 int32 route_id,
23 int32 renderer_id,
24 int32 render_view_id)
22 : channel_(channel), 25 : channel_(channel),
23 handle_(handle), 26 handle_(handle),
24 parent_( 27 parent_(
25 parent ? parent->AsWeakPtr() : base::WeakPtr<GpuCommandBufferStub>()), 28 parent ? parent->AsWeakPtr() : base::WeakPtr<GpuCommandBufferStub>()),
26 initial_size_(size), 29 initial_size_(size),
27 parent_texture_id_(parent_texture_id), 30 parent_texture_id_(parent_texture_id),
28 route_id_(route_id) { 31 route_id_(route_id),
32 renderer_id_(renderer_id),
33 render_view_id_(render_view_id) {
29 } 34 }
30 35
31 GpuCommandBufferStub::~GpuCommandBufferStub() { 36 GpuCommandBufferStub::~GpuCommandBufferStub() {
32 if (processor_.get()) { 37 if (processor_.get()) {
33 processor_->Destroy(); 38 processor_->Destroy();
34 } 39 }
35 } 40 }
36 41
37 void GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { 42 void GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
38 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) 43 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message)
39 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize); 44 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize);
40 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState); 45 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState);
41 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState); 46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState);
42 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush); 47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush);
43 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
44 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateTransferBuffer, 49 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateTransferBuffer,
45 OnCreateTransferBuffer); 50 OnCreateTransferBuffer);
46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, 51 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer,
47 OnDestroyTransferBuffer); 52 OnDestroyTransferBuffer);
48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetTransferBuffer, 53 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetTransferBuffer,
49 OnGetTransferBuffer); 54 OnGetTransferBuffer);
50 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, 55 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer,
51 OnResizeOffscreenFrameBuffer); 56 OnResizeOffscreenFrameBuffer);
57 #if defined(OS_MACOSX)
58 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize);
59 #endif
52 IPC_MESSAGE_UNHANDLED_ERROR() 60 IPC_MESSAGE_UNHANDLED_ERROR()
53 IPC_END_MESSAGE_MAP() 61 IPC_END_MESSAGE_MAP()
54 } 62 }
55 63
56 bool GpuCommandBufferStub::Send(IPC::Message* message) { 64 bool GpuCommandBufferStub::Send(IPC::Message* message) {
57 return channel_->Send(message); 65 return channel_->Send(message);
58 } 66 }
59 67
60 void GpuCommandBufferStub::OnInitialize( 68 void GpuCommandBufferStub::OnInitialize(
61 int32 size, 69 int32 size,
(...skipping 17 matching lines...) Expand all
79 parent_processor, 87 parent_processor,
80 parent_texture_id_)) { 88 parent_texture_id_)) {
81 command_buffer_->SetPutOffsetChangeCallback( 89 command_buffer_->SetPutOffsetChangeCallback(
82 NewCallback(processor_.get(), 90 NewCallback(processor_.get(),
83 &gpu::GPUProcessor::ProcessCommands)); 91 &gpu::GPUProcessor::ProcessCommands));
84 92
85 // Assume service is responsible for duplicating the handle from the 93 // Assume service is responsible for duplicating the handle from the
86 // calling process. 94 // calling process.
87 buffer.shared_memory->ShareToProcess(channel_->renderer_handle(), 95 buffer.shared_memory->ShareToProcess(channel_->renderer_handle(),
88 ring_buffer); 96 ring_buffer);
97 #if defined(OS_MACOSX)
98 if (handle_) {
99 // This context conceptually puts its output directly on the
100 // screen, rendered by the accelerated plugin layer in
101 // RenderWidgetHostViewMac. Set up a pathway to notify the
102 // browser process when its contents change.
103 processor_->SetSwapBuffersCallback(
104 NewCallback(this,
105 &GpuCommandBufferStub::SwapBuffersCallback));
106 }
107 #endif
89 } else { 108 } else {
90 processor_.reset(); 109 processor_.reset();
91 command_buffer_.reset(); 110 command_buffer_.reset();
92 } 111 }
93 } 112 }
94 } 113 }
95 } 114 }
96 115
97 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { 116 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) {
98 *state = command_buffer_->GetState(); 117 *state = command_buffer_->GetState();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 buffer.shared_memory->ShareToProcess(channel_->renderer_handle(), 154 buffer.shared_memory->ShareToProcess(channel_->renderer_handle(),
136 transfer_buffer); 155 transfer_buffer);
137 *size = buffer.shared_memory->max_size(); 156 *size = buffer.shared_memory->max_size();
138 } 157 }
139 } 158 }
140 159
141 void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) { 160 void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) {
142 processor_->ResizeOffscreenFrameBuffer(size); 161 processor_->ResizeOffscreenFrameBuffer(size);
143 } 162 }
144 163
164 #if defined(OS_MACOSX)
165 void GpuCommandBufferStub::OnSetWindowSize(const gfx::Size& size) {
166 ChildThread* gpu_thread = ChildThread::current();
167 // Try using the IOSurface version first.
168 uint64 new_backing_store = processor_->SetWindowSizeForIOSurface(size);
169 if (new_backing_store) {
170 GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params;
171 params.renderer_id = renderer_id_;
172 params.render_view_id = render_view_id_;
173 params.window = handle_;
174 params.width = size.width();
175 params.height = size.height();
176 params.identifier = new_backing_store;
177 gpu_thread->Send(new GpuHostMsg_AcceleratedSurfaceSetIOSurface(params));
178 } else {
179 // TODO(kbr): figure out what to do here. It wouldn't be difficult
180 // to support the compositor on 10.5, but the performance would be
181 // questionable.
182 NOTREACHED();
183 }
184 }
185
186 void GpuCommandBufferStub::SwapBuffersCallback() {
187 ChildThread* gpu_thread = ChildThread::current();
188 gpu_thread->Send(
189 new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(renderer_id_,
190 render_view_id_,
191 handle_));
192 }
193 #endif // defined(OS_MACOSX)
194
145 #endif // ENABLE_GPU 195 #endif // ENABLE_GPU
OLDNEW
« no previous file with comments | « chrome/gpu/gpu_command_buffer_stub.h ('k') | chrome/renderer/ggl/ggl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698