<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 25, 2013 at 2:24 PM, Jianhua Shao <span dir="ltr"><<a href="mailto:alex.sjh@gmail.com" target="_blank">alex.sjh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 25, 2013 at 1:58 PM, Emmanuel Rodriguez <span dir="ltr"><<a href="mailto:emmanuel.rodriguez@gmail.com" target="_blank">emmanuel.rodriguez@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>On 25 April 2013 03:37, Jianhua Shao <span dir="ltr"><<a href="mailto:alex.sjh@gmail.com" target="_blank">alex.sjh@gmail.com</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div>On Thu, Apr 25, 2013 at 5:32 AM, Emmanuel Rodriguez <span dir="ltr"><<a href="mailto:emmanuel.rodriguez@gmail.com" target="_blank">emmanuel.rodriguez@gmail.com</a>></span> wrote:<br>
</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">
<div><span style="color:rgb(34,34,34)">Thanks for sharing your experience. </span><br></div></div></div></div></blockquote></div></div></div><div><div>The version 1.6.3 does not meet my requirements. "enable-accelerated-compositing" is what I need in the newer version, from the dev document I found it is available from version 1.7.5.<br>
Seems I can give a try on version 1.7.x.<br></div></div></div></div></div></blockquote><div>I just ment to try it and see if the transparencies where still enabled in 1.6.3</div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>And have you read my another mail, <br><br>cairo_surface_t* surface = webkit_web_view_get_snapshot(view);<br><div dir="ltr">cairo_surface_write_to_png(surface, "/home/meego/dump.png");<br>
<br>will result a transparent png file...<br>Maybe I need to do some configuration on cario/gtk, but I am new on this subject, anyone can give me some hint?</div></div></div></div></div></blockquote><div><br></div>
</div><div>By the looks of the code of 1.6.3 and 1.10.2 it seems that webkit_web_view_get_snapshot() behaves like the old webkit_web_view_draw().<br></div><div><br></div><div>In 1.6.3 the draw operation is done with:</div>
<div><br></div><div><div>static void paintWebView(Frame* frame, gboolean transparent, GraphicsContext& context, const IntRect& clipRect, const Vector<IntRect>& rects)</div><div>{</div><div> bool coalesce = true;</div>
<div><br></div><div> if (rects.size() > 0)</div><div> coalesce = shouldCoalesce(clipRect, rects);</div><div><br></div><div> if (coalesce) {</div><div> context.clip(clipRect);</div><div> if (transparent)</div>
<div> context.clearRect(clipRect);</div><div> frame->view()->paint(&context, clipRect);</div><div> } else {</div><div> for (size_t i = 0; i < rects.size(); i++) {</div><div> IntRect rect = rects[i];</div>
<div> context.save();</div><div> context.clip(rect);</div><div> if (transparent)</div><div> context.clearRect(rect);</div><div> frame->view()->paint(&context, rect);</div>
<div> context.restore();</div><div> }</div><div> }</div><div><br></div><div> context.save();</div><div> context.clip(clipRect);</div><div> frame->page()->inspectorController()->drawHighlight(context);</div>
<div> context.restore();</div><div>}</div><div><br></div><div><br></div></div><div>In 1.10.2 webkit_web_view_get_snapshot is done with:</div><div><br></div><div><div>cairo_surface_t*</div><div>webkit_web_view_get_snapshot(WebKitWebView* webView)</div>
<div>{</div><div> g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);</div><div><br></div><div> Frame* frame = core(webView)->mainFrame();</div><div> if (!frame || !frame->contentRenderer() || !frame->view())</div>
<div> return 0;</div><div><br></div><div> frame->view()->updateLayoutAndStyleIfNeededRecursive();</div><div> GtkAllocation allocation;</div><div> gtk_widget_get_allocation(GTK_WIDGET(webView), &allocation);</div>
<div> cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height);</div><div> RefPtr<cairo_t> cr = adoptRef(cairo_create(surface));</div><div> GraphicsContext gc(cr.get());</div>
<div><br></div><div> IntRect rect = allocation;</div><div> gc.applyDeviceScaleFactor(frame->page()->deviceScaleFactor());</div><div> gc.save();</div><div> gc.clip(rect);</div><div> if (webView->priv->transparent)</div>
<div> gc.clearRect(rect);</div><div> frame->view()->paint(&gc, rect);</div><div> gc.restore();</div><div><br></div><div> return surface;</div><div>}</div><div><br></div></div><div><br></div>
<div>Both functions have the same drawing logic:</div><div><br></div><div><div> context.clip(clipRect);</div><div> if (transparent)</div><div> context.clearRect(clipRect);</div><div>
frame->view()->paint(&context, clipRect);</div><div> context.restore();<br></div></div><div><br></div><div>Wit the exception that webkit_web_view_get_snapshot() forces the drawing into an image surface except of accepting a cairo context.</div>
<span><font color="#888888">
<div><br></div></font></span></div></div></div></blockquote><div>Yeah, I have modified "webkit_web_view_expose_event" (the webkit_web_view_draw thing for gtk2), and I have made it transparent now.<br><br>Then I tried setting 'enable-accelerated-compositing' flag. the result page I got is not correct. The appearance is a little wired I think.<br>
Firstly, a correct page shows up, then immediately after that (I mean, maybe 0.1 second after that), the page turns gray in most part, and stay at gray.<br><br>The issue exists even if I did not modify "webkit_web_view_expose_event".<br>
<br>Now I am trying to figure out whether something wrong with "WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface()".<span class=""><font color="#888888"><br><br></font></span></div></div></div>
</div></blockquote><div> </div><div>Here I conclude what has been modified in webkit_web_view_expose_event.<br>1. create a GraphicsContext, and call gc.clearRect() on gtkwidget's cario surface if transparent flag is set.<br>
This modification will give me a transparent web page.<br>2. I print the size of backingStore cario_surface, I found if 'enable-accelerated-compositing' flag is set,<br> the size of the backingstore cario_surface sometimes would be 1x1. Which means, the whole page will be cleared, and then it is written by just 1 pixel...<br>
I guess this is the reason why "Firstly, a correct page shows up, then immediately after that (I mean,
maybe 0.1 second after that), the page turns gray in most part, and stay
at gray."<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>
<span class=""><font color="#888888"><br></font></span></div><span class=""><font color="#888888"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><font color="#888888"><div></div><div>-- <br></div></font></span></div><span><font color="#888888">Emmanuel Rodriguez
</font></span></div></div>
</blockquote></font></span></div><br></div></div>
</blockquote></div><br></div></div>