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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 1736643005: Decouple Media Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit + fixed compile issue Created 4 years, 9 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
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.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) 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 "content/common/gpu/gpu_command_buffer_stub.h" 5 #include "content/common/gpu/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"
11 #include "base/hash.h" 11 #include "base/hash.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/shared_memory.h" 14 #include "base/memory/shared_memory.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/common/gpu/gpu_channel.h" 18 #include "content/common/gpu/gpu_channel.h"
19 #include "content/common/gpu/gpu_channel_manager.h" 19 #include "content/common/gpu/gpu_channel_manager.h"
20 #include "content/common/gpu/gpu_channel_manager_delegate.h" 20 #include "content/common/gpu/gpu_channel_manager_delegate.h"
21 #include "content/common/gpu/gpu_memory_manager.h" 21 #include "content/common/gpu/gpu_memory_manager.h"
22 #include "content/common/gpu/gpu_memory_tracking.h" 22 #include "content/common/gpu/gpu_memory_tracking.h"
23 #include "content/common/gpu/gpu_messages.h" 23 #include "content/common/gpu/gpu_messages.h"
24 #include "content/common/gpu/gpu_watchdog.h" 24 #include "content/common/gpu/gpu_watchdog.h"
25 #include "content/common/gpu/image_transport_surface.h" 25 #include "content/common/gpu/image_transport_surface.h"
26 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
27 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
28 #include "content/common/gpu/media_messages.h"
29 #include "content/public/common/content_client.h" 26 #include "content/public/common/content_client.h"
30 #include "gpu/command_buffer/common/constants.h" 27 #include "gpu/command_buffer/common/constants.h"
31 #include "gpu/command_buffer/common/mailbox.h" 28 #include "gpu/command_buffer/common/mailbox.h"
32 #include "gpu/command_buffer/common/sync_token.h" 29 #include "gpu/command_buffer/common/sync_token.h"
33 #include "gpu/command_buffer/service/gl_context_virtual.h" 30 #include "gpu/command_buffer/service/gl_context_virtual.h"
34 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 31 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
35 #include "gpu/command_buffer/service/image_factory.h" 32 #include "gpu/command_buffer/service/image_factory.h"
36 #include "gpu/command_buffer/service/image_manager.h" 33 #include "gpu/command_buffer/service/image_manager.h"
37 #include "gpu/command_buffer/service/logger.h" 34 #include "gpu/command_buffer/service/logger.h"
38 #include "gpu/command_buffer/service/mailbox_manager.h" 35 #include "gpu/command_buffer/service/mailbox_manager.h"
39 #include "gpu/command_buffer/service/memory_tracking.h" 36 #include "gpu/command_buffer/service/memory_tracking.h"
40 #include "gpu/command_buffer/service/query_manager.h" 37 #include "gpu/command_buffer/service/query_manager.h"
41 #include "gpu/command_buffer/service/sync_point_manager.h" 38 #include "gpu/command_buffer/service/sync_point_manager.h"
42 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 39 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
43 #include "gpu/command_buffer/service/valuebuffer_manager.h" 40 #include "gpu/command_buffer/service/valuebuffer_manager.h"
44 #include "ui/gl/gl_bindings.h" 41 #include "ui/gl/gl_bindings.h"
42 #include "ui/gl/gl_image.h"
43 #include "ui/gl/gl_switches.h"
45 44
46 #if defined(OS_WIN) 45 #if defined(OS_WIN)
47 #include "base/win/win_util.h" 46 #include "base/win/win_util.h"
48 #include "content/public/common/sandbox_init.h" 47 #include "content/public/common/sandbox_init.h"
49 #endif 48 #endif
50 49
51 #if defined(OS_ANDROID) 50 #if defined(OS_ANDROID)
52 #include "content/common/gpu/stream_texture_android.h" 51 #include "content/common/gpu/stream_texture_android.h"
53 #endif 52 #endif
54 53
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 OnProduceFrontBuffer); 300 OnProduceFrontBuffer);
302 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange, 301 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange,
303 OnWaitForTokenInRange); 302 OnWaitForTokenInRange);
304 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange, 303 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange,
305 OnWaitForGetOffsetInRange); 304 OnWaitForGetOffsetInRange);
306 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 305 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
307 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, 306 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer,
308 OnRegisterTransferBuffer); 307 OnRegisterTransferBuffer);
309 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, 308 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer,
310 OnDestroyTransferBuffer); 309 OnDestroyTransferBuffer);
311 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder,
312 OnCreateVideoDecoder)
313 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoEncoder,
314 OnCreateVideoEncoder)
315 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncToken, 310 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncToken,
316 OnSignalSyncToken) 311 OnSignalSyncToken)
317 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, 312 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery,
318 OnSignalQuery) 313 OnSignalQuery)
319 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage); 314 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage);
320 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage); 315 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage);
321 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture, 316 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture,
322 OnCreateStreamTexture) 317 OnCreateStreamTexture)
323 IPC_MESSAGE_UNHANDLED(handled = false) 318 IPC_MESSAGE_UNHANDLED(handled = false)
324 IPC_END_MESSAGE_MAP() 319 IPC_END_MESSAGE_MAP()
325 320
326 CheckCompleteWaits(); 321 CheckCompleteWaits();
327 322
328 // Ensure that any delayed work that was created will be handled. 323 // Ensure that any delayed work that was created will be handled.
329 if (have_context) { 324 if (have_context) {
330 if (scheduler_) 325 if (scheduler_)
331 scheduler_->ProcessPendingQueries(); 326 scheduler_->ProcessPendingQueries();
332 ScheduleDelayedWork( 327 ScheduleDelayedWork(
333 base::TimeDelta::FromMilliseconds(kHandleMoreWorkPeriodMs)); 328 base::TimeDelta::FromMilliseconds(kHandleMoreWorkPeriodMs));
334 } 329 }
335 330
336 DCHECK(handled);
337 return handled; 331 return handled;
338 } 332 }
339 333
340 bool GpuCommandBufferStub::Send(IPC::Message* message) { 334 bool GpuCommandBufferStub::Send(IPC::Message* message) {
341 return channel_->Send(message); 335 return channel_->Send(message);
342 } 336 }
343 337
344 bool GpuCommandBufferStub::IsScheduled() { 338 bool GpuCommandBufferStub::IsScheduled() {
345 return (!scheduler_.get() || scheduler_->scheduled()); 339 return (!scheduler_.get() || scheduler_->scheduled());
346 } 340 }
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 watchdog_->CheckArmed(); 860 watchdog_->CheckArmed();
867 } 861 }
868 862
869 void GpuCommandBufferStub::ReportState() { command_buffer_->UpdateState(); } 863 void GpuCommandBufferStub::ReportState() { command_buffer_->UpdateState(); }
870 864
871 void GpuCommandBufferStub::PutChanged() { 865 void GpuCommandBufferStub::PutChanged() {
872 FastSetActiveURL(active_url_, active_url_hash_); 866 FastSetActiveURL(active_url_, active_url_hash_);
873 scheduler_->PutChanged(); 867 scheduler_->PutChanged();
874 } 868 }
875 869
876 void GpuCommandBufferStub::OnCreateVideoDecoder(
877 const media::VideoDecodeAccelerator::Config& config,
878 int32_t decoder_route_id,
879 IPC::Message* reply_message) {
880 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateVideoDecoder");
881 GpuVideoDecodeAccelerator* decoder = new GpuVideoDecodeAccelerator(
882 decoder_route_id, this, channel_->io_task_runner());
883 bool succeeded = decoder->Initialize(config);
884 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(reply_message,
885 succeeded);
886 Send(reply_message);
887 // decoder is registered as a DestructionObserver of this stub and will
888 // self-delete during destruction of this stub.
889 }
890
891 void GpuCommandBufferStub::OnCreateVideoEncoder(
892 media::VideoPixelFormat input_format,
893 const gfx::Size& input_visible_size,
894 media::VideoCodecProfile output_profile,
895 uint32_t initial_bitrate,
896 int32_t encoder_route_id,
897 IPC::Message* reply_message) {
898 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateVideoEncoder");
899 GpuVideoEncodeAccelerator* encoder =
900 new GpuVideoEncodeAccelerator(encoder_route_id, this);
901 bool succeeded = encoder->Initialize(input_format, input_visible_size,
902 output_profile, initial_bitrate);
903 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message,
904 succeeded);
905 Send(reply_message);
906
907 // encoder is registered as a DestructionObserver of this stub and will
908 // self-delete during destruction of this stub.
909 }
910
911 void GpuCommandBufferStub::PullTextureUpdates( 870 void GpuCommandBufferStub::PullTextureUpdates(
912 gpu::CommandBufferNamespace namespace_id, 871 gpu::CommandBufferNamespace namespace_id,
913 gpu::CommandBufferId command_buffer_id, 872 gpu::CommandBufferId command_buffer_id,
914 uint32_t release) { 873 uint32_t release) {
915 gpu::gles2::MailboxManager* mailbox_manager = 874 gpu::gles2::MailboxManager* mailbox_manager =
916 context_group_->mailbox_manager(); 875 context_group_->mailbox_manager();
917 if (mailbox_manager->UsesSync() && MakeCurrent()) { 876 if (mailbox_manager->UsesSync() && MakeCurrent()) {
918 gpu::SyncToken sync_token(namespace_id, 0, command_buffer_id, release); 877 gpu::SyncToken sync_token(namespace_id, 0, command_buffer_id, release);
919 mailbox_manager->PullTextureUpdates(sync_token); 878 mailbox_manager->PullTextureUpdates(sync_token);
920 } 879 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 result)); 1131 result));
1173 } 1132 }
1174 1133
1175 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1134 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1176 base::TimeDelta interval) { 1135 base::TimeDelta interval) {
1177 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1136 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1178 interval)); 1137 interval));
1179 } 1138 }
1180 1139
1181 } // namespace content 1140 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698