[M120 Migration] Fix Terms and Condition wizard shows transparent/white bg 41/306941/3
authorqiang.ji <qiang.ji@samsung.com>
Wed, 12 Apr 2023 02:12:39 +0000 (10:12 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 29 Feb 2024 07:01:28 +0000 (07:01 +0000)
As the viz strategy is totally updated, for bg logic, we need to flow below:

1. Set bg for Render CompositorFrame
EWebView::SetDrawsTransparentBackground -> WebFrameWidgetImpl::SetDrawsTransparentBackground
-> layer_tree_host -> CompositorFrameSinkImpl -> CompositorFrame with transparent bg
2. Set bg for Browser CompositorFrame
EWebView::SetDrawsTransparentBackground ->
RenderWidgetHostViewBase::SetBackgroundColor
2.1 RenderWidgetHostViewAura::UpdateBackgroundColor()
Compositor::SetBackgroundColor
layer_tree_host -> RootCompositorFrameSinkImpl -> CompositorFrame with transparent bg
2.2 RWHVAuraOffscreenHelperEfl::PaintTextureToSurface
RenderWidgetHostViewBase::GetBackgroundColor()
if set transparent bg, need to enable blend.

References:
https://review.tizen.org/gerrit/291210
https://review.tizen.org/gerrit/301497
https://review.tizen.org/gerrit/302739

Change-Id: I1b0650d5446917c6171df97eebef36c2f947f5fc
Signed-off-by: qiang.ji <qiang.ji@samsung.com>
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
content/browser/renderer_host/render_widget_host_view_aura.cc
third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc

index 753881a..9bfdcaf 100644 (file)
@@ -807,6 +807,11 @@ void RenderWidgetHostViewAura::UpdateBackgroundColor() {
   DCHECK(GetBackgroundColor());
 
   SkColor color = *GetBackgroundColor();
+  // Set transparent bg for Browser process
+  if (color == SK_ColorTRANSPARENT && GetCompositor()) {
+    GetCompositor()->SetBackgroundColor(SK_ColorTRANSPARENT);
+  }
+
   bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
   window_->layer()->SetFillsBoundsOpaquely(opaque);
   window_->layer()->SetColor(color);
index b212320..65d3b6c 100644 (file)
@@ -5145,6 +5145,10 @@ void WebFrameWidgetImpl::SetDrawsTransparentBackground(
                                 : static_cast<SkColor>(0xFFFFFFFF);
 
   webview->SetPageBaseBackgroundColor(absl::make_optional(backgroundColor));
+  // set transparent bg for Render process
+  if (draws_transparent_background) {
+    widget_base_->LayerTreeHost()->set_background_color(SkColors::kTransparent);
+  }
 }
 
 void WebFrameWidgetImpl::SetBackgroundColor(int32_t red,
index 4e2f356..bfb1e76 100644 (file)
@@ -250,7 +250,16 @@ bool RWHVAuraOffscreenHelperEfl::MakeCurrent() {
 
 void RWHVAuraOffscreenHelperEfl::ClearBrowserFrame() {
   DCHECK(evas_gl_api_);
-  evas_gl_api_->glClearColor(1.0, 1.0, 1.0, 1.0);
+  absl::optional<SkColor> bg_color = rwhva()->GetBackgroundColor();
+  if (bg_color) {
+    evas_gl_api_->glClearColor(
+        static_cast<float>(SkColorGetR(*bg_color)) / 255.0f,
+        static_cast<float>(SkColorGetG(*bg_color)) / 255.0f,
+        static_cast<float>(SkColorGetB(*bg_color)) / 255.0f,
+        static_cast<float>(SkColorGetA(*bg_color)) / 255.0f);
+  } else {
+    evas_gl_api_->glClearColor(1.0, 1.0, 1.0, 1.0);
+  }
   evas_gl_api_->glClear(GL_COLOR_BUFFER_BIT);
 }
 
@@ -378,7 +387,15 @@ void RWHVAuraOffscreenHelperEfl::PaintTextureToSurface(GLuint texture_id) {
 
   evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
   evas_gl_api_->glViewport(0, 0, width, height);
-  evas_gl_api_->glClearColor(1.0, 1.0, 1.0, 1.0);
+  absl::optional<SkColor> bg_color = rwhva()->GetBackgroundColor();
+  if (bg_color && *bg_color == SK_ColorTRANSPARENT) {
+    LOG(INFO) << __func__ << " transparent bg";
+    evas_gl_api_->glClearColor(0.0, 0.0, 0.0, 0.0);
+    evas_gl_api_->glEnable(GL_BLEND);
+    evas_gl_api_->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+  } else {
+    evas_gl_api_->glClearColor(1.0, 1.0, 1.0, 1.0);
+  }
   evas_gl_api_->glClear(GL_COLOR_BUFFER_BIT);
   evas_gl_api_->glUseProgram(program_id_);
 
@@ -412,6 +429,9 @@ void RWHVAuraOffscreenHelperEfl::PaintTextureToSurface(GLuint texture_id) {
   evas_gl_api_->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL);
 
   evas_gl_api_->glBindTexture(GL_TEXTURE_2D, 0);
+  if (bg_color && *bg_color == SK_ColorTRANSPARENT) {
+    evas_gl_api_->glDisable(GL_BLEND);
+  }
   evas_gl_make_current(evas_gl_, 0, 0);
 
   // for snapshot