1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 // 2021.4.30 platform view adapt ohos. 5 // Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved. 6 7 #ifndef FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_GL_H_ 8 #define FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_GL_H_ 9 10 #include <memory> 11 12 #include "flutter/fml/macros.h" 13 #include "flutter/shell/gpu/gpu_surface_gl.h" 14 #include "flutter/shell/platform/ohos/ohos_surface.h" 15 16 #include "egl_surface.h" 17 18 namespace flutter { 19 class OhosSurfaceGL final : public GPUSurfaceGLDelegate, public OhosSurface { 20 public: 21 OhosSurfaceGL(); 22 23 ~OhosSurfaceGL() override = default; 24 25 // |OhosSurface| 26 bool IsValid() const override; 27 28 // |OhosSurface| 29 std::unique_ptr<Surface> CreateGPUSurface() override; 30 31 // |OhosSurface| 32 void SetPlatformWindow(const ::OHOS::sptr<OHOS::Rosen::Window>& window) override; 33 34 // |OhosSurface| 35 bool OnScreenSurfaceResize(const SkISize& size) override; 36 37 // |OhosSurface| 38 void TeardownOnScreenContext() override; 39 40 // |OhosSurface| 41 bool ResourceContextMakeCurrent() override; 42 43 // |OhosSurface| 44 bool ResourceContextClearCurrent() override; 45 46 // |GPUSurfaceGLDelegate| 47 bool GLContextPresent() override; 48 49 // |GPUSurfaceGLDelegate| 50 intptr_t GLContextFBO() const override; 51 52 // |GPUSurfaceGLDelegate| 53 bool GLContextFBOResetAfterPresent() const override; 54 55 // |GPUSurfaceGLDelegate| 56 bool UseOffscreenSurface() const override; 57 58 // |GPUSurfaceGLDelegate| 59 SkMatrix GLContextSurfaceTransformation() const override; 60 61 // |GPUSurfaceGLDelegate| 62 bool GLContextMakeCurrent() override; 63 64 // |GPUSurfaceGLDelegate| 65 bool GLContextClearCurrent() override; 66 67 // |GPUSurfaceGLDelegate| 68 ExternalViewEmbedder* GetExternalViewEmbedder() override; 69 70 private: 71 OHOS::sptr<OHOS::Rosen::Window> window_; 72 OHOS::sptr<OHOS::EglRenderSurface> eglRenderSurface_; 73 EGLDisplay eglDisplay_; 74 EGLContext eglContext_; 75 EGLSurface eglSurface_; 76 bool valid_ = false; 77 78 bool InitRenderSurface(); 79 80 FML_DISALLOW_COPY_AND_ASSIGN(OhosSurfaceGL); 81 }; 82 } // namespace flutter 83 #endif // FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_GL_H_ 84