Unreviewed build fix for Windows (Cairo).
authorbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Oct 2009 20:51:50 +0000 (20:51 +0000)
committerbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Oct 2009 20:51:50 +0000 (20:51 +0000)
Provide implementation of new BitmapImage::create that was
added in @r49060.

* platform/graphics/win/ImageCairoWin.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@49260 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/win/ImageCairoWin.cpp

index 0391fb6..6d591e8 100644 (file)
@@ -1,3 +1,12 @@
+2009-10-07  Brent Fulgham  <bfulgham@webkit.org>
+
+        Unreviewed build fix for Windows (Cairo).
+
+        Provide implementation of new BitmapImage::create that was
+        added in @r49060.
+
+        * platform/graphics/win/ImageCairoWin.cpp:
+
 2009-10-07  Andrew Scherkus  <scherkus@chromium.org>
 
         Reviewed by Eric Carlson.
index 591375f..0b27438 100644 (file)
 #include "BitmapImage.h"
 #include "GraphicsContext.h"
 #include <cairo.h>
+#include <cairo-win32.h>
 
 #include <windows.h>
 #include "PlatformString.h"
 
 namespace WebCore {
 
+PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
+{
+    DIBSECTION dibSection;
+    if (!GetObject(hBitmap, sizeof(DIBSECTION), &dibSection))
+        return 0;
+
+    ASSERT(dibSection.dsBm.bmBitsPixel == 32);
+    if (dibSection.dsBm.bmBitsPixel != 32)
+        return 0;
+
+    ASSERT(dibSection.dsBm.bmBits);
+    if (!dibSection.dsBm.bmBits)
+        return 0;
+
+    cairo_surface_t* image = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight);
+
+    // The BitmapImage object takes over ownership of the cairo_surface_t*, so no need to destroy here.
+    return adoptRef(new BitmapImage(image));
+}
+
 bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
 {
     ASSERT(bmp);