Commit ce18d4bb authored by alexst's avatar alexst Committed by Commit bot

Remove the assumption about client_id from gpu memory buffer allocation on the browser side.

BUG=

Review URL: https://codereview.chromium.org/557353002

Cr-Commit-Position: refs/heads/master@{#294199}
parent 23c94098
......@@ -43,18 +43,21 @@ struct BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferRequest {
AllocateGpuMemoryBufferRequest(size_t width,
size_t height,
unsigned internalformat,
unsigned usage)
unsigned usage,
int client_id)
: event(true, false),
width(width),
height(height),
internalformat(internalformat),
usage(usage) {}
usage(usage),
client_id(client_id) {}
~AllocateGpuMemoryBufferRequest() {}
base::WaitableEvent event;
size_t width;
size_t height;
unsigned internalformat;
unsigned usage;
int client_id;
scoped_ptr<gfx::GpuMemoryBuffer> result;
};
......@@ -387,7 +390,8 @@ BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer(size_t width,
unsigned usage) {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
AllocateGpuMemoryBufferRequest request(width, height, internalformat, usage);
AllocateGpuMemoryBufferRequest request(
width, height, internalformat, usage, gpu_client_id_);
GetIOLoopProxy()->PostTask(
FROM_HERE,
base::Bind(&BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferOnIO,
......@@ -459,6 +463,7 @@ void BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferOnIO(
gfx::Size(request->width, request->height),
request->internalformat,
request->usage,
request->client_id,
base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated,
base::Unretained(request)));
}
......
......@@ -23,20 +23,21 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
virtual ~GpuMemoryBufferImpl();
// Creates a GPU memory buffer instance with |size| and |internalformat| for
// |usage|.
// |usage| by the current process and |client_id|.
static void Create(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback);
// Allocates a GPU memory buffer with |size| and |internalformat| for |usage|
// by |child_process| identified by |child_id|. The |handle| returned can be
// by |child_process| and |child_client_id|. The |handle| returned can be
// used by the |child_process| to create an instance of this class.
static void AllocateForChildProcess(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
base::ProcessHandle child_process,
int child_id,
int child_client_id,
const AllocationCallback& callback);
// Notify that GPU memory buffer has been deleted by |child_process|.
......
......@@ -13,6 +13,7 @@ namespace content {
void GpuMemoryBufferImpl::Create(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......@@ -30,7 +31,7 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
unsigned internalformat,
unsigned usage,
base::ProcessHandle child_process,
int child_id,
int child_client_id,
const AllocationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......
......@@ -12,6 +12,7 @@ namespace content {
void GpuMemoryBufferImpl::Create(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......@@ -29,7 +30,7 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
unsigned internalformat,
unsigned usage,
base::ProcessHandle child_process,
int child_id,
int child_client_id,
const AllocationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......
......@@ -13,6 +13,7 @@ namespace content {
void GpuMemoryBufferImpl::Create(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......@@ -30,7 +31,7 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
unsigned internalformat,
unsigned usage,
base::ProcessHandle child_process,
int child_id,
int child_client_id,
const AllocationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......
......@@ -13,11 +13,12 @@ namespace content {
void GpuMemoryBufferImpl::Create(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback) {
if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported(
internalformat, usage)) {
GpuMemoryBufferImplOzoneNativeBuffer::Create(
size, internalformat, usage, callback);
size, internalformat, usage, client_id, callback);
return;
}
......@@ -37,12 +38,12 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
unsigned internalformat,
unsigned usage,
base::ProcessHandle child_process,
int child_id,
int child_client_id,
const AllocationCallback& callback) {
if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported(
internalformat, usage)) {
GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId(
size, internalformat, usage, child_id, callback);
size, internalformat, usage, child_client_id, callback);
return;
}
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
......
......@@ -39,12 +39,11 @@ void GpuMemoryBufferImplOzoneNativeBuffer::Create(
const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback) {
gfx::GpuMemoryBufferHandle handle;
handle.global_id.primary_id = g_next_buffer_id.GetNext();
// This code makes an assumption that client_id for GPU channel using this
// buffer is zero.
handle.global_id.secondary_id = 0;
handle.global_id.secondary_id = client_id;
handle.type = gfx::OZONE_NATIVE_BUFFER;
GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer(
handle,
......@@ -59,11 +58,11 @@ void GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId(
const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int child_id,
int child_client_id,
const AllocationCallback& callback) {
gfx::GpuMemoryBufferHandle handle;
handle.global_id.primary_id = g_next_buffer_id.GetNext();
handle.global_id.secondary_id = child_id;
handle.global_id.secondary_id = child_client_id;
handle.type = gfx::OZONE_NATIVE_BUFFER;
GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer(
handle,
......
......@@ -19,6 +19,7 @@ class GpuMemoryBufferImplOzoneNativeBuffer : public GpuMemoryBufferImpl {
static void Create(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback);
// Allocates an Ozone native buffer backed GPU memory buffer with |size| and
......@@ -27,7 +28,7 @@ class GpuMemoryBufferImplOzoneNativeBuffer : public GpuMemoryBufferImpl {
const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int child_id,
int child_client_id,
const AllocationCallback& callback);
static bool IsFormatSupported(unsigned internalformat);
......
......@@ -12,6 +12,7 @@ namespace content {
void GpuMemoryBufferImpl::Create(const gfx::Size& size,
unsigned internalformat,
unsigned usage,
int client_id,
const CreationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......@@ -29,7 +30,7 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
unsigned internalformat,
unsigned usage,
base::ProcessHandle child_process,
int child_id,
int child_client_id,
const AllocationCallback& callback) {
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment