Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[macOS Monterey and Big Sur] Enable AVIF image decoding using libavif…
… and dav1d https://bugs.webkit.org/show_bug.cgi?id=246925 rdar://101481679 Reviewed by Said Abou-Hallawa. We checked in libavif and dav1d sources in 494a012. This patch hooks up image decoding to use them, on macOS Monterey and Big Sur. It does so by using the same glue code that non-Apple platforms use: ScalableImageDecoder and AVIFImageDecoder. This patch includes those files in Sources.txt for all ports, and refactors ScalableImageDecoder on Cocoa platforms to only support AVIF, as per https://webkit.slack.com/archives/CU64U6FDW/p1666556573569359?thread_ts=1666555605.109619&cid=CU64U6FDW. This patch re-uses the same USE(AVIF) flag that the non-Apple ports have been using. There are currently 2 AVIF flags: - USE(AVIF) indicates that libavif will be used to decode AVIF images, using the ScalableImageDecoder infrastructure. This is enabled on the non-Apple ports, and on macOS Monterey and Big Sur. - HAVE(AVIF) indicates that the platform can decode AVIF images directly. This is enabled on macOS Ventura and later (and other Cocoa ports). These flags are mutually exclusive; no port has both enabled at the same time. The Apple Windows port has neither of these flags enabled. * Source/WTF/wtf/PlatformUse.h: * Source/WebCore/Configurations/WebCore.xcconfig: * Source/WebCore/PAL/libavif/Configurations/libavif.xcconfig: * Source/WebCore/Sources.txt: * Source/WebCore/SourcesCocoa.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/graphics/ImageDecoder.cpp: (WebCore::ImageDecoder::create): * Source/WebCore/platform/graphics/cg/ImageBackingStoreCG.cpp: Copied from Source/WebCore/platform/image-decoders/avif/AVIFImageDecoder.h. (WebCore::ImageBackingStore::image const): * Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp: (WebCore::ImageDecoderCG::decodeUTI const): (WebCore::ImageDecoderCG::decodeUTI): * Source/WebCore/platform/graphics/cg/ImageDecoderCG.h: * Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp: (WebCore::ScalableImageDecoder::create): * Source/WebCore/platform/image-decoders/avif/AVIFImageDecoder.h: * Source/WebCore/platform/image-decoders/avif/AVIFImageReader.cpp: (WebCore::AVIFImageReader::decodeFrame): Canonical link: https://commits.webkit.org/255984@main
- Loading branch information
Showing
14 changed files
with
180 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2022 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. ``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 | ||
* 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 "ImageBackingStore.h" | ||
|
||
namespace WebCore { | ||
|
||
PlatformImagePtr ImageBackingStore::image() const | ||
{ | ||
static const size_t bytesPerPixel = 4; | ||
static const size_t bitsPerComponent = 8; | ||
size_t width = size().width(); | ||
size_t height = size().height(); | ||
size_t bytesPerRow = bytesPerPixel * width; | ||
|
||
auto colorSpace = adoptCF(CGColorSpaceCreateWithName(kCGColorSpaceSRGB)); | ||
auto dataProvider = adoptCF(CGDataProviderCreateWithData(nullptr, m_pixelsPtr, height * bytesPerRow, nullptr)); | ||
return adoptCF(CGImageCreate(width, height, bitsPerComponent, bytesPerPixel * 8, bytesPerRow, colorSpace.get(), (m_premultiplyAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaFirst) | kCGImageByteOrder32Little, dataProvider.get(), nullptr, true, kCGRenderingIntentDefault)); | ||
} | ||
|
||
} // namespace WebCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.