Changeset 120142 in webkit


Ignore:
Timestamp:
Jun 12, 2012, 5:10:03 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
https://bugs.webkit.org/show_bug.cgi?id=88597

Patch by James Robinson <jamesr@chromium.org> on 2012-06-12
Reviewed by Adrienne Walker.

Source/Platform:

This adds two new APIs to WebExternalTextureLayer that are used by the accelerated 2d canvas path:

  • willModifyTexture() is called to indicate that a system outside the compositor's control is about to modify

the texture backing the WebExternalTextureLayer. This indicates to the compositor that it needs to avoid
producing more frames using this texture until it can do a full commit - either by double buffering or
appropriate flow control.

  • setRateLimitContext() is called to enable rate limiting for this texture. The rate limiting logic blocks if

too many invalidate() or invalidateRect() calls are made on the texture outside of the context of a
WebLayerTreeViewClient::updateAnimations() call to prevent a non-vsynced producer from getting too far ahead of
the compositor.

  • chromium/public/WebExternalTextureLayer.h:

(WebKit::WebExternalTextureLayer::WebExternalTextureLayer):
(WebExternalTextureLayer):

Source/WebCore:

This converts Canvas2DLayerBridge to using public WebLayer API types instead of LayerChromium types.

  • platform/graphics/chromium/Canvas2DLayerBridge.cpp:

(WebCore::AcceleratedDeviceContext::AcceleratedDeviceContext):
(WebCore::AcceleratedDeviceContext::prepareForDraw):
(AcceleratedDeviceContext):
(WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::skCanvas):
(WebCore::Canvas2DLayerBridge::prepareTexture):
(WebCore::Canvas2DLayerBridge::context):
(WebCore::Canvas2DLayerBridge::layer):
(WebCore::Canvas2DLayerBridge::contextAcquired):

  • platform/graphics/chromium/Canvas2DLayerBridge.h:

(WebCore):
(Canvas2DLayerBridge):

Source/WebKit/chromium:

Implementations for new WebExternalTextureLayer APIs, updates test.

  • src/WebExternalTextureLayer.cpp:

(WebKit::WebExternalTextureLayer::willModifyTexture):
(WebKit):
(WebKit::WebExternalTextureLayer::setRateLimitContext):

  • tests/Canvas2DLayerBridgeTest.cpp:

(Canvas2DLayerBridgeTest::fullLifecycleTest):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/Platform/ChangeLog

    r120023 r120142  
     12012-06-12  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=88597
     5
     6        Reviewed by Adrienne Walker.
     7
     8        This adds two new APIs to WebExternalTextureLayer that are used by the accelerated 2d canvas path:
     9        - willModifyTexture() is called to indicate that a system outside the compositor's control is about to modify
     10        the texture backing the WebExternalTextureLayer. This indicates to the compositor that it needs to avoid
     11        producing more frames using this texture until it can do a full commit - either by double buffering or
     12        appropriate flow control.
     13
     14        - setRateLimitContext() is called to enable rate limiting for this texture. The rate limiting logic blocks if
     15        too many invalidate() or invalidateRect() calls are made on the texture outside of the context of a
     16        WebLayerTreeViewClient::updateAnimations() call to prevent a non-vsynced producer from getting too far ahead of
     17        the compositor.
     18
     19        * chromium/public/WebExternalTextureLayer.h:
     20        (WebKit::WebExternalTextureLayer::WebExternalTextureLayer):
     21        (WebExternalTextureLayer):
     22
    1232012-06-11  James Robinson  <jamesr@chromium.org>
    224
  • trunk/Source/Platform/chromium/public/WebExternalTextureLayer.h

    r120023 r120142  
    7777    WEBKIT_EXPORT void setPremultipliedAlpha(bool);
    7878
     79    // Indicates that the most recently provided texture ID is about to be modified externally.
     80    WEBKIT_EXPORT void willModifyTexture();
     81
     82    // Sets whether this context should be rate limited by the compositor. Rate limiting works by blocking
     83    // invalidate() and invalidateRect() calls if the compositor is too many frames behind.
     84    WEBKIT_EXPORT void setRateLimitContext(bool);
     85
    7986private:
    8087#if WEBKIT_IMPLEMENTATION
  • trunk/Source/WebCore/ChangeLog

    r120136 r120142  
     12012-06-12  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=88597
     5
     6        Reviewed by Adrienne Walker.
     7
     8        This converts Canvas2DLayerBridge to using public WebLayer API types instead of LayerChromium types.
     9
     10        * platform/graphics/chromium/Canvas2DLayerBridge.cpp:
     11        (WebCore::AcceleratedDeviceContext::AcceleratedDeviceContext):
     12        (WebCore::AcceleratedDeviceContext::prepareForDraw):
     13        (AcceleratedDeviceContext):
     14        (WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
     15        (WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
     16        (WebCore::Canvas2DLayerBridge::skCanvas):
     17        (WebCore::Canvas2DLayerBridge::prepareTexture):
     18        (WebCore::Canvas2DLayerBridge::context):
     19        (WebCore::Canvas2DLayerBridge::layer):
     20        (WebCore::Canvas2DLayerBridge::contextAcquired):
     21        * platform/graphics/chromium/Canvas2DLayerBridge.h:
     22        (WebCore):
     23        (Canvas2DLayerBridge):
     24
    1252012-06-12  Alexis Menard  <alexis.menard@openbossa.org>
    226
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp

    r120117 r120142  
    3434#include "SkCanvas.h"
    3535#include "SkDeferredCanvas.h"
    36 #include "TextureLayerChromium.h"
    3736#include "cc/CCProxy.h"
    3837#include "cc/CCTextureUpdater.h"
     38#include <public/WebGraphicsContext3D.h>
     39
     40using WebKit::WebExternalTextureLayer;
     41using WebKit::WebGraphicsContext3D;
     42using WebKit::WebTextureUpdater;
    3943
    4044namespace WebCore {
     
    4246class AcceleratedDeviceContext : public SkDeferredCanvas::DeviceContext {
    4347public:
    44     AcceleratedDeviceContext(GraphicsContext3D* context, TextureLayerChromium* layer, bool useDoubleBuffering)
     48    AcceleratedDeviceContext(WebGraphicsContext3D* context, WebExternalTextureLayer layer, bool useDoubleBuffering)
    4549        : m_layer(layer)
    4650        , m_context()
     
    4852    {
    4953        ASSERT(context);
    50         ASSERT(layer);
     54        ASSERT(!layer.isNull());
    5155        m_context = context;
    5256    }
     
    5559    {
    5660        if (!m_useDoubleBuffering)
    57             m_layer->willModifyTexture();
     61            m_layer.willModifyTexture();
    5862        m_context->makeContextCurrent();
    5963    }
    6064
    6165private:
    62     TextureLayerChromium* m_layer;
    63     GraphicsContext3D* m_context;
     66    WebExternalTextureLayer m_layer;
     67    WebGraphicsContext3D* m_context;
    6468    bool m_useDoubleBuffering;
    6569};
     
    9397    }
    9498
    95     m_layer = TextureLayerChromium::create(this);
    96     m_layer->setTextureId(textureId);
    97     m_layer->setRateLimitContext(!CCProxy::hasImplThread() || m_useDoubleBuffering);
     99    m_layer = WebExternalTextureLayer::create(this);
     100    m_layer.setTextureId(textureId);
     101    m_layer.setRateLimitContext(!CCProxy::hasImplThread() || m_useDoubleBuffering);
    98102}
    99103
     
    101105Canvas2DLayerBridge::~Canvas2DLayerBridge()
    102106{
    103     m_layer->setTextureId(0);
     107    m_layer.setTextureId(0);
    104108    if (m_useDoubleBuffering) {
    105109        m_context->makeContextCurrent();
     
    107111        m_context->flush();
    108112    }
    109     m_layer->clearClient();
     113    m_layer.clearClient();
    110114}
    111115
     
    113117{
    114118    if (m_deferralMode == Deferred) {
    115         SkAutoTUnref<AcceleratedDeviceContext> deviceContext(new AcceleratedDeviceContext(m_context.get(), m_layer.get(), m_useDoubleBuffering));
     119        SkAutoTUnref<AcceleratedDeviceContext> deviceContext(new AcceleratedDeviceContext(context(), m_layer, m_useDoubleBuffering));
    116120        m_canvas = new SkDeferredCanvas(device, deviceContext.get());
    117121    } else
     
    122126
    123127
    124 unsigned Canvas2DLayerBridge::prepareTexture(CCTextureUpdater& updater)
     128unsigned Canvas2DLayerBridge::prepareTexture(WebTextureUpdater& updater)
    125129{
    126130    m_context->makeContextCurrent();
     
    141145}
    142146
    143 WebKit::WebGraphicsContext3D* Canvas2DLayerBridge::context()
     147WebGraphicsContext3D* Canvas2DLayerBridge::context()
    144148{
    145149    return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_context.get());
     
    148152LayerChromium* Canvas2DLayerBridge::layer() const
    149153{
    150     return m_layer.get();
     154    return m_layer.unwrap<LayerChromium>();
    151155}
    152156
     
    154158{
    155159    if (m_deferralMode == NonDeferred && !m_useDoubleBuffering)
    156         m_layer->willModifyTexture();
     160        m_layer.willModifyTexture();
    157161}
    158162
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h

    r120023 r120142  
    2929#include "ImageBuffer.h" // For DeferralMode enum.
    3030#include "IntSize.h"
    31 #include "TextureLayerChromium.h"
     31#include <public/WebExternalTextureLayer.h>
     32#include <public/WebExternalTextureLayerClient.h>
    3233#include <wtf/PassOwnPtr.h>
    3334#include <wtf/RefPtr.h>
     
    4344
    4445class LayerChromium;
    45 class TextureLayerChromium;
    4646
    47 class Canvas2DLayerBridge : public TextureLayerChromiumClient {
     47class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient {
    4848    WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
    4949public:
     
    5555    virtual ~Canvas2DLayerBridge();
    5656
    57     // TextureLayerChromiumClient implementation.
    58     virtual unsigned prepareTexture(CCTextureUpdater&) OVERRIDE;
     57    // WebKit::WebExternalTextureLayerClient implementation.
     58    virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE;
    5959    virtual WebKit::WebGraphicsContext3D* context() OVERRIDE;
    6060
     
    7272    IntSize m_size;
    7373    SkCanvas* m_canvas;
    74     RefPtr<TextureLayerChromium> m_layer;
     74    WebKit::WebExternalTextureLayer m_layer;
    7575    RefPtr<GraphicsContext3D> m_context;
    7676};
  • trunk/Source/WebKit/chromium/ChangeLog

    r120135 r120142  
     12012-06-12  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Port Canvas2DLayerBridge over to WebExternalTextureLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=88597
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Implementations for new WebExternalTextureLayer APIs, updates test.
     9
     10        * src/WebExternalTextureLayer.cpp:
     11        (WebKit::WebExternalTextureLayer::willModifyTexture):
     12        (WebKit):
     13        (WebKit::WebExternalTextureLayer::setRateLimitContext):
     14        * tests/Canvas2DLayerBridgeTest.cpp:
     15        (Canvas2DLayerBridgeTest::fullLifecycleTest):
     16
    1172012-06-12  Adrienne Walker  <enne@google.com>
    218
  • trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp

    r120023 r120142  
    113113}
    114114
     115void WebExternalTextureLayer::willModifyTexture()
     116{
     117    unwrap<TextureLayerChromium>()->willModifyTexture();
     118}
     119
     120void WebExternalTextureLayer::setRateLimitContext(bool rateLimit)
     121{
     122    unwrap<TextureLayerChromium>()->setRateLimitContext(rateLimit);
     123}
     124
    115125WebExternalTextureLayer::WebExternalTextureLayer(PassRefPtr<TextureLayerChromium> layer)
    116126    : WebLayer(layer)
  • trunk/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp

    r120117 r120142  
    3030#include "GraphicsContext3DPrivate.h"
    3131#include "ImageBuffer.h"
    32 #include "TextureCopier.h"
     32#include "LayerChromium.h"
    3333#include "TextureManager.h"
    3434#include "WebCompositor.h"
     
    6060};
    6161
    62 class MockTextureCopier : public TextureCopier {
     62class MockWebTextureUpdater : public WebTextureUpdater {
    6363public:
    64     MOCK_METHOD4(copyTexture, void(CCGraphicsContext*, unsigned, unsigned, const IntSize&));
     64    MOCK_METHOD3(appendCopy, void(unsigned, unsigned, WebSize));
    6565};
    6666
     
    8585        MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get()));
    8686
    87         MockTextureCopier copierMock;
    88         CCTextureUpdater updater;
     87        MockWebTextureUpdater updater;
    8988
    9089        const IntSize size(300, 150);
     
    110109
    111110        EXPECT_CALL(mainMock, flush());
     111        if (threadMode == Threaded && deferralMode == NonDeferred)
     112            EXPECT_CALL(updater, appendCopy(backTextureId, frontTextureId, WebSize(300, 150)));
    112113        EXPECT_EQ(frontTextureId, bridge->prepareTexture(updater));
    113114        ::testing::Mock::VerifyAndClearExpectations(&mainMock);
    114 
    115         if (threadMode == Threaded && deferralMode == NonDeferred) {
    116             EXPECT_CALL(copierMock, copyTexture(ccImplContext.get(), backTextureId, frontTextureId, size));
    117             EXPECT_CALL(implMock, flush());
    118         }
    119         updater.update(ccImplContext.get(), 0, &copierMock, 0, 100);
    120         ::testing::Mock::VerifyAndClearExpectations(&implMock);
     115        ::testing::Mock::VerifyAndClearExpectations(&updater);
    121116
    122117        if (threadMode == Threaded && deferralMode == NonDeferred) {
Note: See TracChangeset for help on using the changeset viewer.