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" |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); | 922 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); |
| 923 #if defined(OS_ANDROID) | 923 #if defined(OS_ANDROID) |
| 924 // Verify that renderer is not trying to use a surface texture it doesn't own. | 924 // Verify that renderer is not trying to use a surface texture it doesn't own. |
| 925 if (handle.type == gfx::SURFACE_TEXTURE_BUFFER && | 925 if (handle.type == gfx::SURFACE_TEXTURE_BUFFER && |
| 926 handle.surface_texture_id.secondary_id != channel()->client_id()) { | 926 handle.surface_texture_id.secondary_id != channel()->client_id()) { |
| 927 LOG(ERROR) << "Illegal surface texture ID for renderer."; | 927 LOG(ERROR) << "Illegal surface texture ID for renderer."; |
| 928 return; | 928 return; |
| 929 } | 929 } |
| 930 #endif | 930 #endif |
| 931 | 931 |
| 932 if (!decoder_) | |
| 933 return; | |
| 934 | |
| 935 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | |
| 936 DCHECK(image_manager); | |
| 937 if (image_manager->LookupImage(id)) { | |
| 938 LOG(ERROR) << "Image already exists with same ID."; | |
| 939 return; | |
| 940 } | |
| 941 | |
| 932 GpuChannelManager* manager = channel_->gpu_channel_manager(); | 942 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 933 scoped_refptr<gfx::GLImage> image = | 943 scoped_refptr<gfx::GLImage> image = |
| 934 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer( | 944 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer( |
| 935 handle, | 945 handle, |
| 936 gfx::Size(width, height), | 946 gfx::Size(width, height), |
| 937 internalformat, | 947 internalformat, |
| 938 channel()->client_id()); | 948 channel()->client_id()); |
| 939 if (!image) | 949 if (!image) |
| 940 return; | 950 return; |
| 941 | 951 |
| 942 // For Android specific workaround. | 952 // For Android specific workaround. |
| 943 if (context_group_->feature_info()->workarounds().release_image_after_use) | 953 if (context_group_->feature_info()->workarounds().release_image_after_use) |
| 944 image->SetReleaseAfterUse(); | 954 image->SetReleaseAfterUse(); |
| 945 | 955 |
| 946 if (decoder_) { | 956 image_manager->AddImage(image.get(), id); |
| 947 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | |
| 948 DCHECK(image_manager); | |
| 949 image_manager->AddImage(image.get(), id); | |
| 950 } | |
| 951 } | 957 } |
| 952 | 958 |
| 953 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { | 959 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { |
| 954 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); | 960 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); |
| 955 | 961 |
| 956 if (decoder_) { | 962 if (!decoder_) |
| 957 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 963 return; |
|
reveman
2014/07/30 16:00:04
nit: blank line here for consistency
sohanjg
2014/07/30 16:04:38
Done.
| |
| 958 DCHECK(image_manager); | 964 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
| 959 image_manager->RemoveImage(id); | 965 DCHECK(image_manager); |
| 966 if (!image_manager->LookupImage(id)) { | |
| 967 LOG(ERROR) << "Image with ID doesn't exist."; | |
| 968 return; | |
| 960 } | 969 } |
|
reveman
2014/07/30 16:00:04
nit: I would add a blank line here too
sohanjg
2014/07/30 16:04:38
Done.
| |
| 970 image_manager->RemoveImage(id); | |
| 961 } | 971 } |
| 962 | 972 |
| 963 void GpuCommandBufferStub::SendConsoleMessage( | 973 void GpuCommandBufferStub::SendConsoleMessage( |
| 964 int32 id, | 974 int32 id, |
| 965 const std::string& message) { | 975 const std::string& message) { |
| 966 GPUCommandBufferConsoleMessage console_message; | 976 GPUCommandBufferConsoleMessage console_message; |
| 967 console_message.id = id; | 977 console_message.id = id; |
| 968 console_message.message = message; | 978 console_message.message = message; |
| 969 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( | 979 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( |
| 970 route_id_, console_message); | 980 route_id_, console_message); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 if (decoder_) | 1062 if (decoder_) |
| 1053 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 1063 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
| 1054 command_buffer_->SetParseError(gpu::error::kLostContext); | 1064 command_buffer_->SetParseError(gpu::error::kLostContext); |
| 1055 } | 1065 } |
| 1056 | 1066 |
| 1057 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1067 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
| 1058 return GetMemoryManager()->GetClientMemoryUsage(this); | 1068 return GetMemoryManager()->GetClientMemoryUsage(this); |
| 1059 } | 1069 } |
| 1060 | 1070 |
| 1061 } // namespace content | 1071 } // namespace content |
| OLD | NEW |