| 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" |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( | 921 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( |
| 922 this, surface_id_ != 0, true)); | 922 this, surface_id_ != 0, true)); |
| 923 } | 923 } |
| 924 } else { | 924 } else { |
| 925 memory_manager_client_state_.reset(); | 925 memory_manager_client_state_.reset(); |
| 926 } | 926 } |
| 927 } | 927 } |
| 928 | 928 |
| 929 void GpuCommandBufferStub::OnRegisterGpuMemoryBuffer( | 929 void GpuCommandBufferStub::OnRegisterGpuMemoryBuffer( |
| 930 int32 id, | 930 int32 id, |
| 931 gfx::GpuMemoryBufferHandle gpu_memory_buffer, | 931 gfx::GpuMemoryBufferHandle handle, |
| 932 uint32 width, | 932 uint32 width, |
| 933 uint32 height, | 933 uint32 height, |
| 934 uint32 internalformat) { | 934 uint32 internalformat) { |
| 935 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); | 935 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); |
| 936 |
| 937 // Verify that renderer is not trying to use a buffer it doesn't own. |
| 938 switch (handle.type) { |
| 936 #if defined(OS_ANDROID) | 939 #if defined(OS_ANDROID) |
| 937 // Verify that renderer is not trying to use a surface texture it doesn't own. | 940 case gfx::SURFACE_TEXTURE_BUFFER: |
| 938 if (gpu_memory_buffer.type == gfx::SURFACE_TEXTURE_BUFFER && | 941 if (handle.surface_texture_id.secondary_id != channel()->client_id()) { |
| 939 gpu_memory_buffer.surface_texture_id.secondary_id != | 942 LOG(ERROR) << "Illegal surface texture ID for renderer."; |
| 940 channel()->client_id()) { | 943 return; |
| 941 LOG(ERROR) << "Illegal surface texture ID for renderer."; | 944 } |
| 942 return; | 945 break; |
| 946 #endif |
| 947 #if defined(USE_X11) |
| 948 case gfx::X11_PIXMAP_BUFFER: |
| 949 if (handle.global_id.secondary_id != channel()->client_id()) { |
| 950 LOG(ERROR) << "Illegal global ID for renderer."; |
| 951 return; |
| 952 } |
| 953 break; |
| 954 #endif |
| 955 default: |
| 956 break; |
| 943 } | 957 } |
| 944 #endif | 958 |
| 945 if (gpu_control_service_) { | 959 if (gpu_control_service_) { |
| 946 gpu_control_service_->RegisterGpuMemoryBuffer( | 960 gpu_control_service_->RegisterGpuMemoryBuffer( |
| 947 id, gpu_memory_buffer, width, height, internalformat); | 961 id, handle, width, height, internalformat); |
| 948 } | 962 } |
| 949 } | 963 } |
| 950 | 964 |
| 951 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { | 965 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { |
| 952 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); | 966 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); |
| 953 if (gpu_control_service_) | 967 if (gpu_control_service_) |
| 954 gpu_control_service_->UnregisterGpuMemoryBuffer(id); | 968 gpu_control_service_->UnregisterGpuMemoryBuffer(id); |
| 955 } | 969 } |
| 956 | 970 |
| 957 void GpuCommandBufferStub::SendConsoleMessage( | 971 void GpuCommandBufferStub::SendConsoleMessage( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 if (decoder_) | 1060 if (decoder_) |
| 1047 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 1061 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
| 1048 command_buffer_->SetParseError(gpu::error::kLostContext); | 1062 command_buffer_->SetParseError(gpu::error::kLostContext); |
| 1049 } | 1063 } |
| 1050 | 1064 |
| 1051 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1065 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
| 1052 return GetMemoryManager()->GetClientMemoryUsage(this); | 1066 return GetMemoryManager()->GetClientMemoryUsage(this); |
| 1053 } | 1067 } |
| 1054 | 1068 |
| 1055 } // namespace content | 1069 } // namespace content |
| OLD | NEW |