| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/ipc/service/gpu_command_buffer_stub.h" | 5 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 base::TimeDelta::FromMilliseconds(kHandleMoreWorkPeriodMs)); | 268 base::TimeDelta::FromMilliseconds(kHandleMoreWorkPeriodMs)); |
| 269 } | 269 } |
| 270 | 270 |
| 271 return handled; | 271 return handled; |
| 272 } | 272 } |
| 273 | 273 |
| 274 bool GpuCommandBufferStub::Send(IPC::Message* message) { | 274 bool GpuCommandBufferStub::Send(IPC::Message* message) { |
| 275 return channel_->Send(message); | 275 return channel_->Send(message); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void GpuCommandBufferStub::DidSwapBuffersComplete( |
| 279 SwapBuffersCompleteParams params) { |
| 280 GpuCommandBufferMsg_SwapBuffersCompleted_Params send_params; |
| 281 #if defined(OS_MACOSX) |
| 282 send_params.ca_context_id = params.ca_context_id; |
| 283 send_params.fullscreen_low_power_ca_context_valid = |
| 284 params.fullscreen_low_power_ca_context_valid; |
| 285 send_params.io_surface = params.io_surface; |
| 286 send_params.pixel_size = params.pixel_size; |
| 287 send_params.scale_factor = params.scale_factor; |
| 288 send_params.in_use_responses = params.in_use_responses; |
| 289 #endif |
| 290 send_params.latency_info = std::move(params.latency_info); |
| 291 send_params.result = params.result; |
| 292 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, send_params)); |
| 293 } |
| 294 |
| 295 const gles2::FeatureInfo* GpuCommandBufferStub::GetFeatureInfo() const { |
| 296 return context_group_->feature_info(); |
| 297 } |
| 298 |
| 299 void GpuCommandBufferStub::SetLatencyInfoCallback( |
| 300 const LatencyInfoCallback& callback) { |
| 301 latency_info_callback_ = callback; |
| 302 } |
| 303 |
| 304 void GpuCommandBufferStub::UpdateVSyncParameters(base::TimeTicks timebase, |
| 305 base::TimeDelta interval) { |
| 306 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 307 interval)); |
| 308 } |
| 309 |
| 278 bool GpuCommandBufferStub::IsScheduled() { | 310 bool GpuCommandBufferStub::IsScheduled() { |
| 279 return (!executor_.get() || executor_->scheduled()); | 311 return (!executor_.get() || executor_->scheduled()); |
| 280 } | 312 } |
| 281 | 313 |
| 282 void GpuCommandBufferStub::PollWork() { | 314 void GpuCommandBufferStub::PollWork() { |
| 283 // Post another delayed task if we have not yet reached the time at which | 315 // Post another delayed task if we have not yet reached the time at which |
| 284 // we should process delayed work. | 316 // we should process delayed work. |
| 285 base::TimeTicks current_time = base::TimeTicks::Now(); | 317 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 286 DCHECK(!process_delayed_work_time_.is_null()); | 318 DCHECK(!process_delayed_work_time_.is_null()); |
| 287 if (process_delayed_work_time_ > current_time) { | 319 if (process_delayed_work_time_ > current_time) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 CommandBufferNamespace::GPU_IO, command_buffer_id_); | 549 CommandBufferNamespace::GPU_IO, command_buffer_id_); |
| 518 | 550 |
| 519 executor_->SetPreemptByFlag(channel_->preempted_flag()); | 551 executor_->SetPreemptByFlag(channel_->preempted_flag()); |
| 520 | 552 |
| 521 decoder_->set_engine(executor_.get()); | 553 decoder_->set_engine(executor_.get()); |
| 522 | 554 |
| 523 if (offscreen) { | 555 if (offscreen) { |
| 524 surface_ = default_surface; | 556 surface_ = default_surface; |
| 525 } else { | 557 } else { |
| 526 surface_ = ImageTransportSurface::CreateNativeSurface( | 558 surface_ = ImageTransportSurface::CreateNativeSurface( |
| 527 manager, this, surface_handle_, surface_format); | 559 manager, AsWeakPtr(), surface_handle_, surface_format); |
| 528 if (!surface_ || !surface_->Initialize(surface_format)) { | 560 if (!surface_ || !surface_->Initialize(surface_format)) { |
| 529 surface_ = nullptr; | 561 surface_ = nullptr; |
| 530 DLOG(ERROR) << "Failed to create surface."; | 562 DLOG(ERROR) << "Failed to create surface."; |
| 531 return false; | 563 return false; |
| 532 } | 564 } |
| 533 } | 565 } |
| 534 | 566 |
| 535 scoped_refptr<gl::GLContext> context; | 567 scoped_refptr<gl::GLContext> context; |
| 536 gl::GLShareGroup* gl_share_group = channel_->share_group(); | 568 gl::GLShareGroup* gl_share_group = channel_->share_group(); |
| 537 if (use_virtualized_gl_context_ && gl_share_group) { | 569 if (use_virtualized_gl_context_ && gl_share_group) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id, | 679 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id, |
| 648 int32_t stream_id, | 680 int32_t stream_id, |
| 649 bool* succeeded) { | 681 bool* succeeded) { |
| 650 #if defined(OS_ANDROID) | 682 #if defined(OS_ANDROID) |
| 651 *succeeded = StreamTexture::Create(this, texture_id, stream_id); | 683 *succeeded = StreamTexture::Create(this, texture_id, stream_id); |
| 652 #else | 684 #else |
| 653 *succeeded = false; | 685 *succeeded = false; |
| 654 #endif | 686 #endif |
| 655 } | 687 } |
| 656 | 688 |
| 657 void GpuCommandBufferStub::SetLatencyInfoCallback( | |
| 658 const LatencyInfoCallback& callback) { | |
| 659 latency_info_callback_ = callback; | |
| 660 } | |
| 661 | |
| 662 void GpuCommandBufferStub::OnSetGetBuffer(int32_t shm_id, | 689 void GpuCommandBufferStub::OnSetGetBuffer(int32_t shm_id, |
| 663 IPC::Message* reply_message) { | 690 IPC::Message* reply_message) { |
| 664 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); | 691 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); |
| 665 if (command_buffer_) | 692 if (command_buffer_) |
| 666 command_buffer_->SetGetBuffer(shm_id); | 693 command_buffer_->SetGetBuffer(shm_id); |
| 667 Send(reply_message); | 694 Send(reply_message); |
| 668 } | 695 } |
| 669 | 696 |
| 670 void GpuCommandBufferStub::OnTakeFrontBuffer(const Mailbox& mailbox) { | 697 void GpuCommandBufferStub::OnTakeFrontBuffer(const Mailbox& mailbox) { |
| 671 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnTakeFrontBuffer"); | 698 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnTakeFrontBuffer"); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 void GpuCommandBufferStub::AddDestructionObserver( | 1081 void GpuCommandBufferStub::AddDestructionObserver( |
| 1055 DestructionObserver* observer) { | 1082 DestructionObserver* observer) { |
| 1056 destruction_observers_.AddObserver(observer); | 1083 destruction_observers_.AddObserver(observer); |
| 1057 } | 1084 } |
| 1058 | 1085 |
| 1059 void GpuCommandBufferStub::RemoveDestructionObserver( | 1086 void GpuCommandBufferStub::RemoveDestructionObserver( |
| 1060 DestructionObserver* observer) { | 1087 DestructionObserver* observer) { |
| 1061 destruction_observers_.RemoveObserver(observer); | 1088 destruction_observers_.RemoveObserver(observer); |
| 1062 } | 1089 } |
| 1063 | 1090 |
| 1064 const gles2::FeatureInfo* GpuCommandBufferStub::GetFeatureInfo() const { | |
| 1065 return context_group_->feature_info(); | |
| 1066 } | |
| 1067 | |
| 1068 gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const { | 1091 gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const { |
| 1069 return context_group_->memory_tracker(); | 1092 return context_group_->memory_tracker(); |
| 1070 } | 1093 } |
| 1071 | 1094 |
| 1072 bool GpuCommandBufferStub::CheckContextLost() { | 1095 bool GpuCommandBufferStub::CheckContextLost() { |
| 1073 DCHECK(command_buffer_); | 1096 DCHECK(command_buffer_); |
| 1074 CommandBuffer::State state = command_buffer_->GetLastState(); | 1097 CommandBuffer::State state = command_buffer_->GetLastState(); |
| 1075 bool was_lost = state.error == error::kLostContext; | 1098 bool was_lost = state.error == error::kLostContext; |
| 1076 | 1099 |
| 1077 if (was_lost) { | 1100 if (was_lost) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1101 if (!command_buffer_ || | 1124 if (!command_buffer_ || |
| 1102 command_buffer_->GetLastState().error == error::kLostContext) | 1125 command_buffer_->GetLastState().error == error::kLostContext) |
| 1103 return; | 1126 return; |
| 1104 | 1127 |
| 1105 command_buffer_->SetContextLostReason(error::kUnknown); | 1128 command_buffer_->SetContextLostReason(error::kUnknown); |
| 1106 if (decoder_) | 1129 if (decoder_) |
| 1107 decoder_->MarkContextLost(error::kUnknown); | 1130 decoder_->MarkContextLost(error::kUnknown); |
| 1108 command_buffer_->SetParseError(error::kLostContext); | 1131 command_buffer_->SetParseError(error::kLostContext); |
| 1109 } | 1132 } |
| 1110 | 1133 |
| 1111 void GpuCommandBufferStub::SendSwapBuffersCompleted( | |
| 1112 const GpuCommandBufferMsg_SwapBuffersCompleted_Params& params) { | |
| 1113 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); | |
| 1114 } | |
| 1115 | |
| 1116 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | |
| 1117 base::TimeDelta interval) { | |
| 1118 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | |
| 1119 interval)); | |
| 1120 } | |
| 1121 | |
| 1122 } // namespace gpu | 1134 } // namespace gpu |
| OLD | NEW |