Changeset 111959 in webkit


Ignore:
Timestamp:
Mar 23, 2012 6:12:23 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Add WebPageCompositor class to BlackBerry WebKit API
https://bugs.webkit.org/show_bug.cgi?id=81121
RIM PR: 136687

Patch by Arvid Nilsson <anilsson@rim.com> on 2012-03-23
Reviewed by Rob Buis.

The idea is for the API client to use a WebPageCompositor object to
render the WebPage when there's no screen window available.

The WebPageCompositorPrivate becomes reference counted in order to be
kept alive either because it's used for accelerated compositing layers
or used for the WebPageCompositor API. It can still work standalone.

Clean up some code - no need to keep track of a separate boolean
WebPagePrivate::m_isAcceleratedCompositingActive when the state of
m_compositor can tell you.

Also remove duplicated code from WebPagePrivate - go directly to the
compositor object instead, if you need to draw the AC layers.

Reviewed internally by Robin Cao and the hasBlitJobs/blitOnIdle change
by Filip Spacek.

  • Api/BackingStore.cpp:

(BlackBerry::WebKit::BackingStore::hasBlitJobs):
(BlackBerry::WebKit::BackingStore::blitOnIdle):
(BlackBerry::WebKit::BackingStorePrivate::blitContents):
(BlackBerry::WebKit::BackingStorePrivate::drawSubLayers):
(BlackBerry::WebKit::BackingStorePrivate::drawAndBlendLayersForDirectRendering):
(BlackBerry::WebKit::BackingStorePrivate::surfaceSize):
(BlackBerry::WebKit::BackingStorePrivate::buffer):

  • Api/WebPage.cpp:

(BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
(BlackBerry::WebKit::WebPagePrivate::drawLayersOnCommit):
(BlackBerry::WebKit::WebPagePrivate::setCompositor):
(BlackBerry::WebKit::WebPagePrivate::setRootLayerCompositingThread):
(BlackBerry::WebKit::WebPagePrivate::createCompositor):
(BlackBerry::WebKit::WebPagePrivate::destroyCompositor):

  • Api/WebPage.h:
  • Api/WebPageCompositor.cpp:

(BlackBerry::WebKit::WebPageCompositorPrivate::WebPageCompositorPrivate):
(BlackBerry::WebKit::WebPageCompositorPrivate::setContext):
(BlackBerry::WebKit::WebPageCompositorPrivate::hardwareCompositing):
(BlackBerry::WebKit::WebPageCompositorPrivate::setRootLayer):
(BlackBerry::WebKit::WebPageCompositorPrivate::render):
(BlackBerry::WebKit::WebPageCompositorPrivate::drawLayers):
(BlackBerry::WebKit::WebPageCompositorPrivate::animationTimerFired):
(BlackBerry::WebKit::WebPageCompositorPrivate::compositorDestroyed):
(BlackBerry::WebKit::WebPageCompositor::WebPageCompositor):
(BlackBerry::WebKit::WebPageCompositor::~WebPageCompositor):
(BlackBerry::WebKit::WebPageCompositor::client):
(BlackBerry::WebKit::WebPageCompositor::prepareFrame):
(BlackBerry::WebKit::WebPageCompositor::render):
(BlackBerry::WebKit::WebPageCompositor::cleanup):
(BlackBerry::WebKit::WebPageCompositor::contextLost):

  • Api/WebPageCompositor.h: Added.
  • Api/WebPageCompositorClient.h: Added.
  • Api/WebPageCompositor_p.h:

(BlackBerry::WebKit::WebPageCompositorPrivate::create):
(BlackBerry::WebKit::WebPageCompositorPrivate::context):
(BlackBerry::WebKit::WebPageCompositorPrivate::animationFrameTimestamp):
(BlackBerry::WebKit::WebPageCompositorPrivate::page):
(BlackBerry::WebKit::WebPageCompositorPrivate::client):

  • Api/WebPage_p.h:

(BlackBerry::WebKit::WebPagePrivate::client):
(BlackBerry::WebKit::WebPagePrivate::isAcceleratedCompositingActive):
(BlackBerry::WebKit::WebPagePrivate::compositor):

Location:
trunk/Source/WebKit/blackberry
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/BackingStore.cpp

    r111398 r111959  
    3333#include "WebPage.h"
    3434#include "WebPageClient.h"
     35#include "WebPageCompositorClient.h"
     36#include "WebPageCompositor_p.h"
    3537#include "WebPage_p.h"
    3638#include "WebSettings.h"
     
    12411243
    12421244    if (m_defersBlit && !force) {
     1245#if USE(ACCELERATED_COMPOSITING)
     1246        // If there's a WebPageCompositorClient, let it schedule the blit.
     1247        if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor()) {
     1248            if (WebPageCompositorClient* client = compositor->client()) {
     1249                client->invalidate(compositor->animationFrameTimestamp());
     1250                return;
     1251            }
     1252        }
     1253#endif
     1254
    12431255        m_hasBlitJobs = true;
    12441256        return;
     
    14461458        WebCore::FloatRect contentsRect = m_webPage->d->mapFromTransformedFloatRect(
    14471459            WebCore::FloatRect(WebCore::IntRect(contents)));
    1448         m_webPage->d->drawSubLayers(dstRect, contentsRect);
     1460        if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor())
     1461            compositor->drawLayers(dstRect, contentsRect);
    14491462    } else if (compositingSurface)
    14501463        blendCompositingSurface(dstRect);
     
    25202533        return false;
    25212534
     2535    if (!m_webPage->d->compositor())
     2536        return false;
     2537
    25222538    Platform::IntRect dst = m_webPage->client()->userInterfaceBlittedDestinationRect();
    25232539    if (dst.isEmpty())
     
    25272543    WebCore::FloatRect contentsRect = m_webPage->d->mapFromTransformedFloatRect(
    25282544        WebCore::FloatRect(WebCore::IntRect(src)));
    2529     return m_webPage->d->drawSubLayers(dst, contentsRect);
     2545    return m_webPage->d->compositor()->drawLayers(dst, contentsRect);
    25302546}
    25312547
     
    25582574    // Check if rendering caused a commit and we need to redraw the layers.
    25592575    m_needsDrawLayersOnCommit = false;
    2560     m_webPage->d->drawSubLayers(dstRect, untransformedContentsRect);
     2576    if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor())
     2577        compositor->drawLayers(dstRect, untransformedContentsRect);
    25612578
    25622579#if ENABLE_COMPOSITING_SURFACE
     
    26812698bool BackingStore::hasBlitJobs() const
    26822699{
     2700#if USE(ACCELERATED_COMPOSITING)
     2701    // If there's a WebPageCompositorClient, let it schedule the blit.
     2702    WebPageCompositorPrivate* compositor = d->m_webPage->d->compositor();
     2703    if (compositor && compositor->client())
     2704        return false;
     2705#endif
     2706
    26832707    // Normally, this would be called from the compositing thread,
    26842708    // and the flag is set on the compositing thread, so no need for
     
    26892713void BackingStore::blitOnIdle()
    26902714{
     2715#if USE(ACCELERATED_COMPOSITING)
     2716    // If there's a WebPageCompositorClient, let it schedule the blit.
     2717    WebPageCompositorPrivate* compositor = d->m_webPage->d->compositor();
     2718    if (compositor && compositor->client())
     2719        return;
     2720#endif
     2721
    26912722    d->blitVisibleContents(true /*force*/);
    26922723}
     
    26972728        return window->surfaceSize();
    26982729
     2730#if USE(ACCELERATED_COMPOSITING)
     2731    if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor())
     2732        return compositor->context()->surfaceSize();
     2733#endif
     2734
    26992735    return Platform::IntSize();
    27002736}
     
    27052741        return window->buffer();
    27062742
     2743#if USE(ACCELERATED_COMPOSITING)
     2744    if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor())
     2745        return compositor->context()->buffer();
     2746#endif
     2747
    27072748    return 0;
    27082749}
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r111811 r111959  
    329329    , m_inRegionScrollStartingNode(0)
    330330#if USE(ACCELERATED_COMPOSITING)
    331     , m_isAcceleratedCompositingActive(false)
    332331    , m_rootLayerCommitTimer(adoptPtr(new Timer<WebPagePrivate>(this, &WebPagePrivate::rootLayerCommitTimerFired)))
    333332    , m_needsOneShotDrawingSynchronization(false)
     
    51955194    }
    51965195
    5197     if (!drawSubLayers())
     5196    if (!m_backingStore->d->drawSubLayers())
    51985197        return;
    51995198
     
    52125211
    52135212    m_backingStore->d->blitVisibleContents();
    5214 }
    5215 
    5216 bool WebPagePrivate::drawSubLayers(const IntRect& dstRect, const FloatRect& contents)
    5217 {
    5218     ASSERT(Platform::userInterfaceThreadMessageClient()->isCurrentThread());
    5219     if (!Platform::userInterfaceThreadMessageClient()->isCurrentThread())
    5220         return false;
    5221 
    5222     if (m_compositor) {
    5223         m_compositor->setBackingStoreUsesOpenGL(m_backingStore->d->isOpenGLCompositing());
    5224         return m_compositor->drawLayers(dstRect, contents);
    5225     }
    5226 
    5227     return false;
    5228 }
    5229 
    5230 bool WebPagePrivate::drawSubLayers()
    5231 {
    5232     ASSERT(Platform::userInterfaceThreadMessageClient()->isCurrentThread());
    5233     if (!Platform::userInterfaceThreadMessageClient()->isCurrentThread())
    5234         return false;
    5235 
    5236     return m_backingStore->d->drawSubLayers();
    52375213}
    52385214
     
    52715247}
    52725248
     5249void WebPagePrivate::setCompositor(PassRefPtr<WebPageCompositorPrivate> compositor)
     5250{
     5251    using namespace BlackBerry::Platform;
     5252
     5253    // The m_compositor member has to be modified during a sync call for thread
     5254    // safe access to m_compositor and its refcount.
     5255    if (!userInterfaceThreadMessageClient()->isCurrentThread()) {
     5256        userInterfaceThreadMessageClient()->dispatchSyncMessage(createMethodCallMessage(&WebPagePrivate::setCompositor, this, compositor));
     5257        return;
     5258    }
     5259
     5260    m_compositor = compositor;
     5261
     5262    // The previous compositor, if any, has now released it's OpenGL resources,
     5263    // so we can safely free the owned context, if any.
     5264    m_ownedContext.clear();
     5265}
     5266
    52735267void WebPagePrivate::commitRootLayer(const IntRect& layoutRectForCompositing,
    52745268                                     const IntSize& contentsSizeForCompositing)
     
    53685362    if (commitRootLayerIfNeeded())
    53695363        drawLayersOnCommit();
    5370 }
    5371 
    5372 void WebPagePrivate::setIsAcceleratedCompositingActive(bool active)
    5373 {
    5374     // Backing store can be null here because it happens during teardown.
    5375     if (m_isAcceleratedCompositingActive == active || !m_backingStore)
    5376         return;
    5377 
    5378     m_isAcceleratedCompositingActive = active;
    5379 
    5380     if (!active) {
    5381         m_compositor.clear();
    5382         resetCompositingSurface();
    5383         return;
    5384     }
    5385 
    5386     if (!m_compositor) {
    5387         m_compositor = adoptPtr(new WebPageCompositorPrivate(this));
    5388         m_isAcceleratedCompositingActive = m_compositor->hardwareCompositing();
    5389         if (!m_isAcceleratedCompositingActive)
    5390             m_compositor.clear();
    5391     }
    53925364}
    53935365
     
    54505422         // called syncDestroyCompositorOnCompositingThread() to destroy
    54515423         // the compositor.
    5452          setIsAcceleratedCompositingActive(false);
     5424         destroyCompositor();
     5425         resetCompositingSurface();
    54535426         return;
    54545427    }
    54555428
    54565429    if (!m_compositor)
    5457         setIsAcceleratedCompositingActive(true);
     5430        createCompositor();
    54585431
    54595432    // Don't ASSERT(m_compositor) here because setIsAcceleratedCompositingActive(true)
     
    54635436}
    54645437
     5438bool WebPagePrivate::createCompositor()
     5439{
     5440    m_ownedContext = GLES2Context::create(this);
     5441    m_compositor = WebPageCompositorPrivate::create(this, 0);
     5442    m_compositor->setContext(m_ownedContext.get());
     5443
     5444    if (!m_compositor->hardwareCompositing()) {
     5445        destroyCompositor();
     5446        return false;
     5447    }
     5448
     5449    return true;
     5450}
     5451
    54655452void WebPagePrivate::destroyCompositor()
    54665453{
    5467      m_compositor.clear();
     5454    // We shouldn't release the compositor unless we created and own the
     5455    // context. If the compositor was created from the WebPageCompositor API,
     5456    // keep it around and reuse it later.
     5457    if (!m_ownedContext)
     5458        return;
     5459
     5460    m_compositor.clear();
     5461    m_ownedContext.clear();
    54685462}
    54695463
  • trunk/Source/WebKit/blackberry/Api/WebPage.h

    r111811 r111959  
    6363class RenderQueue;
    6464class WebPageClient;
     65class WebPageCompositor;
    6566class WebPageGroupLoadDeferrer;
    6667class WebPagePrivate;
     
    336337    friend class WebKit::BackingStorePrivate;
    337338    friend class WebKit::RenderQueue;
     339    friend class WebKit::WebPageCompositor;
    338340    friend class WebKit::WebPageGroupLoadDeferrer;
    339341    friend class WebKit::WebPagePrivate;
  • trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp

    r111180 r111959  
    1919#include "config.h"
    2020
     21#include "WebPageCompositor.h"
     22
    2123#if USE(ACCELERATED_COMPOSITING)
     24#include "WebPageCompositorClient.h"
    2225#include "WebPageCompositor_p.h"
    2326
     
    2629#include "WebPage_p.h"
    2730
     31#include <BlackBerryPlatformDebugMacros.h>
    2832#include <BlackBerryPlatformExecutableMessage.h>
    2933#include <BlackBerryPlatformMessage.h>
     
    3741namespace WebKit {
    3842
    39 WebPageCompositorPrivate::WebPageCompositorPrivate(WebPagePrivate* page)
    40     : m_webPage(page)
    41     , m_context(GLES2Context::create(page))
    42     , m_layerRenderer(LayerRenderer::create(m_context.get()))
    43     , m_backingStoreUsesOpenGL(false)
     43WebPageCompositorPrivate::WebPageCompositorPrivate(WebPagePrivate* page, WebPageCompositorClient* client)
     44    : m_client(client)
     45    , m_webPage(page)
    4446    , m_animationTimer(this, &WebPageCompositorPrivate::animationTimerFired)
    4547    , m_timerClient(new Platform::GenericTimerClient(Platform::userInterfaceThreadTimerClient()))
     48    , m_pendingAnimationFrame(0.0)
    4649{
    4750    m_animationTimer.setClient(m_timerClient);
     
    5457}
    5558
     59void WebPageCompositorPrivate::setContext(Platform::Graphics::GLES2Context* context)
     60{
     61    if (m_context == context)
     62        return;
     63
     64    m_context = context;
     65    if (!m_context) {
     66        m_layerRenderer.clear();
     67        return;
     68    }
     69
     70    m_layerRenderer = LayerRenderer::create(m_context);
     71}
     72
    5673bool WebPageCompositorPrivate::hardwareCompositing() const
    5774{
    58     return m_layerRenderer->hardwareCompositing();
     75    return m_layerRenderer && m_layerRenderer->hardwareCompositing();
    5976}
    6077
     
    6279{
    6380    m_rootLayer = rootLayer;
    64     m_layerRenderer->setRootLayer(m_rootLayer.get());
    65 }
    66 
    67 void WebPageCompositorPrivate::setBackingStoreUsesOpenGL(bool backingStoreUsesOpenGL)
    68 {
    69     m_backingStoreUsesOpenGL = backingStoreUsesOpenGL;
    70     m_layerRenderer->setClearSurfaceOnDrawLayers(!backingStoreUsesOpenGL);
     81
     82    ASSERT(m_layerRenderer);
     83    if (m_layerRenderer)
     84        m_layerRenderer->setRootLayer(m_rootLayer.get());
    7185}
    7286
     
    7993}
    8094
     95void WebPageCompositorPrivate::render(const IntRect& dstRect, const IntRect& transformedContents)
     96{
     97    // It's not safe to call into the BackingStore if the compositor hasn't been set yet.
     98    // For thread safety, we have to do it using a round-trip to the WebKit thread, so the
     99    // embedder might call this before the round-trip to WebPagePrivate::setCompositor() is
     100    // done.
     101    if (m_webPage->compositor() != this)
     102        return;
     103
     104    // The BackingStore is the root layer
     105    if (BackingStore* backingStore = m_webPage->m_backingStore)
     106        backingStore->d->blitContents(dstRect, transformedContents, true);
     107    else {
     108        FloatRect contents = m_webPage->mapFromTransformedFloatRect(FloatRect(transformedContents));
     109        drawLayers(dstRect, contents);
     110    }
     111}
     112
    81113bool WebPageCompositorPrivate::drawLayers(const IntRect& dstRect, const FloatRect& contents)
    82114{
     115    if (!m_layerRenderer)
     116        return false;
     117
     118    m_pendingAnimationFrame = 0.0;
     119
     120    bool shouldClear = false;
     121    if (BackingStore* backingStore = m_webPage->m_backingStore)
     122        shouldClear = !backingStore->d->isOpenGLCompositing();
     123    m_layerRenderer->setClearSurfaceOnDrawLayers(shouldClear);
     124
    83125    m_layerRenderer->drawLayers(contents, m_layoutRectForCompositing, m_contentsSizeForCompositing, dstRect);
    84126    m_lastCompositingResults = m_layerRenderer->lastRenderingResults();
     
    86128    if (m_lastCompositingResults.needsAnimationFrame) {
    87129        // Using a timeout of 0 actually won't start a timer, it will send a message.
    88         m_animationTimer.start(1.0 / 60.0);
    89         m_webPage->updateDelegatedOverlays();
     130        if (m_client)
     131            m_pendingAnimationFrame = m_client->requestAnimationFrame();
     132        else {
     133            m_animationTimer.start(1.0 / 60.0);
     134            m_webPage->updateDelegatedOverlays();
     135        }
    90136    }
    91137
     
    100146void WebPageCompositorPrivate::animationTimerFired()
    101147{
    102     if (m_webPage->m_backingStore->d->shouldDirectRenderingToWindow()) {
    103         if (m_webPage->m_backingStore->d->isDirectRenderingAnimationMessageScheduled())
     148    BackingStore* backingStore = m_webPage->m_backingStore;
     149    if (!backingStore) {
     150        drawLayers(m_webPage->client()->userInterfaceBlittedDestinationRect(),
     151                   IntRect(m_webPage->client()->userInterfaceBlittedVisibleContentsRect()));
     152        return;
     153    }
     154
     155    if (backingStore->d->shouldDirectRenderingToWindow()) {
     156        if (backingStore->d->isDirectRenderingAnimationMessageScheduled())
    104157            return; // don't send new messages as long as we haven't rerendered
    105158
    106         m_webPage->m_backingStore->d->setDirectRenderingAnimationMessageScheduled();
    107         BlackBerry::Platform::webKitThreadMessageClient()->dispatchMessage(
    108             BlackBerry::Platform::createMethodCallMessage(
    109                 &BackingStorePrivate::renderVisibleContents, m_webPage->m_backingStore->d));
     159        using namespace BlackBerry::Platform;
     160
     161        backingStore->d->setDirectRenderingAnimationMessageScheduled();
     162        webKitThreadMessageClient()->dispatchMessage(createMethodCallMessage(&BackingStorePrivate::renderVisibleContents, backingStore->d));
    110163        return;
    111164    }
    112165    m_webPage->blitVisibleContents();
     166}
     167
     168void WebPageCompositorPrivate::compositorDestroyed()
     169{
     170    if (m_client)
     171        m_client->compositorDestroyed();
     172
     173    m_client = 0;
     174}
     175
     176WebPageCompositor::WebPageCompositor(WebPage* page, WebPageCompositorClient* client)
     177{
     178    using namespace BlackBerry::Platform;
     179
     180    RefPtr<WebPageCompositorPrivate> tmp = WebPageCompositorPrivate::create(page->d, client);
     181
     182    // Keep one ref ourselves...
     183    d = tmp.get();
     184    d->ref();
     185
     186    // ...And pass one ref to the web page.
     187    // This ensures that the compositor will be around for as long as it's
     188    // needed. Unfortunately RefPtr<T> is not public, so we have declare to
     189    // resort to manual refcounting.
     190    webKitThreadMessageClient()->dispatchMessage(createMethodCallMessage(&WebPagePrivate::setCompositor, d->page(), tmp));
     191}
     192
     193WebPageCompositor::~WebPageCompositor()
     194{
     195    using namespace BlackBerry::Platform;
     196
     197    webKitThreadMessageClient()->dispatchMessage(createMethodCallMessage(&WebPagePrivate::setCompositor, d->page(), PassRefPtr<WebPageCompositorPrivate>(0)));
     198    d->compositorDestroyed();
     199    d->deref();
     200}
     201
     202WebPageCompositorClient* WebPageCompositor::client() const
     203{
     204    return 0;
     205}
     206
     207void WebPageCompositor::prepareFrame(Platform::Graphics::GLES2Context* context, double timestamp)
     208{
     209    d->setContext(context);
     210}
     211
     212void WebPageCompositor::render(Platform::Graphics::GLES2Context* context, const Platform::IntRect& dstRect, const Platform::IntRect& contents)
     213{
     214    d->setContext(context);
     215    d->render(dstRect, contents);
     216}
     217
     218void WebPageCompositor::cleanup(Platform::Graphics::GLES2Context* context)
     219{
     220    d->setContext(0);
     221}
     222
     223void WebPageCompositor::contextLost()
     224{
     225    // This method needs to delete the compositor in a way that not tries to
     226    // use any OpenGL calls (the context is gone, so we can't and don't need to
     227    // free any OpenGL resources.
     228    notImplemented();
    113229}
    114230
     
    116232} // namespace BlackBerry
    117233
     234#else // USE(ACCELERATED_COMPOSITING)
     235
     236namespace BlackBerry {
     237namespace WebKit {
     238
     239WebPageCompositor::WebPageCompositor(WebPage*, WebPageCompositorClient*)
     240    : d(0)
     241{
     242}
     243
     244WebPageCompositor::~WebPageCompositor()
     245{
     246}
     247
     248WebPageCompositorClient* WebPageCompositor::client() const
     249{
     250    return 0;
     251}
     252
     253void WebPageCompositor::prepareFrame(Platform::Graphics::GLES2Context*, double)
     254{
     255}
     256
     257void WebPageCompositor::render(Platform::Graphics::GLES2Context*, const Platform::IntRect&, const Platform::IntRect&)
     258{
     259}
     260
     261void WebPageCompositor::cleanup(Platform::Graphics::GLES2Context*)
     262{
     263}
     264
     265void WebPageCompositor::contextLost()
     266{
     267}
     268
     269} // namespace WebKit
     270} // namespace BlackBerry
     271
    118272#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h

    r111180 r111959  
    2222#if USE(ACCELERATED_COMPOSITING)
    2323
    24 #include "GLES2Context.h"
    2524#include "LayerCompositingThread.h"
    2625#include "LayerRenderer.h"
    2726
     27#include <BlackBerryPlatformGLES2Context.h>
    2828#include <BlackBerryPlatformTimer.h>
    2929#include <wtf/OwnPtr.h>
     30#include <wtf/RefCounted.h>
    3031#include <wtf/RefPtr.h>
    3132
     
    3738namespace WebKit {
    3839
     40class WebPageCompositorClient;
    3941class WebPagePrivate;
    4042
    41 // This class may only be used on the compositing thread.
    42 class WebPageCompositorPrivate {
     43// This class may only be used on the compositing thread. So it does not need to be threadsaferefcounted.
     44class WebPageCompositorPrivate : public RefCounted<WebPageCompositorPrivate> {
    4345public:
    44     WebPageCompositorPrivate(WebPagePrivate*);
     46    static PassRefPtr<WebPageCompositorPrivate> create(WebPagePrivate* page, WebPageCompositorClient* client)
     47    {
     48        return adoptRef(new WebPageCompositorPrivate(page, client));
     49    }
     50
    4551    ~WebPageCompositorPrivate();
    4652
    4753    bool hardwareCompositing() const;
    4854
     55    Platform::Graphics::GLES2Context* context() const { return m_context; }
     56    void setContext(Platform::Graphics::GLES2Context*);
     57
    4958    void setRootLayer(WebCore::LayerCompositingThread*);
    50 
    51     void setBackingStoreUsesOpenGL(bool);
    5259
    5360    void commit(WebCore::LayerWebKitThread* rootLayerProxy);
    5461
     62    // This is mapped from the public API, thus takes transformed contents
     63    void render(const WebCore::IntRect& dstRect, const WebCore::IntRect& transformedContents);
     64
     65    // Render everything but the root layer
    5566    bool drawLayers(const WebCore::IntRect& dstRect, const WebCore::FloatRect& contents);
    5667
     
    6475    void setLastCompositingResults(const WebCore::LayerRenderingResults& results) { m_lastCompositingResults = results; }
    6576
     77    double animationFrameTimestamp() const { return m_pendingAnimationFrame; }
     78
    6679    void releaseLayerResources();
     80
     81    WebPagePrivate* page() const { return m_webPage; }
     82    WebPageCompositorClient* client() const { return m_client; }
     83    void compositorDestroyed();
     84
     85protected:
     86    WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
    6787
    6888private:
    6989    void animationTimerFired();
    7090
     91    WebPageCompositorClient* m_client;
    7192    WebPagePrivate* m_webPage;
    72     // Please maintain this order since m_layerRenderer depends on m_context in initialization list.
    73     OwnPtr<GLES2Context> m_context;
     93    Platform::Graphics::GLES2Context* m_context;
    7494    OwnPtr<WebCore::LayerRenderer> m_layerRenderer;
    7595    RefPtr<WebCore::LayerCompositingThread> m_rootLayer;
     
    7797    WebCore::IntSize m_contentsSizeForCompositing;
    7898    WebCore::LayerRenderingResults m_lastCompositingResults;
    79     bool m_backingStoreUsesOpenGL;
    8099    BlackBerry::Platform::Timer<WebPageCompositorPrivate> m_animationTimer;
    81100    BlackBerry::Platform::TimerClient* m_timerClient;
     101    double m_pendingAnimationFrame;
    82102};
    83103
  • trunk/Source/WebKit/blackberry/Api/WebPage_p.h

    r111810 r111959  
    2222#include "ChromeClient.h"
    2323#if USE(ACCELERATED_COMPOSITING)
     24#include "GLES2Context.h"
    2425#include "LayerRenderer.h"
    2526#endif
     
    8283
    8384    static WebCore::Page* core(const WebPage*);
     85
     86    WebPageClient* client() const { return m_client; }
    8487
    8588    void init(const WebString& pageGroupName);
     
    369372    void resetCompositingSurface();
    370373    void drawLayersOnCommit(); // Including backing store blit.
    371     bool drawSubLayers(const WebCore::IntRect& dstRect, const WebCore::FloatRect& contents);
    372     bool drawSubLayers(); // Draw them at last known position.
    373374
    374375    // Compositing thread.
    375376    void setRootLayerCompositingThread(WebCore::LayerCompositingThread*);
    376377    void commitRootLayer(const WebCore::IntRect&, const WebCore::IntSize&);
    377     void setIsAcceleratedCompositingActive(bool);
    378     bool isAcceleratedCompositingActive() const { return m_isAcceleratedCompositingActive; }
     378    bool isAcceleratedCompositingActive() const { return m_compositor; }
     379    WebPageCompositorPrivate* compositor() const { return m_compositor.get(); }
     380    void setCompositor(PassRefPtr<WebPageCompositorPrivate>);
     381    bool createCompositor();
    379382    void destroyCompositor();
    380383    void syncDestroyCompositorOnCompositingThread();
     
    503506    bool m_isAcceleratedCompositingActive;
    504507    OwnPtr<FrameLayers> m_frameLayers; // WebKit thread only.
    505     OwnPtr<WebPageCompositorPrivate> m_compositor; // Compositing thread only.
     508
     509    // Compositing thread only, used only when the WebKit layer created the context.
     510    // If the API client created the context, this will be null.
     511    OwnPtr<GLES2Context> m_ownedContext;
     512
     513    RefPtr<WebPageCompositorPrivate> m_compositor; // Compositing thread only.
    506514    OwnPtr<WebCore::Timer<WebPagePrivate> > m_rootLayerCommitTimer;
    507515    bool m_needsOneShotDrawingSynchronization;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r111814 r111959  
     12012-03-23  Arvid Nilsson  <anilsson@rim.com>
     2
     3        [BlackBerry] Add WebPageCompositor class to BlackBerry WebKit API
     4        https://bugs.webkit.org/show_bug.cgi?id=81121
     5        RIM PR: 136687
     6
     7        Reviewed by Rob Buis.
     8
     9        The idea is for the API client to use a WebPageCompositor object to
     10        render the WebPage when there's no screen window available.
     11
     12        The WebPageCompositorPrivate becomes reference counted in order to be
     13        kept alive either because it's used for accelerated compositing layers
     14        or used for the WebPageCompositor API. It can still work standalone.
     15
     16        Clean up some code - no need to keep track of a separate boolean
     17        WebPagePrivate::m_isAcceleratedCompositingActive when the state of
     18        m_compositor can tell you.
     19
     20        Also remove duplicated code from WebPagePrivate - go directly to the
     21        compositor object instead, if you need to draw the AC layers.
     22
     23        Reviewed internally by Robin Cao and the hasBlitJobs/blitOnIdle change
     24        by Filip Spacek.
     25
     26        * Api/BackingStore.cpp:
     27        (BlackBerry::WebKit::BackingStore::hasBlitJobs):
     28        (BlackBerry::WebKit::BackingStore::blitOnIdle):
     29        (BlackBerry::WebKit::BackingStorePrivate::blitContents):
     30        (BlackBerry::WebKit::BackingStorePrivate::drawSubLayers):
     31        (BlackBerry::WebKit::BackingStorePrivate::drawAndBlendLayersForDirectRendering):
     32        (BlackBerry::WebKit::BackingStorePrivate::surfaceSize):
     33        (BlackBerry::WebKit::BackingStorePrivate::buffer):
     34        * Api/WebPage.cpp:
     35        (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
     36        (BlackBerry::WebKit::WebPagePrivate::drawLayersOnCommit):
     37        (BlackBerry::WebKit::WebPagePrivate::setCompositor):
     38        (BlackBerry::WebKit::WebPagePrivate::setRootLayerCompositingThread):
     39        (BlackBerry::WebKit::WebPagePrivate::createCompositor):
     40        (BlackBerry::WebKit::WebPagePrivate::destroyCompositor):
     41        * Api/WebPage.h:
     42        * Api/WebPageCompositor.cpp:
     43        (BlackBerry::WebKit::WebPageCompositorPrivate::WebPageCompositorPrivate):
     44        (BlackBerry::WebKit::WebPageCompositorPrivate::setContext):
     45        (BlackBerry::WebKit::WebPageCompositorPrivate::hardwareCompositing):
     46        (BlackBerry::WebKit::WebPageCompositorPrivate::setRootLayer):
     47        (BlackBerry::WebKit::WebPageCompositorPrivate::render):
     48        (BlackBerry::WebKit::WebPageCompositorPrivate::drawLayers):
     49        (BlackBerry::WebKit::WebPageCompositorPrivate::animationTimerFired):
     50        (BlackBerry::WebKit::WebPageCompositorPrivate::compositorDestroyed):
     51        (BlackBerry::WebKit::WebPageCompositor::WebPageCompositor):
     52        (BlackBerry::WebKit::WebPageCompositor::~WebPageCompositor):
     53        (BlackBerry::WebKit::WebPageCompositor::client):
     54        (BlackBerry::WebKit::WebPageCompositor::prepareFrame):
     55        (BlackBerry::WebKit::WebPageCompositor::render):
     56        (BlackBerry::WebKit::WebPageCompositor::cleanup):
     57        (BlackBerry::WebKit::WebPageCompositor::contextLost):
     58        * Api/WebPageCompositor.h: Added.
     59        * Api/WebPageCompositorClient.h: Added.
     60        * Api/WebPageCompositor_p.h:
     61        (BlackBerry::WebKit::WebPageCompositorPrivate::create):
     62        (BlackBerry::WebKit::WebPageCompositorPrivate::context):
     63        (BlackBerry::WebKit::WebPageCompositorPrivate::animationFrameTimestamp):
     64        (BlackBerry::WebKit::WebPageCompositorPrivate::page):
     65        (BlackBerry::WebKit::WebPageCompositorPrivate::client):
     66        * Api/WebPage_p.h:
     67        (BlackBerry::WebKit::WebPagePrivate::client):
     68        (BlackBerry::WebKit::WebPagePrivate::isAcceleratedCompositingActive):
     69        (BlackBerry::WebKit::WebPagePrivate::compositor):
     70
    1712012-03-22  Charles Wei  <charles.wei@torchmobile.com.cn>
    272
Note: See TracChangeset for help on using the changeset viewer.