<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>24687</bug_id>
          
          <creation_ts>2009-03-18 17:01:54 -0700</creation_ts>
          <short_desc>Gradient text in canvas not working on chromium/skia.</short_desc>
          <delta_ts>2009-03-20 09:39:54 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Text</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Stephen White">senorblanco</reporter>
          <assigned_to name="Stephen White">senorblanco</assigned_to>
          <cc>eric</cc>
    
    <cc>krit</cc>
    
    <cc>senorblanco</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>114256</commentid>
    <comment_count>0</comment_count>
    <who name="Stephen White">senorblanco</who>
    <bug_when>2009-03-18 17:01:54 -0700</bug_when>
    <thetext>Gradient text in canvas is not working on chromium/skia: the gradient is there, but is not scaled correctly (is solid colour, should be gradient).  See LayoutTest/fast/canvas/canvas-text-alignment.html.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114258</commentid>
    <comment_count>1</comment_count>
      <attachid>28739</attachid>
    <who name="Stephen White">senorblanco</who>
    <bug_when>2009-03-18 17:09:19 -0700</bug_when>
    <thetext>Created attachment 28739
Fix for canvas text gradient problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114284</commentid>
    <comment_count>2</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2009-03-19 00:04:44 -0700</bug_when>
    <thetext>&gt; +#if PLATFORM(CG)
&gt;      if (boundingBoxMode() &amp;&amp; !isPaintingText) {
&gt; +#else
&gt; +    if (boundingBoxMode()) {
&gt; +#endif

It&apos;s not just CG, that uses this code. Please just use 

#if !PLATFORM(SKIA)
    if (boundingBoxMode() &amp;&amp; !isPaintingText) {
#else
    if (boundingBoxMode()) {
#endif

if it is necessary. I think you will break some tests of batik. Have you checked this?
And the special skia code, that we have in SVGPaintServer, is just needed for fillAndStrokePath. (btw. this can be fixed by closing the path after filling or stroking inf gc:fillPath() and gc::strokePath()).

I&apos;m still not sure if I get the problem. Gradients don&apos;t work for Skia in Canvas, right? And you fix SVG, because the transformation matrix is applied twice for Canvas. Wehre (beside SkiaFontWin.cpp) and why?

To add more platform code to SVG is maybe not the best way and it can break some tests. Can we fix in internally?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114313</commentid>
    <comment_count>3</comment_count>
    <who name="Stephen White">senorblanco</who>
    <bug_when>2009-03-19 08:33:00 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; &gt; +#if PLATFORM(CG)
&gt; &gt;      if (boundingBoxMode() &amp;&amp; !isPaintingText) {
&gt; &gt; +#else
&gt; &gt; +    if (boundingBoxMode()) {
&gt; &gt; +#endif
&gt; 
&gt; It&apos;s not just CG, that uses this code. Please just use 
&gt; 
&gt; #if !PLATFORM(SKIA)
&gt;     if (boundingBoxMode() &amp;&amp; !isPaintingText) {
&gt; #else
&gt;     if (boundingBoxMode()) {
&gt; #endif
&gt; 
&gt; if it is necessary. I think you will break some tests of batik. Have you
&gt; checked this?

There were no regressions in the batik tests on Chromium on Win32 or Webkit on Mac.

I&apos;m pretty sure that those other platforms will need this matrix in order to
do gradient text correctly.  It&apos;s only CG that won&apos;t need it, since it uses the gradient later in teardown() to fill a rect.  I can change it to be skia-only,
if you still want, but I&apos;m pretty sure you&apos;re going to need this matrix for Cairo as well (I&apos;m assuming that&apos;s what you&apos;re worried about).

&gt; And the special skia code, that we have in SVGPaintServer, is just needed for
&gt; fillAndStrokePath. (btw. this can be fixed by closing the path after filling or
&gt; stroking inf gc:fillPath() and gc::strokePath()).

You&apos;re saying that we could remove the skia-specific code in SVGPaintServer?
That sounds good, but is orthogonal to this patch.

&gt; I&apos;m still not sure if I get the problem. Gradients don&apos;t work for Skia in
&gt; Canvas, right? And you fix SVG, because the transformation matrix is applied
&gt; twice for Canvas. Wehre (beside SkiaFontWin.cpp) and why?

Basically, the correct way to do gradient text is to scale up the gradient to 
the appropriate size (the bounding box, in this case) before rendering the text.
Canvas was already doing that (m_p0 was 0,0 and m_p1 was 600,600 in this test),
so when I added code in a previous CL to scale up the gradient in SkiaFontWin, it was getting scaled twice.  So I removed my previous code to scale the
gradient (in SkiaFontWin), and allowed the SVG path to set the matrix from 
the bounding box instead.

&gt; To add more platform code to SVG is maybe not the best way and it can break
&gt; some tests. Can we fix in internally?

I don&apos;t think there&apos;s any other way to fix it, since the lower-level 
rendering code needs that bounding box in order to correctly scale the 
gradient.  And the lower level doesn&apos;t know if it has been already set
(as in the canvas case) or unset (as in the SVG case).  The only reason 
CG doesn&apos;t need the matrix is that it doesn&apos;t use the gradient during 
text rendering; it applies it in teardown().

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114334</commentid>
    <comment_count>4</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2009-03-19 10:33:47 -0700</bug_when>
    <thetext>I got it. Yes the current code in SVGPaintServerGradient does only work for CG correctly. Your patch is ok. :-). eseidel? r+?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114376</commentid>
    <comment_count>5</comment_count>
      <attachid>28739</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-03-19 14:40:54 -0700</bug_when>
    <thetext>Comment on attachment 28739
Fix for canvas text gradient problem.

Looks fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114502</commentid>
    <comment_count>6</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-03-20 09:38:05 -0700</bug_when>
    <thetext>I expect this will break qt/gtk pixel results (if those exist), but I have no easy way to update those, and from what I can tell from Dirk and Stephen this will be a progression for both sets of results.

Also, Stephen, be sure to add the bug URL to the ChangeLog in the future. ;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114503</commentid>
    <comment_count>7</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-03-20 09:39:54 -0700</bug_when>
    <thetext>Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebCore/ChangeLog
	M	WebCore/platform/graphics/skia/SkiaFontWin.cpp
	M	WebCore/svg/graphics/SVGPaintServerGradient.cpp
Committed r41860

Thanks again for the patch!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>28739</attachid>
            <date>2009-03-18 17:09:19 -0700</date>
            <delta_ts>2009-03-19 14:40:54 -0700</delta_ts>
            <desc>Fix for canvas text gradient problem.</desc>
            <filename>canvas-gradient-text.patch</filename>
            <type>text/plain</type>
            <size>3718</size>
            <attacher name="Stephen White">senorblanco</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA0MTgxOCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMjIgQEAKKzIwMDktMDMtMTggIFN0ZXBoZW4gV2hpdGUgIDxzZW5vcmJsYW5jb0Bj
aHJvbWl1bS5vcmc+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgT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24ndCB1c2UgZ3JhZGllbnRzIGZvciAx
ZCBvYmplY3RzIGxpa2UgaG9yaXpvbnRhbC92ZXJ0aWNhbCAKICAgICAgICAgLy8gbGluZXMgb3Ig
cmVjdGFuZ2xlcyB3aXRob3V0IHdpZHRoIG9yIGhlaWdodC4KICAgICAgICAgaWYgKGJib3gud2lk
dGgoKSA9PSAwIHx8IGJib3guaGVpZ2h0KCkgPT0gMCkgewogICAgICAgICAgICAgQ29sb3IgY29s
b3IoMCwgMCwgMCk7Cg==
</data>
<flag name="review"
          id="14169"
          type_id="1"
          status="+"
          setter="eric"
    />
          </attachment>
      

    </bug>

</bugzilla>