Refactor gfxFont to separate out drawing stroke and drawing to path

RESOLVED FIXED in mozilla12



8 years ago
7 years ago


(Reporter: eflores, Assigned: eflores)


Dependency tree / graph

Firefox Tracking Flags

(Not tracked)



(1 attachment, 4 obsolete attachments)

Posted patch Patch (obsolete) — Splinter Review
Attachment #581522 - Flags: review?(roc)
+            mTextRun->Draw(mThebes,
+                           point,
+                           gfxFont::GLYPH_STROKE,
+                           0,
+                           mTextRun->GetLength(),
+                           nsnull,
+                           nsnull);
             // mOp == TEXT_DRAW_OPERATION_FILL
+                           gfxFont::GLYPH_FILL,

Combine these into a single Draw call with a conditional expression for the flags.

+        if (aDrawMode == gfxFont::GLYPH_FILL)
+            DrawPartialLigature(font, aContext, start, ligatureRunStart, &pt, aProvider);

+        if (aDrawMode == gfxFont::GLYPH_FILL)
+            DrawPartialLigature(font, aContext, ligatureRunEnd, end, &pt, aProvider);

{} around if body

Not being able to draw partial ligatures with stroking sucks a bit, but we'll deal I guess. We could pass the draw mode into DrawPartialLigature, which draws the glyph with some clipping to cut it up into pieces, but that wouldn't work well with stroking.

+    typedef enum {
+        GLYPH_FILL      = 1,
+        GLYPH_STROKE    = 2,
+        GLYPH_PATH      = 4
+    } DrawMode;

Need to document that GLYPH_FILL and GLYPH_STROKE can be used together, but they can't be used with GLYPH_PATH. Actually, add NS_ASSERTIONs about that to gfxTextRun:::Draw and gfxFont::Draw. Also document that GLYPH_STROKE destroys the current path in the context.

Otherwise looks good!! Please post a new patch.
+        GLYPH_FILL      = 1,
+        GLYPH_STROKE    = 2,
+        GLYPH_PATH      = 4

Also the indenting before = is unnecessary.
CCing font guys for feedback.

This is a relatively simple change to avoid using text-to-path when we just need to stroke the text. We're doing this so that when we introduce fonts with SVG glyphs, stroking can work well. (It's difficult/impossible to get a path for an SVG glyph in general.)
Posted patch Patch #2 (obsolete) — Splinter Review
Attachment #581522 - Attachment is obsolete: true
Attachment #581522 - Flags: review?(roc)
Attachment #581791 - Flags: review?
Attachment #581791 - Flags: review? → review?(roc)
Comment on attachment 581791 [details] [diff] [review]
Patch #2

Review of attachment 581791 [details] [diff] [review]:

Good stuff!

::: content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ +2796,5 @@
>          }
> +        mTextRun->Draw(mThebes,
> +                       point,
> +                       mOp == nsCanvasRenderingContext2D::TEXT_DRAW_OPERATION_STROKE ? gfxFont::GLYPH_STROKE : gfxFont::GLYPH_FILL,

80 column line limit
Attachment #581791 - Flags: review?(roc)
Attachment #581791 - Flags: review+
Attachment #581791 - Flags: checkin?
Backed out on inbound (along with other patches in the same push) because of Mac and Win7 reftest failures:
Whiteboard: [inbound]

REFTEST TEST-UNEXPECTED-FAIL | file:///c:/talos-slave/test/build/reftest/tests/layout/reftests/scrolling/iframe-border-radius.html | image comparison (==) 

The test failure is caused by the reference stroking all three characters at once, while the test strokes the characters individually. This gives different rendering when the strokes on the characters partially overlap. I'm not sure why this patch changed the behavior here, but we can probably work around it by putting spaces between the characters in the tests so they don't overlap.
My guess at the problem was also wrong.

My next guess is that Quartz and D2D are rasterizing path("ABC") differently from path("A") U path("B") U path("C") even where the glyphs don't overlap.
Posted file Patch #3 (obsolete) —
Just updates the reftest. Draws each letter separately to get rid of weird (negligible) artefacts from drawing more than one glyph at a time.
Attachment #581791 - Attachment is obsolete: true
Attachment #581791 - Flags: checkin?
Attachment #582732 - Flags: review?(roc)
Hmm, ignore that last patch
Posted patch Patch Numero Quattro (obsolete) — Splinter Review
Again, just updated the failing reftest.
Attachment #582732 - Attachment is obsolete: true
Attachment #582732 - Flags: review?(roc)
Attachment #582738 - Flags: review?(roc)
Attachment #582738 - Attachment is obsolete: true
Attachment #589664 - Flags: review?(roc)
Last Resolved: 7 years ago
Resolution: --- → FIXED
Comment on attachment 589664 [details] [diff] [review]
Same patch, just rebased

>--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
>+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
>+    bool doUseIntermediateSurface = NeedToUseIntermediateSurface()
>+        || NeedIntermediateSurfaceToHandleGlobalAlpha(style);

Note: we put || at the end of the line, not at the start.


7 years ago
Depends on: 745676


7 years ago
Depends on: 771853
You need to log in before you can comment on or make changes to this bug.