| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" |
| 8 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 9 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| 10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 11 #include "content/common/child_thread.h" | 12 #include "content/common/child_thread.h" |
| 12 #include "content/common/gpu/gpu_channel.h" | 13 #include "content/common/gpu/gpu_channel.h" |
| 13 #include "content/common/gpu/gpu_channel_manager.h" | 14 #include "content/common/gpu/gpu_channel_manager.h" |
| 14 #include "content/common/gpu/gpu_command_buffer_stub.h" | 15 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 15 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
| 16 #include "content/common/gpu/gpu_watchdog.h" | 17 #include "content/common/gpu/gpu_watchdog.h" |
| 17 #include "gpu/command_buffer/common/constants.h" | 18 #include "gpu/command_buffer/common/constants.h" |
| 18 #include "gpu/common/gpu_trace_event.h" | |
| 19 #include "ui/gfx/gl/gl_context.h" | 19 #include "ui/gfx/gl/gl_context.h" |
| 20 #include "ui/gfx/gl/gl_surface.h" | 20 #include "ui/gfx/gl/gl_surface.h" |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 #include "base/win/wrapped_window_proc.h" | 23 #include "base/win/wrapped_window_proc.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 using gpu::Buffer; | 26 using gpu::Buffer; |
| 27 | 27 |
| 28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { | 177 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { |
| 178 *state = command_buffer_->GetState(); | 178 *state = command_buffer_->GetState(); |
| 179 if (state->error == gpu::error::kLostContext && | 179 if (state->error == gpu::error::kLostContext && |
| 180 gfx::GLContext::LosesAllContextsOnContextLost()) | 180 gfx::GLContext::LosesAllContextsOnContextLost()) |
| 181 channel_->LoseAllContexts(); | 181 channel_->LoseAllContexts(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void GpuCommandBufferStub::OnFlush(int32 put_offset, | 184 void GpuCommandBufferStub::OnFlush(int32 put_offset, |
| 185 int32 last_known_get, | 185 int32 last_known_get, |
| 186 gpu::CommandBuffer::State* state) { | 186 gpu::CommandBuffer::State* state) { |
| 187 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnFlush"); | 187 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnFlush"); |
| 188 *state = command_buffer_->FlushSync(put_offset, last_known_get); | 188 *state = command_buffer_->FlushSync(put_offset, last_known_get); |
| 189 if (state->error == gpu::error::kLostContext && | 189 if (state->error == gpu::error::kLostContext && |
| 190 gfx::GLContext::LosesAllContextsOnContextLost()) | 190 gfx::GLContext::LosesAllContextsOnContextLost()) |
| 191 channel_->LoseAllContexts(); | 191 channel_->LoseAllContexts(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset) { | 194 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset) { |
| 195 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnAsyncFlush"); | 195 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnAsyncFlush"); |
| 196 command_buffer_->Flush(put_offset); | 196 command_buffer_->Flush(put_offset); |
| 197 // TODO(piman): Do this everytime the scheduler finishes processing a batch of | 197 // TODO(piman): Do this everytime the scheduler finishes processing a batch of |
| 198 // commands. | 198 // commands. |
| 199 MessageLoop::current()->PostTask(FROM_HERE, | 199 MessageLoop::current()->PostTask(FROM_HERE, |
| 200 task_factory_.NewRunnableMethod(&GpuCommandBufferStub::ReportState)); | 200 task_factory_.NewRunnableMethod(&GpuCommandBufferStub::ReportState)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void GpuCommandBufferStub::OnCreateTransferBuffer(int32 size, | 203 void GpuCommandBufferStub::OnCreateTransferBuffer(int32 size, |
| 204 int32 id_request, | 204 int32 id_request, |
| 205 int32* id) { | 205 int32* id) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 transfer_buffer); | 250 transfer_buffer); |
| 251 *size = buffer.size; | 251 *size = buffer.size; |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) { | 255 void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) { |
| 256 scheduler_->ResizeOffscreenFrameBuffer(size); | 256 scheduler_->ResizeOffscreenFrameBuffer(size); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void GpuCommandBufferStub::OnSwapBuffers() { | 259 void GpuCommandBufferStub::OnSwapBuffers() { |
| 260 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSwapBuffers"); | 260 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSwapBuffers"); |
| 261 Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); | 261 Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); |
| 262 } | 262 } |
| 263 | 263 |
| 264 #if defined(OS_MACOSX) | 264 #if defined(OS_MACOSX) |
| 265 void GpuCommandBufferStub::OnSetWindowSize(const gfx::Size& size) { | 265 void GpuCommandBufferStub::OnSetWindowSize(const gfx::Size& size) { |
| 266 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 266 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 267 // Try using the IOSurface version first. | 267 // Try using the IOSurface version first. |
| 268 uint64 new_backing_store = scheduler_->SetWindowSizeForIOSurface(size); | 268 uint64 new_backing_store = scheduler_->SetWindowSizeForIOSurface(size); |
| 269 if (new_backing_store) { | 269 if (new_backing_store) { |
| 270 GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params; | 270 GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 gfx::GLContext::LosesAllContextsOnContextLost()) { | 350 gfx::GLContext::LosesAllContextsOnContextLost()) { |
| 351 channel_->LoseAllContexts(); | 351 channel_->LoseAllContexts(); |
| 352 } else { | 352 } else { |
| 353 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); | 353 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); |
| 354 msg->set_unblock(true); | 354 msg->set_unblock(true); |
| 355 Send(msg); | 355 Send(msg); |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 | 358 |
| 359 #endif // defined(ENABLE_GPU) | 359 #endif // defined(ENABLE_GPU) |
| OLD | NEW |