NEW 213105
Refactor SVG Filter Image Data Pipeline
https://bugs.webkit.org/show_bug.cgi?id=213105
Summary Refactor SVG Filter Image Data Pipeline
frankhome61
Reported 2020-06-11 17:23:04 PDT
Currently in SVG filters, image pixel data is passed around from filter to filter in one of the three forms, m_imageBufferResult (ImageBuffer), m_unmultipliedImageResult (ImageData) or m_premultipliedImageResult (ImageData). For any given SVG filter object, of the three pixel data pointers, only one will be non null. This creates an complication in color space conversion on CG platforms, because color space conversion on CG platforms are handled when writing an ImageBuffer to another ImageBuffer, by the CG backend. However when a filter consumes data from an input which contains no ImageBuffer, but instead ImageData, by calling FilterEffect::copyUnmultipliedResult or FilterEffect::copyPremultipliedResult, color space conversion has to be handled separately. Therefore, to simplify the color conversion process, one idea would be refactoring the code to only use ImageBuffers to store image information, without using ImageData.
Attachments
Radar WebKit Bug Importer
Comment 1 2020-06-11 17:23:30 PDT
Said Abou-Hallawa
Comment 2 2020-06-11 20:15:06 PDT
>> Therefore, to simplify the color conversion process, one idea would be refactoring the code to only use ImageBuffers to store image information, without using ImageData. There are two main differences between ImageBuffer and ImageData: 1) The pixels of the rows in the ImageBuffer are not necessarily contiguous. There might be gaps between the rows because of an alignment applied to each row. See ImageBufferCairoSurfaceBackend::bytesPerRow() ImageBufferIOSurfaceBackend::bytesPerRow() ImageBufferBackend::bytesPerRow() For CG filters we create unaccelerated ImageBuffers which means the pixels of the rows are contagious. But for Cairo, the pixels of the rows are not contagious. The pixels of ImageData have to be contiguous. 2) The color format of the ImageBuffer might be RGBA or BGRA. But the pixels of the ImageData have to be RGBA. See ImageBufferCairoBackend::backendColorFormat() ImageBufferCGBitmapBackend::backendColorFormat() ImageBufferIOSurfaceBackend::backendColorFormat() Keep in mind, ImageBuffer can be backed by a memory buffer but the pixels of this buffer have to be arranged such that a GraphicsContext can be created on top of this buffer and we can draw to this GraphicsContext. But ImageData is simply a buffer where pixels can be enumerated easily. So converting between ImageData and ImageBuffer is an expensive operation that we should avoid as much as we can.
Note You need to log in before you can comment on or make changes to this bug.