Changeset 152307 in webkit


Ignore:
Timestamp:
Jul 2, 2013 12:17:14 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Jae Hyun Park <jae.park@company100.net> 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:
Location:
trunk/Source
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152306 r152307  
     12013-07-02  Jae Hyun Park  <jae.park@company100.net>
     2
     3        Implement CoordinatedSurface for Threaded Coordinated Graphics
     4        https://bugs.webkit.org/show_bug.cgi?id=109661
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        This is a preparation patch for Threaded Coordianted Graphics.
     9
     10        This patch implements ThreadSafeCoordinatedSurface using ImageBuffer as a
     11        backend. Also, this patch moves common implementation to CoordinatedSurface to
     12        prevent duplication of code.
     13
     14        * platform/graphics/texmap/coordinated/CoordinatedSurface.cpp:
     15        (WebCore::CoordinatedSurface::CoordinatedSurface):
     16        * platform/graphics/texmap/coordinated/CoordinatedSurface.h:
     17        (WebCore::CoordinatedSurface::size):
     18        (WebCore::CoordinatedSurface::flags):
     19        * platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp: Added.
     20        (WebCore::ThreadSafeCoordinatedSurface::create):
     21        (WebCore::ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface):
     22        (WebCore::ThreadSafeCoordinatedSurface::~ThreadSafeCoordinatedSurface):
     23        (WebCore::ThreadSafeCoordinatedSurface::paintToSurface):
     24        (WebCore::ThreadSafeCoordinatedSurface::copyToTexture):
     25        * platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h: Added.
     26
    1272013-07-02  Geoffrey Garen  <ggaren@apple.com>
    228
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp

    r141543 r152307  
    4444}
    4545
     46CoordinatedSurface::CoordinatedSurface(const IntSize& size, Flags flags)
     47    : m_size(size)
     48    , m_flags(flags)
     49{
     50}
     51
    4652} // namespace WebCore
    4753
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h

    r151262 r152307  
    2424#if USE(COORDINATED_GRAPHICS)
    2525#include "IntRect.h"
    26 #include <wtf/PassOwnPtr.h>
    2726#include <wtf/PassRefPtr.h>
    2827#include <wtf/ThreadSafeRefCounted.h>
     
    5352
    5453    bool supportsAlpha() const { return flags() & SupportsAlpha; }
    55     virtual IntSize size() const = 0;
     54    IntSize size() const { return m_size; }
    5655
    5756    virtual void paintToSurface(const IntRect&, Client*) = 0;
     
    6261
    6362protected:
    64     virtual Flags flags() const = 0;
     63    CoordinatedSurface(const IntSize&, Flags);
     64    Flags flags() const { return m_flags; }
     65
     66    IntSize m_size;
     67    Flags m_flags;
    6568
    6669private:
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp

    r152306 r152307  
    2525
    2626#include "config.h"
    27 #include "CoordinatedSurface.h"
     27#include "ThreadSafeCoordinatedSurface.h"
    2828
    2929#if USE(COORDINATED_GRAPHICS)
    3030
     31#include "TextureMapper.h"
     32
    3133namespace WebCore {
    3234
    33 CoordinatedSurface::Factory* CoordinatedSurface::s_factory = 0;
    34 
    35 void CoordinatedSurface::setFactory(CoordinatedSurface::Factory factory)
     35PassRefPtr<ThreadSafeCoordinatedSurface> ThreadSafeCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags)
    3636{
    37     s_factory = factory;
     37    return adoptRef(new ThreadSafeCoordinatedSurface(size, flags, ImageBuffer::create(size)));
    3838}
    3939
    40 PassRefPtr<CoordinatedSurface> CoordinatedSurface::create(const IntSize& size, Flags flags)
     40ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, PassOwnPtr<ImageBuffer> buffer)
     41    : CoordinatedSurface(size, flags)
     42    , m_imageBuffer(buffer)
    4143{
    42     ASSERT(s_factory);
    43     return s_factory(size, flags);
     44}
     45
     46ThreadSafeCoordinatedSurface::~ThreadSafeCoordinatedSurface()
     47{
     48}
     49
     50void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
     51{
     52    ASSERT(client);
     53    ASSERT(m_imageBuffer);
     54
     55    GraphicsContext* context = m_imageBuffer->context();
     56    context->save();
     57    context->clip(rect);
     58    context->translate(rect.x(), rect.y());
     59
     60    client->paintToSurfaceContext(context);
     61
     62    context->restore();
     63}
     64
     65void ThreadSafeCoordinatedSurface::copyToTexture(PassRefPtr<BitmapTexture> passTexture, const IntRect& target, const IntPoint& sourceOffset)
     66{
     67    RefPtr<BitmapTexture> texture(passTexture);
     68
     69    ASSERT(m_imageBuffer);
     70    RefPtr<Image> image = m_imageBuffer->copyImage(DontCopyBackingStore);
     71    texture->updateContents(image.get(), target, sourceOffset, BitmapTexture::UpdateCanModifyOriginalImageData);
    4472}
    4573
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h

    r152306 r152307  
    2424 */
    2525
    26 #include "config.h"
    27 #include "CoordinatedSurface.h"
     26#ifndef ThreadSafeCoordinatedSurface_h
     27#define ThreadSafeCoordinatedSurface_h
    2828
    2929#if USE(COORDINATED_GRAPHICS)
     30#include "CoordinatedSurface.h"
     31#include "ImageBuffer.h"
    3032
    3133namespace WebCore {
    3234
    33 CoordinatedSurface::Factory* CoordinatedSurface::s_factory = 0;
     35class ThreadSafeCoordinatedSurface : public CoordinatedSurface {
     36public:
     37    virtual ~ThreadSafeCoordinatedSurface();
    3438
    35 void CoordinatedSurface::setFactory(CoordinatedSurface::Factory factory)
    36 {
    37     s_factory = factory;
    38 }
     39    static PassRefPtr<ThreadSafeCoordinatedSurface> create(const IntSize&, Flags);
    3940
    40 PassRefPtr<CoordinatedSurface> CoordinatedSurface::create(const IntSize& size, Flags flags)
    41 {
    42     ASSERT(s_factory);
    43     return s_factory(size, flags);
    44 }
     41    virtual void paintToSurface(const IntRect&, CoordinatedSurface::Client*) OVERRIDE;
     42    virtual void copyToTexture(PassRefPtr<BitmapTexture>, const IntRect& target, const IntPoint& sourceOffset) OVERRIDE;
     43
     44private:
     45    ThreadSafeCoordinatedSurface(const IntSize&, Flags, PassOwnPtr<ImageBuffer>);
     46
     47    OwnPtr<ImageBuffer> m_imageBuffer;
     48};
    4549
    4650} // namespace WebCore
    4751
    4852#endif // USE(COORDINATED_GRAPHICS)
     53
     54#endif // ThreadSafeCoordinatedSurface_h
  • trunk/Source/WebKit2/ChangeLog

    r152273 r152307  
     12013-07-02  Jae Hyun Park  <jae.park@company100.net>
     2
     3        Implement CoordinatedSurface for Threaded Coordinated Graphics
     4        https://bugs.webkit.org/show_bug.cgi?id=109661
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        This is a preparation patch for Threaded Coordianted Graphics.
     9
     10        This patch implements ThreadSafeCoordinatedSurface using ImageBuffer as a
     11        backend. Also, this patch moves common implementation to CoordinatedSurface to
     12        prevent duplication of code.
     13
     14        * Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp:
     15        (WebKit::WebCoordinatedSurface::WebCoordinatedSurface):
     16        * Shared/CoordinatedGraphics/WebCoordinatedSurface.h:
     17
    1182013-07-01  Alexey Proskuryakov  <ap@apple.com>
    219
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp

    r151353 r152307  
    124124
    125125WebCoordinatedSurface::WebCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<ShareableBitmap> bitmap)
    126     : m_size(size)
    127     , m_flags(flags)
     126    : CoordinatedSurface(size, flags)
    128127    , m_bitmap(bitmap)
    129128{
     
    132131#if USE(GRAPHICS_SURFACE)
    133132WebCoordinatedSurface::WebCoordinatedSurface(const WebCore::IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<WebCore::GraphicsSurface> surface)
    134     : m_size(size)
    135     , m_flags(flags)
     133    : CoordinatedSurface(size, flags)
    136134    , m_graphicsSurface(surface)
    137135{
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h

    r151262 r152307  
    7272    virtual ~WebCoordinatedSurface();
    7373
    74     virtual WebCore::IntSize size() const OVERRIDE { return m_size; }
    75 
    7674    virtual void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client*) OVERRIDE;
    7775
     
    8280private:
    8381    WebCoordinatedSurface(const WebCore::IntSize&, Flags, PassRefPtr<ShareableBitmap>);
    84 
    85     virtual Flags flags() const OVERRIDE { return m_flags; }
    8682
    8783    // Create a WebCoordinatedSurface referencing an existing ShareableBitmap.
     
    9995#endif
    10096
    101     WebCore::IntSize m_size;
    102     Flags m_flags;
    10397    RefPtr<ShareableBitmap> m_bitmap;
    10498
Note: See TracChangeset for help on using the changeset viewer.