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

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

Issue 301793003: During image destroy, delete textures only if we have a GL context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve android clang dbg build issue. Created 6 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
« no previous file with comments | « no previous file | content/common/gpu/stream_texture_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); 959 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer");
960 #if defined(OS_ANDROID) 960 #if defined(OS_ANDROID)
961 // Verify that renderer is not trying to use a surface texture it doesn't own. 961 // Verify that renderer is not trying to use a surface texture it doesn't own.
962 if (handle.type == gfx::SURFACE_TEXTURE_BUFFER && 962 if (handle.type == gfx::SURFACE_TEXTURE_BUFFER &&
963 handle.surface_texture_id.secondary_id != channel()->client_id()) { 963 handle.surface_texture_id.secondary_id != channel()->client_id()) {
964 LOG(ERROR) << "Illegal surface texture ID for renderer."; 964 LOG(ERROR) << "Illegal surface texture ID for renderer.";
965 return; 965 return;
966 } 966 }
967 #endif 967 #endif
968 968
969 if (!decoder_)
970 return;
971
972 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
973 DCHECK(image_manager);
974 if (image_manager->LookupImage(id)) {
975 LOG(ERROR) << "Image already exists with same ID.";
976 return;
977 }
978
969 GpuChannelManager* manager = channel_->gpu_channel_manager(); 979 GpuChannelManager* manager = channel_->gpu_channel_manager();
970 scoped_refptr<gfx::GLImage> image = 980 scoped_refptr<gfx::GLImage> image =
971 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer( 981 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer(
972 handle, 982 handle,
973 gfx::Size(width, height), 983 gfx::Size(width, height),
974 internalformat, 984 internalformat,
975 channel()->client_id()); 985 channel()->client_id());
976 if (!image) 986 if (!image)
977 return; 987 return;
978 988
979 // For Android specific workaround. 989 // For Android specific workaround.
980 if (context_group_->feature_info()->workarounds().release_image_after_use) 990 if (context_group_->feature_info()->workarounds().release_image_after_use)
981 image->SetReleaseAfterUse(); 991 image->SetReleaseAfterUse();
982 992
983 if (decoder_) { 993 image_manager->AddImage(image.get(), id);
984 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
985 DCHECK(image_manager);
986 image_manager->AddImage(image.get(), id);
987 }
988 } 994 }
989 995
990 void GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer(int32 id) { 996 void GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer(int32 id) {
991 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer"); 997 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer");
992 998
993 if (decoder_) { 999 if (!decoder_)
994 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 1000 return;
995 DCHECK(image_manager); 1001
996 image_manager->RemoveImage(id); 1002 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
1003 DCHECK(image_manager);
1004 if (!image_manager->LookupImage(id)) {
1005 LOG(ERROR) << "Image with ID doesn't exist.";
1006 return;
997 } 1007 }
1008
1009 image_manager->RemoveImage(id);
998 } 1010 }
999 1011
1000 void GpuCommandBufferStub::SendConsoleMessage( 1012 void GpuCommandBufferStub::SendConsoleMessage(
1001 int32 id, 1013 int32 id,
1002 const std::string& message) { 1014 const std::string& message) {
1003 GPUCommandBufferConsoleMessage console_message; 1015 GPUCommandBufferConsoleMessage console_message;
1004 console_message.id = id; 1016 console_message.id = id;
1005 console_message.message = message; 1017 console_message.message = message;
1006 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( 1018 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg(
1007 route_id_, console_message); 1019 route_id_, console_message);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 if (decoder_) 1101 if (decoder_)
1090 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); 1102 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
1091 command_buffer_->SetParseError(gpu::error::kLostContext); 1103 command_buffer_->SetParseError(gpu::error::kLostContext);
1092 } 1104 }
1093 1105
1094 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 1106 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
1095 return GetMemoryManager()->GetClientMemoryUsage(this); 1107 return GetMemoryManager()->GetClientMemoryUsage(this);
1096 } 1108 }
1097 1109
1098 } // namespace content 1110 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/stream_texture_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698