summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/command_buffer_proxy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/renderer/command_buffer_proxy.cc')
-rw-r--r--chrome/renderer/command_buffer_proxy.cc77
1 files changed, 17 insertions, 60 deletions
diff --git a/chrome/renderer/command_buffer_proxy.cc b/chrome/renderer/command_buffer_proxy.cc
index 43fe0c0..aade75f 100644
--- a/chrome/renderer/command_buffer_proxy.cc
+++ b/chrome/renderer/command_buffer_proxy.cc
@@ -53,6 +53,16 @@ void CommandBufferProxy::OnChannelError() {
last_state_.error = gpu::error::kLostContext;
}
+bool CommandBufferProxy::Send(IPC::Message* msg) {
+ if (channel_)
+ return channel_->Send(msg);
+
+ // Callee takes ownership of message, regardless of whether Send is
+ // successful. See IPC::Message::Sender.
+ delete msg;
+ return false;
+}
+
bool CommandBufferProxy::Initialize(int32 size) {
DCHECK(!ring_buffer_.get());
@@ -84,21 +94,14 @@ Buffer CommandBufferProxy::GetRingBuffer() {
}
gpu::CommandBuffer::State CommandBufferProxy::GetState() {
- // Send will flag state with lost context if IPC fails.
- if (last_state_.error == gpu::error::kNoError)
- Send(new GpuCommandBufferMsg_GetState(route_id_, &last_state_));
-
+ Send(new GpuCommandBufferMsg_GetState(route_id_, &last_state_));
return last_state_;
}
gpu::CommandBuffer::State CommandBufferProxy::Flush(int32 put_offset) {
- // Send will flag state with lost context if IPC fails.
- if (last_state_.error == gpu::error::kNoError) {
- Send(new GpuCommandBufferMsg_Flush(route_id_,
- put_offset,
- &last_state_));
- }
-
+ Send(new GpuCommandBufferMsg_Flush(route_id_,
+ put_offset,
+ &last_state_));
return last_state_;
}
@@ -108,22 +111,14 @@ void CommandBufferProxy::SetGetOffset(int32 get_offset) {
}
int32 CommandBufferProxy::CreateTransferBuffer(size_t size) {
- if (last_state_.error == gpu::error::kNoError) {
- int32 id;
- if (Send(new GpuCommandBufferMsg_CreateTransferBuffer(route_id_,
- size,
- &id))) {
- return id;
- }
- }
+ int32 id;
+ if (Send(new GpuCommandBufferMsg_CreateTransferBuffer(route_id_, size, &id)))
+ return id;
return -1;
}
void CommandBufferProxy::DestroyTransferBuffer(int32 id) {
- if (last_state_.error != gpu::error::kNoError)
- return;
-
// Remove the transfer buffer from the client side4 cache.
TransferBufferMap::iterator it = transfer_buffers_.find(id);
DCHECK(it != transfer_buffers_.end());
@@ -137,9 +132,6 @@ void CommandBufferProxy::DestroyTransferBuffer(int32 id) {
}
Buffer CommandBufferProxy::GetTransferBuffer(int32 id) {
- if (last_state_.error != gpu::error::kNoError)
- return Buffer();
-
// Check local cache to see if there is already a client side shared memory
// object for this id.
TransferBufferMap::iterator it = transfer_buffers_.find(id);
@@ -205,12 +197,8 @@ void CommandBufferProxy::SetSwapBuffersCallback(Callback0::Type* callback) {
}
void CommandBufferProxy::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
- if (last_state_.error != gpu::error::kNoError)
- return;
-
IPC::Message* message =
new GpuCommandBufferMsg_ResizeOffscreenFrameBuffer(route_id_, size);
-
// We need to set the unblock flag on this message to guarantee the
// order in which it is processed in the GPU process. Ordinarily in
// certain situations, namely if a synchronous message is being
@@ -232,17 +220,11 @@ void CommandBufferProxy::SetNotifyRepaintTask(Task* task) {
#if defined(OS_MACOSX)
void CommandBufferProxy::SetWindowSize(const gfx::Size& size) {
- if (last_state_.error != gpu::error::kNoError)
- return;
-
Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, size));
}
#endif
void CommandBufferProxy::AsyncGetState(Task* completion_task) {
- if (last_state_.error != gpu::error::kNoError)
- return;
-
IPC::Message* message = new GpuCommandBufferMsg_AsyncGetState(route_id_);
// Do not let a synchronous flush hold up this message. If this handler is
@@ -255,9 +237,6 @@ void CommandBufferProxy::AsyncGetState(Task* completion_task) {
}
void CommandBufferProxy::AsyncFlush(int32 put_offset, Task* completion_task) {
- if (last_state_.error != gpu::error::kNoError)
- return;
-
IPC::Message* message = new GpuCommandBufferMsg_AsyncFlush(route_id_,
put_offset);
@@ -270,28 +249,6 @@ void CommandBufferProxy::AsyncFlush(int32 put_offset, Task* completion_task) {
pending_async_flush_tasks_.push(linked_ptr<Task>(completion_task));
}
-bool CommandBufferProxy::Send(IPC::Message* msg) {
- // Caller should not intentionally send a message if the context is lost.
- DCHECK(last_state_.error == gpu::error::kNoError);
-
- if (channel_) {
- if (channel_->Send(msg)) {
- return true;
- } else {
- // Flag the command buffer as lost. Defer deleting the channel until
- // OnChannelError is called after returning to the message loop in case
- // it is referenced elsewhere.
- last_state_.error = gpu::error::kLostContext;
- return false;
- }
- }
-
- // Callee takes ownership of message, regardless of whether Send is
- // successful. See IPC::Message::Sender.
- delete msg;
- return false;
-}
-
void CommandBufferProxy::OnUpdateState(gpu::CommandBuffer::State state) {
last_state_ = state;