From 4076110e4f36bbdc87e546292ce74347be43e076 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 25 May 2021 01:42:18 +0000 Subject: [PATCH] browser(webkit): fix jpeg encoding on mac after last roll (#6732) --- browser_patches/webkit/BUILD_NUMBER | 4 ++-- browser_patches/webkit/patches/bootstrap.diff | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER index 049eb5eb39..90ffa7cfc9 100644 --- a/browser_patches/webkit/BUILD_NUMBER +++ b/browser_patches/webkit/BUILD_NUMBER @@ -1,2 +1,2 @@ -1484 -Changed: yurys@chromium.org Mon 24 May 2021 02:43:11 PM PDT +1485 +Changed: yurys@chromium.org Mon May 24 18:35:09 PDT 2021 diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diff index 70b308d056..137ce176f5 100644 --- a/browser_patches/webkit/patches/bootstrap.diff +++ b/browser_patches/webkit/patches/bootstrap.diff @@ -6699,17 +6699,22 @@ index d79728555b7db9b59cb615c55a7a7a6851cb57c8..61d3cc4b488e35ef9e1afa1ce3ac5f5d if (!image || !encodeImage(image, mimeType, &encodedImage)) return { }; diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h b/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h -index 998311795537117f8c476adb3e2e0f007c69b609..315ea8866421ae0707fb54c504756a52a1665bfc 100644 +index 998311795537117f8c476adb3e2e0f007c69b609..ccfdafa2974601c9d3b1fa5ec1b15354e5f37576 100644 --- a/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h +++ b/Source/WebCore/platform/graphics/cg/ImageBufferUtilitiesCG.h -@@ -40,6 +40,7 @@ RetainPtr utiFromImageBufferMIMEType(const String&); +@@ -35,10 +35,10 @@ class PixelBuffer; - Vector data(CGImageRef, CFStringRef destinationUTI, Optional quality); + WEBCORE_EXPORT uint8_t verifyImageBufferIsBigEnough(const void* buffer, size_t bufferSize); + +-CFStringRef jpegUTI(); ++WEBCORE_EXPORT CFStringRef jpegUTI(); + RetainPtr utiFromImageBufferMIMEType(const String&); + +-Vector data(CGImageRef, CFStringRef destinationUTI, Optional quality); ++WEBCORE_EXPORT Vector data(CGImageRef, CFStringRef destinationUTI, Optional quality); Vector data(const PixelBuffer&, const String& mimeType, Optional quality); -+WEBCORE_EXPORT bool encodeImage(CGImageRef, CFStringRef uti, Optional quality, CFMutableDataRef); String dataURL(CGImageRef, CFStringRef destinationUTI, const String& mimeType, Optional quality); - String dataURL(const PixelBuffer&, const String& mimeType, Optional quality); diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp index ce4c0fb9a237ac8c72a0c23f79f0c023530d90ab..789e3814ad16fa10a353ea3ef645c6961a040601 100644 --- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp @@ -11965,10 +11970,10 @@ index 0000000000000000000000000000000000000000..4ec8b96bbbddf8a7b042f53a8068754a +cairo_status_t cairo_image_surface_write_to_jpeg_mem(cairo_surface_t *sfc, unsigned char **data, size_t *len, int quality); diff --git a/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp new file mode 100644 -index 0000000000000000000000000000000000000000..b30668cc6dfc1d090600980d9ff1da5ed52902aa +index 0000000000000000000000000000000000000000..5fdc4b3f236ab8d0351d5dee468e262267532804 --- /dev/null +++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp -@@ -0,0 +1,271 @@ +@@ -0,0 +1,269 @@ +/* + * Copyright (C) 2020 Microsoft Corporation. + * @@ -12217,9 +12222,7 @@ index 0000000000000000000000000000000000000000..b30668cc6dfc1d090600980d9ff1da5e + scaledImageRef = adoptCF(CGBitmapContextCreateImage(context.get())); + imagePtr = scaledImageRef.get(); + } -+ auto cfData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0)); -+ WebCore::encodeImage(imagePtr, CFSTR("public.jpeg"), m_screencastQuality * 0.1, cfData.get()); -+ String base64Data = base64EncodeToString(CFDataGetBytePtr(cfData.get()), CFDataGetLength(cfData.get())); ++ String base64Data = base64EncodeToString(WebCore::data(imagePtr, WebCore::jpegUTI(), m_screencastQuality * 0.1)); + ++m_screencastFramesInFlight; + m_frontendDispatcher->screencastFrame(base64Data, displaySize.width(), displaySize.height()); + }