[M120 Migration] Skip flushAndSubmit sync call on gpu side for webgl 43/307143/8 submit/tizen/20240311.160013
authoruzair <uzair.jaleel@samsung.com>
Mon, 17 Apr 2023 03:00:14 +0000 (08:30 +0530)
committerDae-Hyun Ko <dhyuna.ko@samsung.com>
Mon, 11 Mar 2024 05:25:09 +0000 (05:25 +0000)
This commit enables flushAndSubmit sync call in gpu process for
all types of content excluding canvas and video which helps fixing
blackcsreen issues observed during alexa testing.

Reference:
https://review.tizen.org/gerrit/c/291434

Change-Id: Id473d14e22bf8089e0017906e7b806ec215af595
Signed-off-by: uzair <uzair.jaleel@samsung.com>
Signed-off-by: Chandan Padhi <c.padhi@samsung.com>
20 files changed:
cc/layers/layer_impl.h
cc/layers/texture_layer_impl.h
cc/layers/video_layer_impl.h
cc/trees/layer_tree_host_impl.cc
cc/trees/layer_tree_host_impl.h
cc/trees/layer_tree_impl.cc
cc/trees/layer_tree_impl.h
components/viz/common/quads/compositor_frame_metadata.cc
components/viz/common/quads/compositor_frame_metadata.h
components/viz/service/display/aggregated_frame.h
components/viz/service/display/direct_renderer.h
components/viz/service/display/display.cc
components/viz/service/display/output_surface_frame.h
components/viz/service/display/skia_renderer.cc
components/viz/service/display/surface_aggregator.cc
components/viz/service/display_embedder/skia_output_device_offscreen.cc
services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc
services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h
services/viz/public/mojom/BUILD.gn
services/viz/public/mojom/compositing/compositor_frame_metadata.mojom

index 9660e89..20c3639 100644 (file)
@@ -68,6 +68,16 @@ enum ViewportLayerType {
   LAST_VIEWPORT_LAYER_TYPE = OUTER_VIEWPORT_SCROLL,
 };
 
+#if BUILDFLAG(IS_EFL)
+enum LayerType {
+  LAYER_TYPE_NORMAL = 1,
+  LAYER_TYPE_TEXTURE = 1 << 1,
+  LAYER_TYPE_VIDEO = 1 << 2
+};
+
+typedef unsigned LayerTypeMask;
+#endif
+
 class CC_EXPORT LayerImpl {
  public:
   static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
@@ -445,6 +455,10 @@ class CC_EXPORT LayerImpl {
 
   ElementListType GetElementTypeForAnimation() const;
 
+#if BUILDFLAG(IS_EFL)
+  virtual LayerType GetLayerType() const { return LAYER_TYPE_NORMAL; }
+#endif
+
   void set_needs_show_scrollbars(bool yes) { needs_show_scrollbars_ = yes; }
   bool needs_show_scrollbars() { return needs_show_scrollbars_; }
 
index 0e66134..4ab8f18 100644 (file)
@@ -77,6 +77,10 @@ class CC_EXPORT TextureLayerImpl : public LayerImpl {
                               scoped_refptr<CrossThreadSharedBitmap> bitmap);
   void UnregisterSharedBitmapId(viz::SharedBitmapId id);
 
+#if BUILDFLAG(IS_EFL)
+  LayerType GetLayerType() const override { return LAYER_TYPE_TEXTURE; }
+#endif
+
  private:
   TextureLayerImpl(LayerTreeImpl* tree_impl, int id);
 
index de261d5..4aac591 100644 (file)
@@ -65,6 +65,10 @@ class CC_EXPORT VideoLayerImpl : public LayerImpl {
     return video_transform_;
   }
 
+#if BUILDFLAG(IS_EFL)
+  LayerType GetLayerType() const override { return LAYER_TYPE_VIDEO; }
+#endif
+
  private:
   VideoLayerImpl(
       LayerTreeImpl* tree_impl,
index 5dddca5..38e0e67 100644 (file)
@@ -2371,6 +2371,9 @@ viz::CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() {
   }
 
   metadata.capture_bounds = CollectRegionCaptureBounds();
+#if BUILDFLAG(IS_EFL)
+  metadata.can_skip_flush = CanSkipFlush();
+#endif
   return metadata;
 }
 
@@ -2618,6 +2621,14 @@ absl::optional<LayerTreeHostImpl::SubmitInfo> LayerTreeHostImpl::DrawLayers(
   return SubmitInfo{submit_time, std::move(events_metrics)};
 }
 
+#if BUILDFLAG(IS_EFL)
+bool LayerTreeHostImpl::CanSkipFlush() const {
+  if (active_tree_->HasLayer(LAYER_TYPE_TEXTURE | LAYER_TYPE_VIDEO))
+    return true;
+  return false;
+}
+#endif
+
 viz::CompositorFrame LayerTreeHostImpl::GenerateCompositorFrame(
     FrameData* frame) {
   TRACE_EVENT(
index eabafd4..593823d 100644 (file)
@@ -316,6 +316,10 @@ class CC_EXPORT LayerTreeHostImpl : public TileManagerClient,
   void RequestBeginFrameForAnimatedImages() override;
   void RequestInvalidationForAnimatedImages() override;
 
+#if BUILDFLAG(IS_EFL)
+  bool CanSkipFlush() const;
+#endif
+
   base::WeakPtr<LayerTreeHostImpl> AsWeakPtr();
 
   void set_resourceless_software_draw_for_testing() {
index d62ca5c..b7f10da 100644 (file)
@@ -1955,6 +1955,16 @@ void LayerTreeImpl::DidAnimateScrollOffset() {
   host_impl_->DidAnimateScrollOffset();
 }
 
+#if BUILDFLAG(IS_EFL)
+bool LayerTreeImpl::HasLayer(LayerTypeMask layer_type_mask) const {
+  for (auto& layer : layer_list_) {
+    if (layer_type_mask & layer->GetLayerType())
+      return true;
+  }
+  return false;
+}
+#endif
+
 bool LayerTreeImpl::use_gpu_rasterization() const {
   return host_impl_->use_gpu_rasterization();
 }
index 94b9364..6c3991a 100644 (file)
@@ -151,6 +151,9 @@ class CC_EXPORT LayerTreeImpl {
   std::unique_ptr<ScrollbarAnimationController>
   CreateScrollbarAnimationController(ElementId scroll_element_id,
                                      float initial_opacity);
+#if BUILDFLAG(IS_EFL)
+  bool HasLayer(LayerTypeMask) const;
+#endif
   void DidAnimateScrollOffset();
   bool use_gpu_rasterization() const;
   bool create_low_res_tiling() const;
index f227686..ce691bb 100644 (file)
@@ -29,6 +29,9 @@ CompositorFrameMetadata::CompositorFrameMetadata(
       scrollable_viewport_size(other.scrollable_viewport_size),
       content_color_usage(other.content_color_usage),
       may_contain_video(other.may_contain_video),
+#if BUILDFLAG(IS_EFL)
+      can_skip_flush(other.can_skip_flush),
+#endif
       is_resourceless_software_draw_with_scroll_or_animation(
           other.is_resourceless_software_draw_with_scroll_or_animation),
       is_handling_interaction(other.is_handling_interaction),
index 42c9bfa..fc07196 100644 (file)
@@ -88,6 +88,10 @@ class VIZ_COMMON_EXPORT CompositorFrameMetadata {
 
   bool may_contain_video = false;
 
+#if BUILDFLAG(IS_EFL)
+  bool can_skip_flush = false;
+#endif
+
   bool may_throttle_if_undrawn_frames = true;
 
   // WebView makes quality decisions for rastering resourceless software frames
index 054b7a0..5420267 100644 (file)
@@ -50,6 +50,10 @@ class VIZ_SERVICE_EXPORT AggregatedFrame {
   // root render pass |output_rect| (display size) on the root surface.
   bool page_fullscreen_mode = false;
 
+#if BUILDFLAG(IS_EFL)
+  bool can_skip_flush = false;
+#endif
+
   // A list of surface damage rects in the current frame, used for overlays.
   SurfaceDamageRectList surface_damage_rect_list_;
 
index c242001..ae134eb 100644 (file)
@@ -110,6 +110,11 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
     std::vector<ui::LatencyInfo> latency_info;
     int64_t seq = -1;
     bool top_controls_visible_height_changed = false;
+
+#if BUILDFLAG(IS_EFL)
+    bool can_skip_flush = false;
+#endif
+
 #if BUILDFLAG(IS_APPLE)
     gfx::CALayerResult ca_layer_error_code = gfx::kCALayerSuccess;
 #endif
index d61a94f..c87b56b 100644 (file)
@@ -1020,6 +1020,11 @@ bool Display::DrawAndSwap(const DrawAndSwapParams& params) {
           data->set_display_trace_id(swap_trace_id);
         });
 
+
+#if BUILDFLAG(IS_EFL)
+    swap_frame_data.can_skip_flush = frame.can_skip_flush;
+#endif
+
 #if BUILDFLAG(IS_APPLE)
     swap_frame_data.ca_layer_error_code =
         overlay_processor_->GetCALayerErrorCode();
index 45f45bb..99dd611 100644 (file)
@@ -43,6 +43,9 @@ class VIZ_SERVICE_EXPORT OutputSurfaceFrame {
   std::vector<ui::LatencyInfo> latency_info;
   absl::optional<int64_t> choreographer_vsync_id;
   bool top_controls_visible_height_changed = false;
+#if BUILDFLAG(IS_EFL)
+  bool can_skip_flush = false;
+#endif
   // FrameData for GLSurface.
   gfx::FrameData data;
   // Metadata containing information to draw a delegated ink trail using
index c54bfa3..eba8513 100644 (file)
@@ -1089,6 +1089,9 @@ void SkiaRenderer::SwapBuffers(SwapFrameData swap_frame_data) {
   output_frame.latency_info = std::move(swap_frame_data.latency_info);
   output_frame.top_controls_visible_height_changed =
       swap_frame_data.top_controls_visible_height_changed;
+#if BUILDFLAG(IS_EFL)
+  output_frame.can_skip_flush = swap_frame_data.can_skip_flush;
+#endif
   output_frame.choreographer_vsync_id = swap_frame_data.choreographer_vsync_id;
   output_frame.size = viewport_size_for_swap_buffers();
   output_frame.data.seq = swap_frame_data.seq;
index d6010d6..6455212 100644 (file)
@@ -430,6 +430,9 @@ struct SurfaceAggregator::PrewalkResult {
   base::flat_set<SurfaceId> undrawn_surfaces;
   bool frame_sinks_changed = false;
   bool page_fullscreen_mode = false;
+#if BUILDFLAG(IS_EFL)
+  bool can_skip_flush = false;
+#endif
   gfx::ContentColorUsage content_color_usage = gfx::ContentColorUsage::kSRGB;
 };
 
@@ -2156,6 +2159,12 @@ gfx::Rect SurfaceAggregator::PrewalkSurface(ResolvedFrameData& resolved_frame,
     surface->OnWillBeDrawn();
 
   const CompositorFrame& frame = surface->GetActiveOrInterpolatedFrame();
+
+#if BUILDFLAG(IS_EFL)
+  if (frame.metadata.can_skip_flush)
+    result.can_skip_flush = true;
+#endif
+
   for (const SurfaceRange& surface_range : frame.metadata.referenced_surfaces) {
     damage_ranges_[surface_range.end().frame_sink_id()].push_back(
         surface_range);
@@ -2344,6 +2353,9 @@ AggregatedFrame SurfaceAggregator::Aggregate(
   frame.has_copy_requests = has_copy_requests_ && take_copy_requests_;
   frame.content_color_usage = prewalk_result.content_color_usage;
   frame.page_fullscreen_mode = prewalk_result.page_fullscreen_mode;
+#if BUILDFLAG(IS_EFL)
+  frame.can_skip_flush = prewalk_result.can_skip_flush;
+#endif
 
   base::ElapsedTimer copy_timer;
   CopyUndrawnSurfaces(&prewalk_result);
index 55a5d15..1ff8a2c 100644 (file)
@@ -82,8 +82,8 @@ void SkiaOutputDeviceOffscreen::Present(
   DCHECK(backend_texture_.isValid() || graphite_texture_.isValid());
 
   StartSwapBuffers(std::move(feedback));
-#if BUILDFLAG(IS_TIZEN)
-  if (IsMobileProfile()) {
+#if BUILDFLAG(IS_EFL)
+  if (!frame.can_skip_flush) {
     gr_context_->flushAndSubmit(GrSyncCpu::kYes);
   }
 #endif
index 2a11811..5734956 100644 (file)
@@ -47,6 +47,9 @@ bool StructTraits<viz::mojom::CompositorFrameMetadataDataView,
     return false;
 
   out->may_contain_video = data.may_contain_video();
+#if BUILDFLAG(IS_EFL)
+  out->can_skip_flush = data.can_skip_flush();
+#endif
   out->may_throttle_if_undrawn_frames = data.may_throttle_if_undrawn_frames();
   out->has_shared_element_resources = data.has_shared_element_resources();
   out->is_resourceless_software_draw_with_scroll_or_animation =
index 5f0862f..db802e3 100644 (file)
@@ -56,6 +56,12 @@ struct StructTraits<viz::mojom::CompositorFrameMetadataDataView,
     return metadata.may_contain_video;
   }
 
+#if BUILDFLAG(IS_EFL)
+  static bool can_skip_flush(const viz::CompositorFrameMetadata& metadata) {
+    return metadata.can_skip_flush;
+  }
+#endif
+
   static bool may_throttle_if_undrawn_frames(
       const viz::CompositorFrameMetadata& metadata) {
     return metadata.may_throttle_if_undrawn_frames;
index d3ee6e9..212052d 100644 (file)
@@ -608,6 +608,10 @@ mojom("mojom") {
   if (tizen_video_hole) {
     enabled_features += [ "tizen_video_hole" ]
   }
+
+  if (use_efl) {
+    enabled_features += [ "is_efl" ]
+  }
 }
 
 # The enum that SharedImageFormat uses internally to denote singleplanar
index 8b0d74b..8a1fddc 100644 (file)
@@ -29,6 +29,10 @@ struct CompositorFrameMetadata {
   gfx.mojom.SizeF scrollable_viewport_size;
   gfx.mojom.ContentColorUsage content_color_usage;
   bool may_contain_video;
+
+  [EnableIf=is_efl]
+  bool can_skip_flush;
+
   bool may_throttle_if_undrawn_frames;
   bool is_resourceless_software_draw_with_scroll_or_animation;
   bool is_handling_interaction;