Source/WebCore/ChangeLog

 12022-03-02 Ben Nham <nham@apple.com>
 2
 3 Give WebKit-owned IOSurfaces names
 4 https://bugs.webkit.org/show_bug.cgi?id=141586
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * platform/graphics/ca/LayerPool.cpp:
 9 (WebCore::LayerPool::addLayer):
 10 (WebCore::LayerPool::takeLayerWithSize):
 11 Let PlatformCALayers know when they're moving in/out of the layer pool.
 12
 13 * platform/graphics/ca/PlatformCALayer.cpp:
 14 (WebCore::PlatformCALayer::willMoveToLayerPool):
 15 (WebCore::PlatformCALayer::didLeaveLayerPool):
 16 * platform/graphics/ca/PlatformCALayer.h:
 17 * platform/graphics/cg/IOSurfacePool.cpp:
 18 (WebCore::IOSurfacePool::willAddSurface):
 19
 20 * platform/graphics/ConcreteImageBuffer.h:
 21 * platform/graphics/ImageBuffer.h:
 22 * platform/graphics/ImageBufferBackend.h:
 23 (WebCore::ImageBufferBackend::setName):
 24 * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
 25 (WebCore::ImageBufferIOSurfaceBackend::setName):
 26 * platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
 27 * platform/graphics/cocoa/IOSurface.h:
 28 * platform/graphics/cocoa/IOSurface.mm:
 29 (WebCore::IOSurface::setName):
 30
1312022-02-23 Alan Bujtas <zalan@apple.com>
232
333 [IFC][Integration] LineLayout::firstLinePhysicalBaseline/lastLineLogicalBaseline should flip box baseline value for vertical-lr

Source/WebKit/ChangeLog

 12022-03-02 Ben Nham <nham@apple.com>
 2
 3 Give WebKit-owned IOSurfaces names
 4 https://bugs.webkit.org/show_bug.cgi?id=141586
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
 9 * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
 10 (WebKit::RemoteLayerBackingStore::updateSurfaceNames):
 11 (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
 12 Set the names of the various IOSurfaces, providing a way to link together
 13 the surfaces backing a single layer, and noting whether the layer is in
 14 the LayerPool.
 15
 16 * UIProcess/Cocoa/WebViewImpl.mm:
 17 (WebKit::WebViewImpl::takeViewSnapshot):
 18 Set the name of view snapshot surfaces.
 19
 20 * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
 21 (WebKit::PlatformCALayerRemote::willMoveToLayerPool):
 22 (WebKit::PlatformCALayerRemote::didLeaveLayerPool):
 23 * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
 24 (WebKit::PlatformCALayerRemote::isInLayerPool const):
 25 Keep track of whether this layer is in the layer pool,
 26 so RemoteLayerBackingStore can keep the names up to date.
 27
1282022-02-23 Chris Dumez <cdumez@apple.com>
229
330 Share more code between service and shared workers for context connection establishment

Source/WebCore/platform/graphics/ConcreteImageBuffer.h

@@protected:
297297 return true; // Just claim we succeedded.
298298 }
299299
 300 void setName(const String& name) override
 301 {
 302 if (backend())
 303 backend()->setName(name);
 304 }
 305
300306 VolatilityState setNonVolatile() override
301307 {
302308 if (auto* backend = ensureBackendCreated())

Source/WebCore/platform/graphics/ImageBuffer.h

@@public:
9494 virtual bool setVolatile() = 0;
9595 virtual VolatilityState setNonVolatile() = 0;
9696
 97 virtual void setName(const String&) = 0;
 98
9799 virtual std::unique_ptr<ThreadSafeImageBufferFlusher> createFlusher() = 0;
98100
99101 virtual RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const = 0;

Source/WebCore/platform/graphics/ImageBufferBackend.h

@@public:
128128 virtual bool setVolatile() { return true; }
129129 virtual VolatilityState setNonVolatile() { return VolatilityState::Valid; }
130130
 131 virtual void setName(const String&) { }
 132
131133 virtual std::unique_ptr<ThreadSafeImageBufferFlusher> createFlusher() { return nullptr; }
132134
133135 void applyBaseTransformToContext() const;

Source/WebCore/platform/graphics/ca/LayerPool.cpp

@@void LayerPool::addLayer(const RefPtr<PlatformCALayer>& layer)
7979 if (!canReuseLayerWithSize(layerSize))
8080 return;
8181
 82 layer->willMoveToLayerPool();
 83
8284 listOfLayersWithSize(layerSize).prepend(layer);
8385 m_totalBytes += backingStoreBytesForSize(layerSize);
8486

@@RefPtr<PlatformCALayer> LayerPool::takeLayerWithSize(const IntSize& size)
9597 if (reuseList.isEmpty())
9698 return nullptr;
9799 m_totalBytes -= backingStoreBytesForSize(size);
98  return reuseList.takeFirst();
 100 auto layer = reuseList.takeFirst();
 101 layer->didLeaveLayerPool();
 102 return layer;
99103}
100104
101105unsigned LayerPool::decayedCapacity() const

Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp

@@void PlatformCALayer::clearContents()
204204 setContents(nullptr);
205205}
206206
 207void PlatformCALayer::willMoveToLayerPool()
 208{
 209}
 210
 211void PlatformCALayer::didLeaveLayerPool()
 212{
 213}
 214
207215void PlatformCALayer::dumpAdditionalProperties(TextStream&, OptionSet<PlatformLayerTreeAsTextFlags>)
208216{
209217}

Source/WebCore/platform/graphics/ca/PlatformCALayer.h

@@public:
324324 static CGRect frameForLayer(const PlatformLayer*);
325325
326326 void moveToLayerPool();
 327 virtual void willMoveToLayerPool();
 328 virtual void didLeaveLayerPool();
327329
328330 virtual void dumpAdditionalProperties(TextStream&, OptionSet<PlatformLayerTreeAsTextFlags>);
329331

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

@@void IOSurfacePool::willAddSurface(IOSurface& surface, bool inUse)
8686 m_bytesCached += surfaceBytes;
8787 if (inUse)
8888 m_inUseBytesCached += surfaceBytes;
 89
 90#ifndef NDEBUG
 91 surface.setName("IOSurfacePool");
 92#endif
8993}
9094
9195void IOSurfacePool::didRemoveSurface(IOSurface& surface, bool inUse)

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

@@void ImageBufferIOSurfaceBackend::ensureNativeImagesHaveCopiedBackingStore()
259259 flushContext();
260260}
261261
 262void ImageBufferIOSurfaceBackend::setName(const String& name)
 263{
 264 m_surface->setName(name);
 265}
 266
262267} // namespace WebCore
263268
264269#endif // HAVE(IOSURFACE)

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

@@protected:
7373 bool setVolatile() override;
7474 VolatilityState setNonVolatile() override;
7575
 76 void setName(const String&) override;
 77
7678 void ensureNativeImagesHaveCopiedBackingStore() final;
7779
7880 static RetainPtr<CGColorSpaceRef> contextColorSpace(const GraphicsContext&);

Source/WebCore/platform/graphics/cocoa/IOSurface.h

@@public:
158158 // an accurate result from isInUse(), it needs to be released.
159159 WEBCORE_EXPORT void releaseGraphicsContext();
160160
 161 WEBCORE_EXPORT void setName(const String&);
 162
161163#if HAVE(IOSURFACE_ACCELERATOR)
162164 WEBCORE_EXPORT static bool allowConversionFromFormatToFormat(Format, Format);
163165 WEBCORE_EXPORT static void convertToFormat(std::unique_ptr<WebCore::IOSurface>&& inSurface, Format, Function<void(std::unique_ptr<WebCore::IOSurface>)>&&);

Source/WebCore/platform/graphics/cocoa/IOSurface.mm

@@void IOSurface::releaseGraphicsContext()
466466 m_cgContext = nullptr;
467467}
468468
 469void IOSurface::setName(const String& name)
 470{
 471 IOSurfaceSetValue(m_surface.get(), CFSTR("IOSurfaceName"), name);
 472}
 473
469474#if HAVE(IOSURFACE_ACCELERATOR)
470475
471476bool IOSurface::allowConversionFromFormatToFormat(Format sourceFormat, Format destFormat)

Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h

@@public:
112112
113113 MonotonicTime lastDisplayTime() const { return m_lastDisplayTime; }
114114
 115 void updateSurfaceNames();
 116
115117 void clearBackingStore();
116118
117119private:

Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm

@@unsigned RemoteLayerBackingStore::bytesPerPixel() const
212212 return 4;
213213}
214214
 215void RemoteLayerBackingStore::updateSurfaceNames()
 216{
 217#ifndef NDEBUG
 218 if (m_type != Type::IOSurface)
 219 return;
 220
 221 char addr[16] { };
 222 snprintf(addr, sizeof(addr), " (%p)", reinterpret_cast<void*>(this));
 223
 224 if (m_layer && m_layer->isInLayerPool()) {
 225 if (m_frontBuffer.imageBuffer)
 226 m_frontBuffer.imageBuffer->setName(makeString("LayerPool Front", addr));
 227 if (m_backBuffer.imageBuffer)
 228 m_backBuffer.imageBuffer->setName(makeString("LayerPool Back", addr));
 229 if (m_secondaryBackBuffer.imageBuffer)
 230 m_secondaryBackBuffer.imageBuffer->setName(makeString("LayerPool Secondary Back", addr));
 231 return;
 232 }
 233
 234 if (m_frontBuffer.imageBuffer)
 235 m_frontBuffer.imageBuffer->setName(makeString("Front Buffer", addr));
 236 if (m_backBuffer.imageBuffer)
 237 m_backBuffer.imageBuffer->setName(makeString("Back Buffer", addr));
 238 if (m_secondaryBackBuffer.imageBuffer)
 239 m_secondaryBackBuffer.imageBuffer->setName(makeString("Secondary Back Buffer", addr));
 240#endif
 241}
 242
215243void RemoteLayerBackingStore::swapToValidFrontBuffer()
216244{
217245 ASSERT(!WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM));

@@void RemoteLayerBackingStore::swapToValidFrontBuffer()
231259 }
232260 }
233261
 262 updateSurfaceNames();
 263
234264 m_contentsBufferHandle = std::nullopt;
235265 std::swap(m_frontBuffer, m_backBuffer);
236266 auto result = setBufferNonVolatile(m_frontBuffer);

Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

@@RefPtr<ViewSnapshot> WebViewImpl::takeViewSnapshot()
46714671 auto surface = WebCore::IOSurface::createFromImage(croppedSnapshotImage.get());
46724672 if (!surface)
46734673 return nullptr;
 4674#ifndef NDEBUG
 4675 surface->setName("View Snapshot");
 4676#endif
46744677
46754678 auto snapshot = ViewSnapshot::create(WTFMove(surface));
46764679 snapshot->setVolatile(true);

Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp

@@LayerPool& PlatformCALayerRemote::layerPool()
983983 return m_context->layerPool();
984984}
985985
 986void PlatformCALayerRemote::willMoveToLayerPool()
 987{
 988 m_inLayerPool = true;
 989 if (m_properties.backingStore)
 990 m_properties.backingStore->updateSurfaceNames();
 991}
 992
 993void PlatformCALayerRemote::didLeaveLayerPool()
 994{
 995 m_inLayerPool = false;
 996 if (m_properties.backingStore)
 997 m_properties.backingStore->updateSurfaceNames();
 998}
 999
 1000
9861001} // namespace WebKit

Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h

@@public:
217217 void moveToContext(RemoteLayerTreeContext&);
218218 void clearContext() { m_context = nullptr; }
219219 RemoteLayerTreeContext* context() const { return m_context; }
 220
 221 bool isInLayerPool() const { return m_inLayerPool; }
 222 void willMoveToLayerPool() override;
 223 void didLeaveLayerPool() override;
220224
221225 virtual void populateCreationProperties(RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeContext&, WebCore::PlatformCALayer::LayerType);
222226

@@private:
244248
245249 bool m_acceleratesDrawing { false };
246250 bool m_wantsDeepColorBackingStore { false };
 251 bool m_inLayerPool { false };
247252
248253 RemoteLayerTreeContext* m_context;
249254};