OLD | NEW |
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 #include "chrome/renderer/gpu_channel_host.h" | 5 #include "chrome/renderer/gpu_channel_host.h" |
6 | 6 |
7 #include "chrome/common/child_process.h" | 7 #include "chrome/common/child_process.h" |
8 #include "chrome/common/gpu_messages.h" | 8 #include "chrome/common/gpu_messages.h" |
9 #include "chrome/renderer/command_buffer_proxy.h" | 9 #include "chrome/renderer/command_buffer_proxy.h" |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 bool GpuChannelHost::Send(IPC::Message* message) { | 58 bool GpuChannelHost::Send(IPC::Message* message) { |
59 if (!channel_.get()) { | 59 if (!channel_.get()) { |
60 delete message; | 60 delete message; |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 return channel_->Send(message); | 64 return channel_->Send(message); |
65 } | 65 } |
66 | 66 |
67 CommandBufferProxy* GpuChannelHost::CreateCommandBuffer() { | 67 CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( |
| 68 gfx::NativeViewId view) { |
68 #if defined(ENABLE_GPU) | 69 #if defined(ENABLE_GPU) |
69 // An error occurred. Need to get the host again to reinitialize it. | 70 // An error occurred. Need to get the host again to reinitialize it. |
70 if (!channel_.get()) | 71 if (!channel_.get()) |
71 return NULL; | 72 return NULL; |
72 | 73 |
73 int32 route_id; | 74 int32 route_id; |
74 if (!Send(new GpuChannelMsg_CreateCommandBuffer(&route_id)) && | 75 if (!Send(new GpuChannelMsg_CreateViewCommandBuffer(view, &route_id)) && |
75 route_id != MSG_ROUTING_NONE) { | 76 route_id != MSG_ROUTING_NONE) { |
76 return NULL; | 77 return NULL; |
77 } | 78 } |
78 | 79 |
79 CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id); | 80 CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id); |
80 router_.AddRoute(route_id, command_buffer); | 81 router_.AddRoute(route_id, command_buffer); |
81 proxies_[route_id] = command_buffer; | 82 proxies_[route_id] = command_buffer; |
82 return command_buffer; | 83 return command_buffer; |
83 #else | 84 #else |
84 return NULL; | 85 return NULL; |
85 #endif | 86 #endif |
86 } | 87 } |
87 | 88 |
| 89 CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( |
| 90 CommandBufferProxy* parent, |
| 91 const gfx::Size& size, |
| 92 uint32 parent_texture_id) { |
| 93 #if defined(ENABLE_GPU) |
| 94 // An error occurred. Need to get the host again to reinitialize it. |
| 95 if (!channel_.get()) |
| 96 return NULL; |
| 97 |
| 98 int32 parent_route_id = parent ? parent->route_id() : 0; |
| 99 int32 route_id; |
| 100 if (!Send(new GpuChannelMsg_CreateOffscreenCommandBuffer(parent_route_id, |
| 101 size, |
| 102 parent_texture_id, |
| 103 &route_id)) && |
| 104 route_id != MSG_ROUTING_NONE) { |
| 105 return NULL; |
| 106 } |
| 107 |
| 108 CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id); |
| 109 router_.AddRoute(route_id, command_buffer); |
| 110 proxies_[route_id] = command_buffer; |
| 111 return command_buffer; |
| 112 #else |
| 113 return NULL; |
| 114 #endif |
| 115 } |
| 116 |
88 void GpuChannelHost::DestroyCommandBuffer(CommandBufferProxy* command_buffer) { | 117 void GpuChannelHost::DestroyCommandBuffer(CommandBufferProxy* command_buffer) { |
89 #if defined(ENABLE_GPU) | 118 #if defined(ENABLE_GPU) |
90 Send(new GpuChannelMsg_DestroyCommandBuffer(command_buffer->route_id())); | 119 Send(new GpuChannelMsg_DestroyCommandBuffer(command_buffer->route_id())); |
91 | 120 |
92 // Check the proxy has not already been removed after a channel error. | 121 // Check the proxy has not already been removed after a channel error. |
93 int route_id = command_buffer->route_id(); | 122 int route_id = command_buffer->route_id(); |
94 if (proxies_.find(command_buffer->route_id()) != proxies_.end()) { | 123 if (proxies_.find(command_buffer->route_id()) != proxies_.end()) { |
95 proxies_.erase(route_id); | 124 proxies_.erase(route_id); |
96 router_.RemoveRoute(route_id); | 125 router_.RemoveRoute(route_id); |
97 } | 126 } |
98 | 127 |
99 delete command_buffer; | 128 delete command_buffer; |
100 #endif | 129 #endif |
101 } | 130 } |
| 131 |
OLD | NEW |