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

Handle failed GpuMemoryBuffer allocations properly.

It is possible for an allocation to fail on the gpu side, we should handle it gracefully.
Currently we DCHECK that it succeeded in the browser, which in release leads to unexpected behaviour and NOTREACHED hit during destruction on the gpu side.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#302721}
parent aef58f49
...@@ -26,8 +26,12 @@ void GpuMemoryBufferCreated( ...@@ -26,8 +26,12 @@ void GpuMemoryBufferCreated(
gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Format format,
const GpuMemoryBufferImpl::CreationCallback& callback, const GpuMemoryBufferImpl::CreationCallback& callback,
const gfx::GpuMemoryBufferHandle& handle) { const gfx::GpuMemoryBufferHandle& handle) {
DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); if (handle.is_null()) {
callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
return;
}
DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type);
callback.Run(GpuMemoryBufferImplIOSurface::CreateFromHandle( callback.Run(GpuMemoryBufferImplIOSurface::CreateFromHandle(
handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle)));
} }
...@@ -35,7 +39,7 @@ void GpuMemoryBufferCreated( ...@@ -35,7 +39,7 @@ void GpuMemoryBufferCreated(
void GpuMemoryBufferCreatedForChildProcess( void GpuMemoryBufferCreatedForChildProcess(
const GpuMemoryBufferImpl::AllocationCallback& callback, const GpuMemoryBufferImpl::AllocationCallback& callback,
const gfx::GpuMemoryBufferHandle& handle) { const gfx::GpuMemoryBufferHandle& handle) {
DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); DCHECK_IMPLIES(!handle.is_null(), gfx::IO_SURFACE_BUFFER == handle.type);
callback.Run(handle); callback.Run(handle);
} }
......
...@@ -25,8 +25,12 @@ void GpuMemoryBufferCreated( ...@@ -25,8 +25,12 @@ void GpuMemoryBufferCreated(
gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Format format,
const GpuMemoryBufferImpl::CreationCallback& callback, const GpuMemoryBufferImpl::CreationCallback& callback,
const gfx::GpuMemoryBufferHandle& handle) { const gfx::GpuMemoryBufferHandle& handle) {
DCHECK_EQ(gfx::OZONE_NATIVE_BUFFER, handle.type); if (handle.is_null()) {
callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
return;
}
DCHECK_EQ(gfx::OZONE_NATIVE_BUFFER, handle.type);
callback.Run(GpuMemoryBufferImplOzoneNativeBuffer::CreateFromHandle( callback.Run(GpuMemoryBufferImplOzoneNativeBuffer::CreateFromHandle(
handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle)));
} }
...@@ -34,7 +38,7 @@ void GpuMemoryBufferCreated( ...@@ -34,7 +38,7 @@ void GpuMemoryBufferCreated(
void GpuMemoryBufferCreatedForChildProcess( void GpuMemoryBufferCreatedForChildProcess(
const GpuMemoryBufferImpl::AllocationCallback& callback, const GpuMemoryBufferImpl::AllocationCallback& callback,
const gfx::GpuMemoryBufferHandle& handle) { const gfx::GpuMemoryBufferHandle& handle) {
DCHECK_EQ(gfx::OZONE_NATIVE_BUFFER, handle.type); DCHECK_IMPLIES(!handle.is_null(), gfx::OZONE_NATIVE_BUFFER == handle.type);
callback.Run(handle); callback.Run(handle);
} }
......
...@@ -28,8 +28,12 @@ void GpuMemoryBufferCreated( ...@@ -28,8 +28,12 @@ void GpuMemoryBufferCreated(
gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Format format,
const GpuMemoryBufferImpl::CreationCallback& callback, const GpuMemoryBufferImpl::CreationCallback& callback,
const gfx::GpuMemoryBufferHandle& handle) { const gfx::GpuMemoryBufferHandle& handle) {
DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); if (handle.is_null()) {
callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
return;
}
DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type);
callback.Run(GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( callback.Run(GpuMemoryBufferImplSurfaceTexture::CreateFromHandle(
handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle)));
} }
...@@ -37,7 +41,7 @@ void GpuMemoryBufferCreated( ...@@ -37,7 +41,7 @@ void GpuMemoryBufferCreated(
void GpuMemoryBufferCreatedForChildProcess( void GpuMemoryBufferCreatedForChildProcess(
const GpuMemoryBufferImpl::AllocationCallback& callback, const GpuMemoryBufferImpl::AllocationCallback& callback,
const gfx::GpuMemoryBufferHandle& handle) { const gfx::GpuMemoryBufferHandle& handle) {
DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); DCHECK_IMPLIES(!handle.is_null(), gfx::SURFACE_TEXTURE_BUFFER == handle.type);
callback.Run(handle); callback.Run(handle);
} }
......
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