Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 1 | /* |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 2 | ** Copyright 2007, The Android Open Source Project |
| 3 | ** |
Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 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 |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 7 | ** |
Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 9 | ** |
Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 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 |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 14 | ** limitations under the License. |
| 15 | */ |
| 16 | |
Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 17 | #include "egl_object.h" |
| 18 | |
Michael Lentine | e2fc6f8 | 2015-07-28 16:30:10 -0700 | [diff] [blame] | 19 | #include <sstream> |
| 20 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 21 | namespace android { |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 22 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 23 | egl_object_t::egl_object_t(egl_display_t* disp) : display(disp), count(1) { |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 24 | // NOTE: this does an implicit incRef |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 25 | display->addObject(this); |
| 26 | } |
| 27 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 28 | egl_object_t::~egl_object_t() {} |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 29 | |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 30 | void egl_object_t::terminate() { |
| 31 | // this marks the object as "terminated" |
| 32 | display->removeObject(this); |
| 33 | if (decRef() == 1) { |
| 34 | // shouldn't happen because this is called from LocalRef |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 35 | ALOGE("egl_object_t::terminate() removed the last reference!"); |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | |
| 39 | void egl_object_t::destroy() { |
| 40 | if (decRef() == 1) { |
| 41 | delete this; |
| 42 | } |
| 43 | } |
| 44 | |
Mathias Agopian | f0480de | 2011-11-13 20:50:07 -0800 | [diff] [blame] | 45 | bool egl_object_t::get(egl_display_t const* display, egl_object_t* object) { |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 46 | // used by LocalRef, this does an incRef() atomically with |
| 47 | // checking that the object is valid. |
Mathias Agopian | f0480de | 2011-11-13 20:50:07 -0800 | [diff] [blame] | 48 | return display->getObject(object); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Courtney Goeltzenleuchter | 3783657 | 2017-04-26 15:07:51 -0600 | [diff] [blame] | 51 | egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config, EGLNativeWindowType win, |
| 52 | EGLSurface surface, EGLint colorSpace, egl_connection_t const* cnx) |
| 53 | : egl_object_t(dpy), |
| 54 | surface(surface), |
| 55 | config(config), |
| 56 | win(win), |
| 57 | cnx(cnx), |
| 58 | connected(true), |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 59 | colorSpace(colorSpace), |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 60 | egl_smpte2086_dirty(false), |
| 61 | egl_cta861_3_dirty(false) { |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 62 | egl_smpte2086_metadata.displayPrimaryRed = {EGL_DONT_CARE, EGL_DONT_CARE}; |
| 63 | egl_smpte2086_metadata.displayPrimaryGreen = {EGL_DONT_CARE, EGL_DONT_CARE}; |
| 64 | egl_smpte2086_metadata.displayPrimaryBlue = {EGL_DONT_CARE, EGL_DONT_CARE}; |
| 65 | egl_smpte2086_metadata.whitePoint = {EGL_DONT_CARE, EGL_DONT_CARE}; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 66 | egl_smpte2086_metadata.maxLuminance = EGL_DONT_CARE; |
| 67 | egl_smpte2086_metadata.minLuminance = EGL_DONT_CARE; |
| 68 | egl_cta861_3_metadata.maxFrameAverageLightLevel = EGL_DONT_CARE; |
| 69 | egl_cta861_3_metadata.maxContentLightLevel = EGL_DONT_CARE; |
| 70 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 71 | if (win) { |
| 72 | win->incStrong(this); |
| 73 | } |
| 74 | } |
Jesse Hall | 2583859 | 2012-04-05 15:53:28 -0700 | [diff] [blame] | 75 | |
| 76 | egl_surface_t::~egl_surface_t() { |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 77 | if (win != nullptr) { |
Pablo Ceballos | ae8cf0b | 2016-05-02 11:24:13 -0700 | [diff] [blame] | 78 | disconnect(); |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 79 | win->decStrong(this); |
Pablo Ceballos | ae8cf0b | 2016-05-02 11:24:13 -0700 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
| 83 | void egl_surface_t::disconnect() { |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 84 | if (win != nullptr && connected) { |
Jason Macnak | 26c6f83 | 2021-04-02 12:29:08 -0700 | [diff] [blame] | 85 | // NOTE: When using Vulkan backend, the Vulkan runtime makes all the |
| 86 | // native_window_* calls, so don't do them here. |
Peiyong Lin | 5492618 | 2023-06-15 22:35:14 +0000 | [diff] [blame] | 87 | if (!cnx->angleLoaded) { |
Jason Macnak | 26c6f83 | 2021-04-02 12:29:08 -0700 | [diff] [blame] | 88 | native_window_set_buffers_format(win, 0); |
| 89 | if (native_window_api_disconnect(win, NATIVE_WINDOW_API_EGL)) { |
| 90 | ALOGW("EGLNativeWindowType %p disconnect failed", win); |
| 91 | } |
Jesse Hall | 2583859 | 2012-04-05 15:53:28 -0700 | [diff] [blame] | 92 | } |
Pablo Ceballos | ae8cf0b | 2016-05-02 11:24:13 -0700 | [diff] [blame] | 93 | connected = false; |
Jesse Hall | 2583859 | 2012-04-05 15:53:28 -0700 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 97 | EGLBoolean egl_surface_t::setSmpte2086Attribute(EGLint attribute, EGLint value) { |
| 98 | switch (attribute) { |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 99 | case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 100 | egl_smpte2086_metadata.displayPrimaryRed.x = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 101 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 102 | return EGL_TRUE; |
| 103 | case EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 104 | egl_smpte2086_metadata.displayPrimaryRed.y = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 105 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 106 | return EGL_TRUE; |
| 107 | case EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 108 | egl_smpte2086_metadata.displayPrimaryGreen.x = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 109 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 110 | return EGL_TRUE; |
| 111 | case EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 112 | egl_smpte2086_metadata.displayPrimaryGreen.y = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 113 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 114 | return EGL_TRUE; |
| 115 | case EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 116 | egl_smpte2086_metadata.displayPrimaryBlue.x = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 117 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 118 | return EGL_TRUE; |
| 119 | case EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 120 | egl_smpte2086_metadata.displayPrimaryBlue.y = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 121 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 122 | return EGL_TRUE; |
| 123 | case EGL_SMPTE2086_WHITE_POINT_X_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 124 | egl_smpte2086_metadata.whitePoint.x = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 125 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 126 | return EGL_TRUE; |
| 127 | case EGL_SMPTE2086_WHITE_POINT_Y_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 128 | egl_smpte2086_metadata.whitePoint.y = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 129 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 130 | return EGL_TRUE; |
| 131 | case EGL_SMPTE2086_MAX_LUMINANCE_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 132 | egl_smpte2086_metadata.maxLuminance = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 133 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 134 | return EGL_TRUE; |
| 135 | case EGL_SMPTE2086_MIN_LUMINANCE_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 136 | egl_smpte2086_metadata.minLuminance = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 137 | egl_smpte2086_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 138 | return EGL_TRUE; |
| 139 | } |
| 140 | return EGL_FALSE; |
| 141 | } |
| 142 | |
| 143 | EGLBoolean egl_surface_t::setCta8613Attribute(EGLint attribute, EGLint value) { |
| 144 | switch (attribute) { |
| 145 | case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 146 | egl_cta861_3_metadata.maxContentLightLevel = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 147 | egl_cta861_3_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 148 | return EGL_TRUE; |
| 149 | case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 150 | egl_cta861_3_metadata.maxFrameAverageLightLevel = value; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 151 | egl_cta861_3_dirty = true; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 152 | return EGL_TRUE; |
| 153 | } |
| 154 | return EGL_FALSE; |
| 155 | } |
| 156 | |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 157 | EGLBoolean egl_surface_t::getSmpte2086Metadata(android_smpte2086_metadata& metadata) const { |
| 158 | if (!egl_smpte2086_dirty) return EGL_FALSE; |
| 159 | if (egl_smpte2086_metadata.displayPrimaryRed.x == EGL_DONT_CARE || |
| 160 | egl_smpte2086_metadata.displayPrimaryRed.y == EGL_DONT_CARE || |
| 161 | egl_smpte2086_metadata.displayPrimaryGreen.x == EGL_DONT_CARE || |
| 162 | egl_smpte2086_metadata.displayPrimaryGreen.y == EGL_DONT_CARE || |
| 163 | egl_smpte2086_metadata.displayPrimaryBlue.x == EGL_DONT_CARE || |
| 164 | egl_smpte2086_metadata.displayPrimaryBlue.y == EGL_DONT_CARE || |
| 165 | egl_smpte2086_metadata.whitePoint.x == EGL_DONT_CARE || |
| 166 | egl_smpte2086_metadata.whitePoint.y == EGL_DONT_CARE || |
| 167 | egl_smpte2086_metadata.maxLuminance == EGL_DONT_CARE || |
| 168 | egl_smpte2086_metadata.minLuminance == EGL_DONT_CARE) { |
| 169 | ALOGW("egl_surface_t: incomplete SMPTE 2086 metadata!"); |
| 170 | return EGL_FALSE; |
| 171 | } |
| 172 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 173 | metadata.displayPrimaryRed.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.x) / |
| 174 | EGL_METADATA_SCALING_EXT; |
| 175 | metadata.displayPrimaryRed.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.y) / |
| 176 | EGL_METADATA_SCALING_EXT; |
| 177 | metadata.displayPrimaryGreen.x = |
| 178 | static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.x) / |
| 179 | EGL_METADATA_SCALING_EXT; |
| 180 | metadata.displayPrimaryGreen.y = |
| 181 | static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.y) / |
| 182 | EGL_METADATA_SCALING_EXT; |
| 183 | metadata.displayPrimaryBlue.x = |
| 184 | static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.x) / |
| 185 | EGL_METADATA_SCALING_EXT; |
| 186 | metadata.displayPrimaryBlue.y = |
| 187 | static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.y) / |
| 188 | EGL_METADATA_SCALING_EXT; |
| 189 | metadata.whitePoint.x = |
| 190 | static_cast<float>(egl_smpte2086_metadata.whitePoint.x) / EGL_METADATA_SCALING_EXT; |
| 191 | metadata.whitePoint.y = |
| 192 | static_cast<float>(egl_smpte2086_metadata.whitePoint.y) / EGL_METADATA_SCALING_EXT; |
| 193 | metadata.maxLuminance = |
| 194 | static_cast<float>(egl_smpte2086_metadata.maxLuminance) / EGL_METADATA_SCALING_EXT; |
| 195 | metadata.minLuminance = |
| 196 | static_cast<float>(egl_smpte2086_metadata.minLuminance) / EGL_METADATA_SCALING_EXT; |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 197 | |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 198 | return EGL_TRUE; |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 199 | } |
| 200 | |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 201 | EGLBoolean egl_surface_t::getCta8613Metadata(android_cta861_3_metadata& metadata) const { |
| 202 | if (!egl_cta861_3_dirty) return EGL_FALSE; |
| 203 | |
| 204 | if (egl_cta861_3_metadata.maxContentLightLevel == EGL_DONT_CARE || |
| 205 | egl_cta861_3_metadata.maxFrameAverageLightLevel == EGL_DONT_CARE) { |
| 206 | ALOGW("egl_surface_t: incomplete CTA861.3 metadata!"); |
| 207 | return EGL_FALSE; |
| 208 | } |
| 209 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 210 | metadata.maxContentLightLevel = static_cast<float>(egl_cta861_3_metadata.maxContentLightLevel) / |
| 211 | EGL_METADATA_SCALING_EXT; |
| 212 | metadata.maxFrameAverageLightLevel = |
| 213 | static_cast<float>(egl_cta861_3_metadata.maxFrameAverageLightLevel) / |
| 214 | EGL_METADATA_SCALING_EXT; |
Courtney Goeltzenleuchter | 936799c | 2018-03-02 16:47:08 -0700 | [diff] [blame] | 215 | |
| 216 | return EGL_TRUE; |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 217 | } |
| 218 | |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 219 | EGLBoolean egl_surface_t::getColorSpaceAttribute(EGLint attribute, EGLint* value) const { |
| 220 | if (attribute == EGL_GL_COLORSPACE_KHR) { |
| 221 | *value = colorSpace; |
| 222 | return EGL_TRUE; |
| 223 | } |
| 224 | return EGL_FALSE; |
| 225 | } |
| 226 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 227 | EGLBoolean egl_surface_t::getSmpte2086Attribute(EGLint attribute, EGLint* value) const { |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 228 | switch (attribute) { |
| 229 | case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 230 | *value = egl_smpte2086_metadata.displayPrimaryRed.x; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 231 | return EGL_TRUE; |
| 232 | break; |
| 233 | case EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 234 | *value = egl_smpte2086_metadata.displayPrimaryRed.y; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 235 | return EGL_TRUE; |
| 236 | break; |
| 237 | case EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 238 | *value = egl_smpte2086_metadata.displayPrimaryGreen.x; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 239 | return EGL_TRUE; |
| 240 | break; |
| 241 | case EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 242 | *value = egl_smpte2086_metadata.displayPrimaryGreen.y; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 243 | return EGL_TRUE; |
| 244 | break; |
| 245 | case EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 246 | *value = egl_smpte2086_metadata.displayPrimaryBlue.x; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 247 | return EGL_TRUE; |
| 248 | break; |
| 249 | case EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 250 | *value = egl_smpte2086_metadata.displayPrimaryBlue.y; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 251 | return EGL_TRUE; |
| 252 | break; |
| 253 | case EGL_SMPTE2086_WHITE_POINT_X_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 254 | *value = egl_smpte2086_metadata.whitePoint.x; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 255 | return EGL_TRUE; |
| 256 | break; |
| 257 | case EGL_SMPTE2086_WHITE_POINT_Y_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 258 | *value = egl_smpte2086_metadata.whitePoint.y; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 259 | return EGL_TRUE; |
| 260 | break; |
| 261 | case EGL_SMPTE2086_MAX_LUMINANCE_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 262 | *value = egl_smpte2086_metadata.maxLuminance; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 263 | return EGL_TRUE; |
| 264 | break; |
| 265 | case EGL_SMPTE2086_MIN_LUMINANCE_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 266 | *value = egl_smpte2086_metadata.minLuminance; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 267 | return EGL_TRUE; |
| 268 | break; |
| 269 | } |
| 270 | return EGL_FALSE; |
| 271 | } |
| 272 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 273 | EGLBoolean egl_surface_t::getCta8613Attribute(EGLint attribute, EGLint* value) const { |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 274 | switch (attribute) { |
| 275 | case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 276 | *value = egl_cta861_3_metadata.maxContentLightLevel; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 277 | return EGL_TRUE; |
| 278 | break; |
| 279 | case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT: |
Courtney Goeltzenleuchter | 786ab88 | 2018-01-26 13:37:33 -0800 | [diff] [blame] | 280 | *value = egl_cta861_3_metadata.maxFrameAverageLightLevel; |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 281 | return EGL_TRUE; |
| 282 | break; |
| 283 | } |
| 284 | return EGL_FALSE; |
| 285 | } |
| 286 | |
Pablo Ceballos | ae8cf0b | 2016-05-02 11:24:13 -0700 | [diff] [blame] | 287 | void egl_surface_t::terminate() { |
| 288 | disconnect(); |
| 289 | egl_object_t::terminate(); |
| 290 | } |
| 291 | |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 292 | egl_context_t::egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config, |
Yiwei Zhang | 0657fba | 2020-08-12 19:09:26 -0700 | [diff] [blame] | 293 | egl_connection_t const* cnx, int version) |
| 294 | : egl_object_t(get_display(dpy)), |
| 295 | dpy(dpy), |
| 296 | context(context), |
| 297 | config(config), |
| 298 | read(nullptr), |
| 299 | draw(nullptr), |
| 300 | cnx(cnx), |
| 301 | version(version) {} |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 302 | |
| 303 | void egl_context_t::onLooseCurrent() { |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 304 | read = nullptr; |
| 305 | draw = nullptr; |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | void egl_context_t::onMakeCurrent(EGLSurface draw, EGLSurface read) { |
| 309 | this->read = read; |
| 310 | this->draw = draw; |
| 311 | |
| 312 | /* |
| 313 | * Here we cache the GL_EXTENSIONS string for this context and we |
| 314 | * add the extensions always handled by the wrapper |
| 315 | */ |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 316 | if (!gl_extensions.empty()) return; |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 317 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 318 | // call the implementation's glGetString(GL_EXTENSIONS) |
| 319 | const char* exts = (const char*)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS); |
| 320 | if (!exts) return; |
Alistair Strachan | 89301ea | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 321 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 322 | // If this context is sharing with another context, and the other context was reset |
| 323 | // e.g. due to robustness failure, this context might also be reset and glGetString can |
| 324 | // return NULL. |
| 325 | gl_extensions = exts; |
| 326 | if (gl_extensions.find("GL_EXT_debug_marker") == std::string::npos) { |
| 327 | gl_extensions.insert(0, "GL_EXT_debug_marker "); |
| 328 | // eglGetProcAddress could return function pointers to these |
| 329 | // functions while they actually don't work. Fix them now. |
| 330 | __eglMustCastToProperFunctionPointerType* f; |
| 331 | f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version] |
| 332 | ->gl.glInsertEventMarkerEXT; |
| 333 | if (*f != gl_noop) *f = gl_noop; |
| 334 | f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version] |
| 335 | ->gl.glPushGroupMarkerEXT; |
| 336 | if (*f != gl_noop) *f = gl_noop; |
| 337 | f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version] |
| 338 | ->gl.glPopGroupMarkerEXT; |
| 339 | if (*f != gl_noop) *f = gl_noop; |
| 340 | } |
Jesse Hall | 09fc8f9 | 2017-09-29 15:57:42 -0700 | [diff] [blame] | 341 | |
Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 342 | // tokenize the supported extensions for the glGetStringi() wrapper |
| 343 | std::stringstream ss; |
| 344 | std::string str; |
| 345 | ss << gl_extensions; |
| 346 | while (ss >> str) { |
| 347 | tokenized_gl_extensions.push_back(str); |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 348 | } |
| 349 | } |
| 350 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 351 | }; // namespace android |