Skip to content
Permalink
Browse files
Adopt BifurcatedGraphicsContext for backing store + display list Remo…
…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 0bc6e9a78d768ce4deebfc28e1546c3f4096beb1
Showing 7 changed files with 183 additions and 89 deletions.
@@ -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.
@@ -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();
@@ -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,
@@ -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
@@ -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;
@@ -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
>;
};

0 comments on commit 0bc6e9a

Please sign in to comment.