| Index: content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc
|
| diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc
|
| index 7acf59c8e51527215405b8ee7a18c12c2f90160c..0279fd22ad5352cef9efd3bbe715213328b6b61c 100644
|
| --- a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc
|
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc
|
| @@ -4,7 +4,7 @@
|
|
|
| #include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h"
|
|
|
| -#include "ui/ozone/public/surface_factory_ozone.h"
|
| +#include "ui/ozone/public/client_native_pixmap_factory.h"
|
|
|
| namespace content {
|
|
|
| @@ -12,8 +12,9 @@ GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap(
|
| gfx::GpuMemoryBufferId id,
|
| const gfx::Size& size,
|
| gfx::BufferFormat format,
|
| + gfx::BufferUsage usage,
|
| const DestructionCallback& callback)
|
| - : GpuMemoryBufferImpl(id, size, format, callback) {}
|
| + : GpuMemoryBufferImpl(id, size, format, callback), usage_(usage) {}
|
|
|
| GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {}
|
|
|
| @@ -25,22 +26,54 @@ GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle(
|
| gfx::BufferFormat format,
|
| gfx::BufferUsage usage,
|
| const DestructionCallback& callback) {
|
| - return make_scoped_ptr<GpuMemoryBufferImpl>(
|
| - new GpuMemoryBufferImplOzoneNativePixmap(handle.id, size, format,
|
| - callback));
|
| + scoped_ptr<GpuMemoryBufferImplOzoneNativePixmap> buffer =
|
| + make_scoped_ptr(new GpuMemoryBufferImplOzoneNativePixmap(
|
| + handle.id, size, format, usage, callback));
|
| +
|
| + if (!buffer->Initialize(handle))
|
| + return nullptr;
|
| + return buffer.Pass();
|
| }
|
|
|
| -bool GpuMemoryBufferImplOzoneNativePixmap::Map(void** data) {
|
| +bool GpuMemoryBufferImplOzoneNativePixmap::Initialize(
|
| + const gfx::GpuMemoryBufferHandle& handle) {
|
| + DCHECK(ui::ClientNativePixmapFactory::GetInstance());
|
| + switch (usage_) {
|
| + case gfx::BufferUsage::MAP:
|
| + pixmap_ = ui::ClientNativePixmapFactory::GetInstance()
|
| + ->ImportNativePixmap(handle.handle, size_, format_, usage_)
|
| + .Pass();
|
| + return !!pixmap_;
|
| + case gfx::BufferUsage::PERSISTENT_MAP:
|
| + NOTREACHED();
|
| + return false;
|
| + case gfx::BufferUsage::SCANOUT:
|
| + return true;
|
| + }
|
| NOTREACHED();
|
| return false;
|
| }
|
|
|
| +bool GpuMemoryBufferImplOzoneNativePixmap::Map(void** data) {
|
| + DCHECK(!mapped_);
|
| + DCHECK(usage_ == gfx::BufferUsage::MAP);
|
| + DCHECK(pixmap_);
|
| + mapped_ = true;
|
| + return pixmap_->Map(data);
|
| +}
|
| +
|
| void GpuMemoryBufferImplOzoneNativePixmap::Unmap() {
|
| - NOTREACHED();
|
| + DCHECK(mapped_);
|
| + DCHECK(usage_ == gfx::BufferUsage::MAP);
|
| + DCHECK(pixmap_);
|
| + pixmap_->Unmap();
|
| + mapped_ = false;
|
| }
|
|
|
| void GpuMemoryBufferImplOzoneNativePixmap::GetStride(int* stride) const {
|
| - NOTREACHED();
|
| + DCHECK(usage_ == gfx::BufferUsage::MAP);
|
| + DCHECK(pixmap_);
|
| + pixmap_->GetStride(stride);
|
| }
|
|
|
| gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle()
|
|
|