On Thu, Apr 25, 2013 at 2:24 PM, Jianhua Shao <[email protected]> wrote:
> On Thu, Apr 25, 2013 at 1:58 PM, Emmanuel Rodriguez < > [email protected]> wrote: > >> On 25 April 2013 03:37, Jianhua Shao <[email protected]> wrote: >> >>> On Thu, Apr 25, 2013 at 5:32 AM, Emmanuel Rodriguez < >>> [email protected]> wrote: >>> >>>> >>>> >>>> Thanks for sharing your experience. >>>> >>> 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. >>> Seems I can give a try on version 1.7.x. >>> >> I just ment to try it and see if the transparencies where still enabled >> in 1.6.3 >> >> >>> >>> And have you read my another mail, >>> >>> cairo_surface_t* surface = webkit_web_view_get_snapshot(view); >>> cairo_surface_write_to_png(surface, "/home/meego/dump.png"); >>> >>> will result a transparent png file... >>> Maybe I need to do some configuration on cario/gtk, but I am new on this >>> subject, anyone can give me some hint? >>> >> >> 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(). >> >> In 1.6.3 the draw operation is done with: >> >> static void paintWebView(Frame* frame, gboolean transparent, >> GraphicsContext& context, const IntRect& clipRect, const Vector<IntRect>& >> rects) >> { >> bool coalesce = true; >> >> if (rects.size() > 0) >> coalesce = shouldCoalesce(clipRect, rects); >> >> if (coalesce) { >> context.clip(clipRect); >> if (transparent) >> context.clearRect(clipRect); >> frame->view()->paint(&context, clipRect); >> } else { >> for (size_t i = 0; i < rects.size(); i++) { >> IntRect rect = rects[i]; >> context.save(); >> context.clip(rect); >> if (transparent) >> context.clearRect(rect); >> frame->view()->paint(&context, rect); >> context.restore(); >> } >> } >> >> context.save(); >> context.clip(clipRect); >> frame->page()->inspectorController()->drawHighlight(context); >> context.restore(); >> } >> >> >> In 1.10.2 webkit_web_view_get_snapshot is done with: >> >> cairo_surface_t* >> webkit_web_view_get_snapshot(WebKitWebView* webView) >> { >> g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); >> >> Frame* frame = core(webView)->mainFrame(); >> if (!frame || !frame->contentRenderer() || !frame->view()) >> return 0; >> >> frame->view()->updateLayoutAndStyleIfNeededRecursive(); >> GtkAllocation allocation; >> gtk_widget_get_allocation(GTK_WIDGET(webView), &allocation); >> cairo_surface_t* surface = >> cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, >> allocation.height); >> RefPtr<cairo_t> cr = adoptRef(cairo_create(surface)); >> GraphicsContext gc(cr.get()); >> >> IntRect rect = allocation; >> gc.applyDeviceScaleFactor(frame->page()->deviceScaleFactor()); >> gc.save(); >> gc.clip(rect); >> if (webView->priv->transparent) >> gc.clearRect(rect); >> frame->view()->paint(&gc, rect); >> gc.restore(); >> >> return surface; >> } >> >> >> Both functions have the same drawing logic: >> >> context.clip(clipRect); >> if (transparent) >> context.clearRect(clipRect); >> frame->view()->paint(&context, clipRect); >> context.restore(); >> >> Wit the exception that webkit_web_view_get_snapshot() forces the drawing >> into an image surface except of accepting a cairo context. >> >> Yeah, I have modified "webkit_web_view_expose_event" (the > webkit_web_view_draw thing for gtk2), and I have made it transparent now. > > Then I tried setting 'enable-accelerated-compositing' flag. the result > page I got is not correct. The appearance is a little wired I think. > 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. > > The issue exists even if I did not modify "webkit_web_view_expose_event". > > Now I am trying to figure out whether something wrong with > "WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface()". > > Here I conclude what has been modified in webkit_web_view_expose_event. 1. create a GraphicsContext, and call gc.clearRect() on gtkwidget's cario surface if transparent flag is set. This modification will give me a transparent web page. 2. I print the size of backingStore cario_surface, I found if 'enable-accelerated-compositing' flag is set, 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... 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." > -- >> Emmanuel Rodriguez >> > >
_______________________________________________ webkit-gtk mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-gtk
