|
Lines 279-287
ImageBuffer* FilterEffect::imageBufferRe
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec1
|
| 279 |
|
279 |
|
| 280 |
IntRect destinationRect(IntPoint(), m_absolutePaintRect.size()); |
280 |
IntRect destinationRect(IntPoint(), m_absolutePaintRect.size()); |
| 281 |
if (m_premultipliedImageResult) |
281 |
if (m_premultipliedImageResult) |
| 282 |
m_imageBufferResult->putPixelBuffer(AlphaPremultiplication::Premultiplied, *m_premultipliedImageResult, destinationRect); |
282 |
m_imageBufferResult->putPixelBuffer(*m_premultipliedImageResult, destinationRect); |
| 283 |
else |
283 |
else |
| 284 |
m_imageBufferResult->putPixelBuffer(AlphaPremultiplication::Unpremultiplied, *m_unmultipliedImageResult, destinationRect); |
284 |
m_imageBufferResult->putPixelBuffer(*m_unmultipliedImageResult, destinationRect); |
| 285 |
return m_imageBufferResult.get(); |
285 |
return m_imageBufferResult.get(); |
| 286 |
} |
286 |
} |
| 287 |
|
287 |
|
|
Lines 439-445
static void copyUnpremultiplyingAlpha(co
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec2
|
| 439 |
#endif |
439 |
#endif |
| 440 |
} |
440 |
} |
| 441 |
|
441 |
|
| 442 |
Optional<PixelBuffer> FilterEffect::convertPixelBufferToColorSpace(DestinationColorSpace targetColorSpace, PixelBuffer& pixelBuffer, AlphaPremultiplication outputFormat) |
442 |
Optional<PixelBuffer> FilterEffect::convertPixelBufferToColorSpace(DestinationColorSpace targetColorSpace, PixelBuffer& pixelBuffer) |
| 443 |
{ |
443 |
{ |
| 444 |
// FIXME: Using an ImageBuffer to perform the color space conversion is unnecessary. We can do it directly. |
444 |
// FIXME: Using an ImageBuffer to perform the color space conversion is unnecessary. We can do it directly. |
| 445 |
|
445 |
|
|
Lines 450-469
Optional<PixelBuffer> FilterEffect::conv
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec3
|
| 450 |
auto buffer = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), operatingColorSpace(), PixelFormat::BGRA8); |
450 |
auto buffer = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), operatingColorSpace(), PixelFormat::BGRA8); |
| 451 |
if (!buffer) |
451 |
if (!buffer) |
| 452 |
return WTF::nullopt; |
452 |
return WTF::nullopt; |
| 453 |
buffer->putPixelBuffer(outputFormat, pixelBuffer, destinationRect); |
453 |
buffer->putPixelBuffer(pixelBuffer, destinationRect); |
| 454 |
return convertImageBufferToColorSpace(targetColorSpace, *buffer, destinationRect, outputFormat); |
454 |
return convertImageBufferToColorSpace(targetColorSpace, *buffer, destinationRect, pixelBuffer.format().alphaFormat); |
| 455 |
} |
455 |
} |
| 456 |
|
456 |
|
| 457 |
Optional<PixelBuffer> FilterEffect::convertImageBufferToColorSpace(DestinationColorSpace targetColorSpace, ImageBuffer& inputBuffer, const IntRect& rect, AlphaPremultiplication outputFormat) |
457 |
Optional<PixelBuffer> FilterEffect::convertImageBufferToColorSpace(DestinationColorSpace targetColorSpace, ImageBuffer& inputBuffer, const IntRect& rect, AlphaPremultiplication outputAlphaFormat) |
| 458 |
{ |
458 |
{ |
|
|
459 |
// FIXME: This can be done more directly using PixelBufferConversion. |
| 460 |
|
| 459 |
FloatSize clampedSize = ImageBuffer::clampedSize(rect.size()); |
461 |
FloatSize clampedSize = ImageBuffer::clampedSize(rect.size()); |
|
|
462 |
|
| 460 |
// Create an ImageBuffer with the correct color space and utilize CG to handle color space conversion |
463 |
// Create an ImageBuffer with the correct color space and utilize CG to handle color space conversion |
| 461 |
auto convertedBuffer = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), targetColorSpace, PixelFormat::BGRA8); |
464 |
auto convertedBuffer = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), targetColorSpace, PixelFormat::BGRA8); |
| 462 |
if (!convertedBuffer) |
465 |
if (!convertedBuffer) |
| 463 |
return WTF::nullopt; |
466 |
return WTF::nullopt; |
|
|
467 |
|
| 464 |
// Color space conversion happens internally when drawing from one image buffer to another |
468 |
// Color space conversion happens internally when drawing from one image buffer to another |
| 465 |
convertedBuffer->context().drawImageBuffer(inputBuffer, rect); |
469 |
convertedBuffer->context().drawImageBuffer(inputBuffer, rect); |
| 466 |
return convertedBuffer->getPixelBuffer(outputFormat, rect); |
470 |
|
|
|
471 |
PixelBufferFormat format { outputAlphaFormat, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; |
| 472 |
return convertedBuffer->getPixelBuffer(format, rect); |
| 467 |
} |
473 |
} |
| 468 |
|
474 |
|
| 469 |
void FilterEffect::copyConvertedImageBufferToDestination(Uint8ClampedArray& destination, DestinationColorSpace colorSpace, AlphaPremultiplication outputFormat, const IntRect& destRect) |
475 |
void FilterEffect::copyConvertedImageBufferToDestination(Uint8ClampedArray& destination, DestinationColorSpace colorSpace, AlphaPremultiplication outputFormat, const IntRect& destRect) |
|
Lines 475-485
void FilterEffect::copyConvertedImageBuf
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec4
|
| 475 |
copyImageBytes(convertedPixelBuffer->data(), destination, destRect); |
481 |
copyImageBytes(convertedPixelBuffer->data(), destination, destRect); |
| 476 |
} |
482 |
} |
| 477 |
|
483 |
|
| 478 |
void FilterEffect::copyConvertedPixelBufferToDestination(Uint8ClampedArray& destination, PixelBuffer& pixelBuffer, DestinationColorSpace colorSpace, AlphaPremultiplication outputFormat, const IntRect& destRect) |
484 |
void FilterEffect::copyConvertedPixelBufferToDestination(Uint8ClampedArray& destination, PixelBuffer& pixelBuffer, DestinationColorSpace colorSpace, const IntRect& destRect) |
| 479 |
{ |
485 |
{ |
| 480 |
// Converts the data stored in m_unmultipliedImageResult/m_premultipliedImageResult, |
486 |
// Converts the data stored in m_unmultipliedImageResult/m_premultipliedImageResult, |
| 481 |
// whichever isn't null, and save to destination |
487 |
// whichever isn't null, and save to destination |
| 482 |
auto convertedPixelBuffer = convertPixelBufferToColorSpace(colorSpace, pixelBuffer, outputFormat); |
488 |
auto convertedPixelBuffer = convertPixelBufferToColorSpace(colorSpace, pixelBuffer); |
| 483 |
if (!convertedPixelBuffer) |
489 |
if (!convertedPixelBuffer) |
| 484 |
return; |
490 |
return; |
| 485 |
copyImageBytes(convertedPixelBuffer->data(), destination, destRect); |
491 |
copyImageBytes(convertedPixelBuffer->data(), destination, destRect); |
|
Lines 498-504
void FilterEffect::copyUnmultipliedResul
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec5
|
| 498 |
copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Unpremultiplied, rect); |
504 |
copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Unpremultiplied, rect); |
| 499 |
return; |
505 |
return; |
| 500 |
} |
506 |
} |
| 501 |
m_unmultipliedImageResult = m_imageBufferResult->getPixelBuffer(AlphaPremultiplication::Unpremultiplied, { IntPoint(), m_absolutePaintRect.size() }); |
507 |
PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; |
|
|
508 |
m_unmultipliedImageResult = m_imageBufferResult->getPixelBuffer(format, { IntPoint(), m_absolutePaintRect.size() }); |
| 502 |
if (!m_unmultipliedImageResult) |
509 |
if (!m_unmultipliedImageResult) |
| 503 |
return; |
510 |
return; |
| 504 |
} else { |
511 |
} else { |
|
Lines 513-519
void FilterEffect::copyUnmultipliedResul
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec6
|
| 513 |
} |
520 |
} |
| 514 |
} |
521 |
} |
| 515 |
if (requiresPixelBufferColorSpaceConversion(colorSpace)) { |
522 |
if (requiresPixelBufferColorSpaceConversion(colorSpace)) { |
| 516 |
copyConvertedPixelBufferToDestination(destination, *m_unmultipliedImageResult, *colorSpace, AlphaPremultiplication::Unpremultiplied, rect); |
523 |
copyConvertedPixelBufferToDestination(destination, *m_unmultipliedImageResult, *colorSpace, rect); |
| 517 |
return; |
524 |
return; |
| 518 |
} |
525 |
} |
| 519 |
copyImageBytes(m_unmultipliedImageResult->data(), destination, rect); |
526 |
copyImageBytes(m_unmultipliedImageResult->data(), destination, rect); |
|
Lines 532-538
void FilterEffect::copyPremultipliedResu
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec7
|
| 532 |
copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Premultiplied, rect); |
539 |
copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Premultiplied, rect); |
| 533 |
return; |
540 |
return; |
| 534 |
} |
541 |
} |
| 535 |
m_premultipliedImageResult = m_imageBufferResult->getPixelBuffer(AlphaPremultiplication::Premultiplied, { IntPoint(), m_absolutePaintRect.size() }); |
542 |
PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; |
|
|
543 |
m_premultipliedImageResult = m_imageBufferResult->getPixelBuffer(format, { IntPoint(), m_absolutePaintRect.size() }); |
| 536 |
if (!m_premultipliedImageResult) |
544 |
if (!m_premultipliedImageResult) |
| 537 |
return; |
545 |
return; |
| 538 |
} else { |
546 |
} else { |
|
Lines 548-554
void FilterEffect::copyPremultipliedResu
Source/WebCore/platform/graphics/filters/FilterEffect.cpp_sec8
|
| 548 |
} |
556 |
} |
| 549 |
|
557 |
|
| 550 |
if (requiresPixelBufferColorSpaceConversion(colorSpace)) { |
558 |
if (requiresPixelBufferColorSpaceConversion(colorSpace)) { |
| 551 |
copyConvertedPixelBufferToDestination(destination, *m_premultipliedImageResult, *colorSpace, AlphaPremultiplication::Premultiplied, rect); |
559 |
copyConvertedPixelBufferToDestination(destination, *m_premultipliedImageResult, *colorSpace, rect); |
| 552 |
return; |
560 |
return; |
| 553 |
} |
561 |
} |
| 554 |
copyImageBytes(m_premultipliedImageResult->data(), destination, rect); |
562 |
copyImageBytes(m_premultipliedImageResult->data(), destination, rect); |