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_SOFTWARE_H_ 8 #define FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_SOFTWARE_H_ 9 10 #include "flutter/fml/macros.h" 11 #include "flutter/shell/gpu/gpu_surface_software.h" 12 #include "flutter/shell/platform/ohos/ohos_surface.h" 13 14 namespace flutter { 15 16 class OhosSurfaceSoftware final : public OhosSurface, public GPUSurfaceSoftwareDelegate { 17 public: 18 OhosSurfaceSoftware(); 19 20 ~OhosSurfaceSoftware() override = default; 21 22 bool IsValid() const override; 23 24 std::unique_ptr<Surface> CreateGPUSurface() override; 25 26 bool OnScreenSurfaceResize(const SkISize& size) override; 27 28 void SetPlatformWindow(const OHOS::sptr<OHOS::Rosen::Window> &window) override; 29 30 sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override; 31 32 bool PresentBackingStore(sk_sp<SkSurface> backing_store) override; 33 34 void SurfaceDrawBuffer( 35 OHOS::BufferRequestConfig& requestConfig, OHOS::sptr<OHOS::SurfaceBuffer> surfaceBuffer, SkPixmap& pixmap); 36 37 void SurfaceFlushBuffer(OHOS::sptr<OHOS::SurfaceBuffer>); 38 39 ExternalViewEmbedder* GetExternalViewEmbedder() override; 40 41 // |OhosSurface| 42 virtual bool ResourceContextMakeCurrent() override; 43 44 // |OhosSurface| 45 virtual bool ResourceContextClearCurrent() override; 46 47 // |OhosSurface| 48 virtual void TeardownOnScreenContext() override; 49 50 private: 51 sk_sp<SkSurface> sk_surface_; 52 SkColorType target_color_type_; 53 SkAlphaType target_alpha_type_; 54 55 OHOS::sptr<OHOS::Rosen::Window> window_ = nullptr; 56 OHOS::BufferRequestConfig requestConfig_; 57 OHOS::sptr<OHOS::Surface> surface_ = nullptr; 58 59 FML_DISALLOW_COPY_AND_ASSIGN(OhosSurfaceSoftware); 60 }; 61 } // namespace flutter 62 63 #endif // FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_SOFTWARE_H_ 64