Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: components/exo/display.cc

Issue 1427743004: exo: Add support for wl_drm version 2 to wayland bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wayland-drm-third-party
Patch Set: fix unit test and nit Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/display.h ('k') | components/exo/display_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "base/trace_event/trace_event_argument.h" 8 #include "base/trace_event/trace_event_argument.h"
9 #include "components/exo/shared_memory.h" 9 #include "components/exo/shared_memory.h"
10 #include "components/exo/shell_surface.h" 10 #include "components/exo/shell_surface.h"
11 #include "components/exo/sub_surface.h" 11 #include "components/exo/sub_surface.h"
12 #include "components/exo/surface.h" 12 #include "components/exo/surface.h"
13 13
14 #if defined(USE_OZONE)
15 #include "components/exo/buffer.h"
16 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
17 #include "third_party/khronos/GLES2/gl2.h"
18 #include "third_party/khronos/GLES2/gl2ext.h"
19 #include "ui/aura/env.h"
20 #endif
21
14 namespace exo { 22 namespace exo {
15 23
16 //////////////////////////////////////////////////////////////////////////////// 24 ////////////////////////////////////////////////////////////////////////////////
17 // Display, public: 25 // Display, public:
18 26
19 Display::Display() {} 27 Display::Display() {}
20 28
21 Display::~Display() {} 29 Display::~Display() {}
22 30
23 scoped_ptr<Surface> Display::CreateSurface() { 31 scoped_ptr<Surface> Display::CreateSurface() {
24 TRACE_EVENT0("exo", "Display::CreateSurface"); 32 TRACE_EVENT0("exo", "Display::CreateSurface");
25 33
26 return make_scoped_ptr(new Surface); 34 return make_scoped_ptr(new Surface);
27 } 35 }
28 36
29 scoped_ptr<SharedMemory> Display::CreateSharedMemory( 37 scoped_ptr<SharedMemory> Display::CreateSharedMemory(
30 const base::SharedMemoryHandle& handle, 38 const base::SharedMemoryHandle& handle,
31 size_t size) { 39 size_t size) {
32 TRACE_EVENT1("exo", "Display::CreateSharedMemory", "size", size); 40 TRACE_EVENT1("exo", "Display::CreateSharedMemory", "size", size);
33 41
34 if (!base::SharedMemory::IsHandleValid(handle)) 42 if (!base::SharedMemory::IsHandleValid(handle))
35 return nullptr; 43 return nullptr;
36 44
37 return make_scoped_ptr(new SharedMemory(handle)); 45 return make_scoped_ptr(new SharedMemory(handle));
38 } 46 }
39 47
48 #if defined(USE_OZONE)
49 scoped_ptr<Buffer> Display::CreatePrimeBuffer(base::ScopedFD fd,
50 const gfx::Size& size,
51 gfx::BufferFormat format,
52 int stride) {
53 TRACE_EVENT1("exo", "Display::CreatePrimeBuffer", "size", size.ToString());
54
55 gfx::GpuMemoryBufferHandle handle;
56 handle.type = gfx::OZONE_NATIVE_PIXMAP;
57 handle.native_pixmap_handle.fd = base::FileDescriptor(fd.Pass());
58 handle.native_pixmap_handle.stride = stride;
59
60 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer =
61 aura::Env::GetInstance()
62 ->context_factory()
63 ->GetGpuMemoryBufferManager()
64 ->CreateGpuMemoryBufferFromHandle(handle, size, format);
65 if (!gpu_memory_buffer) {
66 LOG(ERROR) << "Failed to create GpuMemoryBuffer from handle";
67 return nullptr;
68 }
69
70 return make_scoped_ptr(
71 new Buffer(gpu_memory_buffer.Pass(), GL_TEXTURE_EXTERNAL_OES));
72 }
73 #endif
74
40 scoped_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { 75 scoped_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) {
41 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", 76 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface",
42 surface->AsTracedValue()); 77 surface->AsTracedValue());
43 78
44 if (surface->HasSurfaceDelegate()) { 79 if (surface->HasSurfaceDelegate()) {
45 DLOG(ERROR) << "Surface has already been assigned a role"; 80 DLOG(ERROR) << "Surface has already been assigned a role";
46 return nullptr; 81 return nullptr;
47 } 82 }
48 83
49 return make_scoped_ptr(new ShellSurface(surface)); 84 return make_scoped_ptr(new ShellSurface(surface));
(...skipping 11 matching lines...) Expand all
61 96
62 if (surface->HasSurfaceDelegate()) { 97 if (surface->HasSurfaceDelegate()) {
63 DLOG(ERROR) << "Surface has already been assigned a role"; 98 DLOG(ERROR) << "Surface has already been assigned a role";
64 return nullptr; 99 return nullptr;
65 } 100 }
66 101
67 return make_scoped_ptr(new SubSurface(surface, parent)); 102 return make_scoped_ptr(new SubSurface(surface, parent));
68 } 103 }
69 104
70 } // namespace exo 105 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/display.h ('k') | components/exo/display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698