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

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

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: address review feedback Created 6 years, 2 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
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 OnSetSurfaceVisible) 264 OnSetSurfaceVisible)
265 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint, 265 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint,
266 OnRetireSyncPoint) 266 OnRetireSyncPoint)
267 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint, 267 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint,
268 OnSignalSyncPoint) 268 OnSignalSyncPoint)
269 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, 269 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery,
270 OnSignalQuery) 270 OnSignalQuery)
271 IPC_MESSAGE_HANDLER( 271 IPC_MESSAGE_HANDLER(
272 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, 272 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback,
273 OnSetClientHasMemoryAllocationChangedCallback) 273 OnSetClientHasMemoryAllocationChangedCallback)
274 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterGpuMemoryBuffer, 274 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage);
275 OnRegisterGpuMemoryBuffer); 275 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage);
276 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UnregisterGpuMemoryBuffer,
277 OnUnregisterGpuMemoryBuffer);
278 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture, 276 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture,
279 OnCreateStreamTexture) 277 OnCreateStreamTexture)
280 IPC_MESSAGE_UNHANDLED(handled = false) 278 IPC_MESSAGE_UNHANDLED(handled = false)
281 IPC_END_MESSAGE_MAP() 279 IPC_END_MESSAGE_MAP()
282 280
283 CheckCompleteWaits(); 281 CheckCompleteWaits();
284 282
285 if (have_context) { 283 if (have_context) {
286 // Ensure that any delayed work that was created will be handled. 284 // Ensure that any delayed work that was created will be handled.
287 ScheduleDelayedWork(kHandleMoreWorkPeriodMs); 285 ScheduleDelayedWork(kHandleMoreWorkPeriodMs);
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 if (has_callback) { 934 if (has_callback) {
937 if (!memory_manager_client_state_) { 935 if (!memory_manager_client_state_) {
938 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( 936 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState(
939 this, surface_id_ != 0, true)); 937 this, surface_id_ != 0, true));
940 } 938 }
941 } else { 939 } else {
942 memory_manager_client_state_.reset(); 940 memory_manager_client_state_.reset();
943 } 941 }
944 } 942 }
945 943
946 void GpuCommandBufferStub::OnRegisterGpuMemoryBuffer( 944 void GpuCommandBufferStub::OnCreateImage(int32 id,
947 int32 id, 945 gfx::GpuMemoryBufferHandle handle,
948 gfx::GpuMemoryBufferHandle handle, 946 gfx::Size size,
949 uint32 width, 947 gfx::GpuMemoryBuffer::Format format,
950 uint32 height, 948 uint32 internalformat) {
951 uint32 internalformat) { 949 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateImage");
952 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer");
953 #if defined(OS_ANDROID) 950 #if defined(OS_ANDROID)
954 // Verify that renderer is not trying to use a surface texture it doesn't own. 951 // Verify that renderer is not trying to use a surface texture it doesn't own.
955 if (handle.type == gfx::SURFACE_TEXTURE_BUFFER && 952 if (handle.type == gfx::SURFACE_TEXTURE_BUFFER &&
956 handle.surface_texture_id.secondary_id != channel()->client_id()) { 953 handle.surface_texture_id.secondary_id != channel()->client_id()) {
957 LOG(ERROR) << "Illegal surface texture ID for renderer."; 954 LOG(ERROR) << "Illegal surface texture ID for renderer.";
958 return; 955 return;
959 } 956 }
960 #endif 957 #endif
961 958
962 if (!decoder_) 959 if (!decoder_)
963 return; 960 return;
964 961
965 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 962 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
966 DCHECK(image_manager); 963 DCHECK(image_manager);
967 if (image_manager->LookupImage(id)) { 964 if (image_manager->LookupImage(id)) {
968 LOG(ERROR) << "Image already exists with same ID."; 965 LOG(ERROR) << "Image already exists with same ID.";
969 return; 966 return;
970 } 967 }
971 968
972 GpuChannelManager* manager = channel_->gpu_channel_manager(); 969 GpuChannelManager* manager = channel_->gpu_channel_manager();
973 scoped_refptr<gfx::GLImage> image = 970 scoped_refptr<gfx::GLImage> image =
974 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer( 971 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer(
975 handle, 972 handle, size, format, internalformat, channel()->client_id());
976 gfx::Size(width, height),
977 internalformat,
978 channel()->client_id());
979 if (!image.get()) 973 if (!image.get())
980 return; 974 return;
981 975
982 image_manager->AddImage(image.get(), id); 976 image_manager->AddImage(image.get(), id);
983 } 977 }
984 978
985 void GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer(int32 id) { 979 void GpuCommandBufferStub::OnDestroyImage(int32 id) {
986 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer"); 980 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage");
987 981
988 if (!decoder_) 982 if (!decoder_)
989 return; 983 return;
990 984
991 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 985 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
992 DCHECK(image_manager); 986 DCHECK(image_manager);
993 if (!image_manager->LookupImage(id)) { 987 if (!image_manager->LookupImage(id)) {
994 LOG(ERROR) << "Image with ID doesn't exist."; 988 LOG(ERROR) << "Image with ID doesn't exist.";
995 return; 989 return;
996 } 990 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 1089 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
1096 return GetMemoryManager()->GetClientMemoryUsage(this); 1090 return GetMemoryManager()->GetClientMemoryUsage(this);
1097 } 1091 }
1098 1092
1099 void GpuCommandBufferStub::SwapBuffersCompleted( 1093 void GpuCommandBufferStub::SwapBuffersCompleted(
1100 const std::vector<ui::LatencyInfo>& latency_info) { 1094 const std::vector<ui::LatencyInfo>& latency_info) {
1101 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); 1095 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info));
1102 } 1096 }
1103 1097
1104 } // namespace content 1098 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698