<?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>33164</bug_id>
          
          <creation_ts>2010-01-04 11:47:08 -0800</creation_ts>
          <short_desc>[WinCairo] Improper Cairo Surface Type Sometimes Used</short_desc>
          <delta_ts>2010-01-04 12:29:55 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</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="Brent Fulgham">bfulgham</reporter>
          <assigned_to name="Brent Fulgham">bfulgham</assigned_to>
          <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>176781</commentid>
    <comment_count>0</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2010-01-04 11:47:08 -0800</bug_when>
    <thetext>I tracked down the cause of an annoying ASSERTION hit during some WebKit operations when running under the WinCairo port.  WebKit would assert when checking that the target bitsPerPixel was 32.

This was caused by two cases:
(1) Sometimes a device context to a 24-bits-per-pixel context was being used (for example, when printing).
(2) Sometimes a new device context was passed that did not have a corresponding (existing) bitmap that could be selected from &apos;GetCurrentObject&apos;.

In the second case, the bitmap structure returned by GetObject was filled with garbage, causing the assertion and possibly causing construction of extremely large image surfaces (as the info.bmWidth/bmHeight field were filled in with uninitialized data).

This patch corrects both problems by confirming that a valid bitmap handle is returned by GetCurrentObject, and falling back to the default cairo_win32_surface_create method, which constructs a standard GDI-compatible 24-bits-per-pixel surface from a raw device context handle.

We only want to pay the price of a 32-bit cairo surface for rendering when its needed, otherwise we take no advantage of native GDI drawing operations inside Cairo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>176784</commentid>
    <comment_count>1</comment_count>
      <attachid>45811</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2010-01-04 11:53:57 -0800</bug_when>
    <thetext>Created attachment 45811
Check bitmap validity, only construct 32-bit surface when needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>176785</commentid>
    <comment_count>2</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2010-01-04 11:56:15 -0800</bug_when>
    <thetext>style-queue ran check-webkit-style on attachment 45811 without any errors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>176792</commentid>
    <comment_count>3</comment_count>
      <attachid>45811</attachid>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2010-01-04 12:08:13 -0800</bug_when>
    <thetext>Comment on attachment 45811
Check bitmap validity, only construct 32-bit surface when needed.

&gt; +    if (!GetObject(bitmap, sizeof(info), &amp;info))
&gt; +        surface = cairo_win32_surface_create(hdc);

Does this surface have an associated bitmap? Do we need to select it into the DC?

Please add a link to this bug in the ChangeLog.

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>176803</commentid>
    <comment_count>4</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2010-01-04 12:24:47 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 45811 [details])
&gt; &gt; +    if (!GetObject(bitmap, sizeof(info), &amp;info))
&gt; &gt; +        surface = cairo_win32_surface_create(hdc);
&gt; 
&gt; Does this surface have an associated bitmap? Do we need to select it into the
&gt; DC?
&gt; 
&gt; Please add a link to this bug in the ChangeLog.
&gt; 
&gt; r=me

No, the created surface references whatever is currently in the DC.  The only reason for the second path is to create a 32-bit image bitmap backing store so that alpha effects can be handled properly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>176805</commentid>
    <comment_count>5</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2010-01-04 12:29:40 -0800</bug_when>
    <thetext>Landed in http://trac.webkit.org/changeset/52752.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>45811</attachid>
            <date>2010-01-04 11:53:57 -0800</date>
            <delta_ts>2010-01-04 12:08:13 -0800</delta_ts>
            <desc>Check bitmap validity, only construct 32-bit surface when needed.</desc>
            <filename>context_fix.patch</filename>
            <type>text/plain</type>
            <size>2329</size>
            <attacher name="Brent Fulgham">bfulgham</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA1Mjc1MSkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTUgQEAKKzIwMTAtMDEtMDQgIEJyZW50IEZ1bGdoYW0gIDxiZnVsZ2hhbUB3ZWJr
aXQub3JnPgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAg
IENvcnJlY3QgZGVidWcgYXNzZXJ0aW9uIChhbmQgcG9zc2libGUgcnVudGltZSBlcnJvcnMpIGJ5
CisgICAgICAgIGNoZWNraW5nIHZhbGlkaXR5IG9mIGJpdG1hcCBzZXR0aW5ncyB1c2VkIHRvIGNy
ZWF0ZQorICAgICAgICB0aGUgV2luZG93cyBDYWlybyBjb250ZXh0cy4KKworICAgICAgICAqIHBs
YXRmb3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gICAg
IGluZm8uYm1XaWR0aEJ5dGVzKTsKKyAgICB9CiAKLSAgICBjYWlyb190KiBjb250ZXh0ID0gY2Fp
cm9fY3JlYXRlKGltYWdlKTsKLSAgICBjYWlyb19zdXJmYWNlX2Rlc3Ryb3koaW1hZ2UpOworICAg
IGNhaXJvX3QqIGNvbnRleHQgPSBjYWlyb19jcmVhdGUoc3VyZmFjZSk7CisgICAgY2Fpcm9fc3Vy
ZmFjZV9kZXN0cm95KHN1cmZhY2UpOwogCiAgICAgcmV0dXJuIGNvbnRleHQ7CiB9Cg==
</data>
<flag name="review"
          id="27948"
          type_id="1"
          status="+"
          setter="aroben"
    />
          </attachment>
      

    </bug>

</bugzilla>