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

Unified Diff: content/common/gpu/client/command_buffer_proxy_impl.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: reveman@ comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.h ('k') | content/common/gpu/gpu_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/client/command_buffer_proxy_impl.cc
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc
index 8241812cc2af9aa068f6bce602727e67ecf841eb..2a2c996578c59472ff5d6fe3e915600ee308d03d 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -347,7 +347,7 @@ gpu::Capabilities CommandBufferProxyImpl::GetCapabilities() {
return capabilities_;
}
-int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer,
+int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer* const buffers,
size_t width,
size_t height,
unsigned internalformat) {
@@ -359,34 +359,60 @@ int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager =
channel_->gpu_memory_buffer_manager();
- gfx::GpuMemoryBuffer* gpu_memory_buffer =
- gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffer);
- DCHECK(gpu_memory_buffer);
- // This handle is owned by the GPU process and must be passed to it or it
- // will leak. In otherwords, do not early out on error between here and the
- // sending of the CreateImage IPC below.
+ // Log and return if the |internalformat| isn't supported.
reveman 2015/03/19 15:39:45 This comment is incorrect
+ DCHECK(gpu::ImageFactory::IsImageFormatSupported(internalformat));
+
+ // Check the buffer count for the given |internalformat| and initialize the
+ // vectors where data will be passed. Log and return if the |internalformat|
+ // isn't supported.
reveman 2015/03/19 15:39:45 Log and return... ? Please update comment
+ size_t num_buffers =
+ gpu::ImageFactory::NumberOfPlanesForImageFormat(internalformat);
+ std::vector<gfx::GpuMemoryBufferHandle> handles;
+ std::vector<gfx::GpuMemoryBuffer::Format> formats;
bool requires_sync_point = false;
- gfx::GpuMemoryBufferHandle handle =
- channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(),
- &requires_sync_point);
-
- DCHECK(gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(
- gfx::Size(width, height), gpu_memory_buffer->GetFormat()));
- DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
- internalformat, gpu_memory_buffer->GetFormat()));
+
+ for (size_t i = 0; i < num_buffers; ++i) {
+ gfx::GpuMemoryBuffer* gpu_memory_buffer =
+ gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffers[i]);
+ DCHECK(gpu_memory_buffer);
+
+ formats.push_back(gpu_memory_buffer->GetFormat());
+ DCHECK(gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(
+ gfx::Size(width, height), formats[i]));
+ DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
+ internalformat, i, formats[i]));
+
+ bool buffer_requires_sync_point = false;
+ // This handle is owned by the GPU process and must be passed to it or it
+ // will leak. In other words, do not early out on error between here and the
+ // sending of the CreateImage IPC below.
+ handles.push_back(channel_->ShareGpuMemoryBufferToGpuProcess(
+ gpu_memory_buffer->GetHandle(), &buffer_requires_sync_point));
+
+ // We set a destruction sync point on all buffers if one happen to require
+ // one.
+ requires_sync_point |= buffer_requires_sync_point;
+ }
+
if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_,
new_id,
- handle,
+ handles,
gfx::Size(width, height),
- gpu_memory_buffer->GetFormat(),
+ formats,
internalformat))) {
return -1;
}
if (requires_sync_point) {
- gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer,
- InsertSyncPoint());
+ uint32 sync_point = InsertSyncPoint();
+ for (size_t i = 0; i < num_buffers; ++i) {
+ gfx::GpuMemoryBuffer* gpu_memory_buffer =
+ gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(
+ buffers[i]);
+ gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer,
+ sync_point);
+ }
}
return new_id;
@@ -406,15 +432,27 @@ int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage(
unsigned internalformat,
unsigned usage) {
CheckLock();
- scoped_ptr<gfx::GpuMemoryBuffer> buffer(
- channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer(
- gfx::Size(width, height),
- gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat),
- gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage)));
- if (!buffer)
- return -1;
-
- return CreateImage(buffer->AsClientBuffer(), width, height, internalformat);
+ DCHECK(gpu::ImageFactory::IsImageFormatSupported(internalformat));
+
+ size_t num_buffers =
+ gpu::ImageFactory::NumberOfPlanesForImageFormat(internalformat);
+ ScopedVector<gfx::GpuMemoryBuffer> buffers;
+ std::vector<ClientBuffer> client_buffers;
+
+ for (size_t i = 0; i < num_buffers; ++i) {
+ gfx::GpuMemoryBuffer::Format format =
+ gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat,
+ i);
+ buffers.push_back(
+ channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer(
+ gfx::Size(width, height), format,
+ gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage)));
+ if (!buffers[i])
+ return -1;
+
+ client_buffers[i] = buffers[i]->AsClientBuffer();
+ }
+ return CreateImage(client_buffers.data(), width, height, internalformat);
}
int CommandBufferProxyImpl::GetRouteID() const {
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.h ('k') | content/common/gpu/gpu_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698