Skip to content

Commit 96f9bbe

Browse files
authored
browser(webkit): fix windows build (#2294)
1 parent 82cab09 commit 96f9bbe

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1236
1+
1237

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5299,15 +5299,14 @@ index 892d8de6d345d91fda80cfa5334c4aa68b757da3..a22497d801a349487be10b15139e9c76
52995299

53005300
#if PLATFORM(IOS_FAMILY)
53015301
diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp
5302-
index d79728555b7db9b59cb615c55a7a7a6851cb57c8..6a6bfcd87074be69790a9d4b7993d427953129f5 100644
5302+
index d79728555b7db9b59cb615c55a7a7a6851cb57c8..6c05bfbcc1056e5fb906bf019cc52472d1b02882 100644
53035303
--- a/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp
53045304
+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp
5305-
@@ -48,6 +48,14 @@
5305+
@@ -48,6 +48,13 @@
53065306
#include <wtf/glib/GUniquePtr.h>
53075307
#endif
53085308

5309-
+#if PLATFORM(WPE)
5310-
+#include <wtf/glib/GUniquePtr.h>
5309+
+#if PLATFORM(WPE) || PLATFORM(WIN)
53115310
+#include <stdio.h> // Needed by jpeglib.h for FILE.
53125311
+extern "C" {
53135312
+#include "jpeglib.h"
@@ -5317,24 +5316,13 @@ index d79728555b7db9b59cb615c55a7a7a6851cb57c8..6a6bfcd87074be69790a9d4b7993d427
53175316
namespace WebCore {
53185317

53195318
#if !PLATFORM(GTK)
5320-
@@ -65,8 +73,71 @@ static bool encodeImage(cairo_surface_t* image, const String& mimeType, Vector<u
5319+
@@ -65,8 +72,75 @@ static bool encodeImage(cairo_surface_t* image, const String& mimeType, Vector<u
53215320
return cairo_surface_write_to_png_stream(image, writeFunction, output) == CAIRO_STATUS_SUCCESS;
53225321
}
53235322

53245323
-Vector<uint8_t> data(cairo_surface_t* image, const String& mimeType, Optional<double>)
53255324
+static Vector<uint8_t> encodeJpeg(cairo_surface_t* image, int quality)
5326-
{
5327-
+ struct jpeg_compress_struct info;
5328-
+ struct jpeg_error_mgr error;
5329-
+ info.err = jpeg_std_error(&error);
5330-
+ jpeg_create_compress(&info);
5331-
+
5332-
+ GUniqueOutPtr<guchar> buffer;
5333-
+ gsize bufferSize;
5334-
+ jpeg_mem_dest(&info, &buffer.outPtr(), &bufferSize);
5335-
+ info.image_width = cairo_image_surface_get_width(image);
5336-
+ info.image_height = cairo_image_surface_get_height(image);
5337-
+
5325+
+{
53385326
+ if (cairo_surface_get_type(image) != CAIRO_SURFACE_TYPE_IMAGE) {
53395327
+ fprintf(stderr, "Unexpected cairo surface type: %d\n", cairo_surface_get_type(image));
53405328
+ return { };
@@ -5344,6 +5332,18 @@ index d79728555b7db9b59cb615c55a7a7a6851cb57c8..6a6bfcd87074be69790a9d4b7993d427
53445332
+ fprintf(stderr, "Unexpected surface image format: %d\n", cairo_image_surface_get_format(image));
53455333
+ return { };
53465334
+ }
5335+
+
5336+
+ struct jpeg_compress_struct info;
5337+
+ struct jpeg_error_mgr error;
5338+
+ info.err = jpeg_std_error(&error);
5339+
+ jpeg_create_compress(&info);
5340+
+
5341+
+ unsigned char* bufferPtr = nullptr;
5342+
+ size_t bufferSize;
5343+
+ jpeg_mem_dest(&info, &bufferPtr, &bufferSize);
5344+
+ info.image_width = cairo_image_surface_get_width(image);
5345+
+ info.image_height = cairo_image_surface_get_height(image);
5346+
+
53475347
+#ifndef LIBJPEG_TURBO_VERSION
53485348
+ COMPILE_ASSERT(false, only_libjpeg_turbo_is_supported);
53495349
+#endif
@@ -5366,20 +5366,23 @@ index d79728555b7db9b59cb615c55a7a7a6851cb57c8..6a6bfcd87074be69790a9d4b7993d427
53665366
+ JSAMPROW row = cairo_image_surface_get_data(image) + (info.next_scanline * cairo_image_surface_get_stride(image));
53675367
+ if (jpeg_write_scanlines(&info, &row, 1) != 1) {
53685368
+ fprintf(stderr, "JPEG library failed to encode line\n");
5369-
+ return { };
5369+
+ break;
53705370
+ }
53715371
+ }
53725372
+
53735373
+ jpeg_finish_compress(&info);
53745374
+ jpeg_destroy_compress(&info);
53755375
+
53765376
+ Vector<uint8_t> output;
5377-
+ output.append(buffer.get(), bufferSize);
5377+
+ output.append(bufferPtr, bufferSize);
5378+
+ // Cannot use unique_ptr as bufferPtr changes during compression. GUniquePtr would work
5379+
+ // but it's under GLib and won't work on Windows.
5380+
+ free(bufferPtr);
53785381
+ return output;
53795382
+}
53805383
+
53815384
+Vector<uint8_t> data(cairo_surface_t* image, const String& mimeType, Optional<double> quality)
5382-
+{
5385+
{
53835386
+ if (mimeType == "image/jpeg") {
53845387
+ int qualityPercent = 100;
53855388
+ if (quality)

0 commit comments

Comments
 (0)