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 #ifndef HDI_GLES_COMPOSITION_H 16 #define HDI_GLES_COMPOSITION_H 17 #include <cstdint> 18 #include <memory> 19 #include <unordered_map> 20 #include "hdi_composer.h" 21 #include "display_type.h" 22 #include "gl_egl_state.h" 23 #include "gles_fbo.h" 24 #include "display_bytrace.h" 25 #include "display_mock_surface.h" 26 #include "gles_gfx_image.h" 27 #include "gles_program.h" 28 29 namespace OHOS { 30 namespace HDI { 31 namespace DISPLAY { 32 class HdiGlesComposition : public HdiComposition { 33 public: 34 int32_t Init(uint32_t width, uint32_t height); 35 int32_t SetLayers(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer); 36 int32_t Apply(bool modeSet); 37 virtual ~HdiGlesComposition(); 38 39 private: 40 int32_t DrawLayer(const BufferHandle &bufferHandle, const IRect &displayRect, GlesProgram &program); 41 int32_t DrawLayer(HdiLayer &layer); 42 int32_t ClearLayer(HdiLayer &layer); 43 bool CanHandle(HdiLayer &hdiLayer); 44 std::vector<float> GetVertexArrays(const IRect &displayRect); 45 std::unordered_map<uint32_t, std::unique_ptr<GlesGfxImage>> imageMaps_; 46 std::unordered_map<uint32_t, std::unique_ptr<GlesFbo>> glesFbo_; 47 int32_t InitProgram(uint32_t width, uint32_t height); 48 std::unique_ptr<GlEglState> eglState_ = nullptr; 49 std::unique_ptr<GlesProgram> programRgba_ = nullptr; 50 std::unique_ptr<GlesProgram> programYuv_ = nullptr; 51 std::unique_ptr<GlesProgram> programClear_ = nullptr; 52 OHOS::sptr<OHOS::DisplayMockSurface> clientSurface_ = nullptr; 53 NativeWindowType nativeWindow_ = 0; 54 55 HdiLayer *mClientLayer = nullptr; 56 }; 57 } // namespace OHOS 58 } // namespace HDI 59 } // namespace DISPLAY 60 61 #endif // HDI_GLES_COMPOSITION_H 62