Chromium Code Reviews| Index: components/mus/gles2/command_buffer_driver.cc |
| diff --git a/components/mus/gles2/command_buffer_driver.cc b/components/mus/gles2/command_buffer_driver.cc |
| index 9fba1fa23ad3e27b91b44ed8d2777c0f891afee1..8b61aee801cb15f54540008f79855edf151f6dc6 100644 |
| --- a/components/mus/gles2/command_buffer_driver.cc |
| +++ b/components/mus/gles2/command_buffer_driver.cc |
| @@ -35,6 +35,10 @@ |
| #include "ui/gl/gl_image_shared_memory.h" |
| #include "ui/gl/gl_surface.h" |
| +#if defined(USE_OZONE) |
| +#include "ui/gl/gl_image_ozone_native_pixmap.h" |
| +#endif |
| + |
| namespace mus { |
| namespace { |
| @@ -84,10 +88,20 @@ bool CommandBufferDriver::Initialize( |
| const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; |
| static scoped_refptr<gfx::GLSurface> underlying_surface; |
| if (offscreen) { |
| - surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); |
| + surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(0, 0)); |
| } else { |
| +#if defined(USE_OZONE) |
| + scoped_refptr<gfx::GLSurface> underlying_surface = |
| + gfx::GLSurface::CreateSurfacelessViewGLSurface(widget_); |
| + if (!underlying_surface) { |
|
Fady Samuel
2016/04/06 22:02:02
nit: unnecessary braces.
rjkroege
2016/04/06 22:45:44
Done.
|
| + underlying_surface = gfx::GLSurface::CreateViewGLSurface(widget_); |
| + } |
| +#else |
| + scoped_refptr<gfx::GLSurface> underlying_surface = |
| + gfx::GLSurface::CreateViewGLSurface(widget_); |
| +#endif |
| scoped_refptr<GLSurfaceAdapterMus> surface_adapter = |
| - new GLSurfaceAdapterMus(gfx::GLSurface::CreateViewGLSurface(widget_)); |
| + new GLSurfaceAdapterMus(underlying_surface); |
| surface_adapter->SetGpuCompletedSwapBuffersCallback( |
| base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers, |
| weak_factory_.GetWeakPtr())); |
| @@ -273,6 +287,32 @@ void CommandBufferDriver::CreateImage(int32_t id, |
| image_manager->AddImage(image.get(), id); |
| } |
| +#if defined(USE_OZONE) |
| +// TODO(rjkroege): It is conceivable that this code belongs in |
| +// ozone_gpu_memory_buffer.cc |
| +void CommandBufferDriver::CreateImageNativeOzone(int32_t id, |
| + int32_t type, |
| + gfx::Size size, |
| + gfx::BufferFormat format, |
| + uint32_t internal_format, |
| + ui::NativePixmap* pixmap) { |
| + gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
| + if (image_manager->LookupImage(id)) { |
| + LOG(ERROR) << "Image already exists with same ID."; |
| + return; |
| + } |
| + |
| + scoped_refptr<gfx::GLImageOzoneNativePixmap> image = |
| + new gfx::GLImageOzoneNativePixmap(size, internal_format); |
| + if (!image->Initialize(pixmap, format)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + image_manager->AddImage(image.get(), id); |
| +} |
| +#endif |
| + |
| void CommandBufferDriver::DestroyImage(int32_t id) { |
| DCHECK(CalledOnValidThread()); |
| gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
| @@ -287,6 +327,7 @@ void CommandBufferDriver::DestroyImage(int32_t id) { |
| bool CommandBufferDriver::IsScheduled() const { |
| DCHECK(CalledOnValidThread()); |
| + DCHECK(executor_); |
| return executor_->scheduled(); |
| } |