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

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: rebase 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 950
954 if (!decoder_) 951 if (!decoder_)
955 return; 952 return;
956 953
957 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 954 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
958 DCHECK(image_manager); 955 DCHECK(image_manager);
959 if (image_manager->LookupImage(id)) { 956 if (image_manager->LookupImage(id)) {
960 LOG(ERROR) << "Image already exists with same ID."; 957 LOG(ERROR) << "Image already exists with same ID.";
961 return; 958 return;
962 } 959 }
963 960
964 GpuChannelManager* manager = channel_->gpu_channel_manager(); 961 GpuChannelManager* manager = channel_->gpu_channel_manager();
965 scoped_refptr<gfx::GLImage> image = 962 scoped_refptr<gfx::GLImage> image =
966 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer( 963 manager->gpu_memory_buffer_factory()->CreateImageForGpuMemoryBuffer(
967 handle, 964 handle, size, format, internalformat, channel()->client_id());
968 gfx::Size(width, height),
969 internalformat,
970 channel()->client_id());
971 if (!image.get()) 965 if (!image.get())
972 return; 966 return;
973 967
974 image_manager->AddImage(image.get(), id); 968 image_manager->AddImage(image.get(), id);
975 } 969 }
976 970
977 void GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer(int32 id) { 971 void GpuCommandBufferStub::OnDestroyImage(int32 id) {
978 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnUnregisterGpuMemoryBuffer"); 972 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage");
979 973
980 if (!decoder_) 974 if (!decoder_)
981 return; 975 return;
982 976
983 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 977 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
984 DCHECK(image_manager); 978 DCHECK(image_manager);
985 if (!image_manager->LookupImage(id)) { 979 if (!image_manager->LookupImage(id)) {
986 LOG(ERROR) << "Image with ID doesn't exist."; 980 LOG(ERROR) << "Image with ID doesn't exist.";
987 return; 981 return;
988 } 982 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 1081 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
1088 return GetMemoryManager()->GetClientMemoryUsage(this); 1082 return GetMemoryManager()->GetClientMemoryUsage(this);
1089 } 1083 }
1090 1084
1091 void GpuCommandBufferStub::SwapBuffersCompleted( 1085 void GpuCommandBufferStub::SwapBuffersCompleted(
1092 const std::vector<ui::LatencyInfo>& latency_info) { 1086 const std::vector<ui::LatencyInfo>& latency_info) {
1093 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); 1087 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info));
1094 } 1088 }
1095 1089
1096 } // namespace content 1090 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_memory_buffer_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698