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

Side by Side Diff: ui/gl/gl_fence.cc

Issue 2418613004: ui: Add EGL_ANDROID_native_fence_sync support.
Patch Set: rebase Created 4 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 | « ui/gl/gl_fence.h ('k') | ui/gl/gl_fence_egl.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gl/gl_fence.h" 5 #include "ui/gl/gl_fence.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "ui/gfx/gpu_fence.h"
9 #include "ui/gl/gl_bindings.h" 10 #include "ui/gl/gl_bindings.h"
10 #include "ui/gl/gl_context.h" 11 #include "ui/gl/gl_context.h"
11 #include "ui/gl/gl_fence_arb.h" 12 #include "ui/gl/gl_fence_arb.h"
12 #include "ui/gl/gl_fence_egl.h" 13 #include "ui/gl/gl_fence_egl.h"
13 #include "ui/gl/gl_fence_nv.h" 14 #include "ui/gl/gl_fence_nv.h"
15 #include "ui/gl/gl_fence_shared_event.h"
14 #include "ui/gl/gl_gl_api_implementation.h" 16 #include "ui/gl/gl_gl_api_implementation.h"
15 #include "ui/gl/gl_implementation.h" 17 #include "ui/gl/gl_implementation.h"
16 #include "ui/gl/gl_version_info.h" 18 #include "ui/gl/gl_version_info.h"
17 19
18 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
19 #include "ui/gl/gl_fence_apple.h" 21 #include "ui/gl/gl_fence_apple.h"
20 #endif 22 #endif
21 23
24 #if defined(OS_LINUX)
25 #include "ui/gl/gl_fence_libsync.h"
26 #endif
27
22 namespace gl { 28 namespace gl {
23 29
24 GLFence::GLFence() { 30 GLFence::GLFence() {
25 } 31 }
26 32
27 GLFence::~GLFence() { 33 GLFence::~GLFence() {
28 } 34 }
29 35
30 bool GLFence::IsSupported() { 36 bool GLFence::IsSupported() {
31 DCHECK(GetGLVersionInfo()); 37 DCHECK(GetGLVersionInfo());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 fence = make_scoped_refptr(new GLFenceEGL); 69 fence = make_scoped_refptr(new GLFenceEGL);
64 #endif 70 #endif
65 } else if (g_driver_gl.ext.b_GL_NV_fence) { 71 } else if (g_driver_gl.ext.b_GL_NV_fence) {
66 fence = make_scoped_refptr(new GLFenceNV); 72 fence = make_scoped_refptr(new GLFenceNV);
67 } 73 }
68 74
69 DCHECK_EQ(!!fence.get(), GLFence::IsSupported()); 75 DCHECK_EQ(!!fence.get(), GLFence::IsSupported());
70 return fence; 76 return fence;
71 } 77 }
72 78
79 scoped_refptr<GLFence> GLFence::CreateFromGpuFenceHandle(
80 const gfx::GpuFenceHandle& handle) {
81 DCHECK(GLContext::GetCurrent()) << "Trying to create fence with no context";
82
83 scoped_refptr<GLFence> fence;
84 #if defined(OS_LINUX)
85 base::ScopedFD fence_fd(handle.fd.fd);
86 if (fence_fd.is_valid()) {
87 if (g_driver_egl.ext.b_EGL_ANDROID_native_fence_sync) {
88 EGLint attribs[] = {EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fence_fd.release(),
89 EGL_NONE};
90 fence = make_scoped_refptr(
91 new GLFenceEGL(EGL_SYNC_NATIVE_FENCE_ANDROID, attribs));
92 } else {
93 fence = make_scoped_refptr(new GLFenceLibsync(std::move(fence_fd)));
94 }
95 } else {
96 fence =
97 make_scoped_refptr(new GLFenceSharedEvent(handle.shared_event_handle));
98 }
99 #else
100 fence =
101 make_scoped_refptr(new GLFenceSharedEvent(handle.shared_event_handle));
102 #endif
103
104 return fence;
105 }
106
73 bool GLFence::ResetSupported() { 107 bool GLFence::ResetSupported() {
74 // Resetting a fence to its original state isn't supported by default. 108 // Resetting a fence to its original state isn't supported by default.
75 return false; 109 return false;
76 } 110 }
77 111
78 void GLFence::ResetState() { 112 void GLFence::ResetState() {
79 NOTIMPLEMENTED(); 113 NOTIMPLEMENTED();
80 } 114 }
81 115
82 void GLFence::Invalidate() { 116 void GLFence::Invalidate() {
83 NOTIMPLEMENTED(); 117 NOTIMPLEMENTED();
84 } 118 }
85 119
86 bool GLFence::SignalSupported() { 120 bool GLFence::SignalSupported() {
87 // Signaling a fence isn't supported by default. 121 // Signaling a fence isn't supported by default.
88 return false; 122 return false;
89 } 123 }
90 124
91 void GLFence::Signal() { 125 void GLFence::Signal() {
92 NOTIMPLEMENTED(); 126 NOTIMPLEMENTED();
93 } 127 }
94 128
95 } // namespace gl 129 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_fence.h ('k') | ui/gl/gl_fence_egl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698