| 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 <iterator> | 7 #include <iterator> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "base/trace_event/trace_event_argument.h" | 14 #include "base/trace_event/trace_event_argument.h" |
| 15 #include "components/exo/notification_surface.h" | 15 #include "components/exo/notification_surface.h" |
| 16 #include "components/exo/notification_surface_manager.h" | 16 #include "components/exo/notification_surface_manager.h" |
| 17 #include "components/exo/shared_memory.h" | 17 #include "components/exo/shared_memory.h" |
| 18 #include "components/exo/shell_surface.h" | 18 #include "components/exo/shell_surface.h" |
| 19 #include "components/exo/sub_surface.h" | 19 #include "components/exo/sub_surface.h" |
| 20 #include "components/exo/surface.h" | 20 #include "components/exo/surface.h" |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 | 22 |
| 23 #if defined(OS_LINUX) |
| 24 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 25 #include "ui/aura/env.h" |
| 26 #endif |
| 27 |
| 23 #if defined(USE_OZONE) | 28 #if defined(USE_OZONE) |
| 24 #include <GLES2/gl2extchromium.h> | 29 #include <GLES2/gl2extchromium.h> |
| 25 #include "components/exo/buffer.h" | 30 #include "components/exo/buffer.h" |
| 26 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | |
| 27 #include "third_party/khronos/GLES2/gl2.h" | 31 #include "third_party/khronos/GLES2/gl2.h" |
| 28 #include "third_party/khronos/GLES2/gl2ext.h" | 32 #include "third_party/khronos/GLES2/gl2ext.h" |
| 29 #include "ui/aura/env.h" | |
| 30 #endif | 33 #endif |
| 31 | 34 |
| 32 namespace exo { | 35 namespace exo { |
| 33 | 36 |
| 34 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
| 35 // Display, public: | 38 // Display, public: |
| 36 | 39 |
| 37 Display::Display() : notification_surface_manager_(nullptr) {} | 40 Display::Display() : notification_surface_manager_(nullptr) {} |
| 38 | 41 |
| 39 Display::Display(NotificationSurfaceManager* notification_surface_manager) | 42 Display::Display(NotificationSurfaceManager* notification_surface_manager) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 gfx::BufferFormat::RGBX_8888}; | 97 gfx::BufferFormat::RGBX_8888}; |
| 95 bool is_overlay_candidate = | 98 bool is_overlay_candidate = |
| 96 std::find(std::begin(kOverlayFormats), std::end(kOverlayFormats), | 99 std::find(std::begin(kOverlayFormats), std::end(kOverlayFormats), |
| 97 format) != std::end(kOverlayFormats); | 100 format) != std::end(kOverlayFormats); |
| 98 | 101 |
| 99 return base::MakeUnique<Buffer>( | 102 return base::MakeUnique<Buffer>( |
| 100 std::move(gpu_memory_buffer), GL_TEXTURE_EXTERNAL_OES, | 103 std::move(gpu_memory_buffer), GL_TEXTURE_EXTERNAL_OES, |
| 101 // COMMANDS_COMPLETED queries are required by native pixmaps. | 104 // COMMANDS_COMPLETED queries are required by native pixmaps. |
| 102 GL_COMMANDS_COMPLETED_CHROMIUM, use_zero_copy, is_overlay_candidate); | 105 GL_COMMANDS_COMPLETED_CHROMIUM, use_zero_copy, is_overlay_candidate); |
| 103 } | 106 } |
| 107 #endif // defined(USE_OZONE) |
| 104 | 108 |
| 109 #if defined(OS_LINUX) |
| 105 std::unique_ptr<gfx::GpuFence> Display::CreateLinuxFence(base::ScopedFD fd) { | 110 std::unique_ptr<gfx::GpuFence> Display::CreateLinuxFence(base::ScopedFD fd) { |
| 106 TRACE_EVENT1("exo", "Display::CreateLinuxFence", "fd", fd.get()); | 111 TRACE_EVENT1("exo", "Display::CreateLinuxFence", "fd", fd.get()); |
| 107 | 112 |
| 108 gfx::GpuFenceHandle handle; | 113 gfx::GpuFenceHandle handle; |
| 109 | 114 |
| 110 handle.fd.fd = fd.release(); | 115 handle.fd.fd = fd.release(); |
| 111 | 116 |
| 112 std::unique_ptr<gfx::GpuFence> gpu_fence = | 117 return aura::Env::GetInstance() |
| 113 aura::Env::GetInstance() | 118 ->context_factory() |
| 114 ->context_factory() | 119 ->GetGpuMemoryBufferManager() |
| 115 ->GetGpuMemoryBufferManager() | 120 ->CreateGpuFenceFromHandle(handle); |
| 116 ->CreateGpuFenceFromHandle(handle); | |
| 117 | |
| 118 return std::move(gpu_fence); | |
| 119 } | 121 } |
| 120 #endif | 122 #endif // defined(OS_LINUX) |
| 121 | 123 |
| 122 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { | 124 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { |
| 123 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", | 125 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", |
| 124 surface->AsTracedValue()); | 126 surface->AsTracedValue()); |
| 125 | 127 |
| 126 if (surface->HasSurfaceDelegate()) { | 128 if (surface->HasSurfaceDelegate()) { |
| 127 DLOG(ERROR) << "Surface has already been assigned a role"; | 129 DLOG(ERROR) << "Surface has already been assigned a role"; |
| 128 return nullptr; | 130 return nullptr; |
| 129 } | 131 } |
| 130 | 132 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 notification_surface_manager_->GetSurface(notification_id)) { | 209 notification_surface_manager_->GetSurface(notification_id)) { |
| 208 DLOG(ERROR) << "Invalid notification id, id=" << notification_id; | 210 DLOG(ERROR) << "Invalid notification id, id=" << notification_id; |
| 209 return nullptr; | 211 return nullptr; |
| 210 } | 212 } |
| 211 | 213 |
| 212 return base::MakeUnique<NotificationSurface>(notification_surface_manager_, | 214 return base::MakeUnique<NotificationSurface>(notification_surface_manager_, |
| 213 surface, notification_id); | 215 surface, notification_id); |
| 214 } | 216 } |
| 215 | 217 |
| 216 } // namespace exo | 218 } // namespace exo |
| OLD | NEW |