How to make the content_shell background as transparent instead of white?

196 views
Skip to first unread message

Arunprasad Rajkumar

unread,
Mar 13, 2014, 3:07:21 AM3/13/14
to chromium-dev
Hello Folks,

I'm trying to change the content shell background as transparent by using below code,

diff --git a/content/shell/browser/shell_aura.cc b/content/shell/browser/shell_aura.cc
index 4719a15..d20aba0 100644
--- a/content/shell/browser/shell_aura.cc
+++ b/content/shell/browser/shell_aura.cc
@@ -4,6 +4,7 @@
 
 #include "content/shell/browser/shell.h"
 
+#include "content/public/browser/render_widget_host_view.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/browser/web_contents_view.h"
 #include "content/shell/browser/shell_platform_data_aura.h"
@@ -39,6 +40,18 @@ void Shell::PlatformSetAddressBarURL(const GURL& url) {
 }
 
 void Shell::PlatformSetIsLoading(bool loading) {
+    // To set background as transparent
+  RenderWidgetHostView* render_widget_host_view = web_contents_?
+        web_contents_->GetRenderWidgetHostView():0;
+  LOG(INFO)<<"RenderWidgetHostView:"<<render_widget_host_view<<", WebContents:"<<web_contents_.get();
+  if (render_widget_host_view) {
+    SkBitmap skBitmap;
+    skBitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
+    skBitmap.allocPixels();
+    skBitmap.eraseColor(0);
+    render_widget_host_view->SetBackground(skBitmap);
+    LOG(INFO)<<"Setting transparent background";
+  }
 }

Actually the content_shell is build with use_aura=1. I traced till renderer process side function WebViewImpl::setIsTransparent(), it was called, but the background is still white :(

Any clues? Am I missing something?

<BR/>
<Arun/>

Brian Salomon

unread,
Mar 13, 2014, 10:48:25 AM3/13/14
to ararun...@gmail.com, chromium-dev
This question is probably more appropriate for another list, possibly chromium-dev. SetBackround() isn't a Skia API and the people on this list aren't the experts in how the widget framework in Chromium works.

Brian



--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Thiago Farina

unread,
Mar 13, 2014, 12:50:03 PM3/13/14
to Brian Salomon, Arunprasad Rajkumar, chromium-dev
On Thu, Mar 13, 2014 at 11:48 AM, Brian Salomon <bsal...@google.com> wrote:
This question is probably more appropriate for another list, possibly chromium-dev. SetBackround() isn't a Skia API and the people on this list aren't the experts in how the widget framework in Chromium works.

Brian, as far as I can see, Arunprasad posted on chromium-dev mainling list rather than skia-discuss (if that is what you meant). ;)

Cheers,

--
Thiago Farina

Brian Salomon

unread,
Mar 13, 2014, 12:51:10 PM3/13/14
to Thiago Farina, Arunprasad Rajkumar, chromium-dev
I'm a moron :) For some reason I thought it was skia-discuss.

Arunprasad Rajkumar

unread,
Mar 13, 2014, 1:01:23 PM3/13/14
to Brian Salomon, Thiago Farina, chromium-dev
@Brian, I thought RenderWidgetHostView is a part of views system in chromium :)

<BR/>
<Arun/>

Arunprasad Rajkumar

unread,
Mar 15, 2014, 1:30:27 AM3/15/14
to Brian Salomon, chromium-dev, Thiago Farina

Folks, any ideas?

Scott Graham

unread,
Mar 15, 2014, 2:35:50 AM3/15/14
to ararun...@gmail.com, Brian Salomon, chromium-dev, Thiago Farina
You want it to be transparent to the system desktop? Or what are you compositing it with?

If you're on Windows, you'd need to investigate telling DWM to do something. I'd look at WS_EX_COMPOSITED, but I don't imagine it will just magically work, so I suspect you're signing up for some debugging.


Folks, any ideas?

Chandan

unread,
Sep 10, 2015, 1:52:47 AM9/10/15
to Chromium-dev
Hi guys,

I  too have a similar requirement of making the background transparent. I need to remove the default white background.

I tried the following but I still see the default white background:
i) void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) {
    content::RenderWidgetHostView* view = host->GetView();
    DCHECK(view);
    view->SetBackgroundColor(SK_ColorTRANSPARENT);
}

ii) Added host_->set_background_color(SK_ColorTRANSPARENT); in ui::Compositor's constructor.

Please help.

Regards,
Chandan

binoy mv (melatt vythakkatt)

unread,
Aug 24, 2016, 2:49:10 AM8/24/16
to Chromium-dev
Hi

I have tried multiple ways explained in the forum to make the content shell transparent, but getting a black screen instead of transparency, do anyone had done this for Linux chromium? 

Thanks,
Binoy
Reply all
Reply to author
Forward
0 new messages