1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GLES_GFX_IMAGE_H 17 #define GLES_GFX_IMAGE_H 18 19 #include <cstdint> 20 #include <memory> 21 #include "GLES/gl.h" 22 #include "GLES2/gl2.h" 23 #include "GLES2/gl2ext.h" 24 #include "EGL/egl.h" 25 #include "EGL/eglext.h" 26 #include "display_type.h" 27 namespace OHOS { 28 namespace HDI { 29 namespace DISPLAY { 30 class GlesGfxImage { 31 public: 32 explicit GlesGfxImage(EGLDisplay dpy); 33 static std::unique_ptr<GlesGfxImage> Creat(EGLDisplay dps, const BufferHandle &bufferHandle); 34 static EGLImage CreateEglImage(EGLDisplay display, const BufferHandle &bufferHandle); 35 static EGLBoolean DestroyEglImage(EGLDisplay display, EGLImageKHR image); 36 bool Init(EGLDisplay dps, const BufferHandle &bufferHandle); 37 ~GlesGfxImage(); 38 static constexpr const uint32_t INDEX_RGB_TEXTURE = 0; 39 static constexpr const uint32_t INDEX_Y_TEXTURE = 0; 40 static constexpr const uint32_t INDEX_U_TEXTURE = 1; 41 static constexpr const uint32_t INDEX_V_TEXTURE = 2; 42 private: 43 bool CreateImageRgb(const BufferHandle &bufferHandle); 44 bool CreateImageYuv(const BufferHandle &bufferHandle); // now sue texImag2d 45 void CreateTextures(uint32_t num); 46 47 static constexpr const uint32_t TEXTURE_COUNT = 3; 48 49 EGLImageKHR eglImageKHr_ = EGL_NO_IMAGE_KHR; 50 GLuint textureId_[TEXTURE_COUNT] = {0}; 51 EGLDisplay eglDisplay_; 52 }; 53 } 54 } 55 } 56 #endif // GLES_GFX_IMAGE_H