Bug 253636 - RemoteImageBufferProxy should be removed once redundant
Summary: RemoteImageBufferProxy should be removed once redundant
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-03-09 00:42 PST by Kimmo Kinnunen
Modified: 2023-03-16 01:42 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Kinnunen 2023-03-09 00:42:01 PST
RemoteImageBufferProxy should be removed once redundant

The point of polymorphism in ImageBuffer is ImageBufferBackend.

RemoteImageBufferProxy does not implement anything that is not hard-coded to be routed via its ImageBufferBackend. This means RemoteImageBufferProxy is redundant.

Each current RemoteImageBuffer message is specific to a particular specific backend type.

The polymorphic behavior is implemented as follows:

- ImageBuffer
  - ImageBufferBackend subclass suitable for the use-case
     - GraphicsContext subclass suitable for above


So we should have:

Mapped memory:
- WP:   RemoteImageBufferBackendSharedProxy
- GPU:  RemoteImageBufferBackendShared

Mapped IOSurface:
- WP:   RemoteImageBufferBackendIOSurfaceProxy 
- GPUP: RemoteImageBufferBackendIOSurface

Non-mapped IOSurface:
- WP:   RemoteImageBufferBackendUnmappedProxy (bad name)
- GPUP: RemoteImageBufferBackendUnmapped
or in case the code can be made so that RemoteImageBufferBackendShared references nicely ImageBufferBackendIOSurface
- WP:   RemoteImageBufferBackendSharedProxy
- GPUP: RemoteImageBufferBackendShared


Preferably the GPUP RemoteImageBufferBackend** types are normal types that are not ImageBufferBackends, rather hold a ref to those.


Currently the RemoteImageBufferProxy has methods of form:

void putImageData() {
 if (canMapBuffer())
     backend->putByMapping()
 else 
     putBySendingMessage()
}

That should be moved down to each individual backend as:

void Backend1::putImageData() {
   putByMapping();
}

void Backend2::putImageData() {
   putBySendingMessage();
}


The RemoteImageBufferBackend*Proxy classes are of form


class RemoteImageBufferBackendSharedProxy : public ImageBufferBackend
{
    std::unique_ptr<RemoteDisplayListRecorderProxy> m_remoteContext;
}

GraphicsContext& RemoteImageBufferBackendSharedProxy::context()
{
   if (!m_remoteContext)
      m_remoteContext = RemoteDisplayListRecorderProxy::create(m_connection, m_identifier, ...);
 
   return m_remoteContext;
}

void RemoteImageBufferBackendSharedProxy::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat)
{
    if (m_remoteContext)
        m_remoteContext->flush();
    ImageBuffer::putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat);
    m_connection->send(RemoteImageBufferBackendShared::Messages::SharedStoreUpdated());
}


class RemoteImageBufferBackendIOSurfaceProxy : public ImageBufferBackendIOSurfaceBase
{
    std::unique_ptr<RemoteDisplayListRecorderProxy> m_remoteContext;
}

void RemoteImageBufferBackendISurfaceProxy::prepareForExternalWrite()
{
    m_connection->send(RemoteImageBufferBackendIOSurface::Messages::PrepareForExternalWrite());
    ImageBufferBackendIOSurfaceBase::prepareForExternalWrite();
}
Comment 1 Radar WebKit Bug Importer 2023-03-16 01:42:14 PDT
<rdar://problem/106797458>