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

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

Issue 22824009: Remove StreamTextureManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 #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 20 matching lines...) Expand all
31 #include "ipc/ipc_channel_proxy.h" 31 #include "ipc/ipc_channel_proxy.h"
32 #include "ui/gl/gl_context.h" 32 #include "ui/gl/gl_context.h"
33 #include "ui/gl/gl_image.h" 33 #include "ui/gl/gl_image.h"
34 #include "ui/gl/gl_surface.h" 34 #include "ui/gl/gl_surface.h"
35 35
36 #if defined(OS_POSIX) 36 #if defined(OS_POSIX)
37 #include "ipc/ipc_channel_posix.h" 37 #include "ipc/ipc_channel_posix.h"
38 #endif 38 #endif
39 39
40 #if defined(OS_ANDROID) 40 #if defined(OS_ANDROID)
41 #include "content/common/gpu/stream_texture_manager_android.h" 41 #include "content/common/android/surface_texture_peer.h"
42 #include "ui/gl/android/gl_image_stream.h"
42 #endif 43 #endif
43 44
44 namespace content { 45 namespace content {
45 namespace { 46 namespace {
46 47
47 // Number of milliseconds between successive vsync. Many GL commands block 48 // Number of milliseconds between successive vsync. Many GL commands block
48 // on vsync, so thresholds for preemption should be multiples of this. 49 // on vsync, so thresholds for preemption should be multiples of this.
49 const int64 kVsyncIntervalMs = 17; 50 const int64 kVsyncIntervalMs = 17;
50 51
51 // Amount of time that we will wait for an IPC to be processed before 52 // Amount of time that we will wait for an IPC to be processed before
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 weak_factory_(this), 450 weak_factory_(this),
450 num_stubs_descheduled_(0) { 451 num_stubs_descheduled_(0) {
451 DCHECK(gpu_channel_manager); 452 DCHECK(gpu_channel_manager);
452 DCHECK(client_id); 453 DCHECK(client_id);
453 454
454 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); 455 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu");
455 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 456 const CommandLine* command_line = CommandLine::ForCurrentProcess();
456 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); 457 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
457 disallowed_features_.multisampling = 458 disallowed_features_.multisampling =
458 command_line->HasSwitch(switches::kDisableGLMultisampling); 459 command_line->HasSwitch(switches::kDisableGLMultisampling);
459 #if defined(OS_ANDROID)
460 stream_texture_manager_.reset(new StreamTextureManagerAndroid(this));
461 #endif
462 } 460 }
463 461
464 462
465 bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop, 463 bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop,
466 base::WaitableEvent* shutdown_event) { 464 base::WaitableEvent* shutdown_event) {
467 DCHECK(!channel_.get()); 465 DCHECK(!channel_.get());
468 466
469 // Map renderer ID to a (single) channel to that process. 467 // Map renderer ID to a (single) channel to that process.
470 channel_.reset(new IPC::SyncChannel( 468 channel_.reset(new IPC::SyncChannel(
471 channel_id_, 469 channel_id_,
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 stubs_.Remove(route_id); 891 stubs_.Remove(route_id);
894 // In case the renderer is currently blocked waiting for a sync reply from the 892 // In case the renderer is currently blocked waiting for a sync reply from the
895 // stub, we need to make sure to reschedule the GpuChannel here. 893 // stub, we need to make sure to reschedule the GpuChannel here.
896 if (need_reschedule) { 894 if (need_reschedule) {
897 // This stub won't get a chance to reschedule, so update the count now. 895 // This stub won't get a chance to reschedule, so update the count now.
898 StubSchedulingChanged(true); 896 StubSchedulingChanged(true);
899 } 897 }
900 } 898 }
901 899
902 #if defined(OS_ANDROID) 900 #if defined(OS_ANDROID)
901 namespace {
902
903 void SendFrameAvailable(const base::WeakPtr<GpuChannel>& channel,
904 int32 route_id) {
905 if (channel)
906 channel->Send(new GpuStreamTextureMsg_FrameAvailable(route_id));
907 }
908
909 void SendMatrixChanged(const base::WeakPtr<GpuChannel>& channel,
910 int32 route_id,
911 const gfx::GLImageStream::Matrix& matrix) {
912 if (channel) {
913 GpuStreamTextureMsg_MatrixChanged_Params params;
914 memcpy(&params.m00, matrix.components, sizeof(matrix.components));
915 channel->Send(new GpuStreamTextureMsg_MatrixChanged(route_id, params));
916 }
917 }
918
919 } // anonymous namespace
920
903 void GpuChannel::OnRegisterStreamTextureProxy( 921 void GpuChannel::OnRegisterStreamTextureProxy(
904 int32 stream_id, int32* route_id) { 922 int32 stream_id, int32* route_id) {
905 // Note that route_id is only used for notifications sent out from here. 923 // Note that route_id is only used for notifications sent out from here.
906 // StreamTextureManager owns all texture objects and for incoming messages 924 // StreamTextureManager owns all texture objects and for incoming messages
907 // it finds the correct object based on stream_id. 925 // it finds the correct object based on stream_id.
908 *route_id = GenerateRouteID(); 926 *route_id = GenerateRouteID();
909 stream_texture_manager_->RegisterStreamTextureProxy(stream_id, *route_id); 927 scoped_refptr<gfx::GLImage> image(image_manager_->LookupImage(stream_id));
piman 2013/08/12 23:22:07 I assume the lookup can fail and you'd get a NULL
no sievers 2013/08/13 00:21:35 oops, thanks.
928 scoped_refptr<gfx::GLImageStream> stream(image->AsGLImageStream());
929 if (!stream)
930 return;
931
932 base::Closure frame_callback =
933 base::Bind(&SendFrameAvailable, weak_factory_.GetWeakPtr(), *route_id);
934 gfx::GLImageStream::MatrixChangedCallBack matrix_callback =
935 base::Bind(&SendMatrixChanged, weak_factory_.GetWeakPtr(), *route_id);
936
937 stream->SetMatrixChangedCallback(matrix_callback);
938 stream->SetFrameAvailableCallback(frame_callback);
910 } 939 }
911 940
912 void GpuChannel::OnEstablishStreamTexture( 941 void GpuChannel::OnEstablishStreamTexture(
913 int32 stream_id, int32 primary_id, int32 secondary_id) { 942 int32 stream_id, int32 primary_id, int32 secondary_id) {
914 stream_texture_manager_->EstablishStreamTexture( 943 scoped_refptr<gfx::GLImage> image(image_manager_->LookupImage(stream_id));
piman 2013/08/12 23:22:07 same here wrt lookup
no sievers 2013/08/13 00:21:35 Done.
915 stream_id, primary_id, secondary_id); 944 scoped_refptr<gfx::GLImageStream> stream(image->AsGLImageStream());
945 if (!stream)
946 return;
947
948 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer(
949 renderer_pid(),
950 stream->GetSurfaceTexture(),
951 primary_id,
952 secondary_id);
916 } 953 }
917 954
918 void GpuChannel::OnSetStreamTextureSize( 955 void GpuChannel::OnSetStreamTextureSize(
919 int32 stream_id, const gfx::Size& size) { 956 int32 stream_id, const gfx::Size& size) {
920 stream_texture_manager_->SetStreamTextureSize(stream_id, size); 957 scoped_refptr<gfx::GLImage> image(image_manager_->LookupImage(stream_id));
piman 2013/08/12 23:22:07 same here wrt lookup
no sievers 2013/08/13 00:21:35 Done.
958 scoped_refptr<gfx::GLImageStream> stream(image->AsGLImageStream());
959 if (!stream)
960 return;
961
962 stream->SetSize(size);
921 } 963 }
922 #endif 964 #endif
923 965
924 void GpuChannel::OnCollectRenderingStatsForSurface( 966 void GpuChannel::OnCollectRenderingStatsForSurface(
925 int32 surface_id, GpuRenderingStats* stats) { 967 int32 surface_id, GpuRenderingStats* stats) {
926 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 968 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
927 !it.IsAtEnd(); it.Advance()) { 969 !it.IsAtEnd(); it.Advance()) {
928 int texture_upload_count = 970 int texture_upload_count =
929 it.GetCurrentValue()->decoder()->GetTextureUploadCount(); 971 it.GetCurrentValue()->decoder()->GetTextureUploadCount();
930 base::TimeDelta total_texture_upload_time = 972 base::TimeDelta total_texture_upload_time =
(...skipping 24 matching lines...) Expand all
955 } 997 }
956 } 998 }
957 999
958 void GpuChannel::CacheShader(const std::string& key, 1000 void GpuChannel::CacheShader(const std::string& key,
959 const std::string& shader) { 1001 const std::string& shader) {
960 gpu_channel_manager_->Send( 1002 gpu_channel_manager_->Send(
961 new GpuHostMsg_CacheShader(client_id_, key, shader)); 1003 new GpuHostMsg_CacheShader(client_id_, key, shader));
962 } 1004 }
963 1005
964 } // namespace content 1006 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698