[CoordGraphics] Remove relay CoordinatedBuffer::Client implementations
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Nov 2017 11:04:05 +0000 (11:04 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Nov 2017 11:04:05 +0000 (11:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179970

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Drop CoordinatedBuffer::painToSurface() in favor of a simpler
GraphicsContext reference getter that returns a reference to the
GraphicsContext object of the internal ImageBuffer.

Remove the ImageBackingSurfaceClient class that only acted as a relay
that enabled a CoordinatedBuffer to draw an image through its context.
Instead, we use the GraphicsContext of the allocated CoordinatedBuffer
to draw the image directly. We still use a rectangle whose size
matches the size of the given Image as the clipping area and as the
source and destination rectangle for the image.

No new tests -- no change in behavior.

* platform/graphics/texmap/coordinated/CoordinatedBuffer.cpp:
(WebCore::CoordinatedBuffer::context):
(WebCore::CoordinatedBuffer::paintToSurface): Deleted.
* platform/graphics/texmap/coordinated/CoordinatedBuffer.h:
* platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:
(WebCore::CoordinatedImageBacking::update):
(WebCore::ImageBackingSurfaceClient::ImageBackingSurfaceClient): Deleted.

Source/WebKit:

Drop the helper UpdateAtlasSurfaceClient class and instead directly use
the CoordinatedBuffer's GraphicsContext to perform clip and translation
operations based on the allocated rectangle, to pre-fill the target rect
with transparent color in case the alpha channel is supported, and to
then invoke CoordinatedBuffer::Client::paintToSurfaceContext() method,
passing the GraphicsContext as the argument.

* WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
(WebKit::UpdateAtlas::paintOnAvailableBuffer):
(): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225113 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBuffer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBuffer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp

index 3be5cf9..3ecbb0b 100644 (file)
@@ -1,5 +1,33 @@
 2017-11-23  Zan Dobersek  <zdobersek@igalia.com>
 
+        [CoordGraphics] Remove relay CoordinatedBuffer::Client implementations
+        https://bugs.webkit.org/show_bug.cgi?id=179970
+
+        Reviewed by Carlos Garcia Campos.
+
+        Drop CoordinatedBuffer::painToSurface() in favor of a simpler
+        GraphicsContext reference getter that returns a reference to the
+        GraphicsContext object of the internal ImageBuffer.
+
+        Remove the ImageBackingSurfaceClient class that only acted as a relay
+        that enabled a CoordinatedBuffer to draw an image through its context.
+        Instead, we use the GraphicsContext of the allocated CoordinatedBuffer
+        to draw the image directly. We still use a rectangle whose size
+        matches the size of the given Image as the clipping area and as the
+        source and destination rectangle for the image.
+
+        No new tests -- no change in behavior.
+
+        * platform/graphics/texmap/coordinated/CoordinatedBuffer.cpp:
+        (WebCore::CoordinatedBuffer::context):
+        (WebCore::CoordinatedBuffer::paintToSurface): Deleted.
+        * platform/graphics/texmap/coordinated/CoordinatedBuffer.h:
+        * platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:
+        (WebCore::CoordinatedImageBacking::update):
+        (WebCore::ImageBackingSurfaceClient::ImageBackingSurfaceClient): Deleted.
+
+2017-11-23  Zan Dobersek  <zdobersek@igalia.com>
+
         [CoordGraphics] TiledBackingStore: use a reference to the client
         https://bugs.webkit.org/show_bug.cgi?id=179969
 
index b87914d..d1d155f 100644 (file)
@@ -50,14 +50,9 @@ CoordinatedBuffer::CoordinatedBuffer(const IntSize& size, Flags flags)
 
 CoordinatedBuffer::~CoordinatedBuffer() = default;
 
-void CoordinatedBuffer::paintToSurface(const IntRect& rect, Client& client)
+GraphicsContext& CoordinatedBuffer::context()
 {
-    GraphicsContext& context = m_imageBuffer->context();
-    context.save();
-    context.clip(rect);
-    context.translate(rect.x(), rect.y());
-    client.paintToSurfaceContext(context);
-    context.restore();
+    return m_imageBuffer->context();
 }
 
 RefPtr<Image> CoordinatedBuffer::uploadImage()
index 294bd15..4c63a55 100644 (file)
@@ -61,7 +61,7 @@ public:
     bool supportsAlpha() const { return m_flags & SupportsAlpha; }
     const IntSize& size() const { return m_size; }
 
-    void paintToSurface(const IntRect&, Client&);
+    GraphicsContext& context();
     RefPtr<Image> uploadImage();
 
 private:
index a221d88..b6a9ffa 100644 (file)
 
 namespace WebCore {
 
-class ImageBackingSurfaceClient : public CoordinatedBuffer::Client {
-public:
-    ImageBackingSurfaceClient(Image& image, const IntRect& rect)
-        : m_image(image)
-        , m_rect(rect)
-    {
-    }
-
-    void paintToSurfaceContext(GraphicsContext& context) override
-    {
-        context.drawImage(m_image, m_rect, m_rect);
-    }
-
-private:
-    Image& m_image;
-    IntRect m_rect;
-};
-
 CoordinatedImageBackingID CoordinatedImageBacking::getCoordinatedImageBackingID(Image* image)
 {
     // CoordinatedImageBacking keeps a RefPtr<Image> member, so the same Image pointer can not refer two different instances until CoordinatedImageBacking releases the member.
@@ -123,8 +105,13 @@ void CoordinatedImageBacking::update()
 
     IntRect rect(IntPoint::zero(), IntSize(m_image->size()));
 
-    ImageBackingSurfaceClient surfaceClient(*m_image, rect);
-    m_buffer->paintToSurface(rect, surfaceClient);
+    {
+        GraphicsContext& context = m_buffer->context();
+        context.save();
+        context.clip(rect);
+        context.drawImage(*m_image, rect, rect);
+        context.restore();
+    }
 
     m_nativeImagePtr = m_image->nativeImageForCurrentFrame();
 
index 3b4f485..8a2ae24 100644 (file)
@@ -1,5 +1,23 @@
 2017-11-23  Zan Dobersek  <zdobersek@igalia.com>
 
+        [CoordGraphics] Remove relay CoordinatedBuffer::Client implementations
+        https://bugs.webkit.org/show_bug.cgi?id=179970
+
+        Reviewed by Carlos Garcia Campos.
+
+        Drop the helper UpdateAtlasSurfaceClient class and instead directly use
+        the CoordinatedBuffer's GraphicsContext to perform clip and translation
+        operations based on the allocated rectangle, to pre-fill the target rect
+        with transparent color in case the alpha channel is supported, and to
+        then invoke CoordinatedBuffer::Client::paintToSurfaceContext() method,
+        passing the GraphicsContext as the argument.
+
+        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
+        (WebKit::UpdateAtlas::paintOnAvailableBuffer):
+        (): Deleted.
+
+2017-11-23  Zan Dobersek  <zdobersek@igalia.com>
+
         [CoordGraphics] Replace CoordinatedSurface, ThreadSafeCoordinatedSurface with CoordinatedBuffer
         https://bugs.webkit.org/show_bug.cgi?id=179967
 
index 0bc6ef4..5d0ebc5 100644 (file)
@@ -32,32 +32,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-class UpdateAtlasSurfaceClient final : public CoordinatedBuffer::Client {
-public:
-    UpdateAtlasSurfaceClient(CoordinatedBuffer::Client& client, const IntSize& size, bool supportsAlpha)
-        : m_client(client)
-        , m_size(size)
-        , m_supportsAlpha(supportsAlpha)
-    {
-    }
-
-    void paintToSurfaceContext(GraphicsContext& context) override
-    {
-        if (m_supportsAlpha) {
-            context.setCompositeOperation(CompositeCopy);
-            context.fillRect(IntRect(IntPoint::zero(), m_size), Color::transparent);
-            context.setCompositeOperation(CompositeSourceOver);
-        }
-
-        m_client.paintToSurfaceContext(context);
-    }
-
-private:
-    CoordinatedBuffer::Client& m_client;
-    IntSize m_size;
-    bool m_supportsAlpha;
-};
-
 UpdateAtlas::UpdateAtlas(Client& client, int dimension, CoordinatedBuffer::Flags flags)
     : m_client(client)
     , m_buffer(CoordinatedBuffer::create(nextPowerOfTwo(IntSize(dimension, dimension)), flags))
@@ -101,8 +75,21 @@ bool UpdateAtlas::paintOnAvailableBuffer(const IntSize& size, uint32_t& atlasID,
     // FIXME: Use tri-state buffers, to allow faster updates.
     offset = rect.location();
 
-    UpdateAtlasSurfaceClient surfaceClient(client, size, supportsAlpha());
-    m_buffer->paintToSurface(rect, surfaceClient);
+    {
+        GraphicsContext& context = m_buffer->context();
+        context.save();
+        context.clip(rect);
+        context.translate(rect.x(), rect.y());
+
+        if (supportsAlpha()) {
+            context.setCompositeOperation(CompositeCopy);
+            context.fillRect(IntRect(IntPoint::zero(), size), Color::transparent);
+            context.setCompositeOperation(CompositeSourceOver);
+        }
+
+        client.paintToSurfaceContext(context);
+        context.restore();
+    }
 
     return true;
 }