Shorten NotifySwap path for offscreen rendering 52/288452/8
authorChandan Padhi <c.padhi@samsung.com>
Thu, 16 Feb 2023 15:33:24 +0000 (21:03 +0530)
committerBot Blink <blinkbot@samsung.com>
Thu, 23 Feb 2023 04:22:23 +0000 (04:22 +0000)
This commit shortens NotifySwap path by removing some
of the changes in upstream code.

w/o patch:
SkiaOutputSurfaceImpl->Display(OutputSurfaceClient)->
RootCompositorFrameSinkImpl(DisplayClient)->FrameSinkManagerImpl->
HostFrameSinkManager(FrameSinkManagerClient)->
DelegatedFrameHost(HostFrameSinkClient)->
DelegatedFrameHostClientAura(DelegatedFrameHostClient)->
RenderWidgetHostViewAura->RWHVAuraOffscreenHelperEfl

with patch:
SkiaOutputSurfaceImpl->Display(OutputSurfaceClient)->
RootCompositorFrameSinkImpl(DisplayClient)->
HostDisplayClient(mojom::DisplayClient)->Compositor->
CompositorObserverEfl(CompositorObserver)->
RWHVAuraOffscreenHelperEfl

Reference: https://review.tizen.org/gerrit/287806/

Change-Id: I5dbfad3a6bb8460804045c6a8b66bae1f74130ac
Signed-off-by: Chandan Padhi <c.padhi@samsung.com>
27 files changed:
components/viz/host/host_frame_sink_client.h
components/viz/host/host_frame_sink_manager.cc
components/viz/host/host_frame_sink_manager.h
components/viz/service/frame_sinks/frame_sink_manager_impl.cc
components/viz/service/frame_sinks/frame_sink_manager_impl.h
components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
content/browser/compositor/viz_process_transport_factory.cc
content/browser/renderer_host/delegated_frame_host.cc
content/browser/renderer_host/delegated_frame_host.h
content/browser/renderer_host/delegated_frame_host_client_aura.cc
content/browser/renderer_host/delegated_frame_host_client_aura.h
content/browser/renderer_host/render_widget_host_view_aura.cc
content/browser/renderer_host/render_widget_host_view_aura.h
services/viz/privileged/mojom/compositing/BUILD.gn
services/viz/privileged/mojom/compositing/display_private.mojom
services/viz/privileged/mojom/compositing/frame_sink_manager.mojom
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h
tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.cc [new file with mode: 0644]
tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.h [new file with mode: 0644]
tizen_src/chromium_impl/ui/ui_efl.gni
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
ui/compositor/BUILD.gn
ui/compositor/compositor.cc
ui/compositor/compositor.h
ui/compositor/compositor_observer.h

index 9e04e64..288cf89 100644 (file)
@@ -22,9 +22,6 @@ class HostFrameSinkClient {
   // Called when a CompositorFrame with a new frame token is provided.
   virtual void OnFrameTokenChanged(uint32_t frame_token,
                                    base::TimeTicks activation_time) = 0;
-#if BUILDFLAG(IS_EFL)
-  virtual void NotifySwap(const uint32_t texture_id) {}
-#endif
 
  protected:
   virtual ~HostFrameSinkClient() {}
index 2e759a3..8d724ed 100644 (file)
@@ -441,16 +441,4 @@ HostFrameSinkManager::FrameSinkData::~FrameSinkData() = default;
 HostFrameSinkManager::FrameSinkData& HostFrameSinkManager::FrameSinkData::
 operator=(FrameSinkData&& other) = default;
 
-#if BUILDFLAG(IS_EFL)
-void HostFrameSinkManager::NotifySwap(const uint32_t texture_id,
-                                      const FrameSinkId& frame_sink_id) {
-  auto iter = frame_sink_data_map_.find(frame_sink_id);
-  if (iter != frame_sink_data_map_.end()) {
-    const FrameSinkData& data = iter->second;
-    if (data.client)
-      data.client->NotifySwap(texture_id);
-  }
-}
-#endif
-
 }  // namespace viz
index b0cada9..0c8c1a6 100644 (file)
@@ -295,11 +295,6 @@ class VIZ_HOST_EXPORT HostFrameSinkManager
 
   const bool enable_sync_window_destruction_;
 
-#if BUILDFLAG(IS_EFL)
-  void NotifySwap(const uint32_t texture_id,
-                  const FrameSinkId& frame_sink_id) override;
-#endif
-
   // Connections to/from FrameSinkManagerImpl.
   mojo::Remote<mojom::FrameSinkManager> frame_sink_manager_remote_;
   // This will point to |frame_sink_manager_remote_| if using mojo or it may
index b95e558..7c25edc 100644 (file)
@@ -808,12 +808,4 @@ void FrameSinkManagerImpl::ClearThrottling(const FrameSinkId& id) {
   UpdateThrottlingRecursively(id, base::TimeDelta());
 }
 
-#if BUILDFLAG(IS_EFL)
-void FrameSinkManagerImpl::NotifySwap(const uint32_t texture_id,
-                                      const FrameSinkId& id) {
-  for (auto child : GetChildrenByParent(id))
-    client_->NotifySwap(texture_id, child);
-}
-#endif
-
 }  // namespace viz
index 418747b..aae01af 100644 (file)
@@ -257,10 +257,6 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl
   bool VerifySandboxedThreadIds(
       base::flat_set<base::PlatformThreadId> thread_ids);
 
-#if BUILDFLAG(IS_EFL)
-  void NotifySwap(const uint32_t texture_id, const FrameSinkId& id);
-#endif
-
  private:
   friend class FrameSinkManagerTest;
 
index 0b6f3f8..821d45b 100644 (file)
@@ -625,8 +625,8 @@ BeginFrameSource* RootCompositorFrameSinkImpl::begin_frame_source() {
 
 #if BUILDFLAG(IS_EFL)
 void RootCompositorFrameSinkImpl::NotifySwap(const uint32_t texture_id) {
-  support_->frame_sink_manager()->NotifySwap(texture_id,
-                                             support_->frame_sink_id());
+  if (display_client_)
+    display_client_->NotifySwap(texture_id);
 }
 #endif
 
index 4c5bf12..5855d1e 100644 (file)
@@ -124,6 +124,12 @@ class HostDisplayClient : public viz::HostDisplayClient {
   }
 #endif
 
+#if BUILDFLAG(IS_EFL)
+  void NotifySwap(const uint32_t texture_id) override {
+    compositor_->NotifySwap(texture_id);
+  }
+#endif
+
  private:
   [[maybe_unused]] const raw_ptr<ui::Compositor> compositor_;
 };
index 2f07bdb..b089659 100644 (file)
@@ -329,12 +329,6 @@ void DelegatedFrameHost::OnFrameTokenChanged(uint32_t frame_token,
   client_->OnFrameTokenChanged(frame_token, activation_time);
 }
 
-#if BUILDFLAG(IS_EFL)
-void DelegatedFrameHost::NotifySwap(const uint32_t texture_id) {
-  client_->NotifySwap(texture_id);
-}
-#endif
-
 // CommitPending without a target for TakeFallbackContentFrom. Since we cannot
 // guarantee that Navigation will complete, evict our surfaces which are from
 // a previous Navigation.
index 85e3aa2..7d55757 100644 (file)
@@ -54,9 +54,6 @@ class CONTENT_EXPORT DelegatedFrameHostClient {
   virtual void InvalidateLocalSurfaceIdOnEviction() = 0;
   virtual std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() = 0;
   virtual bool ShouldShowStaleContentOnEviction() = 0;
-#if BUILDFLAG(IS_EFL)
-  virtual void NotifySwap(const uint32_t texture_id) {}
-#endif
 };
 
 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state
@@ -108,10 +105,6 @@ class CONTENT_EXPORT DelegatedFrameHost
   void OnFrameTokenChanged(uint32_t frame_token,
                            base::TimeTicks activation_time) override;
 
-#if BUILDFLAG(IS_EFL)
-  void NotifySwap(const uint32_t texture_id) override;
-#endif
-
   // Public interface exposed to RenderWidgetHostView.
 
   // kOccluded means the native window for the host was
index d667785..6e1b082 100644 (file)
@@ -64,10 +64,4 @@ bool DelegatedFrameHostClientAura::ShouldShowStaleContentOnEviction() {
   return render_widget_host_view_->ShouldShowStaleContentOnEviction();
 }
 
-#if BUILDFLAG(IS_EFL)
-void DelegatedFrameHostClientAura::NotifySwap(const uint32_t texture_id) {
-  render_widget_host_view_->NotifySwap(texture_id);
-}
-#endif
-
 }  // namespace content
index 074e6e2..87a23e8 100644 (file)
@@ -42,9 +42,6 @@ class CONTENT_EXPORT DelegatedFrameHostClientAura
   void InvalidateLocalSurfaceIdOnEviction() override;
   std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() override;
   bool ShouldShowStaleContentOnEviction() override;
-#if BUILDFLAG(IS_EFL)
-  void NotifySwap(const uint32_t texture_id) override;
-#endif
 
  private:
   raw_ptr<RenderWidgetHostViewAura> render_widget_host_view_;
index 133558d..21d097e 100644 (file)
@@ -564,11 +564,6 @@ void RenderWidgetHostViewAura::BackgroundColorReceived(int callback_id,
     offscreen_helper_->BackgroundColorReceived(callback_id, bg_color);
 }
 
-void RenderWidgetHostViewAura::NotifySwap(const uint32_t texture_id) {
-  if (offscreen_helper_)
-    offscreen_helper_->NotifySwap(texture_id);
-}
-
 void RenderWidgetHostViewAura::DidGetContentSnapshot(const SkBitmap& bitmap,
                                                      int request_id) {
   if (offscreen_helper_)
index 014d829..701f9a2 100644 (file)
@@ -422,7 +422,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
   RWHVAuraOffscreenHelperEfl* offscreen_helper() {
     return offscreen_helper_.get();
   }
-  void NotifySwap(const uint32_t texture_id);
   void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) override;
   void DidHandleKeyEvent(blink::WebInputEvent::Type input_event,
                          bool processed) override;
index 8a28eee..a7fe718 100644 (file)
@@ -44,7 +44,7 @@ mojom("compositing") {
     enabled_features += [ "enable_cast_overlay_strategy" ]
   }
   if (use_efl) {
-    enabled_features += [ "use_efl" ]
+    enabled_features += [ "is_efl" ]
   }
 
   cpp_typemaps = [
index 44e7dde..116905f 100644 (file)
@@ -125,4 +125,7 @@ interface DisplayClient {
 
   [EnableIf=is_android]
   SetPreferredRefreshRate(float refresh_rate);
+
+  [EnableIf=is_efl]
+  NotifySwap(uint32 texture_id);
 };
index 2ac593f..5776b0b 100644 (file)
@@ -192,7 +192,4 @@ interface FrameSinkManagerClient {
   // when a surface of the provided |frame_sink_id| activates.
   OnFrameTokenChanged(FrameSinkId frame_sink_id, uint32 frame_token,
                       mojo_base.mojom.TimeTicks activation_time);
-
-  [EnableIf=use_efl]
-  NotifySwap(uint32 texture_id, FrameSinkId frame_sink_id);
 };
index cf06dce..ee3e3f8 100644 (file)
@@ -14,6 +14,7 @@
 #include "content/browser/web_contents/web_contents_view_aura.h"
 #include "content/public/browser/render_widget_host_helper.h"
 #include "content/public/browser/web_contents_delegate.h"
+#include "ecore_x_wayland_wrapper.h"
 #include "gpu/command_buffer/service/texture_base.h"
 #include "skia/ext/image_operations.h"
 #include "tizen/system_info.h"
index d462660..42ad061 100644 (file)
@@ -14,7 +14,6 @@
 #include <Ecore_Evas.h>
 #include <Ecore_Input.h>
 #include <Elementary.h>
-#include "ecore_x_wayland_wrapper.h"
 
 #include "base/callback.h"
 #include "base/containers/id_map.h"
diff --git a/tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.cc b/tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.cc
new file mode 100644 (file)
index 0000000..52dcb89
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/compositor_observer_efl.h"
+
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/compositor/compositor.h"
+
+namespace ui {
+
+CompositorObserverEfl::CompositorObserverEfl(ui::Compositor* compositor,
+                                             content::WebContents* web_contents)
+    : compositor_(compositor), web_contents_(web_contents) {
+  compositor_->AddObserver(this);
+}
+
+CompositorObserverEfl::~CompositorObserverEfl() {
+  if (compositor_)
+    compositor_->RemoveObserver(this);
+}
+
+void CompositorObserverEfl::NotifySwap(const uint32_t texture_id) {
+  auto* rwhva = static_cast<content::RenderWidgetHostViewAura*>(
+      web_contents_->GetRenderWidgetHostView());
+  if (!rwhva || !rwhva->offscreen_helper())
+    return;
+
+  rwhva->offscreen_helper()->NotifySwap(texture_id);
+}
+
+void CompositorObserverEfl::OnCompositingShuttingDown(
+    ui::Compositor* compositor) {
+  DCHECK_EQ(compositor, compositor_);
+  compositor_->RemoveObserver(this);
+  compositor_ = nullptr;
+}
+}  // namespace ui
diff --git a/tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.h b/tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.h
new file mode 100644 (file)
index 0000000..2bf46b7
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_COMPOSITOR_COMPOSITOR_OBSERVER_EFL_H_
+#define UI_COMPOSITOR_COMPOSITOR_OBSERVER_EFL_H_
+
+#include "ui/compositor/compositor_export.h"
+#include "ui/compositor/compositor_observer.h"
+
+namespace content {
+class WebContents;
+}  // namespace content
+
+namespace ui {
+
+class Compositor;
+
+class COMPOSITOR_EXPORT CompositorObserverEfl : public CompositorObserver {
+ public:
+  CompositorObserverEfl(Compositor* compositor,
+                        content::WebContents* web_contents);
+
+  CompositorObserverEfl(const CompositorObserverEfl&) = delete;
+  CompositorObserverEfl& operator=(const CompositorObserverEfl&) = delete;
+
+  ~CompositorObserverEfl() override;
+
+  ui::Compositor* compositor() { return compositor_; }
+
+ private:
+  // ui::CompositorObserver implementation:
+  void NotifySwap(const uint32_t texture_id) override;
+  void OnCompositingShuttingDown(Compositor* compositor) override;
+
+  Compositor* compositor_;
+  content::WebContents* web_contents_;
+};
+
+}  // namespace ui
+
+#endif  // UI_COMPOSITOR_COMPOSITOR_OBSERVER_EFL_H_
index 1a0117f..7e08db0 100644 (file)
@@ -134,4 +134,9 @@ if (!use_aura) {
 external_ui_accessiblility_platform_sources = [
   "//tizen_src/chromium_impl/ui/accessibility/platform/ax_platform_node_efl.cc",
   "//tizen_src/chromium_impl/ui/accessibility/platform/ax_platform_node_efl.h",
-]
\ No newline at end of file
+]
+
+external_ui_compositor_sources = [
+  "//tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.cc",
+  "//tizen_src/chromium_impl/ui/compositor/compositor_observer_efl.h",
+]
index 5d6f3a4..76e4b48 100644 (file)
@@ -77,6 +77,7 @@
 #include "ui/aura/window.h"
 #include "ui/base/clipboard/clipboard_helper_efl.h"
 #include "ui/base/l10n/l10n_util.h"
+#include "ui/compositor/compositor_observer_efl.h"
 #include "ui/display/screen.h"
 #include "ui/events/event_switches.h"
 #include "ui/gfx/geometry/dip_util.h"
@@ -435,6 +436,8 @@ EWebView::~EWebView() {
   context_menu_.reset();
   mhtml_callback_map_.Clear();
 
+  compositor_observer_.reset();
+
   // Release manually those scoped pointers to
   // make sure they are released in correct order
   web_contents_.reset();
@@ -2498,6 +2501,8 @@ void EWebView::InitializeWindowTreeHost() {
       std::make_unique<aura::test::TestFocusClient>(host_->window());
   window_parenting_client_ =
       std::make_unique<aura::test::TestWindowParentingClient>(host_->window());
+  compositor_observer_ = std::make_unique<ui::CompositorObserverEfl>(
+      host_->compositor(), web_contents_.get());
 
   aura::Window* content = web_contents_->GetNativeView();
   aura::Window* parent = host_->window();
index 17cb0c3..571af8c 100644 (file)
@@ -864,6 +864,7 @@ class EWebView {
   std::unique_ptr<aura::WindowTreeHost> host_;
   std::unique_ptr<aura::client::FocusClient> focus_client_;
   std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
+  std::unique_ptr<ui::CompositorObserver> compositor_observer_;
   content::DateTimeChooserEfl* date_time_chooser_ = nullptr;
 
 #if defined(TIZEN_ATK_SUPPORT)
index d42dd37..cdf5544 100644 (file)
@@ -5,6 +5,10 @@
 import("//build/config/ui.gni")
 import("//testing/test.gni")
 
+if (use_efl) {
+  import("//tizen_src/chromium_impl/ui/ui_efl.gni")
+}
+
 component("compositor") {
   sources = [
     "animation_throughput_reporter.cc",
@@ -87,6 +91,10 @@ component("compositor") {
     ]
   }
 
+  if (use_efl) {
+    sources += external_ui_compositor_sources
+  }
+
   defines = [ "COMPOSITOR_IMPLEMENTATION" ]
 
   public_deps = [ "//cc" ]
index ea97a5f..16177cf 100644 (file)
@@ -875,6 +875,13 @@ void Compositor::OnCompleteSwapWithNewSize(const gfx::Size& size) {
 }
 #endif
 
+#if BUILDFLAG(IS_EFL)
+void Compositor::NotifySwap(const uint32_t texture_id) {
+  for (auto& observer : observer_list_)
+    observer.NotifySwap(texture_id);
+}
+#endif
+
 void Compositor::SetOutputIsSecure(bool output_is_secure) {
   output_is_secure_ = output_is_secure;
   if (display_private_)
index ad691e7..1fedaa1 100644 (file)
@@ -424,6 +424,10 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
   void OnCompleteSwapWithNewSize(const gfx::Size& size);
 #endif
 
+#if BUILDFLAG(IS_EFL)
+  void NotifySwap(const uint32_t texture_id);
+#endif
+
   bool IsLocked() { return lock_manager_.IsLocked(); }
 
   void SetOutputIsSecure(bool output_is_secure);
index 8e00a18..1814689 100644 (file)
@@ -54,6 +54,10 @@ class COMPOSITOR_EXPORT CompositorObserver {
                                                     const gfx::Size& size) {}
 #endif  // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
 
+#if BUILDFLAG(IS_EFL)
+  virtual void NotifySwap(const uint32_t texture_id) {}
+#endif
+
   // Called at the top of the compositor's destructor, to give observers a
   // chance to remove themselves.
   virtual void OnCompositingShuttingDown(Compositor* compositor) {}