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

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

Issue 962723002: Change CHROMIUM_image declarations to support multi planar input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added implementations of ImageFactory::CreateImageForGpuMemoryBuffers(). Created 5 years, 9 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/hash.h" 8 #include "base/hash.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 if (has_callback) { 933 if (has_callback) {
934 if (!memory_manager_client_state_) { 934 if (!memory_manager_client_state_) {
935 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( 935 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState(
936 this, surface_id_ != 0, true)); 936 this, surface_id_ != 0, true));
937 } 937 }
938 } else { 938 } else {
939 memory_manager_client_state_.reset(); 939 memory_manager_client_state_.reset();
940 } 940 }
941 } 941 }
942 942
943 void GpuCommandBufferStub::OnCreateImage(int32 id, 943 void GpuCommandBufferStub::OnCreateImage(
944 gfx::GpuMemoryBufferHandle handle, 944 int32 id,
945 gfx::Size size, 945 std::vector<gfx::GpuMemoryBufferHandle> handles,
946 gfx::GpuMemoryBuffer::Format format, 946 gfx::Size size,
947 uint32 internalformat) { 947 std::vector<gfx::GpuMemoryBuffer::Format> formats,
948 uint32 internalformat) {
948 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateImage"); 949 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateImage");
949 950
950 if (!decoder_) 951 if (!decoder_)
951 return; 952 return;
952 953
953 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 954 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
954 DCHECK(image_manager); 955 DCHECK(image_manager);
955 if (image_manager->LookupImage(id)) { 956 if (image_manager->LookupImage(id)) {
956 LOG(ERROR) << "Image already exists with same ID."; 957 LOG(ERROR) << "Image already exists with same ID.";
957 return; 958 return;
958 } 959 }
959 960
960 if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( 961 int num_buffers =
961 format, decoder_->GetCapabilities())) { 962 gpu::ImageFactory::GpuMemoryBufferCountForImageFormat(internalformat);
962 LOG(ERROR) << "Format is not supported."; 963 CHECK_EQ(static_cast<int>(handles.size()), num_buffers);
reveman 2015/03/10 04:27:21 CHECKS here makes it possible for a malicious rend
emircan 2015/03/11 18:36:35 Done.
963 return; 964 CHECK_EQ(static_cast<int>(formats.size()), num_buffers);
965
966 for (int i = 0; i < num_buffers; ++i) {
967 const gfx::GpuMemoryBuffer::Format& format = formats[i];
968 if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported(
969 format, decoder_->GetCapabilities())) {
970 LOG(ERROR) << "Format is not supported.";
971 return;
972 }
973 if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(
974 size, format)) {
975 LOG(ERROR) << "Invalid image size for format.";
976 return;
977 }
978 if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
979 internalformat, i, format)) {
980 LOG(ERROR) << "Incompatible image format.";
981 return;
982 }
964 } 983 }
965 984
966 if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(size, 985 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffers(
967 format)) { 986 handles, size, formats, internalformat);
968 LOG(ERROR) << "Invalid image size for format.";
969 return;
970 }
971
972 if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
973 internalformat, format)) {
974 LOG(ERROR) << "Incompatible image format.";
975 return;
976 }
977
978 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer(
979 handle, size, format, internalformat);
980 if (!image.get()) 987 if (!image.get())
981 return; 988 return;
982 989
983 image_manager->AddImage(image.get(), id); 990 image_manager->AddImage(image.get(), id);
984 } 991 }
985 992
986 void GpuCommandBufferStub::OnDestroyImage(int32 id) { 993 void GpuCommandBufferStub::OnDestroyImage(int32 id) {
987 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage"); 994 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage");
988 995
989 if (!decoder_) 996 if (!decoder_)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); 1109 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info));
1103 } 1110 }
1104 1111
1105 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1112 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1106 base::TimeDelta interval) { 1113 base::TimeDelta interval) {
1107 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1114 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1108 interval)); 1115 interval));
1109 } 1116 }
1110 1117
1111 } // namespace content 1118 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_memory_buffer_factory_io_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698