Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit ae8dc6a

Browse files
[GPU Process]: Introduce RemoteResourceCacheProxy to manage the remote resources in Web Process
https://bugs.webkit.org/show_bug.cgi?id=217558 Patch by Said Abou-Hallawa <[email protected]> on 2020-10-26 Reviewed by Simon Fraser. Source/WebCore: Rename Recorder::Observer to Recorder::Delegate because it will be responsible for creating DisplayListItems in future patches. So it will not be just an observer. Also do not make DisplayList::ImageBuffer a superclass of it. RemoteImageBufferProxy, which is a superclass of DisplayList::ImageBuffer, will be the superclass of Recorder::Delegate. Make ImageBufferBackend::isAccelerated a static member instead of a virtual method. RemoteRenderingBackendProxy would want to know whether the backend of an ImageBuffer isAccelerated or not without having to create it. ImageBufferBackend::isAccelerated will be set to false and ImageBufferIOSurfaceBackend::isAccelerated will be set to true. * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: * platform/graphics/ConcreteImageBuffer.h: * platform/graphics/ImageBuffer.h: (WebCore::ImageBuffer::renderingResourceIdentifier const): * platform/graphics/ImageBufferBackend.h: (WebCore::ImageBufferBackend::isAccelerated const): Deleted. * platform/graphics/RenderingResourceIdentifier.h: Renamed from Source/WebCore/platform/graphics/RemoteResourceIdentifier.h. * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp: (WebCore::ImageBufferIOSurfaceBackend::isAccelerated const): Deleted. * platform/graphics/cg/ImageBufferIOSurfaceBackend.h: * platform/graphics/displaylists/DisplayListDrawingContext.cpp: (WebCore::DisplayList::DrawingContext::DrawingContext): * platform/graphics/displaylists/DisplayListDrawingContext.h: (WebCore::DisplayList::DrawingContext::DrawingContext): * platform/graphics/displaylists/DisplayListImageBuffer.h: (WebCore::DisplayList::ImageBuffer::ImageBuffer): * platform/graphics/displaylists/DisplayListRecorder.cpp: (WebCore::DisplayList::Recorder::Recorder): (WebCore::DisplayList::Recorder::willAppendItem): * platform/graphics/displaylists/DisplayListRecorder.h: (WebCore::DisplayList::Recorder::Delegate::~Delegate): (WebCore::DisplayList::Recorder::Observer::~Observer): Deleted. (WebCore::DisplayList::Recorder::Observer::willAppendItem): Deleted. Source/WebKit: Remove RemoteImageBufferMessageHandlerProxy and move sending the messages to RemoteRenderingBackendProxy. To allow casting ImageBuffer to RemoteImageBufferProxy, a new method named remoteResourceIdentifier() is added to IamgeBuffer and it is only overridden by RemoteImageBufferProxy. This method is used in SPECIALIZE_TYPE_TRAITS macros along with IamgeBuffer::isAccelerated(). Introduce RemoteResourceCacheProxy which will manage caching and releasing the RemoteImageBufferProxy. Caching NativeImage will be added to it in future patches. More about controlling the life cycles of remote resources will be added also when supporting drawing remote resources to remote client in future patches. * GPUProcess/graphics/RemoteImageBuffer.h: (WebKit::RemoteImageBuffer::create): (WebKit::RemoteImageBuffer::RemoteImageBuffer): * GPUProcess/graphics/RemoteRenderingBackend.cpp: (WebKit::RemoteRenderingBackend::imageBufferBackendWasCreated): (WebKit::RemoteRenderingBackend::flushDisplayListWasCommitted): (WebKit::RemoteRenderingBackend::createImageBuffer): (WebKit::RemoteRenderingBackend::flushDisplayList): (WebKit::RemoteRenderingBackend::flushDisplayListAndCommit): (WebKit::RemoteRenderingBackend::getImageData): (WebKit::RemoteRenderingBackend::releaseRemoteResource): * GPUProcess/graphics/RemoteRenderingBackend.h: * GPUProcess/graphics/RemoteRenderingBackend.messages.in: * GPUProcess/graphics/RemoteResourceCache.cpp: (WebKit::RemoteResourceCache::cacheImageBuffer): (WebKit::RemoteResourceCache::cachedImageBuffer): (WebKit::RemoteResourceCache::releaseRemoteResource): * GPUProcess/graphics/RemoteResourceCache.h: * Scripts/webkit/messages.py: * Sources.txt: * WebKit.xcodeproj/project.pbxproj: * WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h: (isType): * WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.cpp: Removed. * WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.h: Removed. * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: (WebKit::RemoteImageBufferProxy::create): (WebKit::RemoteImageBufferProxy::~RemoteImageBufferProxy): (WebKit::RemoteImageBufferProxy::createBackend): (WebKit::RemoteImageBufferProxy::commitFlushDisplayList): (WebKit::RemoteImageBufferProxy::RemoteImageBufferProxy): (WebKit::RemoteImageBufferProxy::isPendingFlush const): (WebKit::RemoteImageBufferProxy::timeoutWaitForFlushDisplayListWasCommitted): (WebKit::RemoteImageBufferProxy::flushDrawingContextAndCommit): * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: (WebKit::RemoteRenderingBackendProxy::createImageBuffer): (WebKit::RemoteRenderingBackendProxy::getImageData): (WebKit::RemoteRenderingBackendProxy::flushDisplayList): (WebKit::RemoteRenderingBackendProxy::flushDisplayListAndCommit): (WebKit::RemoteRenderingBackendProxy::releaseRemoteResource): (WebKit::RemoteRenderingBackendProxy::imageBufferBackendWasCreated): (WebKit::RemoteRenderingBackendProxy::flushDisplayListWasCommitted): * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h: (WebKit::RemoteRenderingBackendProxy::remoteResourceCacheProxy): (WebKit::RemoteRenderingBackendProxy::renderingBackendIdentifier const): Deleted. * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in: * WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp: Copied from Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp. (WebKit::RemoteResourceCacheProxy::RemoteResourceCacheProxy): (WebKit::RemoteResourceCacheProxy::cacheImageBuffer): (WebKit::RemoteResourceCacheProxy::cachedImageBuffer): (WebKit::RemoteResourceCacheProxy::releaseImageBuffer): * WebProcess/GPU/graphics/RemoteResourceCacheProxy.h: Copied from Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@269022 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 96b1328 commit ae8dc6a

33 files changed

+487
-332
lines changed

Source/WebCore/ChangeLog

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
2020-10-26 Said Abou-Hallawa <[email protected]>
2+
3+
[GPU Process]: Introduce RemoteResourceCacheProxy to manage the remote resources in Web Process
4+
https://bugs.webkit.org/show_bug.cgi?id=217558
5+
6+
Reviewed by Simon Fraser.
7+
8+
Rename Recorder::Observer to Recorder::Delegate because it will be responsible
9+
for creating DisplayListItems in future patches. So it will not be just
10+
an observer. Also do not make DisplayList::ImageBuffer a superclass of it.
11+
RemoteImageBufferProxy, which is a superclass of DisplayList::ImageBuffer,
12+
will be the superclass of Recorder::Delegate.
13+
14+
Make ImageBufferBackend::isAccelerated a static member instead of a virtual
15+
method. RemoteRenderingBackendProxy would want to know whether the backend
16+
of an ImageBuffer isAccelerated or not without having to create it.
17+
ImageBufferBackend::isAccelerated will be set to false and
18+
ImageBufferIOSurfaceBackend::isAccelerated will be set to true.
19+
20+
* Headers.cmake:
21+
* WebCore.xcodeproj/project.pbxproj:
22+
* platform/graphics/ConcreteImageBuffer.h:
23+
* platform/graphics/ImageBuffer.h:
24+
(WebCore::ImageBuffer::renderingResourceIdentifier const):
25+
* platform/graphics/ImageBufferBackend.h:
26+
(WebCore::ImageBufferBackend::isAccelerated const): Deleted.
27+
* platform/graphics/RenderingResourceIdentifier.h: Renamed from Source/WebCore/platform/graphics/RemoteResourceIdentifier.h.
28+
* platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
29+
(WebCore::ImageBufferIOSurfaceBackend::isAccelerated const): Deleted.
30+
* platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
31+
* platform/graphics/displaylists/DisplayListDrawingContext.cpp:
32+
(WebCore::DisplayList::DrawingContext::DrawingContext):
33+
* platform/graphics/displaylists/DisplayListDrawingContext.h:
34+
(WebCore::DisplayList::DrawingContext::DrawingContext):
35+
* platform/graphics/displaylists/DisplayListImageBuffer.h:
36+
(WebCore::DisplayList::ImageBuffer::ImageBuffer):
37+
* platform/graphics/displaylists/DisplayListRecorder.cpp:
38+
(WebCore::DisplayList::Recorder::Recorder):
39+
(WebCore::DisplayList::Recorder::willAppendItem):
40+
* platform/graphics/displaylists/DisplayListRecorder.h:
41+
(WebCore::DisplayList::Recorder::Delegate::~Delegate):
42+
(WebCore::DisplayList::Recorder::Observer::~Observer): Deleted.
43+
(WebCore::DisplayList::Recorder::Observer::willAppendItem): Deleted.
44+
145
2020-10-26 Stephan Szabo <[email protected]>
246

347
evictCodedFrames does extra work if RELEASE_LOG_DISABLED is set

Source/WebCore/Headers.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
12171217
platform/graphics/PlatformTextTrack.h
12181218
platform/graphics/PlatformTimeRanges.h
12191219
platform/graphics/Region.h
1220-
platform/graphics/RemoteResourceIdentifier.h
12211220
platform/graphics/RemoteVideoSample.h
1221+
platform/graphics/RenderingResourceIdentifier.h
12221222
platform/graphics/RenderingMode.h
12231223
platform/graphics/RoundedRect.h
12241224
platform/graphics/StringTruncator.h

Source/WebCore/WebCore.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,7 @@
21612161
727A7F3A24078B84004D2931 /* ImageBufferIOSurfaceBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3AB23E1E544008D741C /* ImageBufferIOSurfaceBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
21622162
7299BC6723D6A53200CC6883 /* AlphaPremultiplication.h in Headers */ = {isa = PBXBuildFile; fileRef = 7299BC6423D686A600CC6883 /* AlphaPremultiplication.h */; settings = {ATTRIBUTES = (Private, ); }; };
21632163
7299BC6823D6A53E00CC6883 /* RenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 7299BC6623D686C600CC6883 /* RenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
2164-
729D05302531424300422098 /* RemoteResourceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 729D052E25313E2600422098 /* RemoteResourceIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
2164+
729D05302531424300422098 /* RenderingResourceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 729D052E25313E2600422098 /* RenderingResourceIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
21652165
72A73BEF245A3F90001C9D03 /* AnimationFrameRate.h in Headers */ = {isa = PBXBuildFile; fileRef = 722A815C238FD50500C00583 /* AnimationFrameRate.h */; settings = {ATTRIBUTES = (Private, ); }; };
21662166
72BAC3AE23E1F0B0008D741C /* ImageBufferBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3A523E17328008D741C /* ImageBufferBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
21672167
7553CFE8108F473F00EA281E /* TimelineRecordFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 7553CFE6108F473F00EA281E /* TimelineRecordFactory.h */; };
@@ -9946,7 +9946,7 @@
99469946
727AFED31A2EA6A0000442E8 /* EXTsRGB.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTsRGB.idl; sourceTree = "<group>"; };
99479947
7299BC6423D686A600CC6883 /* AlphaPremultiplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AlphaPremultiplication.h; sourceTree = "<group>"; };
99489948
7299BC6623D686C600CC6883 /* RenderingMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderingMode.h; sourceTree = "<group>"; };
9949-
729D052E25313E2600422098 /* RemoteResourceIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteResourceIdentifier.h; sourceTree = "<group>"; };
9949+
729D052E25313E2600422098 /* RenderingResourceIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderingResourceIdentifier.h; sourceTree = "<group>"; };
99509950
72BAC3A423E17327008D741C /* ImageBufferBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferBackend.cpp; sourceTree = "<group>"; };
99519951
72BAC3A523E17328008D741C /* ImageBufferBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBufferBackend.h; sourceTree = "<group>"; };
99529952
72BAC3A623E17328008D741C /* PlatformImageBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformImageBuffer.h; sourceTree = "<group>"; };
@@ -26366,10 +26366,10 @@
2636626366
074E82B918A69F0E007EF54C /* PlatformTimeRanges.h */,
2636726367
BCAB417F13E356E800D8AAF3 /* Region.cpp */,
2636826368
BCAB418013E356E800D8AAF3 /* Region.h */,
26369-
729D052E25313E2600422098 /* RemoteResourceIdentifier.h */,
2637026369
073A15512177A39800EA08F2 /* RemoteVideoSample.cpp */,
2637126370
073A15532177A39A00EA08F2 /* RemoteVideoSample.h */,
2637226371
7299BC6623D686C600CC6883 /* RenderingMode.h */,
26372+
729D052E25313E2600422098 /* RenderingResourceIdentifier.h */,
2637326373
A73F95FC12C97BFE0031AAF9 /* RoundedRect.cpp */,
2637426374
A73F95FD12C97BFE0031AAF9 /* RoundedRect.h */,
2637526375
0F3DD44D12F5EA1B000D9190 /* ShadowBlur.cpp */,
@@ -33742,7 +33742,6 @@
3374233742
46B9519A207D635400A7D2DD /* RemoteFrame.h in Headers */,
3374333743
CDC312E922FCD7C0001204EC /* RemotePlayback.h in Headers */,
3374433744
CDC312EB22FCD7C9001204EC /* RemotePlaybackAvailabilityCallback.h in Headers */,
33745-
729D05302531424300422098 /* RemoteResourceIdentifier.h in Headers */,
3374633745
073A15542177A42600EA08F2 /* RemoteVideoSample.h in Headers */,
3374733746
D06C0D8F0CFD11460065F43F /* RemoveFormatCommand.h in Headers */,
3374833747
93309E05099E64920056E581 /* RemoveNodeCommand.h in Headers */,
@@ -33782,6 +33781,7 @@
3378233781
08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */,
3378333782
08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */,
3378433783
7299BC6823D6A53E00CC6883 /* RenderingMode.h in Headers */,
33784+
729D05302531424300422098 /* RenderingResourceIdentifier.h in Headers */,
3378533785
556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */,
3378633786
BCEA4878097D93020094C9E4 /* RenderInline.h in Headers */,
3378733787
B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */,

Source/WebCore/platform/graphics/ConcreteImageBuffer.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,8 @@ class ConcreteImageBuffer : public ImageBuffer {
5050
return nullptr;
5151
return std::unique_ptr<ImageBufferType>(new ImageBufferType(WTFMove(backend), std::forward<Arguments>(arguments)...));
5252
}
53-
54-
bool isAccelerated() const override
55-
{
56-
if (auto* backend = ensureBackendCreated())
57-
return backend->isAccelerated();
58-
return false;
59-
}
53+
54+
bool isAccelerated() const override { return BackendType::isAccelerated; }
6055

6156
protected:
6257
ConcreteImageBuffer(std::unique_ptr<BackendType>&& backend)

Source/WebCore/platform/graphics/ImageBuffer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include "ImageBufferBackend.h"
3131
#include "RenderingMode.h"
32+
#include "RenderingResourceIdentifier.h"
3233

3334
namespace WebCore {
3435

@@ -60,6 +61,9 @@ class ImageBuffer {
6061

6162
WEBCORE_EXPORT virtual ~ImageBuffer() = default;
6263

64+
virtual bool isAccelerated() const = 0;
65+
virtual RenderingResourceIdentifier renderingResourceIdentifier() const { return { }; }
66+
6367
virtual GraphicsContext& context() const = 0;
6468
virtual void flushContext() = 0;
6569

@@ -104,8 +108,6 @@ class ImageBuffer {
104108
virtual bool copyToPlatformTexture(GraphicsContextGLOpenGL&, GCGLenum, PlatformGLObject, GCGLenum, bool, bool) const = 0;
105109
virtual PlatformLayer* platformLayer() const = 0;
106110

107-
virtual bool isAccelerated() const = 0;
108-
109111
protected:
110112
ImageBuffer() = default;
111113

Source/WebCore/platform/graphics/ImageBufferBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ImageBufferBackend {
101101
virtual bool copyToPlatformTexture(GraphicsContextGLOpenGL&, GCGLenum, PlatformGLObject, GCGLenum, bool, bool) const { return false; }
102102

103103
static constexpr bool isOriginAtUpperLeftCorner = false;
104-
virtual bool isAccelerated() const { return false; }
104+
static constexpr bool isAccelerated = false;
105105

106106
protected:
107107
WEBCORE_EXPORT ImageBufferBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace);

Source/WebCore/platform/graphics/RemoteResourceIdentifier.h renamed to Source/WebCore/platform/graphics/RenderingResourceIdentifier.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@
2525

2626
#pragma once
2727

28-
#if ENABLE(GPU_PROCESS)
29-
3028
#include <wtf/ObjectIdentifier.h>
3129

3230
namespace WebCore {
3331

34-
enum RemoteResourceIdentifierType { };
35-
using RemoteResourceIdentifier = ObjectIdentifier<RemoteResourceIdentifierType>;
32+
enum RenderingResourceIdentifierType { };
33+
using RenderingResourceIdentifier = ObjectIdentifier<RenderingResourceIdentifierType>;
3634

3735
} // namespace WebCore
38-
39-
#endif // ENABLE(GPU_PROCESS)

Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ IOSurface* ImageBufferIOSurfaceBackend::surface()
190190
return m_surface.get();
191191
}
192192

193-
bool ImageBufferIOSurfaceBackend::isAccelerated() const
194-
{
195-
return true;
196-
}
197-
198193
} // namespace WebCore
199194

200195
#endif // HAVE(IOSURFACE)

Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ class WEBCORE_EXPORT ImageBufferIOSurfaceBackend : public ImageBufferCGBackend {
6262
RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const override;
6363
void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;
6464
IOSurface* surface();
65-
bool isAccelerated() const override;
6665

6766
static constexpr bool isOriginAtUpperLeftCorner = true;
67+
static constexpr bool isAccelerated = true;
6868

6969
protected:
7070
static RetainPtr<CGColorSpaceRef> contextColorSpace(const GraphicsContext&);

Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
namespace WebCore {
3434
namespace DisplayList {
3535

36-
DrawingContext::DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM, Recorder::Observer* observer)
36+
DrawingContext::DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM, Recorder::Delegate* delegate)
3737
: m_context([&](GraphicsContext& displayListContext) {
38-
return makeUnique<Recorder>(displayListContext, m_displayList, GraphicsContextState(), FloatRect({ }, logicalSize), initialCTM, observer);
38+
return makeUnique<Recorder>(displayListContext, m_displayList, GraphicsContextState(), FloatRect({ }, logicalSize), initialCTM, delegate);
3939
})
4040
{
4141
}

0 commit comments

Comments
 (0)