John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 17 | #include "EglManager.h" |
| 18 | |
Mark Salyzyn | 96bf598 | 2016-09-28 16:15:30 -0700 | [diff] [blame] | 19 | #include <cutils/properties.h> |
| 20 | #include <log/log.h> |
Stan Iliev | 564ca3e | 2018-09-04 22:00:00 +0000 | [diff] [blame^] | 21 | #include <private/gui/SyncFeatures.h> |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 22 | #include <utils/Trace.h> |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 23 | #include "utils/StringUtils.h" |
Mark Salyzyn | 96bf598 | 2016-09-28 16:15:30 -0700 | [diff] [blame] | 24 | |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 25 | #include "DeviceInfo.h" |
Greg Daniel | cd55852 | 2016-11-17 13:31:40 -0500 | [diff] [blame] | 26 | #include "Frame.h" |
John Reck | d04794a | 2015-05-08 10:04:36 -0700 | [diff] [blame] | 27 | #include "Properties.h" |
Mark Salyzyn | 173215d | 2017-01-12 08:27:11 -0800 | [diff] [blame] | 28 | |
John Reck | 5515637 | 2015-01-21 07:46:37 -0800 | [diff] [blame] | 29 | #include <EGL/eglext.h> |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 30 | |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 31 | #include <string> |
| 32 | #include <vector> |
Derek Sollenberger | 7e044fe | 2016-11-07 10:57:59 -0500 | [diff] [blame] | 33 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 34 | #define GLES_VERSION 2 |
| 35 | |
| 36 | // Android-specific addition that is used to show when frames began in systrace |
| 37 | EGLAPI void EGLAPIENTRY eglBeginFrame(EGLDisplay dpy, EGLSurface surface); |
| 38 | |
| 39 | namespace android { |
| 40 | namespace uirenderer { |
| 41 | namespace renderthread { |
| 42 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 43 | #define ERROR_CASE(x) \ |
| 44 | case x: \ |
| 45 | return #x; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 46 | static const char* egl_error_str(EGLint error) { |
| 47 | switch (error) { |
| 48 | ERROR_CASE(EGL_SUCCESS) |
| 49 | ERROR_CASE(EGL_NOT_INITIALIZED) |
| 50 | ERROR_CASE(EGL_BAD_ACCESS) |
| 51 | ERROR_CASE(EGL_BAD_ALLOC) |
| 52 | ERROR_CASE(EGL_BAD_ATTRIBUTE) |
| 53 | ERROR_CASE(EGL_BAD_CONFIG) |
| 54 | ERROR_CASE(EGL_BAD_CONTEXT) |
| 55 | ERROR_CASE(EGL_BAD_CURRENT_SURFACE) |
| 56 | ERROR_CASE(EGL_BAD_DISPLAY) |
| 57 | ERROR_CASE(EGL_BAD_MATCH) |
| 58 | ERROR_CASE(EGL_BAD_NATIVE_PIXMAP) |
| 59 | ERROR_CASE(EGL_BAD_NATIVE_WINDOW) |
| 60 | ERROR_CASE(EGL_BAD_PARAMETER) |
| 61 | ERROR_CASE(EGL_BAD_SURFACE) |
| 62 | ERROR_CASE(EGL_CONTEXT_LOST) |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 63 | default: |
| 64 | return "Unknown error"; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 65 | } |
| 66 | } |
sergeyv | 694d499 | 2016-10-27 10:23:13 -0700 | [diff] [blame] | 67 | const char* EglManager::eglErrorString() { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 68 | return egl_error_str(eglGetError()); |
| 69 | } |
| 70 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 71 | static struct { |
| 72 | bool bufferAge = false; |
| 73 | bool setDamage = false; |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 74 | bool noConfigContext = false; |
| 75 | bool pixelFormatFloat = false; |
| 76 | bool glColorSpace = false; |
Romain Guy | 26b6a64 | 2017-07-11 09:48:28 -0700 | [diff] [blame] | 77 | bool scRGB = false; |
Jorim Jaggi | 767e25e | 2018-04-04 23:07:35 +0200 | [diff] [blame] | 78 | bool contextPriority = false; |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 79 | bool surfacelessContext = false; |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 80 | } EglExtensions; |
| 81 | |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 82 | EglManager::EglManager() |
| 83 | : mEglDisplay(EGL_NO_DISPLAY) |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 84 | , mEglConfig(nullptr) |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 85 | , mEglConfigWideGamut(nullptr) |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 86 | , mEglContext(EGL_NO_CONTEXT) |
| 87 | , mPBufferSurface(EGL_NO_SURFACE) |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 88 | , mCurrentSurface(EGL_NO_SURFACE) {} |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 89 | |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 90 | EglManager::~EglManager() { |
| 91 | destroy(); |
| 92 | } |
| 93 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 94 | void EglManager::initialize() { |
| 95 | if (hasEglContext()) return; |
| 96 | |
John Reck | fbc8df0 | 2014-11-14 16:18:41 -0800 | [diff] [blame] | 97 | ATRACE_NAME("Creating EGLContext"); |
| 98 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 99 | mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 100 | LOG_ALWAYS_FATAL_IF(mEglDisplay == EGL_NO_DISPLAY, "Failed to get EGL_DEFAULT_DISPLAY! err=%s", |
| 101 | eglErrorString()); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 102 | |
| 103 | EGLint major, minor; |
| 104 | LOG_ALWAYS_FATAL_IF(eglInitialize(mEglDisplay, &major, &minor) == EGL_FALSE, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 105 | "Failed to initialize display %p! err=%s", mEglDisplay, eglErrorString()); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 106 | |
| 107 | ALOGI("Initialized EGL, version %d.%d", (int)major, (int)minor); |
| 108 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 109 | initExtensions(); |
Season Li | 13d1b4a | 2015-07-29 17:16:19 -0700 | [diff] [blame] | 110 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 111 | // Now that extensions are loaded, pick a swap behavior |
| 112 | if (Properties::enablePartialUpdates) { |
Matt Sarett | b77c94a | 2016-12-07 12:22:37 -0500 | [diff] [blame] | 113 | // An Adreno driver bug is causing rendering problems for SkiaGL with |
| 114 | // buffer age swap behavior (b/31957043). To temporarily workaround, |
| 115 | // we will use preserved swap behavior. |
Derek Sollenberger | b5a12bd | 2017-06-14 15:23:19 -0400 | [diff] [blame] | 116 | if (Properties::useBufferAge && EglExtensions.bufferAge) { |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 117 | mSwapBehavior = SwapBehavior::BufferAge; |
| 118 | } else { |
| 119 | mSwapBehavior = SwapBehavior::Preserved; |
| 120 | } |
| 121 | } |
| 122 | |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 123 | loadConfigs(); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 124 | createContext(); |
John Reck | d7db4d7 | 2015-05-20 07:18:55 -0700 | [diff] [blame] | 125 | createPBufferSurface(); |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 126 | makeCurrent(mPBufferSurface, nullptr, /* force */ true); |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 127 | DeviceInfo::initialize(); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 128 | } |
| 129 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 130 | void EglManager::initExtensions() { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 131 | auto extensions = StringUtils::split(eglQueryString(mEglDisplay, EGL_EXTENSIONS)); |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 132 | |
John Reck | 8733bff | 2016-09-27 14:45:28 -0700 | [diff] [blame] | 133 | // For our purposes we don't care if EGL_BUFFER_AGE is a result of |
| 134 | // EGL_EXT_buffer_age or EGL_KHR_partial_update as our usage is covered |
| 135 | // under EGL_KHR_partial_update and we don't need the expanded scope |
| 136 | // that EGL_EXT_buffer_age provides. |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 137 | EglExtensions.bufferAge = |
| 138 | extensions.has("EGL_EXT_buffer_age") || extensions.has("EGL_KHR_partial_update"); |
Chris Craik | 6e6646c | 2015-09-14 15:54:12 -0700 | [diff] [blame] | 139 | EglExtensions.setDamage = extensions.has("EGL_KHR_partial_update"); |
John Reck | 708b668 | 2015-10-22 13:11:00 -0700 | [diff] [blame] | 140 | LOG_ALWAYS_FATAL_IF(!extensions.has("EGL_KHR_swap_buffers_with_damage"), |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 141 | "Missing required extension EGL_KHR_swap_buffers_with_damage"); |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 142 | |
| 143 | EglExtensions.glColorSpace = extensions.has("EGL_KHR_gl_colorspace"); |
| 144 | EglExtensions.noConfigContext = extensions.has("EGL_KHR_no_config_context"); |
| 145 | EglExtensions.pixelFormatFloat = extensions.has("EGL_EXT_pixel_format_float"); |
Romain Guy | 26b6a64 | 2017-07-11 09:48:28 -0700 | [diff] [blame] | 146 | #ifdef ANDROID_ENABLE_LINEAR_BLENDING |
| 147 | EglExtensions.scRGB = extensions.has("EGL_EXT_gl_colorspace_scrgb_linear"); |
| 148 | #else |
| 149 | EglExtensions.scRGB = extensions.has("EGL_EXT_gl_colorspace_scrgb"); |
| 150 | #endif |
Jorim Jaggi | 767e25e | 2018-04-04 23:07:35 +0200 | [diff] [blame] | 151 | EglExtensions.contextPriority = extensions.has("EGL_IMG_context_priority"); |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 152 | EglExtensions.surfacelessContext = extensions.has("EGL_KHR_surfaceless_context"); |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 153 | } |
| 154 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 155 | bool EglManager::hasEglContext() { |
| 156 | return mEglDisplay != EGL_NO_DISPLAY; |
| 157 | } |
| 158 | |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 159 | void EglManager::loadConfigs() { |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 160 | ALOGD("Swap behavior %d", static_cast<int>(mSwapBehavior)); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 161 | EGLint swapBehavior = |
| 162 | (mSwapBehavior == SwapBehavior::Preserved) ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0; |
| 163 | EGLint attribs[] = {EGL_RENDERABLE_TYPE, |
| 164 | EGL_OPENGL_ES2_BIT, |
| 165 | EGL_RED_SIZE, |
| 166 | 8, |
| 167 | EGL_GREEN_SIZE, |
| 168 | 8, |
| 169 | EGL_BLUE_SIZE, |
| 170 | 8, |
| 171 | EGL_ALPHA_SIZE, |
| 172 | 8, |
| 173 | EGL_DEPTH_SIZE, |
| 174 | 0, |
| 175 | EGL_CONFIG_CAVEAT, |
| 176 | EGL_NONE, |
| 177 | EGL_STENCIL_SIZE, |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 178 | STENCIL_BUFFER_SIZE, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 179 | EGL_SURFACE_TYPE, |
| 180 | EGL_WINDOW_BIT | swapBehavior, |
| 181 | EGL_NONE}; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 182 | |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 183 | EGLint numConfigs = 1; |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 184 | if (!eglChooseConfig(mEglDisplay, attribs, &mEglConfig, numConfigs, &numConfigs) || |
| 185 | numConfigs != 1) { |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 186 | if (mSwapBehavior == SwapBehavior::Preserved) { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 187 | // Try again without dirty regions enabled |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 188 | ALOGW("Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without..."); |
| 189 | mSwapBehavior = SwapBehavior::Discard; |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 190 | loadConfigs(); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 191 | return; // the call to loadConfigs() we just made picks the wide gamut config |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 192 | } else { |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 193 | // Failed to get a valid config |
sergeyv | 694d499 | 2016-10-27 10:23:13 -0700 | [diff] [blame] | 194 | LOG_ALWAYS_FATAL("Failed to choose config, error = %s", eglErrorString()); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 195 | } |
| 196 | } |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 197 | |
| 198 | if (EglExtensions.pixelFormatFloat) { |
| 199 | // If we reached this point, we have a valid swap behavior |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 200 | EGLint attribs16F[] = {EGL_RENDERABLE_TYPE, |
| 201 | EGL_OPENGL_ES2_BIT, |
| 202 | EGL_COLOR_COMPONENT_TYPE_EXT, |
| 203 | EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT, |
| 204 | EGL_RED_SIZE, |
| 205 | 16, |
| 206 | EGL_GREEN_SIZE, |
| 207 | 16, |
| 208 | EGL_BLUE_SIZE, |
| 209 | 16, |
| 210 | EGL_ALPHA_SIZE, |
| 211 | 16, |
| 212 | EGL_DEPTH_SIZE, |
| 213 | 0, |
| 214 | EGL_STENCIL_SIZE, |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 215 | STENCIL_BUFFER_SIZE, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 216 | EGL_SURFACE_TYPE, |
| 217 | EGL_WINDOW_BIT | swapBehavior, |
| 218 | EGL_NONE}; |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 219 | |
| 220 | numConfigs = 1; |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 221 | if (!eglChooseConfig(mEglDisplay, attribs16F, &mEglConfigWideGamut, numConfigs, |
| 222 | &numConfigs) || |
| 223 | numConfigs != 1) { |
Rob Herring | 74883ab | 2017-11-29 09:26:31 -0600 | [diff] [blame] | 224 | ALOGE("Device claims wide gamut support, cannot find matching config, error = %s", |
John Reck | 1a4a981 | 2018-04-18 16:13:31 -0700 | [diff] [blame] | 225 | eglErrorString()); |
Rob Herring | 74883ab | 2017-11-29 09:26:31 -0600 | [diff] [blame] | 226 | EglExtensions.pixelFormatFloat = false; |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 227 | } |
| 228 | } |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | void EglManager::createContext() { |
Jorim Jaggi | 767e25e | 2018-04-04 23:07:35 +0200 | [diff] [blame] | 232 | std::vector<EGLint> contextAttributes; |
| 233 | contextAttributes.reserve(5); |
| 234 | contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION); |
| 235 | contextAttributes.push_back(GLES_VERSION); |
| 236 | if (Properties::contextPriority != 0 && EglExtensions.contextPriority) { |
| 237 | contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG); |
| 238 | contextAttributes.push_back(Properties::contextPriority); |
| 239 | } |
| 240 | contextAttributes.push_back(EGL_NONE); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 241 | mEglContext = eglCreateContext( |
| 242 | mEglDisplay, EglExtensions.noConfigContext ? ((EGLConfig) nullptr) : mEglConfig, |
Jorim Jaggi | 767e25e | 2018-04-04 23:07:35 +0200 | [diff] [blame] | 243 | EGL_NO_CONTEXT, contextAttributes.data()); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 244 | LOG_ALWAYS_FATAL_IF(mEglContext == EGL_NO_CONTEXT, "Failed to create context, error = %s", |
| 245 | eglErrorString()); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 246 | } |
| 247 | |
John Reck | d7db4d7 | 2015-05-20 07:18:55 -0700 | [diff] [blame] | 248 | void EglManager::createPBufferSurface() { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 249 | LOG_ALWAYS_FATAL_IF(mEglDisplay == EGL_NO_DISPLAY, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 250 | "usePBufferSurface() called on uninitialized GlobalContext!"); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 251 | |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 252 | if (mPBufferSurface == EGL_NO_SURFACE && !EglExtensions.surfacelessContext) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 253 | EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 254 | mPBufferSurface = eglCreatePbufferSurface(mEglDisplay, mEglConfig, attribs); |
| 255 | } |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 258 | EGLSurface EglManager::createSurface(EGLNativeWindowType window, bool wideColorGamut) { |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 259 | LOG_ALWAYS_FATAL_IF(!hasEglContext(), "Not initialized"); |
Romain Guy | 253f2c2 | 2016-09-28 17:34:42 -0700 | [diff] [blame] | 260 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 261 | wideColorGamut = wideColorGamut && EglExtensions.glColorSpace && EglExtensions.scRGB && |
| 262 | EglExtensions.pixelFormatFloat && EglExtensions.noConfigContext; |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 263 | |
| 264 | // The color space we want to use depends on whether linear blending is turned |
| 265 | // on and whether the app has requested wide color gamut rendering. When wide |
| 266 | // color gamut rendering is off, the app simply renders in the display's native |
| 267 | // color gamut. |
| 268 | // |
| 269 | // When wide gamut rendering is off: |
| 270 | // - Blending is done by default in gamma space, which requires using a |
| 271 | // linear EGL color space (the GPU uses the color values as is) |
| 272 | // - If linear blending is on, we must use the sRGB EGL color space (the |
| 273 | // GPU will perform sRGB to linear and linear to SRGB conversions before |
| 274 | // and after blending) |
| 275 | // |
| 276 | // When wide gamut rendering is on we cannot rely on the GPU performing |
| 277 | // linear blending for us. We use two different color spaces to tag the |
| 278 | // surface appropriately for SurfaceFlinger: |
| 279 | // - Gamma blending (default) requires the use of the scRGB-nl color space |
| 280 | // - Linear blending requires the use of the scRGB color space |
| 281 | |
| 282 | // Not all Android targets support the EGL_GL_COLOR_SPACE_KHR extension |
| 283 | // We insert to placeholders to set EGL_GL_COLORSPACE_KHR and its value. |
| 284 | // According to section 3.4.1 of the EGL specification, the attributes |
| 285 | // list is considered empty if the first entry is EGL_NONE |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 286 | EGLint attribs[] = {EGL_NONE, EGL_NONE, EGL_NONE}; |
Romain Guy | 253f2c2 | 2016-09-28 17:34:42 -0700 | [diff] [blame] | 287 | |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 288 | if (EglExtensions.glColorSpace) { |
| 289 | attribs[0] = EGL_GL_COLORSPACE_KHR; |
| 290 | #ifdef ANDROID_ENABLE_LINEAR_BLENDING |
| 291 | if (wideColorGamut) { |
| 292 | attribs[1] = EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT; |
| 293 | } else { |
| 294 | attribs[1] = EGL_GL_COLORSPACE_SRGB_KHR; |
| 295 | } |
| 296 | #else |
| 297 | if (wideColorGamut) { |
Romain Guy | 26b6a64 | 2017-07-11 09:48:28 -0700 | [diff] [blame] | 298 | attribs[1] = EGL_GL_COLORSPACE_SCRGB_EXT; |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 299 | } else { |
| 300 | attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR; |
| 301 | } |
| 302 | #endif |
| 303 | } |
| 304 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 305 | EGLSurface surface = eglCreateWindowSurface( |
| 306 | mEglDisplay, wideColorGamut ? mEglConfigWideGamut : mEglConfig, window, attribs); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 307 | LOG_ALWAYS_FATAL_IF(surface == EGL_NO_SURFACE, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 308 | "Failed to create EGLSurface for window %p, eglErr = %s", (void*)window, |
| 309 | eglErrorString()); |
Christian Poetzsch | 9a878a6 | 2016-02-05 14:22:01 +0000 | [diff] [blame] | 310 | |
| 311 | if (mSwapBehavior != SwapBehavior::Preserved) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 312 | LOG_ALWAYS_FATAL_IF(eglSurfaceAttrib(mEglDisplay, surface, EGL_SWAP_BEHAVIOR, |
| 313 | EGL_BUFFER_DESTROYED) == EGL_FALSE, |
Christian Poetzsch | 9a878a6 | 2016-02-05 14:22:01 +0000 | [diff] [blame] | 314 | "Failed to set swap behavior to destroyed for window %p, eglErr = %s", |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 315 | (void*)window, eglErrorString()); |
Christian Poetzsch | 9a878a6 | 2016-02-05 14:22:01 +0000 | [diff] [blame] | 316 | } |
| 317 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 318 | return surface; |
| 319 | } |
| 320 | |
| 321 | void EglManager::destroySurface(EGLSurface surface) { |
| 322 | if (isCurrent(surface)) { |
| 323 | makeCurrent(EGL_NO_SURFACE); |
| 324 | } |
| 325 | if (!eglDestroySurface(mEglDisplay, surface)) { |
sergeyv | 694d499 | 2016-10-27 10:23:13 -0700 | [diff] [blame] | 326 | ALOGW("Failed to destroy surface %p, error=%s", (void*)surface, eglErrorString()); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 327 | } |
| 328 | } |
| 329 | |
| 330 | void EglManager::destroy() { |
| 331 | if (mEglDisplay == EGL_NO_DISPLAY) return; |
| 332 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 333 | eglDestroyContext(mEglDisplay, mEglContext); |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 334 | if (mPBufferSurface != EGL_NO_SURFACE) { |
| 335 | eglDestroySurface(mEglDisplay, mPBufferSurface); |
| 336 | } |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 337 | eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
| 338 | eglTerminate(mEglDisplay); |
| 339 | eglReleaseThread(); |
| 340 | |
| 341 | mEglDisplay = EGL_NO_DISPLAY; |
| 342 | mEglContext = EGL_NO_CONTEXT; |
| 343 | mPBufferSurface = EGL_NO_SURFACE; |
| 344 | mCurrentSurface = EGL_NO_SURFACE; |
| 345 | } |
| 346 | |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 347 | bool EglManager::makeCurrent(EGLSurface surface, EGLint* errOut, bool force) { |
| 348 | if (!force && isCurrent(surface)) return false; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 349 | |
| 350 | if (surface == EGL_NO_SURFACE) { |
John Reck | d7db4d7 | 2015-05-20 07:18:55 -0700 | [diff] [blame] | 351 | // Ensure we always have a valid surface & context |
| 352 | surface = mPBufferSurface; |
| 353 | } |
| 354 | if (!eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) { |
John Reck | f2dcc2a | 2015-07-16 09:17:59 -0700 | [diff] [blame] | 355 | if (errOut) { |
| 356 | *errOut = eglGetError(); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 357 | ALOGW("Failed to make current on surface %p, error=%s", (void*)surface, |
| 358 | egl_error_str(*errOut)); |
John Reck | f2dcc2a | 2015-07-16 09:17:59 -0700 | [diff] [blame] | 359 | } else { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 360 | LOG_ALWAYS_FATAL("Failed to make current on surface %p, error=%s", (void*)surface, |
| 361 | eglErrorString()); |
John Reck | f2dcc2a | 2015-07-16 09:17:59 -0700 | [diff] [blame] | 362 | } |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 363 | } |
| 364 | mCurrentSurface = surface; |
John Reck | a896306 | 2017-06-14 10:47:50 -0700 | [diff] [blame] | 365 | if (Properties::disableVsync) { |
| 366 | eglSwapInterval(mEglDisplay, 0); |
| 367 | } |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 368 | return true; |
| 369 | } |
| 370 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 371 | EGLint EglManager::queryBufferAge(EGLSurface surface) { |
| 372 | switch (mSwapBehavior) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 373 | case SwapBehavior::Discard: |
| 374 | return 0; |
| 375 | case SwapBehavior::Preserved: |
| 376 | return 1; |
| 377 | case SwapBehavior::BufferAge: |
| 378 | EGLint bufferAge; |
| 379 | eglQuerySurface(mEglDisplay, surface, EGL_BUFFER_AGE_EXT, &bufferAge); |
| 380 | return bufferAge; |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 381 | } |
| 382 | return 0; |
| 383 | } |
| 384 | |
| 385 | Frame EglManager::beginFrame(EGLSurface surface) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 386 | LOG_ALWAYS_FATAL_IF(surface == EGL_NO_SURFACE, "Tried to beginFrame on EGL_NO_SURFACE!"); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 387 | makeCurrent(surface); |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 388 | Frame frame; |
| 389 | frame.mSurface = surface; |
| 390 | eglQuerySurface(mEglDisplay, surface, EGL_WIDTH, &frame.mWidth); |
| 391 | eglQuerySurface(mEglDisplay, surface, EGL_HEIGHT, &frame.mHeight); |
| 392 | frame.mBufferAge = queryBufferAge(surface); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 393 | eglBeginFrame(mEglDisplay, surface); |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 394 | return frame; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 395 | } |
| 396 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 397 | void EglManager::damageFrame(const Frame& frame, const SkRect& dirty) { |
| 398 | #ifdef EGL_KHR_partial_update |
| 399 | if (EglExtensions.setDamage && mSwapBehavior == SwapBehavior::BufferAge) { |
| 400 | EGLint rects[4]; |
| 401 | frame.map(dirty, rects); |
| 402 | if (!eglSetDamageRegionKHR(mEglDisplay, frame.mSurface, rects, 1)) { |
| 403 | LOG_ALWAYS_FATAL("Failed to set damage region on surface %p, error=%s", |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 404 | (void*)frame.mSurface, eglErrorString()); |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 405 | } |
| 406 | } |
| 407 | #endif |
| 408 | } |
| 409 | |
John Reck | c96955d | 2016-02-26 14:56:44 -0800 | [diff] [blame] | 410 | bool EglManager::damageRequiresSwap() { |
| 411 | return EglExtensions.setDamage && mSwapBehavior == SwapBehavior::BufferAge; |
| 412 | } |
| 413 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 414 | bool EglManager::swapBuffers(const Frame& frame, const SkRect& screenDirty) { |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 415 | if (CC_UNLIKELY(Properties::waitForGpuCompletion)) { |
John Reck | 5515637 | 2015-01-21 07:46:37 -0800 | [diff] [blame] | 416 | ATRACE_NAME("Finishing GPU work"); |
| 417 | fence(); |
| 418 | } |
John Reck | 5515637 | 2015-01-21 07:46:37 -0800 | [diff] [blame] | 419 | |
John Reck | a672f6b | 2015-10-22 09:53:26 -0700 | [diff] [blame] | 420 | EGLint rects[4]; |
| 421 | frame.map(screenDirty, rects); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 422 | eglSwapBuffersWithDamageKHR(mEglDisplay, frame.mSurface, rects, screenDirty.isEmpty() ? 0 : 1); |
John Reck | d04794a | 2015-05-08 10:04:36 -0700 | [diff] [blame] | 423 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 424 | EGLint err = eglGetError(); |
John Reck | 2cdbc7d | 2014-09-17 16:06:36 -0700 | [diff] [blame] | 425 | if (CC_LIKELY(err == EGL_SUCCESS)) { |
| 426 | return true; |
| 427 | } |
John Reck | c2547fa | 2015-10-26 13:52:52 -0700 | [diff] [blame] | 428 | if (err == EGL_BAD_SURFACE || err == EGL_BAD_NATIVE_WINDOW) { |
John Reck | 2cdbc7d | 2014-09-17 16:06:36 -0700 | [diff] [blame] | 429 | // For some reason our surface was destroyed out from under us |
| 430 | // This really shouldn't happen, but if it does we can recover easily |
| 431 | // by just not trying to use the surface anymore |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 432 | ALOGW("swapBuffers encountered EGL error %d on %p, halting rendering...", err, |
| 433 | frame.mSurface); |
John Reck | 2cdbc7d | 2014-09-17 16:06:36 -0700 | [diff] [blame] | 434 | return false; |
| 435 | } |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 436 | LOG_ALWAYS_FATAL("Encountered EGL error %d %s during rendering", err, egl_error_str(err)); |
John Reck | 2cdbc7d | 2014-09-17 16:06:36 -0700 | [diff] [blame] | 437 | // Impossible to hit this, but the compiler doesn't know that |
| 438 | return false; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 439 | } |
| 440 | |
John Reck | 5515637 | 2015-01-21 07:46:37 -0800 | [diff] [blame] | 441 | void EglManager::fence() { |
| 442 | EGLSyncKHR fence = eglCreateSyncKHR(mEglDisplay, EGL_SYNC_FENCE_KHR, NULL); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 443 | eglClientWaitSyncKHR(mEglDisplay, fence, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR); |
John Reck | 5515637 | 2015-01-21 07:46:37 -0800 | [diff] [blame] | 444 | eglDestroySyncKHR(mEglDisplay, fence); |
| 445 | } |
| 446 | |
John Reck | 1125d1f | 2014-10-23 11:02:19 -0700 | [diff] [blame] | 447 | bool EglManager::setPreserveBuffer(EGLSurface surface, bool preserve) { |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 448 | if (mSwapBehavior != SwapBehavior::Preserved) return false; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 449 | |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 450 | bool preserved = eglSurfaceAttrib(mEglDisplay, surface, EGL_SWAP_BEHAVIOR, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 451 | preserve ? EGL_BUFFER_PRESERVED : EGL_BUFFER_DESTROYED); |
John Reck | 149173d | 2015-08-10 09:52:29 -0700 | [diff] [blame] | 452 | if (!preserved) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 453 | ALOGW("Failed to set EGL_SWAP_BEHAVIOR on surface %p, error=%s", (void*)surface, |
| 454 | eglErrorString()); |
John Reck | 1125d1f | 2014-10-23 11:02:19 -0700 | [diff] [blame] | 455 | // Maybe it's already set? |
| 456 | EGLint swapBehavior; |
| 457 | if (eglQuerySurface(mEglDisplay, surface, EGL_SWAP_BEHAVIOR, &swapBehavior)) { |
| 458 | preserved = (swapBehavior == EGL_BUFFER_PRESERVED); |
| 459 | } else { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 460 | ALOGW("Failed to query EGL_SWAP_BEHAVIOR on surface %p, error=%p", (void*)surface, |
| 461 | eglErrorString()); |
John Reck | 1125d1f | 2014-10-23 11:02:19 -0700 | [diff] [blame] | 462 | } |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 463 | } |
John Reck | 1125d1f | 2014-10-23 11:02:19 -0700 | [diff] [blame] | 464 | |
| 465 | return preserved; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 466 | } |
| 467 | |
Stan Iliev | 564ca3e | 2018-09-04 22:00:00 +0000 | [diff] [blame^] | 468 | status_t EglManager::fenceWait(sp<Fence>& fence) { |
| 469 | if (!hasEglContext()) { |
| 470 | ALOGE("EglManager::fenceWait: EGLDisplay not initialized"); |
| 471 | return INVALID_OPERATION; |
| 472 | } |
| 473 | |
| 474 | if (SyncFeatures::getInstance().useWaitSync() && |
| 475 | SyncFeatures::getInstance().useNativeFenceSync()) { |
| 476 | // Block GPU on the fence. |
| 477 | // Create an EGLSyncKHR from the current fence. |
| 478 | int fenceFd = fence->dup(); |
| 479 | if (fenceFd == -1) { |
| 480 | ALOGE("EglManager::fenceWait: error dup'ing fence fd: %d", errno); |
| 481 | return -errno; |
| 482 | } |
| 483 | EGLint attribs[] = { |
| 484 | EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fenceFd, |
| 485 | EGL_NONE |
| 486 | }; |
| 487 | EGLSyncKHR sync = eglCreateSyncKHR(mEglDisplay, |
| 488 | EGL_SYNC_NATIVE_FENCE_ANDROID, attribs); |
| 489 | if (sync == EGL_NO_SYNC_KHR) { |
| 490 | close(fenceFd); |
| 491 | ALOGE("EglManager::fenceWait: error creating EGL fence: %#x", eglGetError()); |
| 492 | return UNKNOWN_ERROR; |
| 493 | } |
| 494 | |
| 495 | // XXX: The spec draft is inconsistent as to whether this should |
| 496 | // return an EGLint or void. Ignore the return value for now, as |
| 497 | // it's not strictly needed. |
| 498 | eglWaitSyncKHR(mEglDisplay, sync, 0); |
| 499 | EGLint eglErr = eglGetError(); |
| 500 | eglDestroySyncKHR(mEglDisplay, sync); |
| 501 | if (eglErr != EGL_SUCCESS) { |
| 502 | ALOGE("EglManager::fenceWait: error waiting for EGL fence: %#x", eglErr); |
| 503 | return UNKNOWN_ERROR; |
| 504 | } |
| 505 | } else { |
| 506 | // Block CPU on the fence. |
| 507 | status_t err = fence->waitForever("EglManager::fenceWait"); |
| 508 | if (err != NO_ERROR) { |
| 509 | ALOGE("EglManager::fenceWait: error waiting for fence: %d", err); |
| 510 | return err; |
| 511 | } |
| 512 | } |
| 513 | return OK; |
| 514 | } |
| 515 | |
| 516 | status_t EglManager::createReleaseFence(bool useFenceSync, EGLSyncKHR* eglFence, |
| 517 | sp<Fence>& nativeFence) { |
| 518 | if (!hasEglContext()) { |
| 519 | ALOGE("EglManager::createReleaseFence: EGLDisplay not initialized"); |
| 520 | return INVALID_OPERATION; |
| 521 | } |
| 522 | |
| 523 | if (SyncFeatures::getInstance().useNativeFenceSync()) { |
| 524 | EGLSyncKHR sync = eglCreateSyncKHR(mEglDisplay, |
| 525 | EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr); |
| 526 | if (sync == EGL_NO_SYNC_KHR) { |
| 527 | ALOGE("EglManager::createReleaseFence: error creating EGL fence: %#x", |
| 528 | eglGetError()); |
| 529 | return UNKNOWN_ERROR; |
| 530 | } |
| 531 | glFlush(); |
| 532 | int fenceFd = eglDupNativeFenceFDANDROID(mEglDisplay, sync); |
| 533 | eglDestroySyncKHR(mEglDisplay, sync); |
| 534 | if (fenceFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) { |
| 535 | ALOGE("EglManager::createReleaseFence: error dup'ing native fence " |
| 536 | "fd: %#x", eglGetError()); |
| 537 | return UNKNOWN_ERROR; |
| 538 | } |
| 539 | nativeFence = new Fence(fenceFd); |
| 540 | *eglFence = EGL_NO_SYNC_KHR; |
| 541 | } else if (useFenceSync && SyncFeatures::getInstance().useFenceSync()) { |
| 542 | if (*eglFence != EGL_NO_SYNC_KHR) { |
| 543 | // There is already a fence for the current slot. We need to |
| 544 | // wait on that before replacing it with another fence to |
| 545 | // ensure that all outstanding buffer accesses have completed |
| 546 | // before the producer accesses it. |
| 547 | EGLint result = eglClientWaitSyncKHR(mEglDisplay, *eglFence, 0, 1000000000); |
| 548 | if (result == EGL_FALSE) { |
| 549 | ALOGE("EglManager::createReleaseFence: error waiting for previous fence: %#x", |
| 550 | eglGetError()); |
| 551 | return UNKNOWN_ERROR; |
| 552 | } else if (result == EGL_TIMEOUT_EXPIRED_KHR) { |
| 553 | ALOGE("EglManager::createReleaseFence: timeout waiting for previous fence"); |
| 554 | return TIMED_OUT; |
| 555 | } |
| 556 | eglDestroySyncKHR(mEglDisplay, *eglFence); |
| 557 | } |
| 558 | |
| 559 | // Create a fence for the outstanding accesses in the current |
| 560 | // OpenGL ES context. |
| 561 | *eglFence = eglCreateSyncKHR(mEglDisplay, EGL_SYNC_FENCE_KHR, nullptr); |
| 562 | if (*eglFence == EGL_NO_SYNC_KHR) { |
| 563 | ALOGE("EglManager::createReleaseFence: error creating fence: %#x", eglGetError()); |
| 564 | return UNKNOWN_ERROR; |
| 565 | } |
| 566 | glFlush(); |
| 567 | } |
| 568 | return OK; |
| 569 | } |
| 570 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 571 | } /* namespace renderthread */ |
| 572 | } /* namespace uirenderer */ |
| 573 | } /* namespace android */ |