Bug 101883 - [TexMap][Cairo] Accelerated compositing debug visuals
Summary: [TexMap][Cairo] Accelerated compositing debug visuals
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-11 18:58 PST by Helder Correia
Modified: 2012-11-14 15:24 PST (History)
7 users (show)

See Also:


Attachments
Patch (6.05 KB, patch)
2012-11-11 19:16 PST, Helder Correia
no flags Details | Formatted Diff | Diff
Fix style (6.10 KB, patch)
2012-11-14 14:19 PST, Helder Correia
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Helder Correia 2012-11-11 18:58:08 PST
Add a Cairo implementation to complement the patch from bug 90116.
Comment 1 Helder Correia 2012-11-11 19:16:01 PST
Created attachment 173539 [details]
Patch
Comment 2 WebKit Review Bot 2012-11-11 19:17:47 PST
Attachment 173539 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:44:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Viatcheslav Ostapenko 2012-11-14 13:53:02 PST
Comment on attachment 173539 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173539&action=review

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:365
> +    cairo_set_source_rgb(cr, 1, 0, 0);

Qt has comment about blue color that it will turn red because R+B are not swapped. 
Will it result blue or red here? If it will result in different color from specified, IMHO, it requires comment here.

> Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp:114
> +    return (String(getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS")) == "1");

Should we use EFL prefix as Qt does?
Comment 4 Noam Rosenthal 2012-11-14 13:56:57 PST
> > Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp:114
> > +    return (String(getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS")) == "1");
> 
> Should we use EFL prefix as Qt does?
I don't think that's needed, since Cairo is not EFL specific.
Comment 5 Martin Robinson 2012-11-14 13:58:44 PST
Comment on attachment 173539 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173539&action=review

Looks sane to me.

>> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:365
>> +    cairo_set_source_rgb(cr, 1, 0, 0);
> 
> Qt has comment about blue color that it will turn red because R+B are not swapped. 
> Will it result blue or red here? If it will result in different color from specified, IMHO, it requires comment here.

You probably want to do the same thing as Qt above here.

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:372
> +    cairo_move_to(cr, 2, pointSize);

Is this 2 pixels just padding?
Comment 6 Helder Correia 2012-11-14 14:00:49 PST
(In reply to comment #3)
> You probably want to do the same thing as Qt above here.

For Cairo, this patch will paint in red, just like the code above for Qt.

> Is this 2 pixels just padding?

Yes, could be anything.
Comment 7 Viatcheslav Ostapenko 2012-11-14 14:12:14 PST
(In reply to comment #6)
> (In reply to comment #3)
> > You probably want to do the same thing as Qt above here.
> 
> For Cairo, this patch will paint in red, just like the code above for Qt.

Yes, it seems it will be red, because updateContents always swizzles.
Comment 8 Helder Correia 2012-11-14 14:19:06 PST
Created attachment 174259 [details]
Fix style
Comment 9 Kenneth Rohde Christiansen 2012-11-14 14:30:27 PST
Comment on attachment 174259 [details]
Fix style

View in context: https://bugs.webkit.org/attachment.cgi?id=174259&action=review

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:357
> +    // cairo_text_extents() requires a cairo_t, so dimensions need to be guesstimated.

no way of getting hold of that?

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:361
> +    cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);

why not use RefPtr they work for cairo_surface_t! etc

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:362
> +    cairo_t* cr = cairo_create(surface);

Here you have one, a bit too late :)

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:363
> +    cairo_surface_destroy(surface);

Is this safe here? cr stays valid?
Comment 10 Helder Correia 2012-11-14 14:39:16 PST
(In reply to comment #9)
> (From update of attachment 174259 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=174259&action=review
> 
> > Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:357
> > +    // cairo_text_extents() requires a cairo_t, so dimensions need to be guesstimated.
> 
> no way of getting hold of that?

AFAIK no. We need the width and height to create the surface, which we need to create the context, which we need to use the text extents, which we need to create the surface in the first place. In Qt, QFontMetrics don't need a QPainter. There might be a way in Cairo, but I'm not aware of it. Of course I could create a separate context just for the purpose, but I think there's no point.
 
> > Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:361
> > +    cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
> 
> why not use RefPtr they work for cairo_surface_t! etc

I know, I chose to explicitly destroy it locally with no smart pointer allocation because its life cycle is pretty tiny and controlled.

> > Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:363
> > +    cairo_surface_destroy(surface);
> 
> Is this safe here? cr stays valid?

From http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-create :

"This function references target, so you can immediately call cairo_surface_destroy() on it if you don't need to maintain a separate reference to it."
Comment 11 WebKit Review Bot 2012-11-14 15:03:11 PST
Comment on attachment 174259 [details]
Fix style

Clearing flags on attachment: 174259

Committed r134676: <http://trac.webkit.org/changeset/134676>
Comment 12 WebKit Review Bot 2012-11-14 15:03:15 PST
All reviewed patches have been landed.  Closing bug.
Comment 13 Yael 2012-11-14 15:24:00 PST
Can this new code be combined with TextureMapperLayer::drawRepaintCounter somehow?