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

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

Issue 1703163002: Remove dependency on GURL from content/common/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary include from gpu_command_buffer_stub Created 4 years, 10 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/command_line.h" 11 #include "base/command_line.h"
12 #include "base/hash.h" 12 #include "base/hash.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/shared_memory.h" 15 #include "base/memory/shared_memory.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "content/common/gpu/gpu_channel.h" 19 #include "content/common/gpu/gpu_channel.h"
20 #include "content/common/gpu/gpu_channel_manager.h" 20 #include "content/common/gpu/gpu_channel_manager.h"
21 #include "content/common/gpu/gpu_channel_manager_delegate.h"
21 #include "content/common/gpu/gpu_memory_manager.h" 22 #include "content/common/gpu/gpu_memory_manager.h"
22 #include "content/common/gpu/gpu_memory_tracking.h" 23 #include "content/common/gpu/gpu_memory_tracking.h"
23 #include "content/common/gpu/gpu_messages.h" 24 #include "content/common/gpu/gpu_messages.h"
24 #include "content/common/gpu/gpu_watchdog.h" 25 #include "content/common/gpu/gpu_watchdog.h"
25 #include "content/common/gpu/image_transport_surface.h" 26 #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_decode_accelerator.h"
27 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" 28 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
28 #include "content/public/common/content_client.h"
29 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
30 #include "gpu/command_buffer/common/constants.h" 30 #include "gpu/command_buffer/common/constants.h"
31 #include "gpu/command_buffer/common/mailbox.h" 31 #include "gpu/command_buffer/common/mailbox.h"
32 #include "gpu/command_buffer/common/sync_token.h" 32 #include "gpu/command_buffer/common/sync_token.h"
33 #include "gpu/command_buffer/service/gl_context_virtual.h" 33 #include "gpu/command_buffer/service/gl_context_virtual.h"
34 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 34 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
35 #include "gpu/command_buffer/service/image_factory.h" 35 #include "gpu/command_buffer/service/image_factory.h"
36 #include "gpu/command_buffer/service/image_manager.h" 36 #include "gpu/command_buffer/service/image_manager.h"
37 #include "gpu/command_buffer/service/logger.h" 37 #include "gpu/command_buffer/service/logger.h"
38 #include "gpu/command_buffer/service/mailbox_manager.h" 38 #include "gpu/command_buffer/service/mailbox_manager.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 private: 98 private:
99 ~GpuCommandBufferMemoryTracker() override {} 99 ~GpuCommandBufferMemoryTracker() override {}
100 scoped_ptr<GpuMemoryTrackingGroup> tracking_group_; 100 scoped_ptr<GpuMemoryTrackingGroup> tracking_group_;
101 const uint64_t client_tracing_id_; 101 const uint64_t client_tracing_id_;
102 const int client_id_; 102 const int client_id_;
103 const uint64_t share_group_tracing_guid_; 103 const uint64_t share_group_tracing_guid_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); 105 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker);
106 }; 106 };
107 107
108 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the
109 // url_hash matches.
110 void FastSetActiveURL(const GURL& url, size_t url_hash) {
111 // Leave the previously set URL in the empty case -- empty URLs are given by
112 // BlinkPlatformImpl::createOffscreenGraphicsContext3D. Hopefully the
113 // onscreen context URL was set previously and will show up even when a crash
114 // occurs during offscreen command processing.
115 if (url.is_empty())
116 return;
117 static size_t g_last_url_hash = 0;
118 if (url_hash != g_last_url_hash) {
119 g_last_url_hash = url_hash;
120 GetContentClient()->SetActiveURL(url);
121 }
122 }
123
124 // The first time polling a fence, delay some extra time to allow other 108 // The first time polling a fence, delay some extra time to allow other
125 // stubs to process some work, or else the timing of the fences could 109 // stubs to process some work, or else the timing of the fences could
126 // allow a pattern of alternating fast and slow frames to occur. 110 // allow a pattern of alternating fast and slow frames to occur.
127 const int64_t kHandleMoreWorkPeriodMs = 2; 111 const int64_t kHandleMoreWorkPeriodMs = 2;
128 const int64_t kHandleMoreWorkPeriodBusyMs = 1; 112 const int64_t kHandleMoreWorkPeriodBusyMs = 1;
129 113
130 // Prevents idle work from being starved. 114 // Prevents idle work from being starved.
131 const int64_t kMaxTimeSinceIdleMs = 10; 115 const int64_t kMaxTimeSinceIdleMs = 10;
132 116
133 class DevToolsChannelData : public base::trace_event::ConvertableToTraceFormat { 117 class DevToolsChannelData : public base::trace_event::ConvertableToTraceFormat {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 gpu::gles2::SubscriptionRefSet* subscription_ref_set, 171 gpu::gles2::SubscriptionRefSet* subscription_ref_set,
188 gpu::ValueStateMap* pending_valuebuffer_state, 172 gpu::ValueStateMap* pending_valuebuffer_state,
189 const gfx::Size& size, 173 const gfx::Size& size,
190 const gpu::gles2::DisallowedFeatures& disallowed_features, 174 const gpu::gles2::DisallowedFeatures& disallowed_features,
191 const std::vector<int32_t>& attribs, 175 const std::vector<int32_t>& attribs,
192 gfx::GpuPreference gpu_preference, 176 gfx::GpuPreference gpu_preference,
193 int32_t stream_id, 177 int32_t stream_id,
194 int32_t route_id, 178 int32_t route_id,
195 bool offscreen, 179 bool offscreen,
196 GpuWatchdog* watchdog, 180 GpuWatchdog* watchdog,
197 const GURL& active_url) 181 const std::string& active_url)
198 : channel_(channel), 182 : channel_(channel),
199 sync_point_manager_(sync_point_manager), 183 sync_point_manager_(sync_point_manager),
200 task_runner_(task_runner), 184 task_runner_(task_runner),
201 initialized_(false), 185 initialized_(false),
202 handle_(handle), 186 handle_(handle),
203 initial_size_(size), 187 initial_size_(size),
204 disallowed_features_(disallowed_features), 188 disallowed_features_(disallowed_features),
205 requested_attribs_(attribs), 189 requested_attribs_(attribs),
206 gpu_preference_(gpu_preference), 190 gpu_preference_(gpu_preference),
207 use_virtualized_gl_context_(false), 191 use_virtualized_gl_context_(false),
208 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)), 192 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)),
209 stream_id_(stream_id), 193 stream_id_(stream_id),
210 route_id_(route_id), 194 route_id_(route_id),
211 offscreen_(offscreen), 195 offscreen_(offscreen),
212 last_flush_count_(0), 196 last_flush_count_(0),
213 surface_format_(gfx::GLSurface::SURFACE_DEFAULT), 197 surface_format_(gfx::GLSurface::SURFACE_DEFAULT),
214 watchdog_(watchdog), 198 watchdog_(watchdog),
215 waiting_for_sync_point_(false), 199 waiting_for_sync_point_(false),
216 previous_processed_num_(0), 200 previous_processed_num_(0),
217 preemption_flag_(preempt_by_flag), 201 preemption_flag_(preempt_by_flag),
218 active_url_(active_url) { 202 active_url_(active_url) {
219 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); 203 active_url_hash_ = base::Hash(active_url);
220 FastSetActiveURL(active_url_, active_url_hash_); 204 FastSetActiveURL(active_url_, active_url_hash_);
221 205
222 gpu::gles2::ContextCreationAttribHelper attrib_parser; 206 gpu::gles2::ContextCreationAttribHelper attrib_parser;
223 attrib_parser.Parse(requested_attribs_); 207 attrib_parser.Parse(requested_attribs_);
224 208
225 if (share_group) { 209 if (share_group) {
226 context_group_ = share_group->context_group_; 210 context_group_ = share_group->context_group_;
227 DCHECK(context_group_->bind_generates_resource() == 211 DCHECK(context_group_->bind_generates_resource() ==
228 attrib_parser.bind_generates_resource); 212 attrib_parser.bind_generates_resource);
229 } else { 213 } else {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 Send(wait_for_token_->reply.release()); 448 Send(wait_for_token_->reply.release());
465 wait_for_token_.reset(); 449 wait_for_token_.reset();
466 } 450 }
467 if (wait_for_get_offset_) { 451 if (wait_for_get_offset_) {
468 Send(wait_for_get_offset_->reply.release()); 452 Send(wait_for_get_offset_->reply.release());
469 wait_for_get_offset_.reset(); 453 wait_for_get_offset_.reset();
470 } 454 }
471 455
472 if (initialized_) { 456 if (initialized_) {
473 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 457 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
474 if (handle_.is_null() && !active_url_.is_empty()) { 458 if (handle_.is_null() && !active_url_.empty()) {
475 gpu_channel_manager->Send( 459 gpu_channel_manager->Send(
476 new GpuHostMsg_DidDestroyOffscreenContext(active_url_)); 460 new GpuHostMsg_DidDestroyOffscreenContext(active_url_));
477 } 461 }
478 } 462 }
479 463
480 if (decoder_) 464 if (decoder_)
481 decoder_->set_engine(NULL); 465 decoder_->set_engine(NULL);
482 466
483 // The scheduler has raw references to the decoder and the command buffer so 467 // The scheduler has raw references to the decoder and the command buffer so
484 // destroy it before those. 468 // destroy it before those.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 } 651 }
668 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( 652 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory(
669 std::move(shared_state_shm), kSharedStateSize)); 653 std::move(shared_state_shm), kSharedStateSize));
670 654
671 gpu::Capabilities capabilities = decoder_->GetCapabilities(); 655 gpu::Capabilities capabilities = decoder_->GetCapabilities();
672 656
673 GpuCommandBufferMsg_Initialize::WriteReplyParams( 657 GpuCommandBufferMsg_Initialize::WriteReplyParams(
674 reply_message, true, capabilities); 658 reply_message, true, capabilities);
675 Send(reply_message); 659 Send(reply_message);
676 660
677 if (handle_.is_null() && !active_url_.is_empty()) { 661 if (handle_.is_null() && !active_url_.empty()) {
678 manager->Send(new GpuHostMsg_DidCreateOffscreenContext( 662 manager->Send(new GpuHostMsg_DidCreateOffscreenContext(
679 active_url_)); 663 active_url_));
680 } 664 }
681 665
682 initialized_ = true; 666 initialized_ = true;
683 } 667 }
684 668
685 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id, 669 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id,
686 int32_t stream_id, 670 int32_t stream_id,
687 bool* succeeded) { 671 bool* succeeded) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 852
869 if (command_buffer_) 853 if (command_buffer_)
870 command_buffer_->DestroyTransferBuffer(id); 854 command_buffer_->DestroyTransferBuffer(id);
871 } 855 }
872 856
873 void GpuCommandBufferStub::OnCommandProcessed() { 857 void GpuCommandBufferStub::OnCommandProcessed() {
874 if (watchdog_) 858 if (watchdog_)
875 watchdog_->CheckArmed(); 859 watchdog_->CheckArmed();
876 } 860 }
877 861
862 void GpuCommandBufferStub::FastSetActiveURL(const std::string& url,
863 size_t url_hash) {
864 // Leave the previously set URL in the empty case -- empty URLs are given by
865 // BlinkPlatformImpl::createOffscreenGraphicsContext3D. Hopefully the
866 // onscreen context URL was set previously and will show up even when a crash
867 // occurs during offscreen command processing.
868 if (url.empty())
869 return;
870 static size_t g_last_url_hash = 0;
871 if (url_hash != g_last_url_hash) {
872 g_last_url_hash = url_hash;
873 // Plumb request through to a component that knows about the current active
874 // URLs.
875 channel_->gpu_channel_manager()->delegate()->SetActiveURL(url);
876 }
877 }
878
878 void GpuCommandBufferStub::ReportState() { command_buffer_->UpdateState(); } 879 void GpuCommandBufferStub::ReportState() { command_buffer_->UpdateState(); }
879 880
880 void GpuCommandBufferStub::PutChanged() { 881 void GpuCommandBufferStub::PutChanged() {
881 FastSetActiveURL(active_url_, active_url_hash_); 882 FastSetActiveURL(active_url_, active_url_hash_);
882 scheduler_->PutChanged(); 883 scheduler_->PutChanged();
883 } 884 }
884 885
885 void GpuCommandBufferStub::OnCreateVideoDecoder( 886 void GpuCommandBufferStub::OnCreateVideoDecoder(
886 const media::VideoDecodeAccelerator::Config& config, 887 const media::VideoDecodeAccelerator::Config& config,
887 int32_t decoder_route_id, 888 int32_t decoder_route_id,
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 result)); 1180 result));
1180 } 1181 }
1181 1182
1182 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1183 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1183 base::TimeDelta interval) { 1184 base::TimeDelta interval) {
1184 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1185 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1185 interval)); 1186 interval));
1186 } 1187 }
1187 1188
1188 } // namespace content 1189 } // 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