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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ui/gl/gl_surface.h" | 29 #include "ui/gl/gl_surface.h" |
30 | 30 |
31 #if defined(OS_POSIX) | 31 #if defined(OS_POSIX) |
32 #include "ipc/ipc_channel_posix.h" | 32 #include "ipc/ipc_channel_posix.h" |
33 #endif | 33 #endif |
34 | 34 |
35 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) |
36 #include "content/common/gpu/stream_texture_manager_android.h" | 36 #include "content/common/gpu/stream_texture_manager_android.h" |
37 #endif | 37 #endif |
38 | 38 |
| 39 namespace content { |
39 namespace { | 40 namespace { |
40 // This filter does two things: | 41 // This filter does two things: |
41 // - it counts the number of messages coming in on the channel | 42 // - it counts the number of messages coming in on the channel |
42 // - it handles the GpuCommandBufferMsg_InsertSyncPoint message on the IO | 43 // - it handles the GpuCommandBufferMsg_InsertSyncPoint message on the IO |
43 // thread, generating the sync point ID and responding immediately, and then | 44 // thread, generating the sync point ID and responding immediately, and then |
44 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message | 45 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message |
45 // into the channel's queue. | 46 // into the channel's queue. |
46 class SyncPointMessageFilter : public IPC::ChannelProxy::MessageFilter { | 47 class SyncPointMessageFilter : public IPC::ChannelProxy::MessageFilter { |
47 public: | 48 public: |
48 // Takes ownership of gpu_channel (see below). | 49 // Takes ownership of gpu_channel (see below). |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 164 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
164 DCHECK(gpu_channel_manager); | 165 DCHECK(gpu_channel_manager); |
165 DCHECK(client_id); | 166 DCHECK(client_id); |
166 | 167 |
167 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); | 168 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); |
168 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 169 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
169 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); | 170 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
170 disallowed_features_.multisampling = | 171 disallowed_features_.multisampling = |
171 command_line->HasSwitch(switches::kDisableGLMultisampling); | 172 command_line->HasSwitch(switches::kDisableGLMultisampling); |
172 #if defined(OS_ANDROID) | 173 #if defined(OS_ANDROID) |
173 stream_texture_manager_.reset(new content::StreamTextureManagerAndroid(this)); | 174 stream_texture_manager_.reset(new StreamTextureManagerAndroid(this)); |
174 #endif | 175 #endif |
175 } | 176 } |
176 | 177 |
177 | 178 |
178 bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop, | 179 bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop, |
179 base::WaitableEvent* shutdown_event) { | 180 base::WaitableEvent* shutdown_event) { |
180 DCHECK(!channel_.get()); | 181 DCHECK(!channel_.get()); |
181 | 182 |
182 // Map renderer ID to a (single) channel to that process. | 183 // Map renderer ID to a (single) channel to that process. |
183 channel_.reset(new IPC::SyncChannel( | 184 channel_.reset(new IPC::SyncChannel( |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 int32 stream_id, const gfx::Size& initial_size, int32* route_id) { | 565 int32 stream_id, const gfx::Size& initial_size, int32* route_id) { |
565 // Note that route_id is only used for notifications sent out from here. | 566 // Note that route_id is only used for notifications sent out from here. |
566 // StreamTextureManager owns all texture objects and for incoming messages | 567 // StreamTextureManager owns all texture objects and for incoming messages |
567 // it finds the correct object based on stream_id. | 568 // it finds the correct object based on stream_id. |
568 *route_id = GenerateRouteID(); | 569 *route_id = GenerateRouteID(); |
569 stream_texture_manager_->RegisterStreamTextureProxy( | 570 stream_texture_manager_->RegisterStreamTextureProxy( |
570 stream_id, initial_size, *route_id); | 571 stream_id, initial_size, *route_id); |
571 } | 572 } |
572 | 573 |
573 void GpuChannel::OnEstablishStreamTexture( | 574 void GpuChannel::OnEstablishStreamTexture( |
574 int32 stream_id, content::SurfaceTexturePeer::SurfaceTextureTarget type, | 575 int32 stream_id, SurfaceTexturePeer::SurfaceTextureTarget type, |
575 int32 primary_id, int32 secondary_id) { | 576 int32 primary_id, int32 secondary_id) { |
576 stream_texture_manager_->EstablishStreamTexture( | 577 stream_texture_manager_->EstablishStreamTexture( |
577 stream_id, type, primary_id, secondary_id); | 578 stream_id, type, primary_id, secondary_id); |
578 } | 579 } |
579 #endif | 580 #endif |
580 | 581 |
581 void GpuChannel::OnCollectRenderingStatsForSurface( | 582 void GpuChannel::OnCollectRenderingStatsForSurface( |
582 int32 surface_id, IPC::Message* reply_message) { | 583 int32 surface_id, IPC::Message* reply_message) { |
583 content::GpuRenderingStats stats; | 584 GpuRenderingStats stats; |
584 | 585 |
585 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); | 586 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); |
586 !it.IsAtEnd(); it.Advance()) { | 587 !it.IsAtEnd(); it.Advance()) { |
587 int texture_upload_count = | 588 int texture_upload_count = |
588 it.GetCurrentValue()->decoder()->GetTextureUploadCount(); | 589 it.GetCurrentValue()->decoder()->GetTextureUploadCount(); |
589 base::TimeDelta total_texture_upload_time = | 590 base::TimeDelta total_texture_upload_time = |
590 it.GetCurrentValue()->decoder()->GetTotalTextureUploadTime(); | 591 it.GetCurrentValue()->decoder()->GetTotalTextureUploadTime(); |
591 base::TimeDelta total_processing_commands_time = | 592 base::TimeDelta total_processing_commands_time = |
592 it.GetCurrentValue()->decoder()->GetTotalProcessingCommandsTime(); | 593 it.GetCurrentValue()->decoder()->GetTotalProcessingCommandsTime(); |
593 | 594 |
594 stats.global_texture_upload_count += texture_upload_count; | 595 stats.global_texture_upload_count += texture_upload_count; |
595 stats.global_total_texture_upload_time += total_texture_upload_time; | 596 stats.global_total_texture_upload_time += total_texture_upload_time; |
596 stats.global_total_processing_commands_time += | 597 stats.global_total_processing_commands_time += |
597 total_processing_commands_time; | 598 total_processing_commands_time; |
598 if (it.GetCurrentValue()->surface_id() == surface_id) { | 599 if (it.GetCurrentValue()->surface_id() == surface_id) { |
599 stats.texture_upload_count += texture_upload_count; | 600 stats.texture_upload_count += texture_upload_count; |
600 stats.total_texture_upload_time += total_texture_upload_time; | 601 stats.total_texture_upload_time += total_texture_upload_time; |
601 stats.total_processing_commands_time += total_processing_commands_time; | 602 stats.total_processing_commands_time += total_processing_commands_time; |
602 } | 603 } |
603 } | 604 } |
604 | 605 |
605 GpuChannelMsg_CollectRenderingStatsForSurface::WriteReplyParams( | 606 GpuChannelMsg_CollectRenderingStatsForSurface::WriteReplyParams( |
606 reply_message, | 607 reply_message, |
607 stats); | 608 stats); |
608 Send(reply_message); | 609 Send(reply_message); |
609 } | 610 } |
| 611 |
| 612 } // namespace content |
OLD | NEW |