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