Skip to content

Commit

Permalink
[visionOS] Refine activation rules for Image Fullscreen
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=272218
<rdar://125913434>

Reviewed by Said Abou-Hallawa.

Introduce a `shouldUseQuickLookForFullscreen()` method on Images. It
defaults to false and queries the ImageDecoder for bitmap images.

Gate the use of Image Fullscreen on this flag.

* Source/WebCore/platform/graphics/BitmapImage.h:
* Source/WebCore/platform/graphics/BitmapImageSource.cpp:
(WebCore::BitmapImageSource::shouldUseQuickLookForFullscreen const):
* Source/WebCore/platform/graphics/BitmapImageSource.h:
* Source/WebCore/platform/graphics/Image.h:
(WebCore::Image::shouldUseQuickLookForFullscreen const):
* Source/WebCore/platform/graphics/ImageDecoder.h:
(WebCore::ImageDecoder::shouldUseQuickLookForFullscreen const):
* Source/WebCore/platform/graphics/ImageSource.h:
(WebCore::ImageSource::shouldUseQuickLookForFullscreen const):
Wire the `shouldUseQuickLookForFullscreen()` check to the ImageDecoder.

* Source/WebCore/platform/graphics/cg/ImageDecoderCG.h:
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoderCG::shouldUseQuickLookForFullscreen const):
Add the WKA entry point.

* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::enterFullScreenForElement):
Add the `shouldUseQuickLookForFullscreen()` check.

Canonical link: https://commits.webkit.org/277177@main
  • Loading branch information
etiennesegonzac committed Apr 7, 2024
1 parent 6e624ea commit 4ac0a7c
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/BitmapImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class BitmapImage final : public Image {
std::optional<IntPoint> hotSpot() const final { return m_source->hotSpot(); }
std::optional<Color> singlePixelSolidColor() const final { return m_source->singlePixelSolidColor(); }

#if ENABLE(QUICKLOOK_FULLSCREEN)
bool shouldUseQuickLookForFullscreen() const final { return m_source->shouldUseQuickLookForFullscreen(); }
#endif

// Image methods
bool isBitmapImage() const final { return true; }
bool isAnimating() const final { return m_source->isAnimating(); }
Expand Down
7 changes: 7 additions & 0 deletions Source/WebCore/platform/graphics/BitmapImageSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,13 @@ SubsamplingLevel BitmapImageSource::subsamplingLevelForScaleFactor(GraphicsConte
#endif
}

#if ENABLE(QUICKLOOK_FULLSCREEN)
bool BitmapImageSource::shouldUseQuickLookForFullscreen() const
{
return m_decoder->shouldUseQuickLookForFullscreen();
}
#endif

IntSize BitmapImageSource::frameSizeAtIndex(unsigned index, SubsamplingLevel subsamplingLevel) const
{
return const_cast<BitmapImageSource&>(*this).frameAtIndexCacheIfNeeded(index, subsamplingLevel).size();
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/BitmapImageSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ class BitmapImageSource : public ImageSource {

SubsamplingLevel subsamplingLevelForScaleFactor(GraphicsContext&, const FloatSize& scaleFactor, AllowImageSubsampling) final;

#if ENABLE(QUICKLOOK_FULLSCREEN)
bool shouldUseQuickLookForFullscreen() const;
#endif

// ImageFrame metadata
IntSize frameSizeAtIndex(unsigned index, SubsamplingLevel = SubsamplingLevel::Default) const;
ImageOrientation frameOrientationAtIndex(unsigned index) const final;
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/platform/graphics/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class Image : public RefCounted<Image>, public CanMakeWeakPtr<Image> {
#if ASSERT_ENABLED
virtual bool hasSolidColor() { return false; }
#endif
#if ENABLE(QUICKLOOK_FULLSCREEN)
virtual bool shouldUseQuickLookForFullscreen() const { return false; }
#endif

virtual void dump(WTF::TextStream&) const;

Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/ImageDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class ImageDecoder : public ThreadSafeRefCounted<ImageDecoder> {
virtual String accessibilityDescription() const { return emptyString(); };
virtual std::optional<IntPoint> hotSpot() const = 0;

#if ENABLE(QUICKLOOK_FULLSCREEN)
virtual bool shouldUseQuickLookForFullscreen() const { return false; }
#endif

virtual IntSize frameSizeAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const = 0;
virtual bool frameIsCompleteAtIndex(size_t) const = 0;
virtual ImageOrientation frameOrientationAtIndex(size_t) const { return ImageOrientation::Orientation::None; }
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/ImageSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class ImageSource : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<Image

virtual SubsamplingLevel subsamplingLevelForScaleFactor(GraphicsContext&, const FloatSize&, AllowImageSubsampling) { return SubsamplingLevel::Default; }

#if ENABLE(QUICKLOOK_FULLSCREEN)
virtual bool shouldUseQuickLookForFullscreen() const { return false; }
#endif

// ImageFrame Metadata
virtual Seconds frameDurationAtIndex(unsigned) const { RELEASE_ASSERT_NOT_REACHED(); return 0_s; }
virtual ImageOrientation frameOrientationAtIndex(unsigned) const { RELEASE_ASSERT_NOT_REACHED(); return ImageOrientation::Orientation::None; }
Expand Down
12 changes: 12 additions & 0 deletions Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,16 @@ bool ImageDecoderCG::canDecodeType(const String& mimeType)

}

#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/ImageDecoderCGAdditions.cpp>)
#include <WebKitAdditions/ImageDecoderCGAdditions.cpp>
#else
namespace WebCore {

#if ENABLE(QUICKLOOK_FULLSCREEN)
bool ImageDecoderCG::shouldUseQuickLookForFullscreen() const { return false; }
#endif // ENABLE(QUICKLOOK_FULLSCREEN)

}
#endif

#endif // USE(CG)
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/cg/ImageDecoderCG.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class ImageDecoderCG final : public ImageDecoder {

private:
String decodeUTI(const SharedBuffer&) const;

#if ENABLE(QUICKLOOK_FULLSCREEN)
bool shouldUseQuickLookForFullscreen() const;
#endif

bool m_isAllDataReceived { false };
mutable EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::Unknown };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element,
return std::nullopt;

auto* image = renderImage->cachedImage()->image();
if (!image || !image->isBitmapImage())
if (!image || !image->shouldUseQuickLookForFullscreen())
return std::nullopt;

auto* buffer = renderImage->cachedImage()->resourceBuffer();
Expand Down

0 comments on commit 4ac0a7c

Please sign in to comment.