Skip to content

Commit

Permalink
Adopt BifurcatedGraphicsContext for backing store + display list Remo…
Browse files Browse the repository at this point in the history
…teLayerBackingStore

https://bugs.webkit.org/show_bug.cgi?id=226425
<rdar://77929299>

Reviewed by Sam Weinig.

Instead of "display list backed RemoteLayerBackingStore" being its own
backing store type, we make "includes a display list" a separate bit.
This way, we can paint both a bitmap (IOSurface or CG bitmap, all
exactly as it normally is), and also carry a sidecar display list.

* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::ensureBackingStore):
(WebKit::RemoteLayerBackingStore::encode const):
(WebKit::RemoteLayerBackingStore::decode):
(WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
(WebKit::RemoteLayerBackingStore::supportsPartialRepaint):
We can't partially repaint the display list, and require its rendering
to match the painted backing store, so disable partial repaint entirely
if display lists are being used.

(WebKit::RemoteLayerBackingStore::display):
(WebKit::RemoteLayerBackingStore::drawInContext):
Adopt BifurcatedGraphicsContext in order to paint into the aforementioned
bitmap and display list simultaneously.
A future patch may abstract this into a new ImageBuffer type
instead of polluting RemoteLayerBackingStore with it.

Leave a temporary workaround for a CoreAnimation bug, which can be
disabled via `defaults write`, but is enabled by default.

(WebKit::layerContentsForBufferHandle):
(WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
(WebKit::RemoteLayerBackingStore::Buffer::discard):
* UIProcess/RemoteLayerTree/cocoa/RemoteLayerTreeLayers.h:
* UIProcess/RemoteLayerTree/cocoa/RemoteLayerTreeLayers.mm:
(-[WKCompositingLayer _setWKContents:withDisplayList:]):
(-[WKCompositingLayer _setWKContentsDisplayList:]): Deleted.
(-[WKCompositingLayer _wkContentsDisplayList]): Deleted.
Pass the display list data to CoreAnimation alongside the bitmap.

* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::updateBackingStore):


Canonical link: https://commits.webkit.org/239735@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Jul 16, 2021
1 parent cc49337 commit 0bc6e9a
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 89 deletions.
47 changes: 47 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,50 @@
2021-07-16 Tim Horton <timothy_horton@apple.com>

Adopt BifurcatedGraphicsContext for backing store + display list RemoteLayerBackingStore
https://bugs.webkit.org/show_bug.cgi?id=226425
<rdar://77929299>

Reviewed by Sam Weinig.

Instead of "display list backed RemoteLayerBackingStore" being its own
backing store type, we make "includes a display list" a separate bit.
This way, we can paint both a bitmap (IOSurface or CG bitmap, all
exactly as it normally is), and also carry a sidecar display list.

* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::ensureBackingStore):
(WebKit::RemoteLayerBackingStore::encode const):
(WebKit::RemoteLayerBackingStore::decode):
(WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
(WebKit::RemoteLayerBackingStore::supportsPartialRepaint):
We can't partially repaint the display list, and require its rendering
to match the painted backing store, so disable partial repaint entirely
if display lists are being used.

(WebKit::RemoteLayerBackingStore::display):
(WebKit::RemoteLayerBackingStore::drawInContext):
Adopt BifurcatedGraphicsContext in order to paint into the aforementioned
bitmap and display list simultaneously.
A future patch may abstract this into a new ImageBuffer type
instead of polluting RemoteLayerBackingStore with it.

Leave a temporary workaround for a CoreAnimation bug, which can be
disabled via `defaults write`, but is enabled by default.

(WebKit::layerContentsForBufferHandle):
(WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
(WebKit::RemoteLayerBackingStore::Buffer::discard):
* UIProcess/RemoteLayerTree/cocoa/RemoteLayerTreeLayers.h:
* UIProcess/RemoteLayerTree/cocoa/RemoteLayerTreeLayers.mm:
(-[WKCompositingLayer _setWKContents:withDisplayList:]):
(-[WKCompositingLayer _setWKContentsDisplayList:]): Deleted.
(-[WKCompositingLayer _wkContentsDisplayList]): Deleted.
Pass the display list data to CoreAnimation alongside the bitmap.

* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::updateBackingStore):

2021-07-16 Megan Gardner <megan_gardner@apple.com>

Pipe App Highlight scrolling through UI Process in preparation for Note Overlay avoidance.
Expand Down
36 changes: 23 additions & 13 deletions Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h
Expand Up @@ -54,13 +54,11 @@ class RemoteLayerBackingStore {

enum class Type : uint8_t {
IOSurface,
Bitmap,
#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
CGDisplayList,
#endif
Bitmap
};

void ensureBackingStore(Type, WebCore::FloatSize, float scale, bool deepColor, bool isOpaque);
enum class IncludeDisplayList : bool { No, Yes };
void ensureBackingStore(Type, WebCore::FloatSize, float scale, bool deepColor, bool isOpaque, IncludeDisplayList);

void setNeedsDisplay(const WebCore::IntRect);
void setNeedsDisplay();
Expand Down Expand Up @@ -88,7 +86,7 @@ class RemoteLayerBackingStore {
return !!m_frontBuffer.imageBuffer;
}

std::unique_ptr<WebCore::ThreadSafeImageBufferFlusher> takePendingFlusher();
Vector<std::unique_ptr<WebCore::ThreadSafeImageBufferFlusher>> takePendingFlushers();

enum class BufferType {
Front,
Expand Down Expand Up @@ -120,6 +118,9 @@ class RemoteLayerBackingStore {

struct Buffer {
RefPtr<WebCore::ImageBuffer> imageBuffer;
#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
RefPtr<WebCore::ImageBuffer> displayListImageBuffer;
#endif
bool isVolatile = false;

explicit operator bool() const
Expand All @@ -134,10 +135,14 @@ class RemoteLayerBackingStore {
Buffer m_backBuffer;
Buffer m_secondaryBackBuffer;
std::optional<ImageBufferBackendHandle> m_bufferHandle;
#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
std::optional<ImageBufferBackendHandle> m_displayListBufferHandle;
#endif

std::unique_ptr<WebCore::ThreadSafeImageBufferFlusher> m_frontBufferFlusher;
Vector<std::unique_ptr<WebCore::ThreadSafeImageBufferFlusher>> m_frontBufferFlushers;

Type m_type;
IncludeDisplayList m_includeDisplayList { IncludeDisplayList::No };
bool m_deepColor { false };

WebCore::RepaintRectList m_paintingRects;
Expand All @@ -151,12 +156,17 @@ namespace WTF {

template<> struct EnumTraits<WebKit::RemoteLayerBackingStore::Type> {
using values = EnumValues<
WebKit::RemoteLayerBackingStore::Type
, WebKit::RemoteLayerBackingStore::Type::IOSurface
, WebKit::RemoteLayerBackingStore::Type::Bitmap
#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
, WebKit::RemoteLayerBackingStore::Type::CGDisplayList
#endif
WebKit::RemoteLayerBackingStore::Type,
WebKit::RemoteLayerBackingStore::Type::IOSurface,
WebKit::RemoteLayerBackingStore::Type::Bitmap
>;
};

template<> struct EnumTraits<WebKit::RemoteLayerBackingStore::IncludeDisplayList> {
using values = EnumValues<
WebKit::RemoteLayerBackingStore::IncludeDisplayList,
WebKit::RemoteLayerBackingStore::IncludeDisplayList::No,
WebKit::RemoteLayerBackingStore::IncludeDisplayList::Yes
>;
};

Expand Down

0 comments on commit 0bc6e9a

Please sign in to comment.