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

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

Issue 1767673002: Revert of Decouple Media Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
26 #include "content/public/common/content_client.h" 29 #include "content/public/common/content_client.h"
27 #include "gpu/command_buffer/common/constants.h" 30 #include "gpu/command_buffer/common/constants.h"
28 #include "gpu/command_buffer/common/mailbox.h" 31 #include "gpu/command_buffer/common/mailbox.h"
29 #include "gpu/command_buffer/common/sync_token.h" 32 #include "gpu/command_buffer/common/sync_token.h"
30 #include "gpu/command_buffer/service/gl_context_virtual.h" 33 #include "gpu/command_buffer/service/gl_context_virtual.h"
31 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 34 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
32 #include "gpu/command_buffer/service/image_factory.h" 35 #include "gpu/command_buffer/service/image_factory.h"
33 #include "gpu/command_buffer/service/image_manager.h" 36 #include "gpu/command_buffer/service/image_manager.h"
34 #include "gpu/command_buffer/service/logger.h" 37 #include "gpu/command_buffer/service/logger.h"
35 #include "gpu/command_buffer/service/mailbox_manager.h" 38 #include "gpu/command_buffer/service/mailbox_manager.h"
36 #include "gpu/command_buffer/service/memory_tracking.h" 39 #include "gpu/command_buffer/service/memory_tracking.h"
37 #include "gpu/command_buffer/service/query_manager.h" 40 #include "gpu/command_buffer/service/query_manager.h"
38 #include "gpu/command_buffer/service/sync_point_manager.h" 41 #include "gpu/command_buffer/service/sync_point_manager.h"
39 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 42 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
40 #include "gpu/command_buffer/service/valuebuffer_manager.h" 43 #include "gpu/command_buffer/service/valuebuffer_manager.h"
41 #include "ui/gl/gl_bindings.h" 44 #include "ui/gl/gl_bindings.h"
42 #include "ui/gl/gl_image.h"
43 #include "ui/gl/gl_switches.h"
44 45
45 #if defined(OS_WIN) 46 #if defined(OS_WIN)
46 #include "base/win/win_util.h" 47 #include "base/win/win_util.h"
47 #include "content/public/common/sandbox_init.h" 48 #include "content/public/common/sandbox_init.h"
48 #endif 49 #endif
49 50
50 #if defined(OS_ANDROID) 51 #if defined(OS_ANDROID)
51 #include "content/common/gpu/stream_texture_android.h" 52 #include "content/common/gpu/stream_texture_android.h"
52 #endif 53 #endif
53 54
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 OnProduceFrontBuffer); 301 OnProduceFrontBuffer);
301 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange, 302 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange,
302 OnWaitForTokenInRange); 303 OnWaitForTokenInRange);
303 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange, 304 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange,
304 OnWaitForGetOffsetInRange); 305 OnWaitForGetOffsetInRange);
305 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 306 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
306 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, 307 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer,
307 OnRegisterTransferBuffer); 308 OnRegisterTransferBuffer);
308 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, 309 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer,
309 OnDestroyTransferBuffer); 310 OnDestroyTransferBuffer);
311 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder,
312 OnCreateVideoDecoder)
313 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoEncoder,
314 OnCreateVideoEncoder)
310 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncToken, 315 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncToken,
311 OnSignalSyncToken) 316 OnSignalSyncToken)
312 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, 317 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery,
313 OnSignalQuery) 318 OnSignalQuery)
314 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage); 319 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage);
315 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage); 320 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage);
316 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture, 321 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture,
317 OnCreateStreamTexture) 322 OnCreateStreamTexture)
318 IPC_MESSAGE_UNHANDLED(handled = false) 323 IPC_MESSAGE_UNHANDLED(handled = false)
319 IPC_END_MESSAGE_MAP() 324 IPC_END_MESSAGE_MAP()
320 325
321 CheckCompleteWaits(); 326 CheckCompleteWaits();
322 327
323 // Ensure that any delayed work that was created will be handled. 328 // Ensure that any delayed work that was created will be handled.
324 if (have_context) { 329 if (have_context) {
325 if (scheduler_) 330 if (scheduler_)
326 scheduler_->ProcessPendingQueries(); 331 scheduler_->ProcessPendingQueries();
327 ScheduleDelayedWork( 332 ScheduleDelayedWork(
328 base::TimeDelta::FromMilliseconds(kHandleMoreWorkPeriodMs)); 333 base::TimeDelta::FromMilliseconds(kHandleMoreWorkPeriodMs));
329 } 334 }
330 335
336 DCHECK(handled);
331 return handled; 337 return handled;
332 } 338 }
333 339
334 bool GpuCommandBufferStub::Send(IPC::Message* message) { 340 bool GpuCommandBufferStub::Send(IPC::Message* message) {
335 return channel_->Send(message); 341 return channel_->Send(message);
336 } 342 }
337 343
338 bool GpuCommandBufferStub::IsScheduled() { 344 bool GpuCommandBufferStub::IsScheduled() {
339 return (!scheduler_.get() || scheduler_->scheduled()); 345 return (!scheduler_.get() || scheduler_->scheduled());
340 } 346 }
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 watchdog_->CheckArmed(); 866 watchdog_->CheckArmed();
861 } 867 }
862 868
863 void GpuCommandBufferStub::ReportState() { command_buffer_->UpdateState(); } 869 void GpuCommandBufferStub::ReportState() { command_buffer_->UpdateState(); }
864 870
865 void GpuCommandBufferStub::PutChanged() { 871 void GpuCommandBufferStub::PutChanged() {
866 FastSetActiveURL(active_url_, active_url_hash_); 872 FastSetActiveURL(active_url_, active_url_hash_);
867 scheduler_->PutChanged(); 873 scheduler_->PutChanged();
868 } 874 }
869 875
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
870 void GpuCommandBufferStub::PullTextureUpdates( 911 void GpuCommandBufferStub::PullTextureUpdates(
871 gpu::CommandBufferNamespace namespace_id, 912 gpu::CommandBufferNamespace namespace_id,
872 gpu::CommandBufferId command_buffer_id, 913 gpu::CommandBufferId command_buffer_id,
873 uint32_t release) { 914 uint32_t release) {
874 gpu::gles2::MailboxManager* mailbox_manager = 915 gpu::gles2::MailboxManager* mailbox_manager =
875 context_group_->mailbox_manager(); 916 context_group_->mailbox_manager();
876 if (mailbox_manager->UsesSync() && MakeCurrent()) { 917 if (mailbox_manager->UsesSync() && MakeCurrent()) {
877 gpu::SyncToken sync_token(namespace_id, 0, command_buffer_id, release); 918 gpu::SyncToken sync_token(namespace_id, 0, command_buffer_id, release);
878 mailbox_manager->PullTextureUpdates(sync_token); 919 mailbox_manager->PullTextureUpdates(sync_token);
879 } 920 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 result)); 1172 result));
1132 } 1173 }
1133 1174
1134 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1175 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1135 base::TimeDelta interval) { 1176 base::TimeDelta interval) {
1136 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1177 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1137 interval)); 1178 interval));
1138 } 1179 }
1139 1180
1140 } // namespace content 1181 } // 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