• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 package com.google.jetpackcamera.core.camera.effects
17 
18 import android.opengl.EGL14
19 import android.opengl.EGLConfig
20 import android.opengl.EGLContext
21 import androidx.graphics.opengl.egl.EGLSpec
22 
23 val EGLSpec.Companion.V14ES3: EGLSpec
24     get() = object : EGLSpec by V14 {
25 
26         private val contextAttributes = intArrayOf(
27             // GLES VERSION 3
28             EGL14.EGL_CONTEXT_CLIENT_VERSION,
29             3,
30             // HWUI provides the ability to configure a context priority as well but that only
31             // seems to be configured on SystemUIApplication. This might be useful for
32             // front buffer rendering situations for performance.
33             EGL14.EGL_NONE
34         )
35 
eglCreateContextnull36         override fun eglCreateContext(config: EGLConfig): EGLContext {
37             return EGL14.eglCreateContext(
38                 EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY),
39                 config,
40                 // not creating from a shared context
41                 EGL14.EGL_NO_CONTEXT,
42                 contextAttributes,
43                 0
44             )
45         }
46     }
47