Title: [231638] trunk/Source/WebCore
Revision
231638
Author
[email protected]
Date
2018-05-10 07:50:41 -0700 (Thu, 10 May 2018)

Log Message

[GTK] Implement ImageBuffer::toBGRAData
https://bugs.webkit.org/show_bug.cgi?id=185511

Patch by Thibault Saunier <[email protected]> on 2018-05-10
Reviewed by Michael Catanzaro.

This was never implemented but will be required for the MediaStream API
tests.

* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::toBGRAData const):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::toBGRAData const):
* platform/graphics/gtk/ImageBufferGtk.cpp:
(WebCore::ImageBuffer::toBGRAData const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (231637 => 231638)


--- trunk/Source/WebCore/ChangeLog	2018-05-10 08:37:37 UTC (rev 231637)
+++ trunk/Source/WebCore/ChangeLog	2018-05-10 14:50:41 UTC (rev 231638)
@@ -1,3 +1,20 @@
+2018-05-10  Thibault Saunier  <[email protected]>
+
+        [GTK] Implement ImageBuffer::toBGRAData
+        https://bugs.webkit.org/show_bug.cgi?id=185511
+
+        Reviewed by Michael Catanzaro.
+
+        This was never implemented but will be required for the MediaStream API
+        tests.
+
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore::ImageBuffer::toBGRAData const):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::toBGRAData const):
+        * platform/graphics/gtk/ImageBufferGtk.cpp:
+        (WebCore::ImageBuffer::toBGRAData const):
+
 2018-05-10  Yacine Bandou  <[email protected]>
 
         [EME][GStreamer] Add a handler for GStreamer protection event

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (231637 => 231638)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2018-05-10 08:37:37 UTC (rev 231637)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2018-05-10 14:50:41 UTC (rev 231638)
@@ -102,17 +102,13 @@
     return FloatRect(rect.location(), clampedSize(rect.size()));
 }
 
+#if !USE(CG) && !PLATFORM(GTK)
 Vector<uint8_t> ImageBuffer::toBGRAData() const
 {
-#if USE(CG)
-    if (context().isAcceleratedContext())
-        flushContext();
-    return m_data.toBGRAData(context().isAcceleratedContext(), m_size.width(), m_size.height());
-#else
     // FIXME: Implement this for other backends.
     return { };
+}
 #endif
-}
 
 #if !(USE(CG) || USE(DIRECT2D))
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (231637 => 231638)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2018-05-10 08:37:37 UTC (rev 231637)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2018-05-10 14:50:41 UTC (rev 231638)
@@ -630,6 +630,13 @@
     return { };
 }
 
+Vector<uint8_t> ImageBuffer::toBGRAData() const
+{
+    if (context().isAcceleratedContext())
+        flushContext();
+    return m_data.toBGRAData(context().isAcceleratedContext(), m_size.width(), m_size.height());
+}
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp (231637 => 231638)


--- trunk/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp	2018-05-10 08:37:37 UTC (rev 231637)
+++ trunk/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp	2018-05-10 14:50:41 UTC (rev 231638)
@@ -20,8 +20,8 @@
 #include "ImageBuffer.h"
 
 #include "CairoUtilities.h"
+#include "GRefPtrGtk.h"
 #include "GdkCairoUtilities.h"
-#include "GRefPtrGtk.h"
 #include "MIMETypeRegistry.h"
 #include <cairo.h>
 #include <gtk/gtk.h>
@@ -87,6 +87,16 @@
     return "data:" + mimeType + ";base64," + base64Data;
 }
 
+Vector<uint8_t> ImageBuffer::toBGRAData() const
+{
+    auto pixbuf = adoptGRef(cairoSurfaceToGdkPixbuf(m_data.m_surface.get()));
+    auto pixels = gdk_pixbuf_get_pixels(pixbuf.get());
+
+    Vector<uint8_t> imageData;
+    imageData.append(pixels, gdk_pixbuf_get_byte_length(pixbuf.get()));
+    return imageData;
+}
+
 Vector<uint8_t> ImageBuffer::toData(const String& mimeType, std::optional<double> quality) const
 {
     ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to