WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Now with ImageData support
wip2.diff (text/plain), 126.94 KB, created by
Sam Weinig
on 2021-04-30 18:25:12 PDT
(
hide
)
Description:
Now with ImageData support
Filename:
MIME Type:
Creator:
Sam Weinig
Created:
2021-04-30 18:25:12 PDT
Size:
126.94 KB
patch
obsolete
>Index: Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml >=================================================================== >--- Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (revision 276819) >+++ Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (working copy) >@@ -245,6 +245,18 @@ CSSTypedOMEnabled: > "ENABLE(EXPERIMENTAL_FEATURES) && (PLATFORM(GTK) || PLATFORM(WPE))": true > default: false > >+CanvasColorSpaceEnabled: >+ type: bool >+ humanReadableName: "Canvas Color Spaces" >+ humanReadableDescription: "Enable use of predefined canvas color spaces" >+ defaultValue: >+ WebKitLegacy: >+ default: false >+ WebKit: >+ default: false >+ WebCore: >+ default: false >+ > CaptureVideoInGPUProcessEnabled: > type: bool > humanReadableName: "GPU Process: Video Capture" >Index: Source/WTF/wtf/PlatformEnable.h >=================================================================== >--- Source/WTF/wtf/PlatformEnable.h (revision 276819) >+++ Source/WTF/wtf/PlatformEnable.h (working copy) >@@ -245,6 +245,14 @@ > #define ENABLE_DEVICE_ORIENTATION 0 > #endif > >+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3) >+#define ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3 0 >+#endif >+ >+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 1 >+#endif >+ > #if !defined(ENABLE_DOWNLOAD_ATTRIBUTE) > #define ENABLE_DOWNLOAD_ATTRIBUTE 1 > #endif >@@ -816,6 +824,14 @@ > #define ENABLE_GC_VALIDATION 1 > #endif > >+#if OS(DARWIN) && ENABLE(JIT) && USE(APPLE_INTERNAL_SDK) && CPU(ARM64E) && HAVE(JIT_CAGE) >+#define ENABLE_JIT_CAGE 1 >+#endif >+ >+#if OS(DARWIN) && CPU(ADDRESS64) && ENABLE(JIT) && (ENABLE(JIT_CAGE) || ASSERT_ENABLED) >+#define ENABLE_JIT_OPERATION_VALIDATION 1 >+#endif >+ > #if !defined(ENABLE_BINDING_INTEGRITY) && !OS(WINDOWS) > #define ENABLE_BINDING_INTEGRITY 1 > #endif >@@ -887,10 +903,14 @@ > #error "ENABLE(WHLSL_COMPILER) requires ENABLE(WEBGPU)" > #endif > >-#if OS(DARWIN) && ENABLE(JIT) && USE(APPLE_INTERNAL_SDK) && CPU(ARM64E) && HAVE(JIT_CAGE) >-#define ENABLE_JIT_CAGE 1 >+#if USE(CG) >+ >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) && !HAVE(CORE_GRAPHICS_DISPLAY_P3_COLOR_SPACE) >+#error "ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) requires HAVE(CORE_GRAPHICS_DISPLAY_P3_COLOR_SPACE) on platforms using CoreGraphics" >+#endif >+ >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) && !HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE) >+#error "ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) requires HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE) on platforms using CoreGraphics" > #endif > >-#if OS(DARWIN) && CPU(ADDRESS64) && ENABLE(JIT) && (ENABLE(JIT_CAGE) || ASSERT_ENABLED) >-#define ENABLE_JIT_OPERATION_VALIDATION 1 > #endif >Index: Source/WTF/wtf/PlatformEnableCocoa.h >=================================================================== >--- Source/WTF/wtf/PlatformEnableCocoa.h (revision 276819) >+++ Source/WTF/wtf/PlatformEnableCocoa.h (working copy) >@@ -670,3 +670,11 @@ > #if !defined(ENABLE_APP_BOUND_REQUESTS) && PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000 > #define ENABLE_APP_BOUND_REQUESTS 1 > #endif >+ >+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3) >+#define ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3 1 >+#endif >+ >+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 1 >+#endif >Index: Source/WTF/wtf/PlatformEnableWinApple.h >=================================================================== >--- Source/WTF/wtf/PlatformEnableWinApple.h (revision 276819) >+++ Source/WTF/wtf/PlatformEnableWinApple.h (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2006-2020 Apple Inc. All rights reserved. >+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved. > * Copyright (C) 2007-2009 Torch Mobile, Inc. > * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved. > * Copyright (C) 2013 Samsung Electronics. All rights reserved. >@@ -54,3 +54,7 @@ > #if !defined(ENABLE_GEOLOCATION) > #define ENABLE_GEOLOCATION 1 > #endif >+ >+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB) && !HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE) >+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 0 >+#endif >Index: Source/WebCore/CMakeLists.txt >=================================================================== >--- Source/WebCore/CMakeLists.txt (revision 276819) >+++ Source/WebCore/CMakeLists.txt (working copy) >@@ -1023,6 +1023,7 @@ set(WebCore_NON_SVG_IDL_FILES > html/ImageBitmap.idl > html/ImageBitmapOptions.idl > html/ImageData.idl >+ html/ImageDataSettings.idl > html/MediaController.idl > html/MediaEncryptedEvent.idl > html/MediaError.idl >@@ -1066,6 +1067,7 @@ set(WebCore_NON_SVG_IDL_FILES > html/canvas/OffscreenCanvasRenderingContext2D.idl > html/canvas/PaintRenderingContext2D.idl > html/canvas/Path2D.idl >+ html/canvas/PredefinedColorSpaceEnum.idl > > html/track/AudioTrack.idl > html/track/AudioTrackList.idl >Index: Source/WebCore/DerivedSources-input.xcfilelist >=================================================================== >--- Source/WebCore/DerivedSources-input.xcfilelist (revision 276819) >+++ Source/WebCore/DerivedSources-input.xcfilelist (working copy) >@@ -1036,6 +1036,7 @@ $(PROJECT_DIR)/html/HTMLVideoElement.idl > $(PROJECT_DIR)/html/ImageBitmap.idl > $(PROJECT_DIR)/html/ImageBitmapOptions.idl > $(PROJECT_DIR)/html/ImageData.idl >+$(PROJECT_DIR)/html/ImageDataSettings.idl > $(PROJECT_DIR)/html/MediaController.idl > $(PROJECT_DIR)/html/MediaEncryptedEvent.idl > $(PROJECT_DIR)/html/MediaError.idl >@@ -1098,6 +1099,7 @@ $(PROJECT_DIR)/html/canvas/OESVertexArra > $(PROJECT_DIR)/html/canvas/OffscreenCanvasRenderingContext2D.idl > $(PROJECT_DIR)/html/canvas/PaintRenderingContext2D.idl > $(PROJECT_DIR)/html/canvas/Path2D.idl >+$(PROJECT_DIR)/html/canvas/PredefinedColorSpaceEnum.idl > $(PROJECT_DIR)/html/canvas/WebGL2RenderingContext.idl > $(PROJECT_DIR)/html/canvas/WebGLActiveInfo.idl > $(PROJECT_DIR)/html/canvas/WebGLBuffer.idl >Index: Source/WebCore/DerivedSources-output.xcfilelist >=================================================================== >--- Source/WebCore/DerivedSources-output.xcfilelist (revision 276819) >+++ Source/WebCore/DerivedSources-output.xcfilelist (working copy) >@@ -1180,6 +1180,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/Web > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageBitmapRenderingContextSettings.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageData.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageData.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageDataSettings.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageDataSettings.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageSmoothingQuality.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageSmoothingQuality.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInnerHTML.cpp >@@ -1642,6 +1644,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/Web > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPositionOptions.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPostMessageOptions.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPostMessageOptions.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPredefinedColorSpaceEnum.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPredefinedColorSpaceEnum.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSProcessingInstruction.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSProcessingInstruction.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSProgressEvent.cpp >Index: Source/WebCore/DerivedSources.make >=================================================================== >--- Source/WebCore/DerivedSources.make (revision 276819) >+++ Source/WebCore/DerivedSources.make (working copy) >@@ -897,6 +897,7 @@ JS_BINDING_IDLS := \ > $(WebCore)/html/ImageBitmap.idl \ > $(WebCore)/html/ImageBitmapOptions.idl \ > $(WebCore)/html/ImageData.idl \ >+ $(WebCore)/html/ImageDataSettings.idl \ > $(WebCore)/html/MediaController.idl \ > $(WebCore)/html/MediaEncryptedEvent.idl \ > $(WebCore)/html/MediaError.idl \ >@@ -959,6 +960,7 @@ JS_BINDING_IDLS := \ > $(WebCore)/html/canvas/OffscreenCanvasRenderingContext2D.idl \ > $(WebCore)/html/canvas/PaintRenderingContext2D.idl \ > $(WebCore)/html/canvas/Path2D.idl \ >+ $(WebCore)/html/canvas/PredefinedColorSpaceEnum.idl \ > $(WebCore)/html/canvas/WebGL2RenderingContext.idl \ > $(WebCore)/html/canvas/WebGLActiveInfo.idl \ > $(WebCore)/html/canvas/WebGLBuffer.idl \ >Index: Source/WebCore/Headers.cmake >=================================================================== >--- Source/WebCore/Headers.cmake (revision 276819) >+++ Source/WebCore/Headers.cmake (working copy) >@@ -700,6 +700,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > html/ImageBitmap.h > html/ImageBitmapBacking.h > html/ImageData.h >+ html/ImageDataSettings.h > html/ImageDocument.h > html/InputMode.h > html/LabelableElement.h >@@ -1286,6 +1287,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > platform/graphics/Path.h > platform/graphics/PathUtilities.h > platform/graphics/Pattern.h >+ platform/graphics/PixelFormat.h > platform/graphics/PlatformDisplay.h > platform/graphics/PlatformImage.h > platform/graphics/PlatformImageBuffer.h >Index: Source/WebCore/Sources.txt >=================================================================== >--- Source/WebCore/Sources.txt (revision 276819) >+++ Source/WebCore/Sources.txt (working copy) >@@ -1344,6 +1344,7 @@ html/canvas/OffscreenCanvasRenderingCont > html/canvas/PaintRenderingContext2D.cpp > html/canvas/Path2D.cpp > html/canvas/PlaceholderRenderingContext.cpp >+html/canvas/PredefinedColorSpaceEnum.cpp > html/canvas/WebGL2RenderingContext.cpp > html/canvas/WebGLBuffer.cpp > html/canvas/WebGLColorBufferFloat.cpp >@@ -3199,6 +3200,7 @@ JSImageBitmapOptions.cpp > JSImageBitmapRenderingContext.cpp > JSImageBitmapRenderingContextSettings.cpp > JSImageData.cpp >+JSImageDataSettings.cpp > JSImageSmoothingQuality.cpp > JSInputEvent.cpp > JSInspectorAuditAccessibilityObject.cpp >@@ -3367,6 +3369,7 @@ JSPositionCallback.cpp > JSPositionErrorCallback.cpp > JSPositionOptions.cpp > JSPostMessageOptions.cpp >+JSPredefinedColorSpaceEnum.cpp > JSProcessingInstruction.cpp > JSProgressEvent.cpp > JSPromiseRejectionEvent.cpp >Index: Source/WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebCore/WebCore.xcodeproj/project.pbxproj (revision 276819) >+++ Source/WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -4097,6 +4097,9 @@ > BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA257141293C010007A263D /* VerticalPositionCache.h */; }; > BCA2B061105047600043BD1C /* UserScript.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA2B0601050475F0043BD1C /* UserScript.h */; settings = {ATTRIBUTES = (Private, ); }; }; > BCA2B08B10505BCD0043BD1C /* UserScriptTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA2B08A10505BCD0043BD1C /* UserScriptTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ BCA55908263B8142007F19B3 /* PixelFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA55907263B8142007F19B3 /* PixelFormat.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ BCA5590E263C5714007F19B3 /* ImageDataSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA5590A263C56F5007F19B3 /* ImageDataSettings.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ BCA5590F263C573A007F19B3 /* PredefinedColorSpaceEnum.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA55906263B7EBC007F19B3 /* PredefinedColorSpaceEnum.h */; settings = {ATTRIBUTES = (Private, ); }; }; > BCA83E500D7CE1E9003421A8 /* JSDataTransfer.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA83E4E0D7CE1E9003421A8 /* JSDataTransfer.h */; }; > BCA846D70DC67A350026C309 /* RenderReplica.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA846D50DC67A350026C309 /* RenderReplica.h */; }; > BCA8C81E11E3D36900812FB7 /* BackForwardController.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA8C81C11E3D36900812FB7 /* BackForwardController.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -14312,6 +14315,12 @@ > BCA2B08A10505BCD0043BD1C /* UserScriptTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserScriptTypes.h; sourceTree = "<group>"; }; > BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScheduledAction.cpp; sourceTree = "<group>"; }; > BCA378BB0D15F64200B793D6 /* ScheduledAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScheduledAction.h; sourceTree = "<group>"; }; >+ BCA55904263B7EBC007F19B3 /* PredefinedColorSpaceEnum.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PredefinedColorSpaceEnum.idl; sourceTree = "<group>"; }; >+ BCA55906263B7EBC007F19B3 /* PredefinedColorSpaceEnum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PredefinedColorSpaceEnum.h; sourceTree = "<group>"; }; >+ BCA55907263B8142007F19B3 /* PixelFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PixelFormat.h; sourceTree = "<group>"; }; >+ BCA5590A263C56F5007F19B3 /* ImageDataSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDataSettings.h; sourceTree = "<group>"; }; >+ BCA5590C263C56F5007F19B3 /* ImageDataSettings.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ImageDataSettings.idl; sourceTree = "<group>"; }; >+ BCA55910263C66F6007F19B3 /* PredefinedColorSpaceEnum.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PredefinedColorSpaceEnum.cpp; sourceTree = "<group>"; }; > BCA83E360D7CDC4E003421A8 /* DataTransfer.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DataTransfer.idl; sourceTree = "<group>"; }; > BCA83E4D0D7CE1E9003421A8 /* JSDataTransfer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataTransfer.cpp; sourceTree = "<group>"; }; > BCA83E4E0D7CE1E9003421A8 /* JSDataTransfer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDataTransfer.h; sourceTree = "<group>"; }; >@@ -20189,6 +20198,9 @@ > 7C193BB41F5E0EB70088F3E6 /* Path2D.idl */, > 7C7903BA1F86FF3300463A70 /* PlaceholderRenderingContext.cpp */, > 7C7903BC1F86FF3400463A70 /* PlaceholderRenderingContext.h */, >+ BCA55910263C66F6007F19B3 /* PredefinedColorSpaceEnum.cpp */, >+ BCA55906263B7EBC007F19B3 /* PredefinedColorSpaceEnum.h */, >+ BCA55904263B7EBC007F19B3 /* PredefinedColorSpaceEnum.idl */, > D3F3D35B1A69A5060059FC2B /* WebGL2RenderingContext.cpp */, > D3F3D35C1A69A5060059FC2B /* WebGL2RenderingContext.h */, > D3F3D35D1A69A5060059FC2B /* WebGL2RenderingContext.idl */, >@@ -23889,6 +23901,8 @@ > A77979130D6B9D0C003851B9 /* ImageData.cpp */, > A77979140D6B9D0C003851B9 /* ImageData.h */, > A77979150D6B9D0C003851B9 /* ImageData.idl */, >+ BCA5590A263C56F5007F19B3 /* ImageDataSettings.h */, >+ BCA5590C263C56F5007F19B3 /* ImageDataSettings.idl */, > 97205AB11239291000B17380 /* ImageDocument.cpp */, > 97205AB21239291000B17380 /* ImageDocument.h */, > F55B3D8D1251F12D003EF269 /* ImageInputType.cpp */, >@@ -27011,6 +27025,7 @@ > 2D5002FA1B56D7990020AAF7 /* PathUtilities.h */, > A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */, > A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */, >+ BCA55907263B8142007F19B3 /* PixelFormat.h */, > 726D56E1253AE0430002EF90 /* PlatformImage.h */, > 72BAC3A623E17328008D741C /* PlatformImageBuffer.h */, > 550640AD240756DA00AAE045 /* PlatformImageBufferBackend.h */, >@@ -32951,6 +32966,7 @@ > 9175CE5E21E281ED00DF2C27 /* InspectorAuditAccessibilityObject.h in Headers */, > 9175CE5C21E281ED00DF2C27 /* InspectorAuditDOMObject.h in Headers */, > 9109E9C8222CABCA00BB6264 /* InspectorAuditResourcesObject.h in Headers */, >+ BCA5590E263C5714007F19B3 /* ImageDataSettings.h in Headers */, > 6A22E8701F10418600F546C3 /* InspectorCanvas.h in Headers */, > A5B81CA81FAA44620037D1E6 /* InspectorCanvasAgent.h in Headers */, > 95AA571025EEED32004E9283 /* InspectorCanvasCallTracer.h in Headers */, >@@ -35518,6 +35534,7 @@ > 0F54DD091881D5F5003EEDBB /* TouchEvent.h in Headers */, > 0F54DD0A1881D5F5003EEDBB /* TouchList.h in Headers */, > 070334D71459FFD5008D8D45 /* TrackBase.h in Headers */, >+ BCA55908263B8142007F19B3 /* PixelFormat.h in Headers */, > BE88E0C21715CE2600658D98 /* TrackListBase.h in Headers */, > BE913D80181EF92400DCB09E /* TrackPrivateBase.h in Headers */, > FFAC30FE184FB145008C4F1E /* TrailingObjects.h in Headers */, >@@ -35788,6 +35805,7 @@ > 97AABD2714FA09D5007457AE /* WebSocketHandshake.h in Headers */, > 41E12E9F24FE74E20093FFB4 /* WebSocketIdentifier.h in Headers */, > 93B38EC325821DB400198E63 /* WebSpeechRecognizerTask.h in Headers */, >+ BCA5590F263C573A007F19B3 /* PredefinedColorSpaceEnum.h in Headers */, > 93B38EC425821DB700198E63 /* WebSpeechRecognizerTaskMock.h in Headers */, > 1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */, > 31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */, >Index: Source/WebCore/bindings/js/SerializedScriptValue.cpp >=================================================================== >--- Source/WebCore/bindings/js/SerializedScriptValue.cpp (revision 276819) >+++ Source/WebCore/bindings/js/SerializedScriptValue.cpp (working copy) >@@ -1076,7 +1076,7 @@ private: > } > > const IntSize& logicalSize = buffer->logicalSize(); >- auto imageData = buffer->getImageData(AlphaPremultiplication::Premultiplied, { IntPoint::zero(), logicalSize }); >+ auto imageData = buffer->getImageData(AlphaPremultiplication::Premultiplied, { IntPoint::zero(), logicalSize }, buffer->colorSpace()); > if (!imageData) { > code = SerializationReturnCode::ValidationError; > return; >@@ -3384,7 +3384,9 @@ private: > } > IntSize imageSize(width, height); > RELEASE_ASSERT(!length || (imageSize.area() * 4).unsafeGet() <= length); >- auto result = ImageData::create(imageSize); >+ >+ // FIXME: Add support for serializing the color space. >+ auto result = ImageData::create(imageSize, DestinationColorSpace::SRGB); > if (!result) { > fail(); > return JSValue(); >Index: Source/WebCore/html/HTMLCanvasElement.cpp >=================================================================== >--- Source/WebCore/html/HTMLCanvasElement.cpp (revision 276819) >+++ Source/WebCore/html/HTMLCanvasElement.cpp (working copy) >@@ -34,6 +34,7 @@ > #include "CanvasPattern.h" > #include "CanvasRenderingContext2D.h" > #include "CanvasRenderingContext2DSettings.h" >+#include "Chrome.h" > #include "DisplayListDrawingContext.h" > #include "Document.h" > #include "EventNames.h" >@@ -365,13 +366,10 @@ CanvasRenderingContext2D* HTMLCanvasElem > ASSERT(!m_context); > > // Make sure we don't use more pixel memory than the system can support. >- size_t requestedPixelMemory = 4 * width() * height(); >- if (activePixelMemory() + requestedPixelMemory > maxActivePixelMemory()) { >- StringBuilder stringBuilder; >- stringBuilder.appendLiteral("Total canvas memory use exceeds the maximum limit ("); >- stringBuilder.appendNumber(maxActivePixelMemory() / 1024 / 1024); >- stringBuilder.appendLiteral(" MB)."); >- document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, stringBuilder.toString()); >+ auto area = size().area<RecordOverflow>(); >+ auto totalPixelMemory = (area * 4) + activePixelMemory(); >+ if (totalPixelMemory.hasOverflowed() || totalPixelMemory > maxActivePixelMemory()) { >+ document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("Total canvas memory use exceeds the maximum limit (", maxActivePixelMemory() / 1024 / 1024, " MB).")); > return nullptr; > } > >@@ -911,39 +909,40 @@ void HTMLCanvasElement::createImageBuffe > { > ASSERT(!hasCreatedImageBuffer()); > >+ if (!m_context) >+ return; >+ >+ ASSERT(m_context->is2d()); >+ > m_hasCreatedImageBuffer = true; > m_didClearImageBuffer = true; > >- // Perform multiplication as floating point to avoid overflow >- if (float(width()) * height() > maxCanvasArea) { >- StringBuilder stringBuilder; >- stringBuilder.appendLiteral("Canvas area exceeds the maximum limit (width * height > "); >- stringBuilder.appendNumber(maxCanvasArea); >- stringBuilder.appendLiteral(")."); >- document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, stringBuilder.toString()); >+ if (size().isEmpty()) >+ return; >+ >+ auto area = size().area<RecordOverflow>(); >+ if (area.hasOverflowed() || area > maxCanvasArea) { >+ document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("Canvas area exceeds the maximum limit (width * height > ", maxCanvasArea, ").")); > return; > } > > // Make sure we don't use more pixel memory than the system can support. >- size_t requestedPixelMemory = 4 * width() * height(); >- if (activePixelMemory() + requestedPixelMemory > maxActivePixelMemory()) { >- StringBuilder stringBuilder; >- stringBuilder.appendLiteral("Total canvas memory use exceeds the maximum limit ("); >- stringBuilder.appendNumber(maxActivePixelMemory() / 1024 / 1024); >- stringBuilder.appendLiteral(" MB)."); >- document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, stringBuilder.toString()); >+ auto totalPixelMemory = (area * 4) + activePixelMemory(); >+ if (totalPixelMemory.hasOverflowed() || totalPixelMemory > maxActivePixelMemory()) { >+ document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("Total canvas memory use exceeds the maximum limit (", maxActivePixelMemory() / 1024 / 1024, " MB).")); > return; > } > >- if (!width() || !height()) >- return; >- >- auto hostWindow = (document().view() && document().view()->root()) ? document().view()->root()->hostWindow() : nullptr; >+ // FIXME: Does it make sense to creat the buffer if there is no page? >+ auto hostWindow = document().page() ? &document().page()->chrome() : nullptr; > > auto renderingMode = shouldAccelerate(size()) ? RenderingMode::Accelerated : RenderingMode::Unaccelerated; > // FIXME: Add a new setting for DisplayList drawing on canvas. > auto useDisplayList = m_usesDisplayListDrawing.valueOr(document().settings().displayListDrawingEnabled()) ? ShouldUseDisplayList::Yes : ShouldUseDisplayList::No; >- setImageBuffer(ImageBuffer::create(size(), renderingMode, useDisplayList, RenderingPurpose::Canvas, 1, DestinationColorSpace::SRGB, PixelFormat::BGRA8, hostWindow)); >+ auto colorSpace = m_context->colorSpace(); >+ auto pixelFormat = m_context->pixelFormat(); >+ >+ setImageBuffer(ImageBuffer::create(size(), renderingMode, useDisplayList, RenderingPurpose::Canvas, 1, colorSpace, pixelFormat, hostWindow)); > > if (buffer() && buffer()->drawingContext()) > buffer()->drawingContext()->setTracksDisplayListReplay(m_tracksDisplayListReplay); >Index: Source/WebCore/html/HTMLVideoElement.cpp >=================================================================== >--- Source/WebCore/html/HTMLVideoElement.cpp (revision 276819) >+++ Source/WebCore/html/HTMLVideoElement.cpp (working copy) >@@ -281,11 +281,11 @@ void HTMLVideoElement::mediaPlayerFirstV > renderer->updateFromElement(); > } > >-RefPtr<ImageBuffer> HTMLVideoElement::createBufferForPainting(const FloatSize& size, RenderingMode renderingMode) const >+RefPtr<ImageBuffer> HTMLVideoElement::createBufferForPainting(const FloatSize& size, RenderingMode renderingMode, DestinationColorSpace colorSpace, PixelFormat pixelFormat) const > { > auto* hostWindow = document().view() && document().view()->root() ? document().view()->root()->hostWindow() : nullptr; > auto shouldUseDisplayList = document().settings().displayListDrawingEnabled() ? ShouldUseDisplayList::Yes : ShouldUseDisplayList::No; >- return ImageBuffer::create(size, renderingMode, shouldUseDisplayList, RenderingPurpose::MediaPainting, 1, DestinationColorSpace::SRGB, PixelFormat::BGRA8, hostWindow); >+ return ImageBuffer::create(size, renderingMode, shouldUseDisplayList, RenderingPurpose::MediaPainting, 1, colorSpace, pixelFormat, hostWindow); > } > > void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& destRect) >Index: Source/WebCore/html/HTMLVideoElement.h >=================================================================== >--- Source/WebCore/html/HTMLVideoElement.h (revision 276819) >+++ Source/WebCore/html/HTMLVideoElement.h (working copy) >@@ -38,6 +38,8 @@ class ImageBuffer; > class RenderVideo; > class PictureInPictureObserver; > >+enum class DestinationColorSpace : uint8_t; >+enum class PixelFormat : uint8_t; > enum class RenderingMode : bool; > > class HTMLVideoElement final : public HTMLMediaElement, public Supplementable<HTMLVideoElement> { >@@ -70,7 +72,7 @@ public: > void webkitRequestFullscreen() override; > #endif > >- RefPtr<ImageBuffer> createBufferForPainting(const FloatSize&, RenderingMode) const; >+ RefPtr<ImageBuffer> createBufferForPainting(const FloatSize&, RenderingMode, DestinationColorSpace, PixelFormat) const; > > // Used by canvas to gain raw pixel access > void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&); >Index: Source/WebCore/html/ImageBitmap.cpp >=================================================================== >--- Source/WebCore/html/ImageBitmap.cpp (revision 276819) >+++ Source/WebCore/html/ImageBitmap.cpp (working copy) >@@ -502,7 +502,9 @@ void ImageBitmap::createPromise(ScriptEx > auto sourceRectangle = maybeSourceRectangle.releaseReturnValue(); > > auto outputSize = outputSizeForSourceRectangle(sourceRectangle, options); >- auto bitmapData = video->createBufferForPainting(outputSize, bufferRenderingMode); >+ >+ // FIXME: Add support for color spaces / pixel formats to ImageBitmap. >+ auto bitmapData = video->createBufferForPainting(outputSize, bufferRenderingMode, DestinationColorSpace::SRGB, PixelFormat::BGRA8); > if (!bitmapData) { > resolveWithBlankImageBuffer(scriptExecutionContext, !taintsOrigin(scriptExecutionContext.securityOrigin(), *video), WTFMove(promise)); > return; >Index: Source/WebCore/html/ImageBitmapOptions.h >=================================================================== >--- Source/WebCore/html/ImageBitmapOptions.h (revision 276819) >+++ Source/WebCore/html/ImageBitmapOptions.h (working copy) >@@ -25,6 +25,7 @@ > > #pragma once > >+#include "PredefinedColorSpaceEnum.h" > #include <wtf/Optional.h> > > namespace WebCore { >@@ -41,6 +42,8 @@ struct ImageBitmapOptions { > Optional<unsigned> resizeWidth; > Optional<unsigned> resizeHeight; > ResizeQuality resizeQuality { ResizeQuality::Low }; >+ >+ PredefinedColorSpaceEnum colorSpace { PredefinedColorSpaceEnum::SRGB }; > }; > > } >Index: Source/WebCore/html/ImageBitmapOptions.idl >=================================================================== >--- Source/WebCore/html/ImageBitmapOptions.idl (revision 276819) >+++ Source/WebCore/html/ImageBitmapOptions.idl (working copy) >@@ -35,4 +35,7 @@ dictionary ImageBitmapOptions { > [EnforceRange] unsigned long resizeWidth; > [EnforceRange] unsigned long resizeHeight; > ResizeQuality resizeQuality = "low"; >+ >+ // Based on the proposal from https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md. >+ [EnabledBySetting=CanvasColorSpace] PredefinedColorSpaceEnum colorSpace = "srgb"; > }; >Index: Source/WebCore/html/ImageData.cpp >=================================================================== >--- Source/WebCore/html/ImageData.cpp (revision 276819) >+++ Source/WebCore/html/ImageData.cpp (working copy) >@@ -30,37 +30,49 @@ > #include "config.h" > #include "ImageData.h" > >+#include "ColorSpace.h" > #include <JavaScriptCore/JSCInlines.h> > #include <wtf/text/TextStream.h> > > namespace WebCore { > >+static Optional<PredefinedColorSpaceEnum> toPredefinedColorSpaceEnum(DestinationColorSpace colorSpace) >+{ >+ switch (colorSpace) { >+ case DestinationColorSpace::SRGB: >+ return PredefinedColorSpaceEnum::SRGB; >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ case DestinationColorSpace::LinearSRGB: >+ return WTF::nullopt; >+#endif >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ case DestinationColorSpace::DisplayP3: >+ return PredefinedColorSpaceEnum::DisplayP3; >+#endif >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return WTF::nullopt; >+} >+ > Checked<unsigned, RecordOverflow> ImageData::dataSize(const IntSize& size) > { >- Checked<unsigned, RecordOverflow> checkedDataSize = 4; >- checkedDataSize *= static_cast<unsigned>(size.width()); >- checkedDataSize *= static_cast<unsigned>(size.height()); >- return checkedDataSize; >+ return size.area<RecordOverflow>() * 4; > } > >-ExceptionOr<Ref<ImageData>> ImageData::create(unsigned sw, unsigned sh) >+RefPtr<ImageData> ImageData::create(const IntSize& size, DestinationColorSpace colorSpace) > { >- if (!sw || !sh) >- return Exception { IndexSizeError }; >- IntSize size(sw, sh); >- auto dataSize = ImageData::dataSize(size); >- if (dataSize.hasOverflowed()) >- return Exception { RangeError, "Cannot allocate a buffer of this size"_s }; >- auto byteArray = Uint8ClampedArray::tryCreateUninitialized(dataSize.unsafeGet()); >- if (!byteArray) { >- // FIXME: Does this need to be a "real" out of memory error with setOutOfMemoryError called on it? >- return Exception { RangeError, "Out of memory"_s }; >- } >- byteArray->zeroFill(); >- return adoptRef(*new ImageData(size, byteArray.releaseNonNull())); >+ auto predefinedColorSpace = toPredefinedColorSpaceEnum(colorSpace); >+ if (!predefinedColorSpace) >+ return nullptr; >+ >+ ImageDataSettings settings; >+ settings.colorSpace = *predefinedColorSpace; >+ >+ return ImageData::create(size, WTFMove(settings)); > } > >-RefPtr<ImageData> ImageData::create(const IntSize& size) >+RefPtr<ImageData> ImageData::create(const IntSize& size, ImageDataSettings settings) > { > auto dataSize = ImageData::dataSize(size); > if (dataSize.hasOverflowed()) >@@ -68,18 +80,36 @@ RefPtr<ImageData> ImageData::create(cons > auto byteArray = Uint8ClampedArray::tryCreateUninitialized(dataSize.unsafeGet()); > if (!byteArray) > return nullptr; >- return adoptRef(*new ImageData(size, byteArray.releaseNonNull())); >+ return adoptRef(*new ImageData(size, byteArray.releaseNonNull(), WTFMove(settings))); > } > >-RefPtr<ImageData> ImageData::create(const IntSize& size, Ref<Uint8ClampedArray>&& byteArray) >+RefPtr<ImageData> ImageData::create(const IntSize& size, Ref<Uint8ClampedArray>&& byteArray, ImageDataSettings settings) > { > auto dataSize = ImageData::dataSize(size); > if (dataSize.hasOverflowed() || dataSize.unsafeGet() > byteArray->length()) > return nullptr; >- return adoptRef(*new ImageData(size, WTFMove(byteArray))); >+ return adoptRef(*new ImageData(size, WTFMove(byteArray), WTFMove(settings))); > } > >-ExceptionOr<Ref<ImageData>> ImageData::create(Ref<Uint8ClampedArray>&& byteArray, unsigned sw, Optional<unsigned> sh) >+ExceptionOr<Ref<ImageData>> ImageData::create(unsigned sw, unsigned sh, ImageDataSettings settings) >+{ >+ if (!sw || !sh) >+ return Exception { IndexSizeError }; >+ IntSize size(sw, sh); >+ auto dataSize = ImageData::dataSize(size); >+ if (dataSize.hasOverflowed()) >+ return Exception { RangeError, "Cannot allocate a buffer of this size"_s }; >+ auto byteArray = Uint8ClampedArray::tryCreateUninitialized(dataSize.unsafeGet()); >+ if (!byteArray) { >+ // FIXME: Does this need to be a "real" out of memory error with setOutOfMemoryError called on it? >+ return Exception { RangeError, "Out of memory"_s }; >+ } >+ byteArray->zeroFill(); >+ return adoptRef(*new ImageData(size, byteArray.releaseNonNull(), WTFMove(settings))); >+} >+ >+ >+ExceptionOr<Ref<ImageData>> ImageData::create(Ref<Uint8ClampedArray>&& byteArray, unsigned sw, Optional<unsigned> sh, ImageDataSettings settings) > { > unsigned length = byteArray->length(); > if (!length || length % 4) >@@ -93,22 +123,28 @@ ExceptionOr<Ref<ImageData>> ImageData::c > if (sh && sh.value() != height) > return Exception { IndexSizeError, "sh value is not equal to height"_s }; > >- auto result = create(IntSize(sw, height), WTFMove(byteArray)); >+ auto result = create(IntSize(sw, height), WTFMove(byteArray), WTFMove(settings)); > if (!result) > return Exception { RangeError }; > return result.releaseNonNull(); > } > >-ImageData::ImageData(const IntSize& size, Ref<Uint8ClampedArray>&& byteArray) >- : m_size(size) >- , m_data(WTFMove(byteArray)) >+ImageData::ImageData(const IntSize& size, Ref<Uint8ClampedArray>&& byteArray, ImageDataSettings settings) >+ : m_size { size } >+ , m_data { WTFMove(byteArray) } >+ , m_settings { WTFMove(settings) } > { > RELEASE_ASSERT_WITH_SECURITY_IMPLICATION((size.area() * 4).unsafeGet() <= m_data->length()); > } > >+DestinationColorSpace ImageData::colorSpace() const >+{ >+ return toDestinationColorSpace(m_settings.colorSpace); >+} >+ > Ref<ImageData> ImageData::deepClone() const > { >- return adoptRef(*new ImageData(m_size, Uint8ClampedArray::create(m_data->data(), m_data->length()))); >+ return adoptRef(*new ImageData(m_size, Uint8ClampedArray::create(m_data->data(), m_data->length()), m_settings)); > } > > TextStream& operator<<(TextStream& ts, const ImageData& imageData) >Index: Source/WebCore/html/ImageData.h >=================================================================== >--- Source/WebCore/html/ImageData.h (revision 276819) >+++ Source/WebCore/html/ImageData.h (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. >+ * Copyright (C) 2008-2021 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -28,6 +28,7 @@ > > #pragma once > >+#include "ImageDataSettings.h" > #include "ExceptionOr.h" > #include "IntSize.h" > #include <JavaScriptCore/TypedArrayInlines.h> >@@ -35,12 +36,15 @@ > > namespace WebCore { > >+enum class DestinationColorSpace : uint8_t; >+ > class ImageData : public RefCounted<ImageData> { > public: >- WEBCORE_EXPORT static ExceptionOr<Ref<ImageData>> create(unsigned sw, unsigned sh); >- WEBCORE_EXPORT static RefPtr<ImageData> create(const IntSize&); >- WEBCORE_EXPORT static RefPtr<ImageData> create(const IntSize&, Ref<Uint8ClampedArray>&&); >- WEBCORE_EXPORT static ExceptionOr<Ref<ImageData>> create(Ref<Uint8ClampedArray>&&, unsigned sw, Optional<unsigned> sh); >+ WEBCORE_EXPORT static RefPtr<ImageData> create(const IntSize&, DestinationColorSpace); >+ WEBCORE_EXPORT static RefPtr<ImageData> create(const IntSize&, ImageDataSettings); >+ WEBCORE_EXPORT static RefPtr<ImageData> create(const IntSize&, Ref<Uint8ClampedArray>&&, ImageDataSettings = { }); >+ WEBCORE_EXPORT static ExceptionOr<Ref<ImageData>> create(unsigned sw, unsigned sh, ImageDataSettings = { }); >+ WEBCORE_EXPORT static ExceptionOr<Ref<ImageData>> create(Ref<Uint8ClampedArray>&&, unsigned sw, Optional<unsigned> sh, ImageDataSettings = { }); > > IntSize size() const { return m_size; } > int width() const { return m_size.width(); } >@@ -48,14 +52,19 @@ public: > > Uint8ClampedArray* data() const { return m_data.ptr(); } > >+ DestinationColorSpace colorSpace() const; >+ ImageDataSettings getImageDataSettings() const { return m_settings; } >+ > Ref<ImageData> deepClone() const; > > private: >- ImageData(const IntSize&, Ref<Uint8ClampedArray>&&); >+ ImageData(const IntSize&, Ref<Uint8ClampedArray>&&, ImageDataSettings); >+ > static Checked<unsigned, RecordOverflow> dataSize(const IntSize&); > > IntSize m_size; > Ref<Uint8ClampedArray> m_data; >+ ImageDataSettings m_settings; > }; > > WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const ImageData&); >Index: Source/WebCore/html/ImageData.idl >=================================================================== >--- Source/WebCore/html/ImageData.idl (revision 276819) >+++ Source/WebCore/html/ImageData.idl (working copy) >@@ -38,4 +38,9 @@ > readonly attribute unsigned long width; > readonly attribute unsigned long height; > readonly attribute Uint8ClampedArray data; >+ >+ // Based on the proposal from https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md. >+ [EnabledBySetting=CanvasColorSpace] constructor(unsigned long sw, unsigned long sh, ImageDataSettings settings); >+ [EnabledBySetting=CanvasColorSpace] constructor(Uint8ClampedArray data, unsigned long sw, unsigned long sh, ImageDataSettings settings); >+ [EnabledBySetting=CanvasColorSpace] ImageDataSettings getImageDataSettings(); > }; >Index: Source/WebCore/html/ImageDataSettings.h >=================================================================== >--- Source/WebCore/html/ImageDataSettings.h (nonexistent) >+++ Source/WebCore/html/ImageDataSettings.h (working copy) >@@ -0,0 +1,55 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "PredefinedColorSpaceEnum.h" >+#include <wtf/Optional.h> >+ >+namespace WebCore { >+ >+struct ImageDataSettings { >+ PredefinedColorSpaceEnum colorSpace { PredefinedColorSpaceEnum::SRGB }; >+ >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<ImageDataSettings> decode(Decoder&); >+}; >+ >+template<class Encoder> inline void ImageDataSettings::encode(Encoder& encoder) const >+{ >+ encoder << colorSpace; >+} >+ >+template<class Decoder> inline Optional<ImageDataSettings> ImageDataSettings::decode(Decoder& decoder) >+{ >+ ImageDataSettings settings; >+ >+ if (!decoder.decode(settings.colorSpace)) >+ return WTF::nullopt; >+ >+ return settings; >+} >+ >+} >Index: Source/WebCore/html/ImageDataSettings.idl >=================================================================== >--- Source/WebCore/html/ImageDataSettings.idl (nonexistent) >+++ Source/WebCore/html/ImageDataSettings.idl (working copy) >@@ -0,0 +1,31 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+// Based on the proposal from https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md. >+[ >+ JSGenerateToJSObject, >+] dictionary ImageDataSettings { >+ [EnabledBySetting=CanvasColorSpace] PredefinedColorSpaceEnum colorSpace = "srgb"; >+}; >Index: Source/WebCore/html/canvas/CanvasImageData.idl >=================================================================== >--- Source/WebCore/html/canvas/CanvasImageData.idl (revision 276819) >+++ Source/WebCore/html/canvas/CanvasImageData.idl (working copy) >@@ -25,12 +25,10 @@ > > // https://html.spec.whatwg.org/multipage/canvas.html#canvasimagedata > interface mixin CanvasImageData { >- // FIXME: All the float arguments below should be longs. >- > // pixel manipulation >- ImageData createImageData(float sw, float sh); >+ ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh, optional ImageDataSettings settings); > ImageData createImageData(ImageData imagedata); >- ImageData getImageData(float sx, float sy, float sw, float sh); >- undefined putImageData(ImageData imagedata, float dx, float dy); >- undefined putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight); >+ ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh, optional ImageDataSettings settings); >+ undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy); >+ undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight); > }; >Index: Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (working copy) >@@ -37,12 +37,14 @@ > #include "CSSPropertyNames.h" > #include "CSSPropertyParserHelpers.h" > #include "CSSPropertyParserWorkerSafe.h" >+#include "ColorSpace.h" > #include "Gradient.h" > #include "ImageBuffer.h" > #include "ImageData.h" > #include "InspectorInstrumentation.h" > #include "NodeRenderStyle.h" > #include "Path2D.h" >+#include "PixelFormat.h" > #include "RenderTheme.h" > #include "RenderWidget.h" > #include "ResourceLoadObserver.h" >@@ -211,7 +213,8 @@ Ref<TextMetrics> CanvasRenderingContext2 > return measureTextInternal(textRun); > } > >-auto CanvasRenderingContext2D::fontProxy() -> const FontProxy* { >+auto CanvasRenderingContext2D::fontProxy() -> const FontProxy* >+{ > // Intentionally don't update style here, because updating style can cause JS to run synchronously. > // This function is called in the middle of processing, and running arbitrary JS in the middle of processing can cause unexpected behavior. > // Instead, the relevant canvas entry points update style once when they begin running, and we won't touch the style after that. >@@ -243,4 +246,15 @@ void CanvasRenderingContext2D::drawTextI > drawTextUnchecked(textRun, x, y, fill, maxWidth); > } > >+PixelFormat CanvasRenderingContext2D::pixelFormat() const >+{ >+ // FIXME: Take m_settings.alpha into account here and add PixelFormat::BGRX8. >+ return PixelFormat::BGRA8; >+} >+ >+DestinationColorSpace CanvasRenderingContext2D::colorSpace() const >+{ >+ return toDestinationColorSpace(m_settings.colorSpace); >+} >+ > } // namespace WebCore >Index: Source/WebCore/html/canvas/CanvasRenderingContext2D.h >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2D.h (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2D.h (working copy) >@@ -61,6 +61,9 @@ private: > > bool is2d() const final { return true; } > const FontProxy* fontProxy() final; >+ PixelFormat pixelFormat() const final; >+ DestinationColorSpace colorSpace() const final; >+ > void setFontWithoutUpdatingStyle(const String&); > > void drawTextInternal(const String& text, float x, float y, bool fill, Optional<float> maxWidth = WTF::nullopt); >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (working copy) >@@ -1643,7 +1643,7 @@ ExceptionOr<void> CanvasRenderingContext > repaintEntireCanvas = true; > } else if (state().globalComposite == CompositeOperator::Copy) { > if (&sourceCanvas == &canvasBase()) { >- if (auto copy = buffer->copyRectToBuffer(srcRect, DestinationColorSpace::SRGB, *c)) { >+ if (auto copy = buffer->copyRectToBuffer(srcRect, colorSpace(), *c)) { > clearCanvas(); > c->drawImageBuffer(*copy, dstRect, { { }, srcRect.size() }, { state().globalComposite, state().globalBlend }); > } >@@ -2026,7 +2026,7 @@ ExceptionOr<RefPtr<CanvasPattern>> Canva > #endif > > auto renderingMode = !drawingContext() || drawingContext()->isAcceleratedContext() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated; >- auto imageBuffer = videoElement.createBufferForPainting(size(videoElement), renderingMode); >+ auto imageBuffer = videoElement.createBufferForPainting(size(videoElement), renderingMode, colorSpace(), pixelFormat()); > if (!imageBuffer) > return nullptr; > >@@ -2151,9 +2151,9 @@ bool CanvasRenderingContext2DBase::needs > return false; > } > >-static RefPtr<ImageData> createEmptyImageData(const IntSize& size) >+static RefPtr<ImageData> createEmptyImageData(const IntSize& size, ImageDataSettings settings) > { >- auto data = ImageData::create(size); >+ auto data = ImageData::create(size, WTFMove(settings)); > if (data) > data->data()->zeroFill(); > return data; >@@ -2161,28 +2161,19 @@ static RefPtr<ImageData> createEmptyImag > > RefPtr<ImageData> CanvasRenderingContext2DBase::createImageData(ImageData& imageData) const > { >- return createEmptyImageData(imageData.size()); >+ return createEmptyImageData(imageData.size(), imageData.getImageDataSettings()); > } > >-ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::createImageData(float sw, float sh) const >+ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::createImageData(int sw, int sh, ImageDataSettings&& settings) const > { > if (!sw || !sh) > return Exception { IndexSizeError }; > >- FloatSize logicalSize(std::abs(sw), std::abs(sh)); >- if (!logicalSize.isExpressibleAsIntSize()) >- return nullptr; >- >- IntSize size = expandedIntSize(logicalSize); >- if (size.width() < 1) >- size.setWidth(1); >- if (size.height() < 1) >- size.setHeight(1); >- >- return createEmptyImageData(size); >+ IntSize size { std::abs(sw), std::abs(sh) }; >+ return createEmptyImageData(size, WTFMove(settings)); > } > >-ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::getImageData(float sx, float sy, float sw, float sh) const >+ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::getImageData(int sx, int sy, int sw, int sh, ImageDataSettings&& settings) const > { > if (!canvasBase().originClean()) { > static NeverDestroyed<String> consoleMessage(MAKE_STATIC_STRING_IMPL("Unable to get image data from canvas because the canvas has been tainted by cross-origin data.")); >@@ -2202,21 +2193,13 @@ ExceptionOr<RefPtr<ImageData>> CanvasRen > sh = -sh; > } > >- FloatRect logicalRect(sx, sy, sw, sh); >- if (logicalRect.width() < 1) >- logicalRect.setWidth(1); >- if (logicalRect.height() < 1) >- logicalRect.setHeight(1); >- if (!logicalRect.isExpressibleAsIntRect()) >- return nullptr; >- >- IntRect imageDataRect = enclosingIntRect(logicalRect); >+ IntRect imageDataRect { sx, sy, sw, sh }; > > ImageBuffer* buffer = canvasBase().buffer(); > if (!buffer) >- return createEmptyImageData(imageDataRect.size()); >+ return createEmptyImageData(imageDataRect.size(), WTFMove(settings)); > >- auto imageData = buffer->getImageData(AlphaPremultiplication::Unpremultiplied, imageDataRect); >+ auto imageData = buffer->getImageData(AlphaPremultiplication::Unpremultiplied, imageDataRect, toDestinationColorSpace(settings.colorSpace)); > if (!imageData) { > canvasBase().scriptExecutionContext()->addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, > makeString("Unable to get image data from canvas. Requested size was ", imageDataRect.width(), " x ", imageDataRect.height())); >@@ -2226,12 +2209,12 @@ ExceptionOr<RefPtr<ImageData>> CanvasRen > return imageData; > } > >-void CanvasRenderingContext2DBase::putImageData(ImageData& data, float dx, float dy) >+void CanvasRenderingContext2DBase::putImageData(ImageData& data, int dx, int dy) > { > putImageData(data, dx, dy, 0, 0, data.width(), data.height()); > } > >-void CanvasRenderingContext2DBase::putImageData(ImageData& data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight) >+void CanvasRenderingContext2DBase::putImageData(ImageData& data, int dx, int dy, int dirtyX, int dirtyY, int dirtyWidth, int dirtyHeight) > { > ImageBuffer* buffer = canvasBase().buffer(); > if (!buffer) >@@ -2250,20 +2233,20 @@ void CanvasRenderingContext2DBase::putIm > dirtyHeight = -dirtyHeight; > } > >- FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight); >- clipRect.intersect(IntRect(0, 0, data.width(), data.height())); >- IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy)); >- IntRect destRect = enclosingIntRect(clipRect); >+ IntRect clipRect { dirtyX, dirtyY, dirtyWidth, dirtyHeight }; >+ clipRect.intersect(IntRect { 0, 0, data.width(), data.height() }); >+ IntSize destOffset { dx, dy }; >+ IntRect destRect = clipRect; > destRect.move(destOffset); >- destRect.intersect(IntRect(IntPoint(), buffer->logicalSize())); >+ destRect.intersect(IntRect { { }, buffer->logicalSize() }); > if (destRect.isEmpty()) > return; >- IntRect sourceRect(destRect); >+ IntRect sourceRect { destRect }; > sourceRect.move(-destOffset); >- sourceRect.intersect(IntRect(0, 0, data.width(), data.height())); >+ sourceRect.intersect(IntRect { 0, 0, data.width(), data.height() }); > > if (!sourceRect.isEmpty()) >- buffer->putImageData(AlphaPremultiplication::Unpremultiplied, data, sourceRect, IntPoint(destOffset)); >+ buffer->putImageData(AlphaPremultiplication::Unpremultiplied, data, sourceRect, IntPoint { destOffset }); > > didDraw(FloatRect { destRect }, { }); // ignore transform, shadow and clip > } >@@ -2507,7 +2490,7 @@ void CanvasRenderingContext2DBase::drawT > } > }; > >- if (c->clipToDrawingCommands(maskRect, DestinationColorSpace::SRGB, WTFMove(paintMaskImage)) == GraphicsContext::ClipToDrawingCommandsResult::FailedToCreateImageBuffer) >+ if (c->clipToDrawingCommands(maskRect, colorSpace(), WTFMove(paintMaskImage)) == GraphicsContext::ClipToDrawingCommandsResult::FailedToCreateImageBuffer) > return; > > drawStyle.applyFillColor(*c); >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h (working copy) >@@ -42,6 +42,7 @@ > #include "GraphicsContext.h" > #include "GraphicsTypes.h" > #include "ImageBuffer.h" >+#include "ImageDataSettings.h" > #include "ImageSmoothingQuality.h" > #include "Path.h" > #include "PlatformLayer.h" >@@ -188,10 +189,10 @@ public: > ExceptionOr<RefPtr<CanvasPattern>> createPattern(CanvasImageSource&&, const String& repetition); > > RefPtr<ImageData> createImageData(ImageData&) const; >- ExceptionOr<RefPtr<ImageData>> createImageData(float width, float height) const; >- ExceptionOr<RefPtr<ImageData>> getImageData(float sx, float sy, float sw, float sh) const; >- void putImageData(ImageData&, float dx, float dy); >- void putImageData(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight); >+ ExceptionOr<RefPtr<ImageData>> createImageData(int width, int height, ImageDataSettings&& = { }) const; >+ ExceptionOr<RefPtr<ImageData>> getImageData(int sx, int sy, int sw, int sh, ImageDataSettings&& = { }) const; >+ void putImageData(ImageData&, int dx, int dy); >+ void putImageData(ImageData&, int dx, int dy, int dirtyX, int dirtyY, int dirtyWidth, int dirtyHeight); > > static constexpr float webkitBackingStorePixelRatio() { return 1; } > >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h (working copy) >@@ -25,10 +25,13 @@ > > #pragma once > >+#include "PredefinedColorSpaceEnum.h" >+ > namespace WebCore { > > struct CanvasRenderingContext2DSettings { > bool desynchronized { false }; >+ PredefinedColorSpaceEnum colorSpace { PredefinedColorSpaceEnum::SRGB }; > }; > > } // namespace WebCore >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.idl >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.idl (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.idl (working copy) >@@ -30,4 +30,7 @@ > // FIXME: Add support for 'alpha'. > // boolean alpha = true; > boolean desynchronized = false; >+ >+ // Based on the proposal from https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md. >+ [EnabledBySetting=CanvasColorSpace] PredefinedColorSpaceEnum colorSpace = "srgb"; > }; >Index: Source/WebCore/html/canvas/CanvasRenderingContext.cpp >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext.cpp (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext.cpp (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2009 Apple Inc. All rights reserved. >+ * Copyright (C) 2009-2021 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -28,11 +28,13 @@ > > #include "CachedImage.h" > #include "CanvasPattern.h" >+#include "ColorSpace.h" > #include "HTMLCanvasElement.h" > #include "HTMLImageElement.h" > #include "HTMLVideoElement.h" > #include "Image.h" > #include "ImageBitmap.h" >+#include "PixelFormat.h" > #include "SecurityOrigin.h" > #include <wtf/HashSet.h> > #include <wtf/IsoMallocInlines.h> >@@ -80,6 +82,16 @@ void CanvasRenderingContext::deref() > m_canvas.derefCanvasBase(); > } > >+PixelFormat CanvasRenderingContext::pixelFormat() const >+{ >+ return PixelFormat::BGRA8; >+} >+ >+DestinationColorSpace CanvasRenderingContext::colorSpace() const >+{ >+ return DestinationColorSpace::SRGB; >+} >+ > bool CanvasRenderingContext::wouldTaintOrigin(const CanvasPattern* pattern) > { > if (m_canvas.originClean() && pattern && !pattern->originClean()) >Index: Source/WebCore/html/canvas/CanvasRenderingContext.h >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext.h (revision 276819) >+++ Source/WebCore/html/canvas/CanvasRenderingContext.h (working copy) >@@ -42,6 +42,8 @@ class HTMLVideoElement; > class ImageBitmap; > class TypedOMCSSImageValue; > class WebGLObject; >+enum class DestinationColorSpace : uint8_t; >+enum class PixelFormat : uint8_t; > > class CanvasRenderingContext : public ScriptWrappable { > WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); >@@ -86,6 +88,9 @@ public: > virtual bool needsPreparationForDisplay() const { return false; } > virtual void prepareForDisplay() { } > >+ virtual PixelFormat pixelFormat() const; >+ virtual DestinationColorSpace colorSpace() const; >+ > protected: > explicit CanvasRenderingContext(CanvasBase&); > bool wouldTaintOrigin(const CanvasPattern*); >Index: Source/WebCore/html/canvas/PredefinedColorSpaceEnum.cpp >=================================================================== >--- Source/WebCore/html/canvas/PredefinedColorSpaceEnum.cpp (nonexistent) >+++ Source/WebCore/html/canvas/PredefinedColorSpaceEnum.cpp (working copy) >@@ -0,0 +1,48 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "PredefinedColorSpaceEnum.h" >+ >+#include "ColorSpace.h" >+ >+namespace WebCore { >+ >+DestinationColorSpace toDestinationColorSpace(PredefinedColorSpaceEnum colorSpace) >+{ >+ switch (colorSpace) { >+ case PredefinedColorSpaceEnum::SRGB: >+ return DestinationColorSpace::SRGB; >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ case PredefinedColorSpaceEnum::DisplayP3: >+ return DestinationColorSpace::DisplayP3; >+#endif >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return DestinationColorSpace::SRGB; >+} >+ >+} >Index: Source/WebCore/html/canvas/PredefinedColorSpaceEnum.h >=================================================================== >--- Source/WebCore/html/canvas/PredefinedColorSpaceEnum.h (nonexistent) >+++ Source/WebCore/html/canvas/PredefinedColorSpaceEnum.h (working copy) >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/EnumTraits.h> >+ >+namespace WebCore { >+ >+enum class DestinationColorSpace : uint8_t; >+ >+enum class PredefinedColorSpaceEnum { >+ SRGB >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ , DisplayP3 >+#endif >+}; >+ >+DestinationColorSpace toDestinationColorSpace(PredefinedColorSpaceEnum); >+ >+} >+ >+namespace WTF { >+ >+template<> struct EnumTraits<WebCore::PredefinedColorSpaceEnum> { >+ using values = EnumValues< >+ WebCore::PredefinedColorSpaceEnum, >+ WebCore::PredefinedColorSpaceEnum::SRGB >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ , WebCore::PredefinedColorSpaceEnum::DisplayP3 >+#endif >+ >; >+}; >+ >+} // namespace WTF >Index: Source/WebCore/html/canvas/PredefinedColorSpaceEnum.idl >=================================================================== >--- Source/WebCore/html/canvas/PredefinedColorSpaceEnum.idl (nonexistent) >+++ Source/WebCore/html/canvas/PredefinedColorSpaceEnum.idl (working copy) >@@ -0,0 +1,32 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+// Based on the proposal from https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md. >+enum PredefinedColorSpaceEnum { >+ "srgb" >+#if defined(ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3) && ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3 >+ , "display-p3" >+#endif >+}; >Index: Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp >=================================================================== >--- Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp (revision 276819) >+++ Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp (working copy) >@@ -29,7 +29,9 @@ > > #if ENABLE(DATE_AND_TIME_INPUT_TYPES) > >+#include "EventNames.h" > #include "FontCascade.h" >+#include "KeyboardEvent.h" > #include "RenderBlock.h" > #include "RenderStyle.h" > #include <wtf/IsoMallocInlines.h> >Index: Source/WebCore/inspector/InspectorCanvas.cpp >=================================================================== >--- Source/WebCore/inspector/InspectorCanvas.cpp (revision 276819) >+++ Source/WebCore/inspector/InspectorCanvas.cpp (working copy) >@@ -428,6 +428,12 @@ Optional<InspectorCanvasCallTracer::Proc > return {{ valueIndexForData(argument), RecordingSwizzleType::ImageData }}; > } > >+Optional<InspectorCanvasCallTracer::ProcessedArgument> InspectorCanvas::processArgument(ImageDataSettings&) >+{ >+ // FIXME: Implement. >+ return WTF::nullopt; >+} >+ > Optional<InspectorCanvasCallTracer::ProcessedArgument> InspectorCanvas::processArgument(ImageSmoothingQuality argument) > { > return {{ valueIndexForData(convertEnumerationToString(argument)), RecordingSwizzleType::String }}; >Index: Source/WebCore/inspector/InspectorCanvasCallTracer.cpp >=================================================================== >--- Source/WebCore/inspector/InspectorCanvasCallTracer.cpp (revision 276819) >+++ Source/WebCore/inspector/InspectorCanvasCallTracer.cpp (working copy) >@@ -37,6 +37,7 @@ > #include "HTMLImageElement.h" > #include "HTMLVideoElement.h" > #include "ImageData.h" >+#include "ImageDataSettings.h" > #include "InspectorCanvasAgent.h" > #include "InspectorInstrumentation.h" > #include "InstrumentingAgents.h" >Index: Source/WebCore/inspector/InspectorCanvasCallTracer.h >=================================================================== >--- Source/WebCore/inspector/InspectorCanvasCallTracer.h (revision 276819) >+++ Source/WebCore/inspector/InspectorCanvasCallTracer.h (working copy) >@@ -70,6 +70,7 @@ class WebGLTransformFeedback; > class WebGLUniformLocation; > class WebGLVertexArrayObject; > struct DOMMatrix2DInit; >+struct ImageDataSettings; > enum class RecordingSwizzleType : int; > enum class CanvasDirection; > enum class CanvasFillRule; >@@ -150,6 +151,7 @@ enum ImageSmoothingQuality; > macro(HTMLImageElement*) \ > macro(ImageBitmap*) \ > macro(ImageData*) \ >+ macro(ImageDataSettings&) \ > macro(ImageSmoothingQuality) \ > macro(Optional<float>&) \ > macro(Path2D*) \ >Index: Source/WebCore/platform/graphics/Color.cpp >=================================================================== >--- Source/WebCore/platform/graphics/Color.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/Color.cpp (working copy) >@@ -162,6 +162,18 @@ Color Color::semanticColor() const > return { asInline(), Flags::Semantic }; > } > >+ColorComponents<float, 4> Color::toColorComponentsInColorSpace(ColorSpace outputColorSpace) const >+{ >+ auto [inputColorSpace, components] = colorSpaceAndComponents(); >+ return converColorComponents(inputColorSpace, components, outputColorSpace); >+} >+ >+ColorComponents<float, 4> Color::toColorComponentsInColorSpace(DestinationColorSpace outputColorSpace) const >+{ >+ auto [inputColorSpace, components] = colorSpaceAndComponents(); >+ return converColorComponents(inputColorSpace, components, outputColorSpace); >+} >+ > std::pair<ColorSpace, ColorComponents<float, 4>> Color::colorSpaceAndComponents() const > { > if (isOutOfLine()) >Index: Source/WebCore/platform/graphics/Color.h >=================================================================== >--- Source/WebCore/platform/graphics/Color.h (revision 276819) >+++ Source/WebCore/platform/graphics/Color.h (working copy) >@@ -120,6 +120,9 @@ public: > // wrapper around toColorTypeLossy<>(). > template<typename T> SRGBA<T> toSRGBALossy() const { return toColorTypeLossy<SRGBA<T>>(); } > >+ ColorComponents<float, 4> toColorComponentsInColorSpace(ColorSpace) const; >+ ColorComponents<float, 4> toColorComponentsInColorSpace(DestinationColorSpace) const; >+ > WEBCORE_EXPORT std::pair<ColorSpace, ColorComponents<float, 4>> colorSpaceAndComponents() const; > > WEBCORE_EXPORT Color lightened() const; >Index: Source/WebCore/platform/graphics/ColorConversion.cpp >=================================================================== >--- Source/WebCore/platform/graphics/ColorConversion.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/ColorConversion.cpp (working copy) >@@ -26,6 +26,7 @@ > #include "config.h" > #include "ColorConversion.h" > >+#include "ColorSpace.h" > #include <wtf/MathExtras.h> > > namespace WebCore { >@@ -286,4 +287,56 @@ SRGBA<uint8_t> ColorConversion<SRGBA<uin > })); > } > >+// MARK: Conversion functions for raw color components with associated color spaces. >+ >+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, ColorSpace outputColorSpace) >+{ >+ return callWithColorType(inputColorComponents, inputColorSpace, [outputColorSpace] (const auto& inputColor) { >+ switch (outputColorSpace) { >+ case ColorSpace::A98RGB: >+ return asColorComponents(convertColor<A98RGB<float>>(inputColor)); >+ case ColorSpace::DisplayP3: >+ return asColorComponents(convertColor<DisplayP3<float>>(inputColor)); >+ case ColorSpace::LCH: >+ return asColorComponents(convertColor<LCHA<float>>(inputColor)); >+ case ColorSpace::Lab: >+ return asColorComponents(convertColor<Lab<float>>(inputColor)); >+ case ColorSpace::LinearSRGB: >+ return asColorComponents(convertColor<LinearSRGBA<float>>(inputColor)); >+ case ColorSpace::ProPhotoRGB: >+ return asColorComponents(convertColor<ProPhotoRGB<float>>(inputColor)); >+ case ColorSpace::Rec2020: >+ return asColorComponents(convertColor<Rec2020<float>>(inputColor)); >+ case ColorSpace::SRGB: >+ return asColorComponents(convertColor<SRGBA<float>>(inputColor)); >+ case ColorSpace::XYZ_D50: >+ return asColorComponents(convertColor<XYZA<float, WhitePoint::D50>>(inputColor)); >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return asColorComponents(convertColor<SRGBA<float>>(inputColor)); >+ }); >+} >+ >+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, DestinationColorSpace outputColorSpace) >+{ >+ return callWithColorType(inputColorComponents, inputColorSpace, [outputColorSpace] (const auto& inputColor) { >+ switch (outputColorSpace) { >+ case DestinationColorSpace::SRGB: >+ return asColorComponents(convertColor<SRGBA<float>>(inputColor)); >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ case DestinationColorSpace::LinearSRGB: >+ return asColorComponents(convertColor<LinearSRGBA<float>>(inputColor)); >+#endif >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ case DestinationColorSpace::DisplayP3: >+ return asColorComponents(convertColor<DisplayP3<float>>(inputColor)); >+#endif >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return asColorComponents(convertColor<SRGBA<float>>(inputColor)); >+ }); >+} >+ > } // namespace WebCore >Index: Source/WebCore/platform/graphics/ColorConversion.h >=================================================================== >--- Source/WebCore/platform/graphics/ColorConversion.h (revision 276819) >+++ Source/WebCore/platform/graphics/ColorConversion.h (working copy) >@@ -29,6 +29,17 @@ > > namespace WebCore { > >+enum class ColorSpace : uint8_t; >+enum class DestinationColorSpace : uint8_t; >+ >+// Conversion function for typed colors. >+template<typename Output, typename Input> Output convertColor(const Input& color); >+ >+// Conversion functions for raw color components with associated color spaces. >+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, ColorSpace outputColorSpace); >+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, DestinationColorSpace outputColorSpace); >+ >+ > // All color types, other than XYZA or those inheriting from RGBType, must implement > // the following conversions to and from their "Reference" color. > // >@@ -48,7 +59,6 @@ template<typename Output, typename Input > return ColorConversion<Output, Input>::convert(color); > } > >- > // MARK: Chromatic Adaptation conversions. > > // http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html >Index: Source/WebCore/platform/graphics/ColorSpace.cpp >=================================================================== >--- Source/WebCore/platform/graphics/ColorSpace.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/ColorSpace.cpp (working copy) >@@ -67,12 +67,19 @@ TextStream& operator<<(TextStream& ts, C > TextStream& operator<<(TextStream& ts, DestinationColorSpace colorSpace) > { > switch (colorSpace) { >+ case DestinationColorSpace::SRGB: >+ ts << "sRGB"; >+ break; >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) > case DestinationColorSpace::LinearSRGB: > ts << "LinearSRGB"; > break; >- case DestinationColorSpace::SRGB: >- ts << "sRGB"; >+#endif >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ case DestinationColorSpace::DisplayP3: >+ ts << "DisplayP3"; > break; >+#endif > } > return ts; > } >Index: Source/WebCore/platform/graphics/ColorSpace.h >=================================================================== >--- Source/WebCore/platform/graphics/ColorSpace.h (revision 276819) >+++ Source/WebCore/platform/graphics/ColorSpace.h (working copy) >@@ -48,8 +48,13 @@ enum class ColorSpace : uint8_t { > }; > > enum class DestinationColorSpace : uint8_t { >- LinearSRGB, >- SRGB, >+ SRGB >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ , LinearSRGB >+#endif >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ , DisplayP3 >+#endif > }; > > WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ColorSpace); >@@ -97,6 +102,26 @@ template<typename T, typename Functor> c > return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components)); > } > >+template<typename T, typename Functor> constexpr decltype(auto) callWithColorType(const ColorComponents<T, 4>& components, DestinationColorSpace colorSpace, Functor&& functor) >+{ >+ switch (colorSpace) { >+ case DestinationColorSpace::SRGB: >+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components)); >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ case DestinationColorSpace::LinearSRGB: >+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<LinearSRGBA<T>>(components)); >+#endif >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ case DestinationColorSpace::DisplayP3: >+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<DisplayP3<T>>(components)); >+#endif >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components)); >+} >+ >+ > } // namespace WebCore > > namespace WTF { >@@ -119,8 +144,13 @@ template<> struct EnumTraits<WebCore::Co > template<> struct EnumTraits<WebCore::DestinationColorSpace> { > using values = EnumValues< > WebCore::DestinationColorSpace, >- WebCore::DestinationColorSpace::LinearSRGB, > WebCore::DestinationColorSpace::SRGB >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ , WebCore::DestinationColorSpace::LinearSRGB >+#endif >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ , WebCore::DestinationColorSpace::DisplayP3 >+#endif > >; > }; > >Index: Source/WebCore/platform/graphics/ConcreteImageBuffer.h >=================================================================== >--- Source/WebCore/platform/graphics/ConcreteImageBuffer.h (revision 276819) >+++ Source/WebCore/platform/graphics/ConcreteImageBuffer.h (working copy) >@@ -230,11 +230,11 @@ protected: > return { }; > } > >- RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect) const override >+ RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, DestinationColorSpace destinationColorSpace) const override > { > if (auto* backend = ensureBackendCreated()) { > const_cast<ConcreteImageBuffer&>(*this).flushContext(); >- return backend->getImageData(outputFormat, srcRect); >+ return backend->getImageData(outputFormat, srcRect, destinationColorSpace); > } > return nullptr; > } >Index: Source/WebCore/platform/graphics/ImageBuffer.h >=================================================================== >--- Source/WebCore/platform/graphics/ImageBuffer.h (revision 276819) >+++ Source/WebCore/platform/graphics/ImageBuffer.h (working copy) >@@ -127,7 +127,9 @@ public: > virtual Vector<uint8_t> toData(const String& mimeType, Optional<double> quality = WTF::nullopt) const = 0; > virtual Vector<uint8_t> toBGRAData() const = 0; > >- virtual RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect) const = 0; >+ // FIXME: This is a layering violation. ImageData is a WebCore DOM exposed object and should not be reference by this >+ // platform layer object. >+ virtual RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, DestinationColorSpace) const = 0; > virtual void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint = { }, AlphaPremultiplication destFormat = AlphaPremultiplication::Premultiplied) = 0; > > // FIXME: current implementations of this method have the restriction that they only work >Index: Source/WebCore/platform/graphics/ImageBufferBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/ImageBufferBackend.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/ImageBufferBackend.cpp (working copy) >@@ -69,7 +69,7 @@ void ImageBufferBackend::drawConsuming(G > > void ImageBufferBackend::convertToLuminanceMask() > { >- auto imageData = getImageData(AlphaPremultiplication::Unpremultiplied, logicalRect()); >+ auto imageData = getImageData(AlphaPremultiplication::Unpremultiplied, logicalRect(), colorSpace()); > if (!imageData) > return; > >@@ -99,8 +99,8 @@ Vector<uint8_t> ImageBufferBackend::toBG > uint8_t* srcRows = reinterpret_cast<uint8_t*>(data); > > copyImagePixels( >- AlphaPremultiplication::Premultiplied, pixelFormat(), srcBytesPerRow, srcRows, >- AlphaPremultiplication::Unpremultiplied, PixelFormat::BGRA8, destBytesPerRow, result.data(), logicalSize()); >+ AlphaPremultiplication::Premultiplied, pixelFormat(), colorSpace(), srcBytesPerRow, srcRows, >+ AlphaPremultiplication::Unpremultiplied, PixelFormat::BGRA8, colorSpace(), destBytesPerRow, result.data(), logicalSize()); > > return result; > } >@@ -200,13 +200,16 @@ static inline void copyImagePixelsUnacce > } > > void ImageBufferBackend::copyImagePixels( >- AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, unsigned srcBytesPerRow, uint8_t* srcRows, >- AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, unsigned destBytesPerRow, uint8_t* destRows, const IntSize& size) const >+ AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, DestinationColorSpace srcColorSpace, unsigned srcBytesPerRow, uint8_t* srcRows, >+ AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, DestinationColorSpace destColorSpace, unsigned destBytesPerRow, uint8_t* destRows, const IntSize& size) const > { > // We don't currently support getting or putting pixel data with deep color buffers. > ASSERT(srcPixelFormat == PixelFormat::RGBA8 || srcPixelFormat == PixelFormat::BGRA8); > ASSERT(destPixelFormat == PixelFormat::RGBA8 || destPixelFormat == PixelFormat::BGRA8); > >+ // We don't currently support color space transforms in the base case. >+ ASSERT(srcColorSpace == destColorSpace); >+ > if (srcAlphaFormat == destAlphaFormat) { > if (srcAlphaFormat == AlphaPremultiplication::Premultiplied) > copyImagePixelsUnaccelerated<copyPremultipliedToPremultiplied>(srcPixelFormat, srcBytesPerRow, srcRows, destPixelFormat, destBytesPerRow, destRows, size); >@@ -223,11 +226,11 @@ void ImageBufferBackend::copyImagePixels > copyImagePixelsUnaccelerated<copyUnpremultipliedToPremultiplied>(srcPixelFormat, srcBytesPerRow, srcRows, destPixelFormat, destBytesPerRow, destRows, size); > } > >-RefPtr<ImageData> ImageBufferBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, void* data) const >+RefPtr<ImageData> ImageBufferBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, DestinationColorSpace destColorSpace, void* data) const > { > IntRect srcRectScaled = toBackendCoordinates(srcRect); > >- auto imageData = ImageData::create(srcRectScaled.size()); >+ auto imageData = ImageData::create(srcRectScaled.size(), destColorSpace); > if (!imageData) > return nullptr; > >@@ -250,8 +253,8 @@ RefPtr<ImageData> ImageBufferBackend::ge > uint8_t* srcRows = reinterpret_cast<uint8_t*>(data) + srcRectClipped.y() * srcBytesPerRow + srcRectClipped.x() * 4; > > copyImagePixels( >- AlphaPremultiplication::Premultiplied, pixelFormat(), srcBytesPerRow, srcRows, >- outputFormat, PixelFormat::RGBA8, destBytesPerRow, destRows, destRect.size()); >+ AlphaPremultiplication::Premultiplied, pixelFormat(), colorSpace(), srcBytesPerRow, srcRows, >+ outputFormat, PixelFormat::RGBA8, destColorSpace, destBytesPerRow, destRows, destRect.size()); > > return imageData; > } >@@ -274,15 +277,17 @@ void ImageBufferBackend::putImageData(Al > destRect.intersect(backendRect()); > srcRectClipped.setSize(destRect.size()); > >+ auto destColorSpace = colorSpace(); > unsigned destBytesPerRow = bytesPerRow(); > uint8_t* destRows = reinterpret_cast<uint8_t*>(data) + destRect.y() * destBytesPerRow + destRect.x() * 4; > >+ auto srcColorSpace = imageData.colorSpace(); > unsigned srcBytesPerRow = 4 * imageData.size().width(); > uint8_t* srcRows = imageData.data()->data() + srcRectClipped.y() * srcBytesPerRow + srcRectClipped.x() * 4; > > copyImagePixels( >- inputFormat, PixelFormat::RGBA8, srcBytesPerRow, srcRows, >- destFormat, pixelFormat(), destBytesPerRow, destRows, destRect.size()); >+ inputFormat, PixelFormat::RGBA8, srcColorSpace, srcBytesPerRow, srcRows, >+ destFormat, pixelFormat(), destColorSpace, destBytesPerRow, destRows, destRect.size()); > } > > } // namespace WebCore >Index: Source/WebCore/platform/graphics/ImageBufferBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/ImageBufferBackend.h (revision 276819) >+++ Source/WebCore/platform/graphics/ImageBufferBackend.h (working copy) >@@ -29,6 +29,7 @@ > #include "ColorSpace.h" > #include "FloatRect.h" > #include "GraphicsTypesGL.h" >+#include "PixelFormat.h" > #include "ImagePaintingOptions.h" > #include "IntRect.h" > #include "PlatformLayer.h" >@@ -55,13 +56,6 @@ enum class PreserveResolution : uint8_t > Yes, > }; > >-enum class PixelFormat : uint8_t { >- RGBA8, >- BGRA8, >- RGB10, >- RGB10A8, >-}; >- > enum class VolatilityState : uint8_t { > Valid, > Empty >@@ -115,7 +109,7 @@ public: > virtual Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const = 0; > virtual Vector<uint8_t> toBGRAData() const = 0; > >- virtual RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const = 0; >+ virtual RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&, DestinationColorSpace) const = 0; > virtual void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) = 0; > > virtual PlatformLayer* platformLayer() const { return nullptr; } >@@ -155,12 +149,12 @@ protected: > IntRect backendRect() const { return IntRect(IntPoint::zero(), backendSize()); }; > > WEBCORE_EXPORT virtual void copyImagePixels( >- AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, unsigned srcBytesPerRow, uint8_t* srcRows, >- AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, unsigned destBytesPerRow, uint8_t* destRows, const IntSize&) const; >+ AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, DestinationColorSpace srcColorSpace, unsigned srcBytesPerRow, uint8_t* srcRows, >+ AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, DestinationColorSpace destColorSpace, unsigned destBytesPerRow, uint8_t* destRows, const IntSize&) const; > > WEBCORE_EXPORT Vector<uint8_t> toBGRAData(void* data) const; > >- WEBCORE_EXPORT RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, void* data) const; >+ WEBCORE_EXPORT RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, DestinationColorSpace, void* data) const; > WEBCORE_EXPORT void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat, void* data); > > Parameters m_parameters; >@@ -170,16 +164,6 @@ protected: > > namespace WTF { > >-template<> struct EnumTraits<WebCore::PixelFormat> { >- using values = EnumValues< >- WebCore::PixelFormat, >- WebCore::PixelFormat::RGBA8, >- WebCore::PixelFormat::BGRA8, >- WebCore::PixelFormat::RGB10, >- WebCore::PixelFormat::RGB10A8 >- >; >-}; >- > template<> struct EnumTraits<WebCore::PreserveResolution> { > using values = EnumValues< > WebCore::PreserveResolution, >Index: Source/WebCore/platform/graphics/PixelFormat.h >=================================================================== >--- Source/WebCore/platform/graphics/PixelFormat.h (nonexistent) >+++ Source/WebCore/platform/graphics/PixelFormat.h (working copy) >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/EnumTraits.h> >+ >+namespace WebCore { >+ >+enum class PixelFormat : uint8_t { >+ RGBA8, >+ BGRA8, >+ RGB10, >+ RGB10A8, >+}; >+ >+} >+ >+namespace WTF { >+ >+template<> struct EnumTraits<WebCore::PixelFormat> { >+ using values = EnumValues< >+ WebCore::PixelFormat, >+ WebCore::PixelFormat::RGBA8, >+ WebCore::PixelFormat::BGRA8, >+ WebCore::PixelFormat::RGB10, >+ WebCore::PixelFormat::RGB10A8 >+ >; >+}; >+ >+} >Index: Source/WebCore/platform/graphics/ShadowBlur.cpp >=================================================================== >--- Source/WebCore/platform/graphics/ShadowBlur.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/ShadowBlur.cpp (working copy) >@@ -904,7 +904,7 @@ void ShadowBlur::blurShadowBuffer(ImageB > return; > > IntRect blurRect(IntPoint(), templateSize); >- auto layerData = layerImage.getImageData(AlphaPremultiplication::Unpremultiplied, blurRect); >+ auto layerData = layerImage.getImageData(AlphaPremultiplication::Unpremultiplied, blurRect, layerImage.colorSpace()); > if (!layerData) > return; > >Index: Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp >=================================================================== >--- Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (working copy) >@@ -79,7 +79,8 @@ static void wipeAlphaChannelFromPixels(i > > RefPtr<ImageData> GraphicsContextGLOpenGL::readPixelsForPaintResults() > { >- auto imageData = ImageData::create(getInternalFramebufferSize()); >+ // FIXME: Support non-SRGB. >+ auto imageData = ImageData::create(getInternalFramebufferSize(), DestinationColorSpace::SRGB); > if (!imageData) > return nullptr; > ScopedPixelStorageMode packAlignment(GL_PACK_ALIGNMENT); >Index: Source/WebCore/platform/graphics/cg/ColorSpaceCG.h >=================================================================== >--- Source/WebCore/platform/graphics/cg/ColorSpaceCG.h (revision 276819) >+++ Source/WebCore/platform/graphics/cg/ColorSpaceCG.h (working copy) >@@ -123,16 +123,16 @@ static inline CGColorSpaceRef cachedNull > static inline CGColorSpaceRef cachedCGColorSpace(DestinationColorSpace colorSpace) > { > switch (colorSpace) { >- case DestinationColorSpace::LinearSRGB: { >-#if HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE) >- return linearSRGBColorSpaceRef(); >-#else >- // FIXME: Windows should be able to use linear sRGB, this is tracked by http://webkit.org/b/80000. >- return sRGBColorSpaceRef(); >-#endif >- } > case DestinationColorSpace::SRGB: > return sRGBColorSpaceRef(); >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ case DestinationColorSpace::LinearSRGB: >+ return linearSRGBColorSpaceRef(); >+#endif >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ case DestinationColorSpace::DisplayP3: >+ return displayP3ColorSpaceRef(); >+#endif > } > ASSERT_NOT_REACHED(); > return sRGBColorSpaceRef(); >Index: Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp (working copy) >@@ -188,7 +188,7 @@ RetainPtr<CFDataRef> ImageBufferCGBacken > > if (CFEqual(uti.get(), jpegUTI())) { > // JPEGs don't have an alpha channel, so we have to manually composite on top of black. >- auto imageData = getImageData(AlphaPremultiplication::Premultiplied, logicalRect()); >+ auto imageData = getImageData(AlphaPremultiplication::Premultiplied, logicalRect(), colorSpace()); > if (!imageData) > return nullptr; > >@@ -255,13 +255,100 @@ static inline vImage_Buffer makeVImageBu > vImageBuffer.width = static_cast<vImagePixelCount>(size.width()); > vImageBuffer.rowBytes = bytesPerRow; > vImageBuffer.data = rows; >+ > return vImageBuffer; > } > >+static inline vImage_CGImageFormat makeVImageCGImageFormat(AlphaPremultiplication alphaFormat, PixelFormat pixelFormat, DestinationColorSpace colorSpace) >+{ >+ // We currently only support 8 bit pixel formats for these conversions. >+ >+ auto bitsPerComponent = [] (PixelFormat pixelFormat) -> unsigned { >+ switch (pixelFormat) { >+ case PixelFormat::RGBA8: >+ case PixelFormat::BGRA8: >+ return 8; >+ >+ case PixelFormat::RGB10: >+ case PixelFormat::RGB10A8: >+ break; >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return 8; >+ }; >+ >+ auto bitsPerPixel = [] (PixelFormat pixelFormat) -> unsigned { >+ switch (pixelFormat) { >+ case PixelFormat::RGBA8: >+ case PixelFormat::BGRA8: >+ return 32; >+ >+ case PixelFormat::RGB10: >+ case PixelFormat::RGB10A8: >+ break; >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return 32; >+ }; >+ >+ auto bitmapInfo = [] (AlphaPremultiplication alphaFormat, PixelFormat pixelFormat) -> CGBitmapInfo { >+ switch (pixelFormat) { >+ case PixelFormat::RGBA8: >+ if (alphaFormat == AlphaPremultiplication::Premultiplied) >+ return kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast; >+ else >+ return kCGBitmapByteOrder32Big | kCGImageAlphaLast; >+ >+ case PixelFormat::BGRA8: >+ if (alphaFormat == AlphaPremultiplication::Premultiplied) >+ return kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst; >+ else >+ return kCGBitmapByteOrder32Little | kCGImageAlphaFirst; >+ >+ case PixelFormat::RGB10: >+ case PixelFormat::RGB10A8: >+ break; >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return kCGBitmapByteOrder32Little | kCGImageAlphaFirst; >+ }; >+ >+ vImage_CGImageFormat format; >+ >+ format.bitsPerComponent = bitsPerComponent(pixelFormat); >+ format.bitsPerPixel = bitsPerPixel(pixelFormat); >+ format.colorSpace = cachedCGColorSpace(colorSpace); >+ format.bitmapInfo = bitmapInfo(alphaFormat, pixelFormat); >+ format.version = 0; >+ format.decode = nullptr; >+ format.renderingIntent = kCGRenderingIntentDefault; >+ >+ return format; >+} >+ > static inline void copyImagePixelsAccelerated( >- AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, vImage_Buffer& src, >- AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, vImage_Buffer& dest) >+ AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, DestinationColorSpace srcColorSpace, vImage_Buffer& src, >+ AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, DestinationColorSpace destColorSpace, vImage_Buffer& dest) > { >+ if (srcColorSpace != destColorSpace) { >+ // FIXME: Consider using vImageConvert_AnyToAny for all conversions, not just ones that need a color space conversion, >+ // after judiciously performance testing them against each other. >+ >+ auto srcFormat = makeVImageCGImageFormat(srcAlphaFormat, srcPixelFormat, srcColorSpace); >+ auto destFormat = makeVImageCGImageFormat(destAlphaFormat, destPixelFormat, destColorSpace); >+ >+ vImage_Error converterCreateError = kvImageNoError; >+ auto converter = adoptCF(vImageConverter_CreateWithCGImageFormat(&srcFormat, &destFormat, nullptr, kvImageNoFlags, &converterCreateError)); >+ ASSERT_WITH_MESSAGE(converterCreateError != kvImageNoError, "vImageConverter creation failed with error: %zd", converterCreateError); >+ >+ vImage_Error converterConvertError = vImageConvert_AnyToAny(converter.get(), &src, &dest, nullptr, kvImageNoFlags); >+ ASSERT_WITH_MESSAGE(converterConvertError == kvImageNoError, "vImageConvert_AnyToAny failed conversion with error: %zd", converterConvertError); >+ return; >+ } >+ > if (srcAlphaFormat == destAlphaFormat) { > ASSERT(srcPixelFormat != destPixelFormat); > // The destination alpha format can be unpremultiplied in the >@@ -294,22 +381,22 @@ static inline void copyImagePixelsAccele > } > > void ImageBufferCGBackend::copyImagePixels( >- AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, unsigned srcBytesPerRow, uint8_t* srcRows, >- AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, unsigned destBytesPerRow, uint8_t* destRows, const IntSize& size) const >+ AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, DestinationColorSpace srcColorSpace, unsigned srcBytesPerRow, uint8_t* srcRows, >+ AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, DestinationColorSpace destColorSpace, unsigned destBytesPerRow, uint8_t* destRows, const IntSize& size) const > { > // We don't currently support getting or putting pixel data with deep color buffers. > ASSERT(srcPixelFormat == PixelFormat::RGBA8 || srcPixelFormat == PixelFormat::BGRA8); > ASSERT(destPixelFormat == PixelFormat::RGBA8 || destPixelFormat == PixelFormat::BGRA8); > >- if (srcAlphaFormat == destAlphaFormat && srcPixelFormat == destPixelFormat) { >- ImageBufferBackend::copyImagePixels(srcAlphaFormat, srcPixelFormat, srcBytesPerRow, srcRows, destAlphaFormat, destPixelFormat, destBytesPerRow, destRows, size); >+ if (srcAlphaFormat == destAlphaFormat && srcPixelFormat == destPixelFormat && srcColorSpace == destColorSpace) { >+ ImageBufferBackend::copyImagePixels(srcAlphaFormat, srcPixelFormat, srcColorSpace, srcBytesPerRow, srcRows, destAlphaFormat, destPixelFormat, destColorSpace, destBytesPerRow, destRows, size); > return; > } > > vImage_Buffer src = makeVImageBuffer(srcBytesPerRow, srcRows, size); > vImage_Buffer dest = makeVImageBuffer(destBytesPerRow, destRows, size); > >- copyImagePixelsAccelerated(srcAlphaFormat, srcPixelFormat, src, destAlphaFormat, destPixelFormat, dest); >+ copyImagePixelsAccelerated(srcAlphaFormat, srcPixelFormat, srcColorSpace, src, destAlphaFormat, destPixelFormat, destColorSpace, dest); > } > #endif > >Index: Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h (revision 276819) >+++ Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h (working copy) >@@ -57,8 +57,8 @@ protected: > > #if USE(ACCELERATE) > void copyImagePixels( >- AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, unsigned srcBytesPerRow, uint8_t* srcRows, >- AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, unsigned destBytesPerRow, uint8_t* destRows, const IntSize&) const override; >+ AlphaPremultiplication srcAlphaFormat, PixelFormat srcPixelFormat, DestinationColorSpace srcColorSpace, unsigned srcBytesPerRow, uint8_t* srcRows, >+ AlphaPremultiplication destAlphaFormat, PixelFormat destPixelFormat, DestinationColorSpace destColorSpace, unsigned destBytesPerRow, uint8_t* destRows, const IntSize&) const override; > #endif > }; > >Index: Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp (working copy) >@@ -161,9 +161,9 @@ Vector<uint8_t> ImageBufferCGBitmapBacke > return ImageBufferBackend::toBGRAData(m_data); > } > >-RefPtr<ImageData> ImageBufferCGBitmapBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+RefPtr<ImageData> ImageBufferCGBitmapBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, DestinationColorSpace destinationColorSpace) const > { >- return ImageBufferBackend::getImageData(outputFormat, srcRect, m_data); >+ return ImageBufferBackend::getImageData(outputFormat, srcRect, destinationColorSpace, m_data); > } > > void ImageBufferCGBitmapBackend::putImageData(AlphaPremultiplication inputFormat, const ImageData& imageData, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >Index: Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h (revision 276819) >+++ Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h (working copy) >@@ -51,7 +51,7 @@ public: > > Vector<uint8_t> toBGRAData() const override; > >- RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const override; >+ RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&, DestinationColorSpace) const override; > void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; > > static constexpr bool isOriginAtUpperLeftCorner = true; >Index: Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp (working copy) >@@ -183,10 +183,10 @@ Vector<uint8_t> ImageBufferIOSurfaceBack > return ImageBufferBackend::toBGRAData(lock.surfaceBaseAddress()); > } > >-RefPtr<ImageData> ImageBufferIOSurfaceBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+RefPtr<ImageData> ImageBufferIOSurfaceBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, DestinationColorSpace destinationColorSpace) const > { > IOSurface::Locker lock(*m_surface); >- return ImageBufferBackend::getImageData(outputFormat, srcRect, lock.surfaceBaseAddress()); >+ return ImageBufferBackend::getImageData(outputFormat, srcRect, destinationColorSpace, lock.surfaceBaseAddress()); > } > > void ImageBufferIOSurfaceBackend::putImageData(AlphaPremultiplication inputFormat, const ImageData& imageData, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >Index: Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (revision 276819) >+++ Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (working copy) >@@ -61,7 +61,7 @@ public: > RetainPtr<CFDataRef> toCFData(const String& mimeType, Optional<double> quality, PreserveResolution) const override; > Vector<uint8_t> toBGRAData() const override; > >- RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const override; >+ RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&, DestinationColorSpace) const override; > void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; > IOSurface* surface(); > >Index: Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (working copy) >@@ -773,6 +773,7 @@ static TextStream& operator<<(TextStream > { > ts.dumpProperty("outputFormat", item.outputFormat()); > ts.dumpProperty("srcRect", item.srcRect()); >+ ts.dumpProperty("colorSpace", item.colorSpace()); > return ts; > } > >Index: Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (revision 276819) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (working copy) >@@ -1906,18 +1906,21 @@ public: > static constexpr bool isInlineItem = true; > static constexpr bool isDrawingItem = false; > >- GetImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect) >+ GetImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, DestinationColorSpace colorSpace) > : m_srcRect(srcRect) > , m_outputFormat(outputFormat) >+ , m_colorSpace(colorSpace) > { > } > > AlphaPremultiplication outputFormat() const { return m_outputFormat; } > IntRect srcRect() const { return m_srcRect; } >+ DestinationColorSpace colorSpace() const { return m_colorSpace; } > > private: > IntRect m_srcRect; > AlphaPremultiplication m_outputFormat; >+ DestinationColorSpace m_colorSpace; > }; > > class PutImageData { >Index: Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (working copy) >@@ -55,9 +55,9 @@ Recorder::~Recorder() > LOG(DisplayLists, "Recorded display list:\n%s", m_displayList.description().data()); > } > >-void Recorder::getImageData(AlphaPremultiplication outputFormat, const IntRect& sourceRect) >+void Recorder::getImageData(AlphaPremultiplication outputFormat, const IntRect& sourceRect, DestinationColorSpace destinationColorSpace) > { >- append<GetImageData>(outputFormat, sourceRect); >+ append<GetImageData>(outputFormat, sourceRect, destinationColorSpace); > } > > void Recorder::putImageData(WebCore::AlphaPremultiplication inputFormat, const WebCore::ImageData& imageData, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) >Index: Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (revision 276819) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (working copy) >@@ -57,7 +57,7 @@ public: > WEBCORE_EXPORT Recorder(GraphicsContext&, DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, Delegate* = nullptr, DrawGlyphsRecorder::DrawGlyphsDeconstruction = DrawGlyphsRecorder::DrawGlyphsDeconstruction::Deconstruct); > WEBCORE_EXPORT virtual ~Recorder(); > >- WEBCORE_EXPORT void getImageData(AlphaPremultiplication outputFormat, const IntRect& sourceRect); >+ WEBCORE_EXPORT void getImageData(AlphaPremultiplication outputFormat, const IntRect& sourceRect, DestinationColorSpace destinationColorSpace); > WEBCORE_EXPORT void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); > > bool isEmpty() const { return m_displayList.isEmpty(); } >Index: Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp >=================================================================== >--- Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp (working copy) >@@ -286,7 +286,7 @@ void FEColorMatrix::platformApplySoftwar > resultImage->context().drawImageBuffer(*inBuffer, drawingRegionOfInputImage(in->absolutePaintRect())); > > IntRect imageRect(IntPoint(), resultImage->logicalSize()); >- auto imageData = resultImage->getImageData(AlphaPremultiplication::Unpremultiplied, imageRect); >+ auto imageData = resultImage->getImageData(AlphaPremultiplication::Unpremultiplied, imageRect, resultImage->colorSpace()); > if (!imageData) > return; > >Index: Source/WebCore/platform/graphics/filters/FEDropShadow.cpp >=================================================================== >--- Source/WebCore/platform/graphics/filters/FEDropShadow.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/filters/FEDropShadow.cpp (working copy) >@@ -101,7 +101,7 @@ void FEDropShadow::platformApplySoftware > > // TODO: Direct pixel access to ImageBuffer would avoid copying the ImageData. > IntRect shadowArea(IntPoint(), resultImage->logicalSize()); >- auto imageData = resultImage->getImageData(AlphaPremultiplication::Premultiplied, shadowArea); >+ auto imageData = resultImage->getImageData(AlphaPremultiplication::Premultiplied, shadowArea, resultImage->colorSpace()); > if (!imageData) > return; > >Index: Source/WebCore/platform/graphics/filters/FELighting.cpp >=================================================================== >--- Source/WebCore/platform/graphics/filters/FELighting.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/filters/FELighting.cpp (working copy) >@@ -403,14 +403,10 @@ bool FELighting::drawLighting(Uint8Clamp > data.widthMultipliedByPixelSize = width * cPixelSize; > data.widthDecreasedByOne = width - 1; > data.heightDecreasedByOne = height - 1; >- >- if (operatingColorSpace() == DestinationColorSpace::LinearSRGB) { >- auto [r, g, b, a] = m_lightingColor.toColorTypeLossy<LinearSRGBA<float>>(); >- paintingData.initialLightingData.colorVector = FloatPoint3D(r, g, b); >- } else { >- auto [r, g, b, a] = m_lightingColor.toSRGBALossy<float>(); >- paintingData.initialLightingData.colorVector = FloatPoint3D(r, g, b); >- } >+ >+ auto [r, g, b, a] = m_lightingColor.toColorComponentsInColorSpace(operatingColorSpace()); >+ paintingData.initialLightingData.colorVector = FloatPoint3D(r, g, b); >+ > m_lightSource->initPaintingData(*this, paintingData); > > // Top left. >Index: Source/WebCore/platform/graphics/filters/FilterEffect.cpp >=================================================================== >--- Source/WebCore/platform/graphics/filters/FilterEffect.cpp (revision 276819) >+++ Source/WebCore/platform/graphics/filters/FilterEffect.cpp (working copy) >@@ -448,6 +448,8 @@ RefPtr<ImageData> FilterEffect::convertI > > RefPtr<ImageData> FilterEffect::convertImageBufferToColorSpace(DestinationColorSpace targetColorSpace, ImageBuffer& inputBuffer, const IntRect& rect, AlphaPremultiplication outputFormat) > { >+ // FIXME: Now that getImageData() supports color space conversion we no longer need to round trip through a ImageBuffer. >+ > FloatSize clampedSize = ImageBuffer::clampedSize(rect.size()); > // Create an ImageBuffer with the correct color space and utilize CG to handle color space conversion > auto convertedBuffer = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), targetColorSpace); >@@ -455,7 +457,7 @@ RefPtr<ImageData> FilterEffect::convertI > return nullptr; > // Color space conversion happens internally when drawing from one image buffer to another > convertedBuffer->context().drawImageBuffer(inputBuffer, rect); >- return convertedBuffer->getImageData(outputFormat, rect); >+ return convertedBuffer->getImageData(outputFormat, rect, targetColorSpace); > } > > void FilterEffect::copyConvertedImageBufferToDestination(Uint8ClampedArray& destination, DestinationColorSpace colorSpace, AlphaPremultiplication outputFormat, const IntRect& destRect) >@@ -490,14 +492,14 @@ void FilterEffect::copyUnmultipliedResul > copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Unpremultiplied, rect); > return; > } >- m_unmultipliedImageResult = m_imageBufferResult->getImageData(AlphaPremultiplication::Unpremultiplied, { IntPoint(), m_absolutePaintRect.size() }); >+ m_unmultipliedImageResult = m_imageBufferResult->getImageData(AlphaPremultiplication::Unpremultiplied, { IntPoint(), m_absolutePaintRect.size() }, m_resultColorSpace); > if (!m_unmultipliedImageResult) > return; > } else { > IntSize inputSize(m_absolutePaintRect.size()); > ASSERT(!ImageBuffer::sizeNeedsClamping(inputSize)); > inputSize.scale(m_filter.filterScale()); >- m_unmultipliedImageResult = ImageData::create(inputSize); >+ m_unmultipliedImageResult = ImageData::create(inputSize, m_resultColorSpace); > if (!m_unmultipliedImageResult) > return; > copyUnpremultiplyingAlpha(*m_premultipliedImageResult->data(), *m_unmultipliedImageResult->data(), inputSize); >@@ -523,14 +525,14 @@ void FilterEffect::copyPremultipliedResu > copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Premultiplied, rect); > return; > } >- m_premultipliedImageResult = m_imageBufferResult->getImageData(AlphaPremultiplication::Premultiplied, { IntPoint(), m_absolutePaintRect.size() }); >+ m_premultipliedImageResult = m_imageBufferResult->getImageData(AlphaPremultiplication::Premultiplied, { IntPoint(), m_absolutePaintRect.size() }, m_resultColorSpace); > if (!m_premultipliedImageResult) > return; > } else { > IntSize inputSize(m_absolutePaintRect.size()); > ASSERT(!ImageBuffer::sizeNeedsClamping(inputSize)); > inputSize.scale(m_filter.filterScale()); >- m_premultipliedImageResult = ImageData::create(inputSize); >+ m_premultipliedImageResult = ImageData::create(inputSize, m_resultColorSpace); > if (!m_premultipliedImageResult) > return; > copyPremultiplyingAlpha(*m_unmultipliedImageResult->data(), *m_premultipliedImageResult->data(), inputSize); >@@ -570,7 +572,7 @@ ImageData* FilterEffect::createUnmultipl > IntSize resultSize(m_absolutePaintRect.size()); > ASSERT(!ImageBuffer::sizeNeedsClamping(resultSize)); > resultSize.scale(m_filter.filterScale()); >- m_unmultipliedImageResult = ImageData::create(resultSize); >+ m_unmultipliedImageResult = ImageData::create(resultSize, m_resultColorSpace); > return m_unmultipliedImageResult.get(); > } > >@@ -586,7 +588,7 @@ ImageData* FilterEffect::createPremultip > IntSize resultSize(m_absolutePaintRect.size()); > ASSERT(!ImageBuffer::sizeNeedsClamping(resultSize)); > resultSize.scale(m_filter.filterScale()); >- m_premultipliedImageResult = ImageData::create(resultSize); >+ m_premultipliedImageResult = ImageData::create(resultSize, m_resultColorSpace); > return m_premultipliedImageResult.get(); > } > >Index: Source/WebCore/platform/graphics/filters/FilterEffect.h >=================================================================== >--- Source/WebCore/platform/graphics/filters/FilterEffect.h (revision 276819) >+++ Source/WebCore/platform/graphics/filters/FilterEffect.h (working copy) >@@ -241,7 +241,13 @@ private: > // Should the effect clip to its primitive region, or expand to use the combined region of its inputs. > bool m_clipsToBounds { true }; > >- DestinationColorSpace m_operatingColorSpace { DestinationColorSpace::LinearSRGB }; >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ static constexpr auto defaultOperatingColorSpace = DestinationColorSpace::LinearSRGB; >+#else >+ static constexpr auto defaultOperatingColorSpace = DestinationColorSpace::SRGB; >+#endif >+ >+ DestinationColorSpace m_operatingColorSpace { defaultOperatingColorSpace }; > DestinationColorSpace m_resultColorSpace { DestinationColorSpace::SRGB }; > > const Type m_filterEffectClassType; >Index: Source/WebCore/rendering/CSSFilter.cpp >=================================================================== >--- Source/WebCore/rendering/CSSFilter.cpp (revision 276819) >+++ Source/WebCore/rendering/CSSFilter.cpp (working copy) >@@ -109,9 +109,13 @@ RefPtr<FilterEffect> CSSFilter::buildRef > } > > effectElement.setStandardAttributes(effect.get()); >- if (effectElement.renderer()) >+ if (effectElement.renderer()) { >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) > effect->setOperatingColorSpace(effectElement.renderer()->style().svgStyle().colorInterpolationFilters() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB); >- >+#else >+ effect->setOperatingColorSpace(DestinationColorSpace::SRGB); >+#endif >+ } > builder->add(effectElement.result(), effect); > referenceEffects.append(*effect); > } >Index: Source/WebCore/rendering/shapes/Shape.cpp >=================================================================== >--- Source/WebCore/rendering/shapes/Shape.cpp (revision 276819) >+++ Source/WebCore/rendering/shapes/Shape.cpp (working copy) >@@ -197,7 +197,7 @@ std::unique_ptr<Shape> Shape::createRast > if (image) > graphicsContext.drawImage(*image, IntRect(IntPoint(), imageRect.size())); > >- auto imageData = imageBuffer->getImageData(AlphaPremultiplication::Unpremultiplied, { IntPoint(), imageRect.size() }); >+ auto imageData = imageBuffer->getImageData(AlphaPremultiplication::Unpremultiplied, { IntPoint(), imageRect.size() }, imageBuffer->colorSpace()); > > // We could get to a value where imageData could be nullptr. A case where ImageRect.size() is huge, imageData::create > // can return a nullptr because data size has overflowed. Refer rdar://problem/61793884 >Index: Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp >=================================================================== >--- Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp (revision 276819) >+++ Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp (working copy) >@@ -102,8 +102,13 @@ std::unique_ptr<SVGFilterBuilder> Render > builder->appendEffectToEffectReferences(effect.copyRef(), element.renderer()); > element.setStandardAttributes(effect.get()); > effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(&element, filterElement().primitiveUnits(), targetBoundingBox)); >- if (element.renderer()) >+ if (element.renderer()) { >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) > effect->setOperatingColorSpace(element.renderer()->style().svgStyle().colorInterpolationFilters() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB); >+#else >+ effect->setOperatingColorSpace(DestinationColorSpace::SRGB); >+#endif >+ } > builder->add(element.result(), WTFMove(effect)); > } > return builder; >@@ -191,8 +196,13 @@ bool RenderSVGResourceFilter::applyResou > effectiveTransform.scale(scale.width(), scale.height()); > effectiveTransform.multiply(filterData->shearFreeAbsoluteTransform); > >- RenderingMode renderingMode = renderer.settings().acceleratedFiltersEnabled() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated; >- auto sourceGraphic = SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, DestinationColorSpace::LinearSRGB, renderingMode, context); >+ auto renderingMode = renderer.settings().acceleratedFiltersEnabled() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated; >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) >+ auto colorSpace = DestinationColorSpace::LinearSRGB; >+#else >+ auto colorSpace = DestinationColorSpace::SRGB; >+#endif >+ auto sourceGraphic = SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, colorSpace, renderingMode, context); > if (!sourceGraphic) { > ASSERT(!m_rendererFilterDataMap.contains(&renderer)); > filterData->savedContext = context; >Index: Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp >=================================================================== >--- Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (revision 276819) >+++ Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (working copy) >@@ -69,7 +69,13 @@ bool RenderSVGResourceMasker::applyResou > > if (!maskerData->maskImage && !repaintRect.isEmpty()) { > const SVGRenderStyle& svgStyle = style().svgStyle(); >+ >+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) > auto colorSpace = svgStyle.colorInterpolation() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB; >+#else >+ auto colorSpace = DestinationColorSpace::SRGB; >+#endif >+ > // FIXME (149470): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks alpha masking, though. > maskerData->maskImage = SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, colorSpace, RenderingMode::Unaccelerated, context); > if (!maskerData->maskImage) >Index: Source/WebCore/testing/Internals.cpp >=================================================================== >--- Source/WebCore/testing/Internals.cpp (revision 276819) >+++ Source/WebCore/testing/Internals.cpp (working copy) >@@ -6191,7 +6191,7 @@ void Internals::loadArtworkImage(String& > m_artworkImagePromise = makeUnique<ArtworkImagePromise>(WTFMove(promise)); > m_artworkLoader = makeUnique<ArtworkImageLoader>(*contextDocument(), url, [this](Image* image) { > if (image) { >- auto imageData = ImageData::create(unsigned(image->width()), unsigned(image->height())); >+ auto imageData = ImageData::create(static_cast<unsigned>(image->width()), static_cast<unsigned>(image->height())); > if (!imageData.hasException()) > m_artworkImagePromise->resolve(imageData.releaseReturnValue()); > else >Index: Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >=================================================================== >--- Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (revision 276819) >+++ Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (working copy) >@@ -78,7 +78,7 @@ private: > { > if (item.is<WebCore::DisplayList::GetImageData>()) { > auto& getImageDataItem = item.get<WebCore::DisplayList::GetImageData>(); >- auto imageData = BaseConcreteImageBuffer::getImageData(getImageDataItem.outputFormat(), getImageDataItem.srcRect()); >+ auto imageData = BaseConcreteImageBuffer::getImageData(getImageDataItem.outputFormat(), getImageDataItem.srcRect(), getImageDataItem.colorSpace()); > m_remoteRenderingBackend.populateGetImageDataSharedMemory(imageData.get()); > return true; > } >Index: Source/WebKit/Shared/WebCoreArgumentCoders.cpp >=================================================================== >--- Source/WebKit/Shared/WebCoreArgumentCoders.cpp (revision 276819) >+++ Source/WebKit/Shared/WebCoreArgumentCoders.cpp (working copy) >@@ -3144,6 +3144,7 @@ template<typename Encoder> > void ArgumentCoder<Ref<WebCore::ImageData>>::encode(Encoder& encoder, const Ref<WebCore::ImageData>& imageData) > { > encoder << imageData->size(); >+ encoder << imageData->getImageDataSettings(); > > auto rawData = imageData->data(); > encoder << static_cast<uint64_t>(rawData->byteLength()); >@@ -3162,6 +3163,11 @@ Optional<Ref<WebCore::ImageData>> Argume > if (!imageDataSize) > return WTF::nullopt; > >+ Optional<ImageDataSettings> imageDataSettings; >+ decoder >> imageDataSettings; >+ if (!imageDataSettings) >+ return WTF::nullopt; >+ > Optional<uint64_t> dataLength; > decoder >> dataLength; > if (!dataLength) >@@ -3171,7 +3177,7 @@ Optional<Ref<WebCore::ImageData>> Argume > if (!decoder.decodeFixedLengthData(rawData->data(), rawData->length(), 1)) > return WTF::nullopt; > >- auto imageData = ImageData::create(*imageDataSize, WTFMove(rawData)); >+ auto imageData = ImageData::create(*imageDataSize, WTFMove(rawData), WTFMove(*imageDataSettings)); > if (!imageData) > return WTF::nullopt; > >Index: Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (revision 276819) >+++ Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (working copy) >@@ -158,9 +158,9 @@ Vector<uint8_t> ImageBufferShareableBitm > return ImageBufferBackend::toBGRAData(m_bitmap->data()); > } > >-RefPtr<ImageData> ImageBufferShareableBitmapBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+RefPtr<ImageData> ImageBufferShareableBitmapBackend::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, WebCore::DestinationColorSpace destinationColorSpace) const > { >- return ImageBufferBackend::getImageData(outputFormat, srcRect, m_bitmap->data()); >+ return ImageBufferBackend::getImageData(outputFormat, srcRect, destinationColorSpace, m_bitmap->data()); > } > > void ImageBufferShareableBitmapBackend::putImageData(AlphaPremultiplication inputFormat, const ImageData& imageData, const IntRect& srcRect, const IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) >Index: Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h (revision 276819) >+++ Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h (working copy) >@@ -63,7 +63,7 @@ public: > RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::PreserveResolution = WebCore::PreserveResolution::No) const override; > > Vector<uint8_t> toBGRAData() const override; >- RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&) const override; >+ RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&, WebCore::DestinationColorSpace) const override; > void putImageData(WebCore::AlphaPremultiplication inputFormat, const WebCore::ImageData&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override; > > private: >Index: Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (revision 276819) >+++ Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (working copy) >@@ -194,12 +194,12 @@ protected: > return bitmap->createImage(); > } > >- RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect) const override >+ RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect, DestinationColorSpace destinationColorSpace) const override > { > if (UNLIKELY(!m_remoteRenderingBackendProxy)) > return nullptr; > >- auto imageData = WebCore::ImageData::create(srcRect.size()); >+ auto imageData = WebCore::ImageData::create(srcRect.size(), destinationColorSpace); > if (!imageData || !imageData->data()) > return nullptr; > size_t dataSize = imageData->data()->byteLength(); >@@ -210,7 +210,7 @@ protected: > return nullptr; > > auto& mutableThis = const_cast<RemoteImageBufferProxy&>(*this); >- mutableThis.m_drawingContext.recorder().getImageData(outputFormat, srcRect); >+ mutableThis.m_drawingContext.recorder().getImageData(outputFormat, srcRect, destinationColorSpace); > mutableThis.flushDrawingContextAsync(); > > if (m_remoteRenderingBackendProxy->waitForGetImageDataToComplete(timeout)) >Index: Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp (revision 276819) >+++ Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp (working copy) >@@ -120,7 +120,7 @@ Vector<uint8_t> ImageBufferShareableIOSu > return { }; > } > >-RefPtr<ImageData> ImageBufferShareableIOSurfaceBackend::getImageData(AlphaPremultiplication, const IntRect&) const >+RefPtr<ImageData> ImageBufferShareableIOSurfaceBackend::getImageData(AlphaPremultiplication, const IntRect&, DestinationColorSpace) const > { > RELEASE_ASSERT_NOT_REACHED(); > return { }; >Index: Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h (revision 276819) >+++ Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h (working copy) >@@ -60,7 +60,7 @@ public: > String toDataURL(const String& mimeType, Optional<double> quality, WebCore::PreserveResolution) const override; > Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const override; > Vector<uint8_t> toBGRAData() const override; >- RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&) const override; >+ RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&, WebCore::DestinationColorSpace) const override; > void putImageData(WebCore::AlphaPremultiplication inputFormat, const WebCore::ImageData&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override; > > static constexpr bool isOriginAtUpperLeftCorner = true;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 225140
:
427308
|
427309
| 427479