Chromium Code Reviews| 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 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/common/gpu/devtools_gpu_instrumentation.h" | 13 #include "content/common/gpu/devtools_gpu_instrumentation.h" |
| 14 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
| 15 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "content/common/gpu/gpu_channel_manager.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/gpu/gpu_memory_buffer_factory.h" | |
| 17 #include "content/common/gpu/gpu_memory_manager.h" | 18 #include "content/common/gpu/gpu_memory_manager.h" |
| 18 #include "content/common/gpu/gpu_memory_tracking.h" | 19 #include "content/common/gpu/gpu_memory_tracking.h" |
| 19 #include "content/common/gpu/gpu_messages.h" | 20 #include "content/common/gpu/gpu_messages.h" |
| 20 #include "content/common/gpu/gpu_watchdog.h" | 21 #include "content/common/gpu/gpu_watchdog.h" |
| 21 #include "content/common/gpu/image_transport_surface.h" | 22 #include "content/common/gpu/image_transport_surface.h" |
| 22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 23 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | 24 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
| 24 #include "content/common/gpu/sync_point_manager.h" | 25 #include "content/common/gpu/sync_point_manager.h" |
| 25 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 26 #include "gpu/command_buffer/common/constants.h" | 27 #include "gpu/command_buffer/common/constants.h" |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( | 922 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( |
| 922 this, surface_id_ != 0, true)); | 923 this, surface_id_ != 0, true)); |
| 923 } | 924 } |
| 924 } else { | 925 } else { |
| 925 memory_manager_client_state_.reset(); | 926 memory_manager_client_state_.reset(); |
| 926 } | 927 } |
| 927 } | 928 } |
| 928 | 929 |
| 929 void GpuCommandBufferStub::OnRegisterGpuMemoryBuffer( | 930 void GpuCommandBufferStub::OnRegisterGpuMemoryBuffer( |
| 930 int32 id, | 931 int32 id, |
| 931 gfx::GpuMemoryBufferHandle gpu_memory_buffer, | 932 gfx::GpuMemoryBufferHandle handle, |
| 932 uint32 width, | 933 uint32 width, |
| 933 uint32 height, | 934 uint32 height, |
| 934 uint32 internalformat) { | 935 uint32 internalformat) { |
| 935 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); | 936 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); |
| 937 | |
| 938 // Verify that renderer is not trying to use a buffer it doesn't own. | |
| 939 if (!GpuMemoryBufferFactory::RequestAccessToGpuMemoryBuffer( | |
| 940 handle, channel()->client_id())) { | |
| 941 LOG(ERROR) << "Access to GPU memory buffer by renderer denied."; | |
| 942 return; | |
| 943 } | |
|
piman
2014/06/17 23:38:11
Because XID is a field of handle, if you grab the
reveman
2014/06/18 22:06:28
That works in the case of X11 pixmaps and XIDs but
piman
2014/06/18 22:14:36
If the GpuMemoryBufferHandle doesn't include the n
| |
| 936 #if defined(OS_ANDROID) | 944 #if defined(OS_ANDROID) |
| 937 // Verify that renderer is not trying to use a surface texture it doesn't own. | |
| 938 if (gpu_memory_buffer.type == gfx::SURFACE_TEXTURE_BUFFER && | 945 if (gpu_memory_buffer.type == gfx::SURFACE_TEXTURE_BUFFER && |
| 939 gpu_memory_buffer.surface_texture_id.secondary_id != | 946 gpu_memory_buffer.surface_texture_id.secondary_id != |
| 940 channel()->client_id()) { | 947 channel()->client_id()) { |
| 941 LOG(ERROR) << "Illegal surface texture ID for renderer."; | 948 LOG(ERROR) << "Illegal surface texture ID for renderer."; |
| 942 return; | 949 return; |
| 943 } | 950 } |
| 944 #endif | 951 #endif |
| 952 | |
| 945 if (gpu_control_service_) { | 953 if (gpu_control_service_) { |
| 946 gpu_control_service_->RegisterGpuMemoryBuffer( | 954 gpu_control_service_->RegisterGpuMemoryBuffer( |
| 947 id, gpu_memory_buffer, width, height, internalformat); | 955 id, handle, width, height, internalformat); |
| 948 } | 956 } |
| 949 } | 957 } |
| 950 | 958 |
| 951 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { | 959 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { |
| 952 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); | 960 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); |
| 953 if (gpu_control_service_) | 961 if (gpu_control_service_) |
| 954 gpu_control_service_->UnregisterGpuMemoryBuffer(id); | 962 gpu_control_service_->UnregisterGpuMemoryBuffer(id); |
| 955 } | 963 } |
| 956 | 964 |
| 957 void GpuCommandBufferStub::SendConsoleMessage( | 965 void GpuCommandBufferStub::SendConsoleMessage( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1046 if (decoder_) | 1054 if (decoder_) |
| 1047 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 1055 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
| 1048 command_buffer_->SetParseError(gpu::error::kLostContext); | 1056 command_buffer_->SetParseError(gpu::error::kLostContext); |
| 1049 } | 1057 } |
| 1050 | 1058 |
| 1051 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1059 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
| 1052 return GetMemoryManager()->GetClientMemoryUsage(this); | 1060 return GetMemoryManager()->GetClientMemoryUsage(this); |
| 1053 } | 1061 } |
| 1054 | 1062 |
| 1055 } // namespace content | 1063 } // namespace content |
| OLD | NEW |