diff --git a/BUILD.gn b/BUILD.gn index 8d5da39c670ea6703130135c0623bf7bd62721ac..5d8351556bf09c44f18446061e7a3f42f5ee22f0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -59,8 +59,6 @@ template("make_skia_deps") { deps = [ ":ace_fontmgr_$platform", ":ace_gif", - - #":ace_gpu", ":ace_heif", ":ace_jpeg", ":ace_libexpat", @@ -86,6 +84,9 @@ template("make_skia_deps") { if (is_standard_system) { deps += [ ":make_third_party_skia_include_dir" ] + if (ace_enable_gpu) { + deps += [ ":ace_gpu" ] + } } } } @@ -164,7 +165,12 @@ config("flutter_config") { "-fvisibility-inlines-hidden", "-Os", ] - defines = [] + + if (ace_enable_gpu) { + defines = [ "ACE_ENABLE_GPU" ] + } else { + defines = [] + } if (use_mingw_win || use_mac) { defines += ace_common_defines @@ -177,6 +183,9 @@ config("flutter_config") { ] } if (is_standard_system) { + if (ace_enable_gpu) { + cflags += [ "-DEGL_NO_X11" ] + } cflags_cc += [ "-Wno-thread-safety-attributes", "-Wno-thread-safety-analysis", @@ -459,6 +468,9 @@ template("flutter_engine_shell") { "engine/flutter/shell/platform/ohos/platform_task_runner_adapter.cc", "engine/flutter/shell/platform/ohos/platform_view_ohos.cc", ] + if (ace_enable_gpu) { + sources += [ "engine/flutter/shell/platform/ohos/ohos_surface_gl.cc" ] + } external_deps = [ "appexecfwk_standard:libeventhandler", "ipc:ipc_core", @@ -2045,10 +2057,17 @@ ohos_source_set("ace_skia_core") { ] if (is_standard_system) { - defines += [ - "SK_SUPPORT_ATLAS_TEXT=0", - "SK_SUPPORT_GPU=0", - ] + if (ace_enable_gpu) { + defines += [ + "SK_SUPPORT_ATLAS_TEXT=1", + "SK_GL" + ] + } else { + defines += [ + "SK_SUPPORT_ATLAS_TEXT=0", + "SK_SUPPORT_GPU=0", + ] + } } else { defines += [ "SK_SUPPORT_ATLAS_TEXT=1", @@ -2555,6 +2574,10 @@ config("ace_gpu_config") { visibility = [ ":*" ] include_dirs = [ "skia" ] + if (ace_enable_gpu) { + include_dirs += [ "//third_party/weston/include" ] + } + if (use_mingw_win) { include_dirs += [ "skia/third_party/externals/angle2/include" ] } @@ -2637,6 +2660,11 @@ config("ace_gpu_config") { "-fvisibility=hidden", "-Wno-extra-semi", ] + + if (ace_enable_gpu) { + cflags += [ "-DEGL_NO_X11" ] + } + if (use_mingw_win) { cflags_cc += [ "-Wno-unknown-pragmas", @@ -2949,6 +2977,10 @@ ohos_source_set("ace_gpu") { sources -= [ "skia/src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ] sources += [ "skia/src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ] } + + if (ace_enable_gpu) { + deps = [ "//device/rockchip/hardware/gpu:mali-bifrost-g52-g2p0-wayland" ] + } } config("ace_typeface_freetype_config") { diff --git a/engine/flutter/lib/ui/window/window.h b/engine/flutter/lib/ui/window/window.h index 721c075b637f8fa8a18ac94ebf918794d7d97e5e..515bf837b70231d85cc2991d12dff293de339292 100644 --- a/engine/flutter/lib/ui/window/window.h +++ b/engine/flutter/lib/ui/window/window.h @@ -12,6 +12,9 @@ #include "flutter/fml/time/time_point.h" #include "flutter/lib/ui/window/pointer_data_packet.h" #include "flutter/lib/ui/window/viewport_metrics.h" +#ifdef ACE_ENABLE_GPU +#include "third_party/flutter/skia/include/gpu/GrContext.h" +#endif #include "flutter/lib/ui/window/platform_message.h" namespace flutter { diff --git a/engine/flutter/shell/common/rasterizer.cc b/engine/flutter/shell/common/rasterizer.cc index fa8dcfd48381d9e2bb72adfc273a1fc04c2ddc32..493c7cf3a15227c70f6c01f74267c220f1e76313 100644 --- a/engine/flutter/shell/common/rasterizer.cc +++ b/engine/flutter/shell/common/rasterizer.cc @@ -18,6 +18,12 @@ namespace flutter { +#ifdef ACE_ENABLE_GPU +// The rasterizer will tell Skia to purge cached resources that have not been +// used within this interval. +static constexpr std::chrono::milliseconds kSkiaCleanupExpiration(15000); +#endif + // TODO(dnfield): Remove this once internal embedders have caught up. static Rasterizer::DummyDelegate dummy_delegate_; Rasterizer::Rasterizer( @@ -259,6 +265,12 @@ RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) { } FireNextFrameCallbackIfPresent(); +#ifdef ACE_ENABLE_GPU + if (surface_->GetContext()) { + surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration); + } +#endif + return raster_status; } @@ -440,19 +452,29 @@ void Rasterizer::SetResourceCacheMaxBytes(size_t max_bytes, bool from_user) { if (!surface_) { return; } +#ifdef ACE_ENABLE_GPU + GrContext* context = surface_->GetContext(); + if (context) { + int max_resources; + context->getResourceCacheLimits(&max_resources, nullptr); + context->setResourceCacheLimits(max_resources, max_bytes); + } +#endif } std::optional Rasterizer::GetResourceCacheMaxBytes() const { - if (!surface_) { + if (!surface_) { + return std::nullopt; + } +#ifdef ACE_ENABLE_GPU + GrContext* context = surface_->GetContext(); + if (context) { + size_t max_bytes; + context->getResourceCacheLimits(nullptr, &max_bytes); + return max_bytes; + } +#endif return std::nullopt; - } - GrContext* context = surface_->GetContext(); - if (context) { - size_t max_bytes; - context->getResourceCacheLimits(nullptr, &max_bytes); - return max_bytes; - } - return std::nullopt; } Rasterizer::Screenshot::Screenshot() {} diff --git a/engine/flutter/shell/platform/ohos/ohos_surface.h b/engine/flutter/shell/platform/ohos/ohos_surface.h index 158f6d219da55b5edace2e6f70f4783de031d81d..86d16137715994b2766be07e3f43608548b601eb 100644 --- a/engine/flutter/shell/platform/ohos/ohos_surface.h +++ b/engine/flutter/shell/platform/ohos/ohos_surface.h @@ -28,6 +28,12 @@ class OhosSurface { virtual bool OnScreenSurfaceResize(const SkISize& size) = 0; virtual void SetPlatformWindow(const ::OHOS::sptr<::OHOS::Window> &window) = 0; + + virtual bool ResourceContextMakeCurrent() = 0; + + virtual bool ResourceContextClearCurrent() = 0; + + virtual void TeardownOnScreenContext() = 0; }; } // namespace flutter diff --git a/engine/flutter/shell/platform/ohos/ohos_surface_gl.cc b/engine/flutter/shell/platform/ohos/ohos_surface_gl.cc new file mode 100644 index 0000000000000000000000000000000000000000..b6a6b6c2574f019996051a2ae149ef3117cf13a8 --- /dev/null +++ b/engine/flutter/shell/platform/ohos/ohos_surface_gl.cc @@ -0,0 +1,220 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// 2021.4.30 platform view adapt ohos. +// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved. + +#include "flutter/shell/platform/ohos/ohos_surface_gl.h" + +#include + +#include "flutter/fml/logging.h" +#include "flutter/fml/memory/ref_ptr.h" + +namespace flutter { +OhosSurfaceGL::OhosSurfaceGL() + : window_(nullptr), + eglRenderSurface_(nullptr), + eglDisplay_(nullptr), + eglContext_(nullptr), + eglSurface_(nullptr), + width_(0), + height_(0), + valid_(false) +{ + FML_LOG(ERROR) << "OhosSurfaceGL Constructor"; +} + +bool OhosSurfaceGL::IsValid() const +{ + return valid_; +} + +std::unique_ptr OhosSurfaceGL::CreateGPUSurface() +{ + auto surface = std::make_unique(this, true); + return surface->IsValid() ? std::move(surface) : nullptr; +} + +void OhosSurfaceGL::SetPlatformWindow(const OHOS::sptr& window) +{ + if (window == nullptr) { + FML_LOG(ERROR) << "Ohos window is nullptr"; + return; + } + + window_ = window; + + // init render surface + if (!this->InitRenderSurface()) { + FML_LOG(ERROR) << "Failed to init render surface."; + } +} + +bool OhosSurfaceGL::OnScreenSurfaceResize(const SkISize& size) +{ + if (!IsValid()) { + FML_LOG(ERROR) << "OnScreenSurfaceResize surface invalid"; + return false; + } + + width_ = eglRenderSurface_->GetDefaultWidth(); + height_ = eglRenderSurface_->GetDefaultHeight(); + + return true; +} + +void OhosSurfaceGL::TeardownOnScreenContext() +{ + if (!IsValid()) { + FML_LOG(ERROR) << "TeardownOnScreenContext surface invalid"; + return; + } + + if (eglGetCurrentContext() != eglContext_) { + FML_LOG(INFO) << "Egl context is diff"; + return; + } + + if (eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) != EGL_TRUE) { + FML_LOG(ERROR) << "Could not clear the current context"; + return; + } +} + +bool OhosSurfaceGL::ResourceContextMakeCurrent() +{ + return false; +} + +bool OhosSurfaceGL::ResourceContextClearCurrent() +{ + return false; +} + +bool OhosSurfaceGL::GLContextPresent() +{ + if (!IsValid()) { + FML_LOG(ERROR) << "GLContextPresent surface invalid"; + return false; + } + + OHOS::Rect rect = {0, 0, width_, height_}; + OHOS::SurfaceError errorCode = eglRenderSurface_->SwapBuffers(rect); + if (errorCode != OHOS::SURFACE_ERROR_OK) { + FML_LOG(ERROR) << "Failed to swap buffers. code is " << errorCode; + return false; + } + + return true; +} + +intptr_t OhosSurfaceGL::GLContextFBO() const +{ + if (!IsValid()) { + FML_LOG(ERROR) << "GLContextFBO surface invalid"; + return 0; + } + + return static_cast(eglRenderSurface_->GetEglFbo()); +} + +bool OhosSurfaceGL::GLContextMakeCurrent() +{ + if (!IsValid()) { + FML_LOG(ERROR) << "GLContextMakeCurrent surface invalid"; + return false; + } + + // Avoid unused egl called. + if (eglGetCurrentContext() == eglContext_) { + FML_LOG(INFO) << "Egl context is same"; + return true; + } + + if ((eglMakeCurrent(eglDisplay_, eglSurface_, eglSurface_, eglContext_) != EGL_TRUE)) { + FML_LOG(ERROR) << "Could not make the context current. code is " << eglGetError(); + return false; + } + + return true; +} + +bool OhosSurfaceGL::GLContextClearCurrent() +{ + if (!IsValid()) { + FML_LOG(ERROR) << "GLContextClearCurrent surface invalid"; + return false; + } + + if (eglGetCurrentContext() != eglContext_) { + FML_LOG(INFO) << "Egl context is diff"; + return true; + } + + if (eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) != EGL_TRUE) { + FML_LOG(ERROR) << "Could not clear the current context. code is " << eglGetError(); + return false; + } + + return true; +} + +ExternalViewEmbedder* OhosSurfaceGL::GetExternalViewEmbedder() +{ + return nullptr; +} + +bool OhosSurfaceGL::InitRenderSurface() +{ + if (!window_) { + FML_LOG(ERROR) << "window_ is nullptr"; + return false; + } + + OHOS::sptr bufferProducer = window_->GetProducer(); + if (bufferProducer == nullptr) { + FML_LOG(ERROR) << "bufferProducer is nullptr"; + return false; + } + + eglRenderSurface_ = OHOS::EglRenderSurface::CreateEglRenderSurfaceAsProducer(bufferProducer); + if (eglRenderSurface_ == nullptr) { + FML_LOG(ERROR) << "eglRenderSurface_ is nullptr"; + return false; + } + + OHOS::SurfaceError errorCode = eglRenderSurface_->InitContext(); + if (errorCode != OHOS::SURFACE_ERROR_OK) { + FML_LOG(ERROR) << "Failed to init render context. code is " << errorCode; + return false; + } + + if ((eglGetCurrentContext() == eglContext_) && + (eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) != EGL_TRUE)) { + FML_LOG(ERROR) << "Could not clear the current context. code is " << eglGetError(); + } + + eglDisplay_ = eglRenderSurface_->GetEglDisplay(); + if (eglDisplay_ == EGL_NO_DISPLAY) { + FML_LOG(ERROR) << "EglDisplay_ is nullptr"; + return false; + } + + eglContext_ = eglRenderSurface_->GetEglContext(); + if (eglContext_ == EGL_NO_CONTEXT) { + FML_LOG(ERROR) << "EglContext_ is nullptr"; + return false; + } + + // surface default EGL_NO_SURFACE + eglSurface_ = eglRenderSurface_->GetEglSurface(); + width_ = eglRenderSurface_->GetDefaultWidth(); + height_ = eglRenderSurface_->GetDefaultHeight(); + valid_ = true; + + FML_LOG(INFO) << "EglRenderSurface width " << width_ << " height " << height_; + + return true; +} +} // namespace flutter \ No newline at end of file diff --git a/engine/flutter/shell/platform/ohos/ohos_surface_gl.h b/engine/flutter/shell/platform/ohos/ohos_surface_gl.h new file mode 100644 index 0000000000000000000000000000000000000000..f3ba6cda0cf340dcd5b44eb63db6c3c61d961522 --- /dev/null +++ b/engine/flutter/shell/platform/ohos/ohos_surface_gl.h @@ -0,0 +1,76 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// 2021.4.30 platform view adapt ohos. +// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved. + +#ifndef FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_GL_H_ +#define FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_GL_H_ + +#include + +#include "flutter/fml/macros.h" +#include "flutter/shell/gpu/gpu_surface_gl.h" +#include "flutter/shell/platform/ohos/ohos_surface.h" + +#include "egl_surface.h" + +namespace flutter { +class OhosSurfaceGL final : public GPUSurfaceGLDelegate, public OhosSurface { +public: + OhosSurfaceGL(); + + ~OhosSurfaceGL() override = default; + + // |OhosSurface| + bool IsValid() const override; + + // |OhosSurface| + std::unique_ptr CreateGPUSurface() override; + + // |OhosSurface| + void SetPlatformWindow(const ::OHOS::sptr& window) override; + + // |OhosSurface| + bool OnScreenSurfaceResize(const SkISize& size) override; + + // |OhosSurface| + void TeardownOnScreenContext() override; + + // |OhosSurface| + bool ResourceContextMakeCurrent() override; + + // |OhosSurface| + bool ResourceContextClearCurrent() override; + + // |GPUSurfaceGLDelegate| + bool GLContextPresent() override; + + // |GPUSurfaceGLDelegate| + intptr_t GLContextFBO() const override; + + // |GPUSurfaceGLDelegate| + bool GLContextMakeCurrent() override; + + // |GPUSurfaceGLDelegate| + bool GLContextClearCurrent() override; + + // |GPUSurfaceGLDelegate| + ExternalViewEmbedder* GetExternalViewEmbedder() override; + +private: + OHOS::sptr window_; + OHOS::sptr eglRenderSurface_; + EGLDisplay eglDisplay_; + EGLContext eglContext_; + EGLSurface eglSurface_; + int32_t width_ = 0; + int32_t height_ = 0; + bool valid_ = false; + + bool InitRenderSurface(); + + FML_DISALLOW_COPY_AND_ASSIGN(OhosSurfaceGL); +}; +} // namespace flutter +#endif // FLUTTER_SHELL_PLATFORM_OHOS_OHOS_SURFACE_GL_H_ diff --git a/engine/flutter/shell/platform/ohos/ohos_surface_software.cc b/engine/flutter/shell/platform/ohos/ohos_surface_software.cc index 2cb0db2ff6bc80d0d3488e79d58fb44b9a2e4abc..5e8e1818794abe946bc9a354a179287b59de3872 100644 --- a/engine/flutter/shell/platform/ohos/ohos_surface_software.cc +++ b/engine/flutter/shell/platform/ohos/ohos_surface_software.cc @@ -17,7 +17,6 @@ namespace flutter { namespace { - bool GetSkColorType(int32_t buffer_format, SkColorType* color_type, SkAlphaType* alpha_type) @@ -41,6 +40,7 @@ bool GetSkColorType(int32_t buffer_format, OhosSurfaceSoftware::OhosSurfaceSoftware() { + FML_LOG(ERROR) << "OhosSurfaceSoftware Constructor"; GetSkColorType(PIXEL_FMT_RGBA_8888, &target_color_type_, &target_alpha_type_); } @@ -72,7 +72,7 @@ bool OhosSurfaceSoftware::OnScreenSurfaceResize(const SkISize& size) return true; } -void OhosSurfaceSoftware::SetPlatformWindow(const OHOS::sptr &window) +void OhosSurfaceSoftware::SetPlatformWindow(const OHOS::sptr& window) { if (window == nullptr) { FML_LOG(ERROR) << "OhosSurfaceSoftware::SetPlatformWindow, window is nullptr"; @@ -95,8 +95,7 @@ void OhosSurfaceSoftware::SetPlatformWindow(const OHOS::sptr &wind surface_->SetQueueSize(5); } -sk_sp OhosSurfaceSoftware::AcquireBackingStore( - const SkISize& size) +sk_sp OhosSurfaceSoftware::AcquireBackingStore(const SkISize& size) { TRACE_EVENT0("flutter", "OhosSurfaceSoftware::AcquireBackingStore"); if (!IsValid()) { @@ -108,8 +107,8 @@ sk_sp OhosSurfaceSoftware::AcquireBackingStore( return sk_surface_; } - SkImageInfo image_info = SkImageInfo::Make( - size.fWidth, size.fHeight, target_color_type_, target_alpha_type_, SkColorSpace::MakeSRGB()); + SkImageInfo image_info = + SkImageInfo::Make(size.fWidth, size.fHeight, target_color_type_, target_alpha_type_, SkColorSpace::MakeSRGB()); sk_surface_ = SkSurface::MakeRaster(image_info); @@ -207,4 +206,21 @@ ExternalViewEmbedder* OhosSurfaceSoftware::GetExternalViewEmbedder() return nullptr; } +bool OhosSurfaceSoftware::ResourceContextMakeCurrent() +{ + // implement in ohos surface gl + return false; +} + +bool OhosSurfaceSoftware::ResourceContextClearCurrent() +{ + // implement in ohos surface gl + return false; +} + +void OhosSurfaceSoftware::TeardownOnScreenContext() +{ + // implement in ohos surface gl +} + } // namespace flutter diff --git a/engine/flutter/shell/platform/ohos/ohos_surface_software.h b/engine/flutter/shell/platform/ohos/ohos_surface_software.h index 831ee42005d82a18e6b04e967b6c19d8f0134df2..ce0694797cc6ef0643b5d1ea845f90bddeb522e9 100644 --- a/engine/flutter/shell/platform/ohos/ohos_surface_software.h +++ b/engine/flutter/shell/platform/ohos/ohos_surface_software.h @@ -13,37 +13,45 @@ namespace flutter { -class OhosSurfaceSoftware final : public OhosSurface, - public GPUSurfaceSoftwareDelegate { - public: - OhosSurfaceSoftware(); +class OhosSurfaceSoftware final : public OhosSurface, public GPUSurfaceSoftwareDelegate { +public: + OhosSurfaceSoftware(); - ~OhosSurfaceSoftware() override = default; + ~OhosSurfaceSoftware() override = default; - bool IsValid() const override; + bool IsValid() const override; - std::unique_ptr CreateGPUSurface() override; + std::unique_ptr CreateGPUSurface() override; - bool OnScreenSurfaceResize(const SkISize& size) override; + bool OnScreenSurfaceResize(const SkISize& size) override; - void SetPlatformWindow(const OHOS::sptr &window) override; + void SetPlatformWindow(const OHOS::sptr& window) override; - sk_sp AcquireBackingStore(const SkISize& size) override; + sk_sp AcquireBackingStore(const SkISize& size) override; - bool PresentBackingStore(sk_sp backing_store) override; + bool PresentBackingStore(sk_sp backing_store) override; - ExternalViewEmbedder* GetExternalViewEmbedder() override; + ExternalViewEmbedder* GetExternalViewEmbedder() override; - private: - sk_sp sk_surface_; - SkColorType target_color_type_; - SkAlphaType target_alpha_type_; + // |OhosSurface| + virtual bool ResourceContextMakeCurrent() override; - OHOS::sptr window_ = nullptr; - OHOS::BufferRequestConfig requestConfig_; - OHOS::sptr surface_ = nullptr; + // |OhosSurface| + virtual bool ResourceContextClearCurrent() override; - FML_DISALLOW_COPY_AND_ASSIGN(OhosSurfaceSoftware); + // |OhosSurface| + virtual void TeardownOnScreenContext() override; + +private: + sk_sp sk_surface_; + SkColorType target_color_type_; + SkAlphaType target_alpha_type_; + + OHOS::sptr window_ = nullptr; + OHOS::BufferRequestConfig requestConfig_; + OHOS::sptr surface_ = nullptr; + + FML_DISALLOW_COPY_AND_ASSIGN(OhosSurfaceSoftware); }; } // namespace flutter diff --git a/engine/flutter/shell/platform/ohos/platform_view_ohos.cc b/engine/flutter/shell/platform/ohos/platform_view_ohos.cc index 862e1a251cb9c410767b97a7ea172eb08f7068b6..102080d2810f83c1e2562773541faf62861f622e 100644 --- a/engine/flutter/shell/platform/ohos/platform_view_ohos.cc +++ b/engine/flutter/shell/platform/ohos/platform_view_ohos.cc @@ -10,6 +10,9 @@ #include #include "flutter/common/settings.h" +#ifdef ACE_ENABLE_GPU +#include "flutter/shell/platform/ohos/ohos_surface_gl.h" +#endif #include "flutter/shell/platform/ohos/ohos_surface_software.h" #include "flutter/shell/platform/ohos/vsync_waiter_embedder.h" @@ -21,15 +24,30 @@ PlatformViewOhos::PlatformViewOhos( bool use_software_rendering) : PlatformView(delegate, std::move(task_runners)) { +#ifdef ACE_ENABLE_GPU + surface_ = std::make_shared(); +#else if (use_software_rendering) { - surface_ = std::make_unique(); + surface_ = std::make_shared(); } +#endif } void PlatformViewOhos::NotifyCreated(const ::OHOS::sptr<::OHOS::Window> &window) { if (surface_) { +#ifdef ACE_ENABLE_GPU + fml::AutoResetWaitableEvent latch; + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetGPUTaskRunner(), + [&latch, surface = surface_.get(), &window]() mutable { + surface->SetPlatformWindow(window); + latch.Signal(); + }); + latch.Wait(); +#else surface_->SetPlatformWindow(window); +#endif } PlatformView::NotifyCreated(); @@ -38,7 +56,18 @@ void PlatformViewOhos::NotifyCreated(const ::OHOS::sptr<::OHOS::Window> &window) void PlatformViewOhos::NotifyChanged(const SkISize& size) { if (surface_) { +#ifdef ACE_ENABLE_GPU + fml::AutoResetWaitableEvent latch; + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetGPUTaskRunner(), + [&latch, surface = surface_.get(), &size]() mutable { + surface->OnScreenSurfaceResize(size); + latch.Signal(); + }); + latch.Wait(); +#else surface_->OnScreenSurfaceResize(size); +#endif } } diff --git a/engine/flutter/shell/platform/ohos/platform_view_ohos.h b/engine/flutter/shell/platform/ohos/platform_view_ohos.h index 1db430537c059eb93ab351a3b4af7ea35e60aeac..65983ae69a2fe42953db461cf348c96364ea58e6 100644 --- a/engine/flutter/shell/platform/ohos/platform_view_ohos.h +++ b/engine/flutter/shell/platform/ohos/platform_view_ohos.h @@ -22,7 +22,7 @@ public: std::unique_ptr CreateVSyncWaiter(int32_t platform); private: - std::unique_ptr surface_; + std::shared_ptr surface_; FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewOhos); }; diff --git a/flutter_ace_config.gni b/flutter_ace_config.gni index f528f5b6244fadf7019f4b0083795edacac116ee..dcc10aeaa4e40597ff821061c11d349cc92fe267 100644 --- a/flutter_ace_config.gni +++ b/flutter_ace_config.gni @@ -60,6 +60,12 @@ if (enable_glfw_window) { ace_common_defines += [ "USE_GLFW_WINDOW" ] } +if ("${product_name}" == "rk3566" || "${product_name}" == "rk3568") { + ace_enable_gpu = false # temporary cpu +} else { + ace_enable_gpu = false +} + enable_native_view = use_system_skia && (!only_wearable_enable || is_wearable_product) && !use_mingw_win && !use_mac