<?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>67054</bug_id>
          
          <creation_ts>2011-08-26 13:02:59 -0700</creation_ts>
          <short_desc>Allow canvas backing store to be lazily allocated</short_desc>
          <delta_ts>2011-10-04 11:40:38 -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>Canvas</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Matthew Delaney">mdelaney7</reporter>
          <assigned_to name="Matthew Delaney">mdelaney7</assigned_to>
          <cc>mdelaney7</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>457715</commentid>
    <comment_count>0</comment_count>
    <who name="Matthew Delaney">mdelaney7</who>
    <bug_when>2011-08-26 13:02:59 -0700</bug_when>
    <thetext>I noticed that the lazy construction of a canvas (i.e. lazy allocation of backing store, etc.) is thwarted by setting the lineWidth in the CRC2D ctor. This was added in https://bugs.webkit.org/show_bug.cgi?id=26187 to rectify the issue that skia and cairo graphics contexts start with linewidth equal to 0 and 2 respectively where canvas needs them to be 1.

I imagine there&apos;s a better solution here that allows us to continue to have lazy construction/allocation for canvas. In particular, the case that sucks is when a page creates a bunch of canvases (e.g. pages that use cufonts), then get their 2d contexts, then resize the canvases, then use them. This has each canvas getting a 300x150 backing store created then throw right away once the width/height are changed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>457716</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2011-08-26 13:03:54 -0700</bug_when>
    <thetext>&lt;rdar://problem/10031538&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>477285</commentid>
    <comment_count>2</comment_count>
      <attachid>109540</attachid>
    <who name="Matthew Delaney">mdelaney7</who>
    <bug_when>2011-10-03 15:25:54 -0700</bug_when>
    <thetext>Created attachment 109540
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>477288</commentid>
    <comment_count>3</comment_count>
    <who name="Matthew Delaney">mdelaney7</who>
    <bug_when>2011-10-03 15:30:07 -0700</bug_when>
    <thetext>For the record, setting lineWidth() ends up grabbing the graphics context of the ImageBuffer to set the line width on. Grabbing the graphics context requires creation of the ImageBuffer.

Instead, I added the line width setter call to createImageBuffer alongside the other setter calls for other default settings. This ensures the platform graphics context gets the correct default value (for all platforms) and removes the dependency between HTMLCanvasElement creation and ImageBuffer creation which was time consuming and often a waste of memory (when the width and height were called shortly thereafter in most cases).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>477291</commentid>
    <comment_count>4</comment_count>
      <attachid>109540</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2011-10-03 15:33:06 -0700</bug_when>
    <thetext>Comment on attachment 109540
Patch

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

r=me on this; it’s OK to land this as is, but I think the fix isn’t quite right

&gt; Source/WebCore/ChangeLog:3
&gt; +        Investigate removing lineWidth() from CanvasRenderingContext2D.cpp&apos;s ctor

This is a really confusing name for the patch!

The patch itself seems clearly like a good idea.

&gt; Source/WebCore/html/HTMLCanvasElement.cpp:461
&gt; +    m_imageBuffer-&gt;context()-&gt;setStrokeThickness(1);

It seems to me that it’s a bug that the a GraphicsContext starts with a stroke thickness that is platform-dependent. I understand that the different graphics libraries have different defaults, but the point of the platform layer is to abstract away such differences. The code that sets the thickness to 1 should be in the platform directory instead of here in the canvas code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>477805</commentid>
    <comment_count>5</comment_count>
    <who name="Matthew Delaney">mdelaney7</who>
    <bug_when>2011-10-04 11:40:38 -0700</bug_when>
    <thetext>Committed r96624: &lt;http://trac.webkit.org/changeset/96624&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>109540</attachid>
            <date>2011-10-03 15:25:54 -0700</date>
            <delta_ts>2011-10-03 15:33:05 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-67054-20111003152554.patch</filename>
            <type>text/plain</type>
            <size>2402</size>
            <attacher name="Matthew Delaney">mdelaney7</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDk2NTQ3KQorKysgU291cmNlL1dlYkNvcmUvQ2hhbmdl
TG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTggQEAKKzIwMTEtMTAtMDMgIE1hdHRoZXcg
RGVsYW5leSAgPG1kZWxhbmV5QGFwcGxlLmNvbT4KKworICAgICAgICBJbnZlc3RpZ2F0ZSByZW1v
dmluZyBsaW5lV2lkdGgoKSBmcm9tIENhbnZhc1JlbmRlcmluZ0NvbnRleHQyRC5jcHAncyBjdG9y
CisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD02NzA1NAor
CisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgIC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kFCTEUoREFTSEJPQVJEX1NVUFBPUlQpCiAgICAgQVNTRVJUX1VOVVNFRCh1c2VzRGFz
aGJvYXJkQ29tcGF0aWJpbGl0eU1vZGUsICF1c2VzRGFzaGJvYXJkQ29tcGF0aWJpbGl0eU1vZGUp
OwogI2VuZGlmCi0KLSAgICAvLyBNYWtlIHN1cmUgdGhhdCBldmVuIGlmIHRoZSBkcmF3aW5nQ29u
dGV4dCgpIGhhcyBhIGRpZmZlcmVudCBkZWZhdWx0Ci0gICAgLy8gdGhpY2tuZXNzLCBpdCBpcyBp
biBzeW5jIHdpdGggdGhlIGNhbnZhcyB0aGlja25lc3MuCi0gICAgc2V0TGluZVdpZHRoKGxpbmVX
aWR0aCgpKTsKIH0KIAogdm9pZCBDYW52YXNSZW5kZXJpbmdDb250ZXh0MkQ6OnVud2luZFN0YXRl
U3RhY2soKQo=
</data>
<flag name="review"
          id="106798"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>