Title: [167887] trunk/Source/WebCore
Revision
167887
Author
mrobin...@webkit.org
Date
2014-04-28 08:18:57 -0700 (Mon, 28 Apr 2014)

Log Message

[GTK] Builtin cursors do not properly handle transparency
https://bugs.webkit.org/show_bug.cgi?id=131866

Reviewed by Gustavo Noronha Silva.

Tested by ManualTests/cursor.html.

* platform/gtk/CursorGtk.cpp:
(WebCore::createNamedCursor): Instead of interpreting the source bitmap as an A1 image, use
it as a 1-bit black and white image. We do this by:
    1. Painting the result to a full color image with transparency instead of an alpha-only surface.
    2. Masking a white background using the cursor alpha surface.
    3. Painting the black parts of the cursor by painting the source surface, where black pixels
    will be interpreted as full opaque pixels.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (167886 => 167887)


--- trunk/Source/WebCore/ChangeLog	2014-04-28 15:06:05 UTC (rev 167886)
+++ trunk/Source/WebCore/ChangeLog	2014-04-28 15:18:57 UTC (rev 167887)
@@ -1,3 +1,20 @@
+2014-04-28  Martin Robinson  <mrobin...@igalia.com>
+
+        [GTK] Builtin cursors do not properly handle transparency
+        https://bugs.webkit.org/show_bug.cgi?id=131866
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Tested by ManualTests/cursor.html.
+
+        * platform/gtk/CursorGtk.cpp:
+        (WebCore::createNamedCursor): Instead of interpreting the source bitmap as an A1 image, use
+        it as a 1-bit black and white image. We do this by:
+            1. Painting the result to a full color image with transparency instead of an alpha-only surface.
+            2. Masking a white background using the cursor alpha surface.
+            3. Painting the black parts of the cursor by painting the source surface, where black pixels
+            will be interpreted as full opaque pixels.
+
 2014-04-28  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Unreviewed. Update GObject DOM bindings symbols file.

Modified: trunk/Source/WebCore/platform/gtk/CursorGtk.cpp (167886 => 167887)


--- trunk/Source/WebCore/platform/gtk/CursorGtk.cpp	2014-04-28 15:06:05 UTC (rev 167886)
+++ trunk/Source/WebCore/platform/gtk/CursorGtk.cpp	2014-04-28 15:18:57 UTC (rev 167887)
@@ -48,12 +48,16 @@
 
     RefPtr<cairo_surface_t> source = adoptRef(cairo_image_surface_create_for_data(const_cast<unsigned char*>(cursor.bits), CAIRO_FORMAT_A1, 32, 32, 4));
     RefPtr<cairo_surface_t> mask = adoptRef(cairo_image_surface_create_for_data(const_cast<unsigned char*>(cursor.mask_bits), CAIRO_FORMAT_A1, 32, 32, 4));
-    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_A1, 32, 32));
+
+    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 32, 32));
     RefPtr<cairo_t> cr = adoptRef(cairo_create(surface.get()));
 
-    cairo_set_source_surface(cr.get(), source.get(), 0, 0);
+    cairo_set_source_rgb(cr.get(), 1, 1, 1);
     cairo_mask_surface(cr.get(), mask.get(), 0, 0);
 
+    cairo_set_source_surface(cr.get(), source.get(), 0, 0);
+    cairo_paint(cr.get());
+
 #if GTK_CHECK_VERSION(3, 9, 12)
     return adoptGRef(gdk_cursor_new_from_surface(gdk_display_get_default(), surface.get(), cursor.hot_x, cursor.hot_y));
 #else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to