| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/exo/display.h" | 5 #include "components/exo/display.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 8 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| 9 #include "components/exo/shared_memory.h" | 11 #include "components/exo/shared_memory.h" |
| 10 #include "components/exo/shell_surface.h" | 12 #include "components/exo/shell_surface.h" |
| 11 #include "components/exo/sub_surface.h" | 13 #include "components/exo/sub_surface.h" |
| 12 #include "components/exo/surface.h" | 14 #include "components/exo/surface.h" |
| 13 | 15 |
| 14 #if defined(USE_OZONE) | 16 #if defined(USE_OZONE) |
| 15 #include "components/exo/buffer.h" | 17 #include "components/exo/buffer.h" |
| 16 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 18 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 47 | 49 |
| 48 #if defined(USE_OZONE) | 50 #if defined(USE_OZONE) |
| 49 scoped_ptr<Buffer> Display::CreatePrimeBuffer(base::ScopedFD fd, | 51 scoped_ptr<Buffer> Display::CreatePrimeBuffer(base::ScopedFD fd, |
| 50 const gfx::Size& size, | 52 const gfx::Size& size, |
| 51 gfx::BufferFormat format, | 53 gfx::BufferFormat format, |
| 52 int stride) { | 54 int stride) { |
| 53 TRACE_EVENT1("exo", "Display::CreatePrimeBuffer", "size", size.ToString()); | 55 TRACE_EVENT1("exo", "Display::CreatePrimeBuffer", "size", size.ToString()); |
| 54 | 56 |
| 55 gfx::GpuMemoryBufferHandle handle; | 57 gfx::GpuMemoryBufferHandle handle; |
| 56 handle.type = gfx::OZONE_NATIVE_PIXMAP; | 58 handle.type = gfx::OZONE_NATIVE_PIXMAP; |
| 57 handle.native_pixmap_handle.fd = base::FileDescriptor(fd.Pass()); | 59 handle.native_pixmap_handle.fd = base::FileDescriptor(std::move(fd)); |
| 58 handle.native_pixmap_handle.stride = stride; | 60 handle.native_pixmap_handle.stride = stride; |
| 59 | 61 |
| 60 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = | 62 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = |
| 61 aura::Env::GetInstance() | 63 aura::Env::GetInstance() |
| 62 ->context_factory() | 64 ->context_factory() |
| 63 ->GetGpuMemoryBufferManager() | 65 ->GetGpuMemoryBufferManager() |
| 64 ->CreateGpuMemoryBufferFromHandle(handle, size, format); | 66 ->CreateGpuMemoryBufferFromHandle(handle, size, format); |
| 65 if (!gpu_memory_buffer) { | 67 if (!gpu_memory_buffer) { |
| 66 LOG(ERROR) << "Failed to create GpuMemoryBuffer from handle"; | 68 LOG(ERROR) << "Failed to create GpuMemoryBuffer from handle"; |
| 67 return nullptr; | 69 return nullptr; |
| 68 } | 70 } |
| 69 | 71 |
| 70 return make_scoped_ptr( | 72 return make_scoped_ptr( |
| 71 new Buffer(gpu_memory_buffer.Pass(), GL_TEXTURE_EXTERNAL_OES)); | 73 new Buffer(std::move(gpu_memory_buffer), GL_TEXTURE_EXTERNAL_OES)); |
| 72 } | 74 } |
| 73 #endif | 75 #endif |
| 74 | 76 |
| 75 scoped_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { | 77 scoped_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { |
| 76 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", | 78 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", |
| 77 surface->AsTracedValue()); | 79 surface->AsTracedValue()); |
| 78 | 80 |
| 79 if (surface->HasSurfaceDelegate()) { | 81 if (surface->HasSurfaceDelegate()) { |
| 80 DLOG(ERROR) << "Surface has already been assigned a role"; | 82 DLOG(ERROR) << "Surface has already been assigned a role"; |
| 81 return nullptr; | 83 return nullptr; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 | 98 |
| 97 if (surface->HasSurfaceDelegate()) { | 99 if (surface->HasSurfaceDelegate()) { |
| 98 DLOG(ERROR) << "Surface has already been assigned a role"; | 100 DLOG(ERROR) << "Surface has already been assigned a role"; |
| 99 return nullptr; | 101 return nullptr; |
| 100 } | 102 } |
| 101 | 103 |
| 102 return make_scoped_ptr(new SubSurface(surface, parent)); | 104 return make_scoped_ptr(new SubSurface(surface, parent)); |
| 103 } | 105 } |
| 104 | 106 |
| 105 } // namespace exo | 107 } // namespace exo |
| OLD | NEW |