Title: [152307] trunk/Source
Revision
152307
Author
[email protected]
Date
2013-07-02 12:17:14 -0700 (Tue, 02 Jul 2013)

Log Message

Implement CoordinatedSurface for Threaded Coordinated Graphics
https://bugs.webkit.org/show_bug.cgi?id=109661

Patch by Jae Hyun Park <[email protected]> on 2013-07-02
Reviewed by Noam Rosenthal.

This is a preparation patch for Threaded Coordianted Graphics.

This patch implements ThreadSafeCoordinatedSurface using ImageBuffer as a
backend. Also, this patch moves common implementation to CoordinatedSurface to
prevent duplication of code.

Source/WebCore:

* platform/graphics/texmap/coordinated/CoordinatedSurface.cpp:
(WebCore::CoordinatedSurface::CoordinatedSurface):
* platform/graphics/texmap/coordinated/CoordinatedSurface.h:
(WebCore::CoordinatedSurface::size):
(WebCore::CoordinatedSurface::flags):
* platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp: Added.
(WebCore::ThreadSafeCoordinatedSurface::create):
(WebCore::ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface):
(WebCore::ThreadSafeCoordinatedSurface::~ThreadSafeCoordinatedSurface):
(WebCore::ThreadSafeCoordinatedSurface::paintToSurface):
(WebCore::ThreadSafeCoordinatedSurface::copyToTexture):
* platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h: Added.

Source/WebKit2:

* Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp:
(WebKit::WebCoordinatedSurface::WebCoordinatedSurface):
* Shared/CoordinatedGraphics/WebCoordinatedSurface.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152306 => 152307)


--- trunk/Source/WebCore/ChangeLog	2013-07-02 19:09:44 UTC (rev 152306)
+++ trunk/Source/WebCore/ChangeLog	2013-07-02 19:17:14 UTC (rev 152307)
@@ -1,3 +1,29 @@
+2013-07-02  Jae Hyun Park  <[email protected]>
+
+        Implement CoordinatedSurface for Threaded Coordinated Graphics
+        https://bugs.webkit.org/show_bug.cgi?id=109661
+
+        Reviewed by Noam Rosenthal.
+
+        This is a preparation patch for Threaded Coordianted Graphics.
+
+        This patch implements ThreadSafeCoordinatedSurface using ImageBuffer as a
+        backend. Also, this patch moves common implementation to CoordinatedSurface to
+        prevent duplication of code.
+
+        * platform/graphics/texmap/coordinated/CoordinatedSurface.cpp:
+        (WebCore::CoordinatedSurface::CoordinatedSurface):
+        * platform/graphics/texmap/coordinated/CoordinatedSurface.h:
+        (WebCore::CoordinatedSurface::size):
+        (WebCore::CoordinatedSurface::flags):
+        * platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp: Added.
+        (WebCore::ThreadSafeCoordinatedSurface::create):
+        (WebCore::ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface):
+        (WebCore::ThreadSafeCoordinatedSurface::~ThreadSafeCoordinatedSurface):
+        (WebCore::ThreadSafeCoordinatedSurface::paintToSurface):
+        (WebCore::ThreadSafeCoordinatedSurface::copyToTexture):
+        * platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h: Added.
+
 2013-07-02  Geoffrey Garen  <[email protected]>
 
         plainText() is O(N^2)

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp (152306 => 152307)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp	2013-07-02 19:09:44 UTC (rev 152306)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp	2013-07-02 19:17:14 UTC (rev 152307)
@@ -43,6 +43,12 @@
     return s_factory(size, flags);
 }
 
+CoordinatedSurface::CoordinatedSurface(const IntSize& size, Flags flags)
+    : m_size(size)
+    , m_flags(flags)
+{
+}
+
 } // namespace WebCore
 
 #endif // USE(COORDINATED_GRAPHICS)

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h (152306 => 152307)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h	2013-07-02 19:09:44 UTC (rev 152306)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h	2013-07-02 19:17:14 UTC (rev 152307)
@@ -23,7 +23,6 @@
 
 #if USE(COORDINATED_GRAPHICS)
 #include "IntRect.h"
-#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -52,7 +51,7 @@
     virtual ~CoordinatedSurface() { }
 
     bool supportsAlpha() const { return flags() & SupportsAlpha; }
-    virtual IntSize size() const = 0;
+    IntSize size() const { return m_size; }
 
     virtual void paintToSurface(const IntRect&, Client*) = 0;
 
@@ -61,8 +60,12 @@
 #endif
 
 protected:
-    virtual Flags flags() const = 0;
+    CoordinatedSurface(const IntSize&, Flags);
+    Flags flags() const { return m_flags; }
 
+    IntSize m_size;
+    Flags m_flags;
+
 private:
     static CoordinatedSurface::Factory* s_factory;
 };

Copied: trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp (from rev 152306, trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp) (0 => 152307)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp	2013-07-02 19:17:14 UTC (rev 152307)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ThreadSafeCoordinatedSurface.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "TextureMapper.h"
+
+namespace WebCore {
+
+PassRefPtr<ThreadSafeCoordinatedSurface> ThreadSafeCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags)
+{
+    return adoptRef(new ThreadSafeCoordinatedSurface(size, flags, ImageBuffer::create(size)));
+}
+
+ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, PassOwnPtr<ImageBuffer> buffer)
+    : CoordinatedSurface(size, flags)
+    , m_imageBuffer(buffer)
+{
+}
+
+ThreadSafeCoordinatedSurface::~ThreadSafeCoordinatedSurface()
+{
+}
+
+void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
+{
+    ASSERT(client);
+    ASSERT(m_imageBuffer);
+
+    GraphicsContext* context = m_imageBuffer->context();
+    context->save();
+    context->clip(rect);
+    context->translate(rect.x(), rect.y());
+
+    client->paintToSurfaceContext(context);
+
+    context->restore();
+}
+
+void ThreadSafeCoordinatedSurface::copyToTexture(PassRefPtr<BitmapTexture> passTexture, const IntRect& target, const IntPoint& sourceOffset)
+{
+    RefPtr<BitmapTexture> texture(passTexture);
+
+    ASSERT(m_imageBuffer);
+    RefPtr<Image> image = m_imageBuffer->copyImage(DontCopyBackingStore);
+    texture->updateContents(image.get(), target, sourceOffset, BitmapTexture::UpdateCanModifyOriginalImageData);
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)

Copied: trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h (from rev 152306, trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp) (0 => 152307)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h	2013-07-02 19:17:14 UTC (rev 152307)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ThreadSafeCoordinatedSurface_h
+#define ThreadSafeCoordinatedSurface_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedSurface.h"
+#include "ImageBuffer.h"
+
+namespace WebCore {
+
+class ThreadSafeCoordinatedSurface : public CoordinatedSurface {
+public:
+    virtual ~ThreadSafeCoordinatedSurface();
+
+    static PassRefPtr<ThreadSafeCoordinatedSurface> create(const IntSize&, Flags);
+
+    virtual void paintToSurface(const IntRect&, CoordinatedSurface::Client*) OVERRIDE;
+    virtual void copyToTexture(PassRefPtr<BitmapTexture>, const IntRect& target, const IntPoint& sourceOffset) OVERRIDE;
+
+private:
+    ThreadSafeCoordinatedSurface(const IntSize&, Flags, PassOwnPtr<ImageBuffer>);
+
+    OwnPtr<ImageBuffer> m_imageBuffer;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // ThreadSafeCoordinatedSurface_h

Modified: trunk/Source/WebKit2/ChangeLog (152306 => 152307)


--- trunk/Source/WebKit2/ChangeLog	2013-07-02 19:09:44 UTC (rev 152306)
+++ trunk/Source/WebKit2/ChangeLog	2013-07-02 19:17:14 UTC (rev 152307)
@@ -1,3 +1,20 @@
+2013-07-02  Jae Hyun Park  <[email protected]>
+
+        Implement CoordinatedSurface for Threaded Coordinated Graphics
+        https://bugs.webkit.org/show_bug.cgi?id=109661
+
+        Reviewed by Noam Rosenthal.
+
+        This is a preparation patch for Threaded Coordianted Graphics.
+
+        This patch implements ThreadSafeCoordinatedSurface using ImageBuffer as a
+        backend. Also, this patch moves common implementation to CoordinatedSurface to
+        prevent duplication of code.
+
+        * Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp:
+        (WebKit::WebCoordinatedSurface::WebCoordinatedSurface):
+        * Shared/CoordinatedGraphics/WebCoordinatedSurface.h:
+
 2013-07-01  Alexey Proskuryakov  <[email protected]>
 
         Clean up private browsing session tracking

Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp (152306 => 152307)


--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp	2013-07-02 19:09:44 UTC (rev 152306)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp	2013-07-02 19:17:14 UTC (rev 152307)
@@ -123,16 +123,14 @@
 }
 
 WebCoordinatedSurface::WebCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<ShareableBitmap> bitmap)
-    : m_size(size)
-    , m_flags(flags)
+    : CoordinatedSurface(size, flags)
     , m_bitmap(bitmap)
 {
 }
 
 #if USE(GRAPHICS_SURFACE)
 WebCoordinatedSurface::WebCoordinatedSurface(const WebCore::IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<WebCore::GraphicsSurface> surface)
-    : m_size(size)
-    , m_flags(flags)
+    : CoordinatedSurface(size, flags)
     , m_graphicsSurface(surface)
 {
 }

Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h (152306 => 152307)


--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h	2013-07-02 19:09:44 UTC (rev 152306)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h	2013-07-02 19:17:14 UTC (rev 152307)
@@ -71,8 +71,6 @@
 
     virtual ~WebCoordinatedSurface();
 
-    virtual WebCore::IntSize size() const OVERRIDE { return m_size; }
-
     virtual void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client*) OVERRIDE;
 
 #if USE(TEXTURE_MAPPER)
@@ -82,8 +80,6 @@
 private:
     WebCoordinatedSurface(const WebCore::IntSize&, Flags, PassRefPtr<ShareableBitmap>);
 
-    virtual Flags flags() const OVERRIDE { return m_flags; }
-
     // Create a WebCoordinatedSurface referencing an existing ShareableBitmap.
     static PassRefPtr<WebCoordinatedSurface> create(const WebCore::IntSize&, Flags, PassRefPtr<ShareableBitmap>);
 
@@ -98,8 +94,6 @@
     bool isBackedByGraphicsSurface() const { return !!m_graphicsSurface; }
 #endif
 
-    WebCore::IntSize m_size;
-    Flags m_flags;
     RefPtr<ShareableBitmap> m_bitmap;
 
 #if USE(GRAPHICS_SURFACE)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to