Changeset 109638 in webkit


Ignore:
Timestamp:
Mar 2, 2012 5:22:24 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Accelerated compositing: Checkerboard never goes away
https://bugs.webkit.org/show_bug.cgi?id=79020
RIM PR #134164

Patch by Arvid Nilsson <anilsson@rim.com> on 2012-03-02
Reviewed by Adam Treat.

Checkerboard appears in accelerated compositing layers when there's no
texture for (part of) a layer. The layer renderer queues up some render
jobs and schedules a commit to make the WebKit thread process those
jobs. Render jobs performed during commit cause texture upload jobs to
be scheduled on the UI thread. Texture uploads are performed when next
drawing the layers.

Unfortunately, sometimes commit operation happens without a subsequent
call draw the layers.

In order to implement one-shot drawing sync, I added a call to
commitRootLayerIfNeeded() in BackingStore::renderContents(), and
I was lucky that most of the time, renderContents() is followed by
blit(Visible)Contents() which in turn draws the layers.
However, render is not always followed by a blit, for example when
rendering offscreen tiles in BackingStore::renderOnIdle(), and in
direct rendering mode.

Fixed by making sure that every call to commitRootLayerIfNeeded() that
returns true is followed by a call to drawLayersOnCommit(), unless a
blit was requested already.

Also tweak the logic for one-shot drawing sync to make the code in
drawLayersOnCommit() reusable outside of rootLayerCommitTimerFired().

  • Api/BackingStore.cpp:

(BlackBerry::WebKit::BackingStorePrivate::BackingStorePrivate):
(BlackBerry::WebKit::BackingStorePrivate::renderOnTimer):
(BlackBerry::WebKit::BackingStorePrivate::renderOnIdle):
(BlackBerry::WebKit::BackingStorePrivate::willFireTimer):
(BlackBerry::WebKit::BackingStorePrivate::renderDirectToWindow):
(BlackBerry::WebKit::BackingStorePrivate::render):
(BlackBerry::WebKit::BackingStorePrivate::blitVisibleContents):
(BlackBerry::WebKit::BackingStorePrivate::blitContents):
(BlackBerry::WebKit::BackingStorePrivate::renderContents):
(WebKit):
(BlackBerry::WebKit::BackingStorePrivate::drawLayersOnCommitIfNeeded):

  • Api/BackingStore_p.h:

(BackingStorePrivate):
(BlackBerry::WebKit::BackingStorePrivate::willDrawLayersOnCommit):

Location:
trunk/Source/WebKit/blackberry
Files:
3 edited

Legend:

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

    r109592 r109638  
    202202    , m_preferredTileMatrixDimension(Vertical)
    203203    , m_blitGeneration(-1)
     204#if USE(ACCELERATED_COMPOSITING)
     205    , m_needsDrawLayersOnCommit(false)
     206#endif
    204207{
    205208    m_frontState = reinterpret_cast<unsigned>(new BackingStoreGeometry);
     
    465468        m_renderQueue->render(!m_suspendRegularRenderJobs);
    466469
    467     if (!shouldPerformRegularRenderJobs() || !m_renderQueue->hasCurrentRegularRenderJob())
    468         return;
    469 
    470     m_renderQueue->renderAllCurrentRegularRenderJobs();
     470    if (shouldPerformRegularRenderJobs() && m_renderQueue->hasCurrentRegularRenderJob())
     471        m_renderQueue->renderAllCurrentRegularRenderJobs();
     472
     473#if USE(ACCELERATED_COMPOSITING)
     474    drawLayersOnCommitIfNeeded();
     475#endif
    471476}
    472477
     
    484489
    485490    m_renderQueue->render(!m_suspendRegularRenderJobs);
     491
     492#if USE(ACCELERATED_COMPOSITING)
     493    drawLayersOnCommitIfNeeded();
     494#endif
    486495}
    487496
     
    512521    if (m_renderQueue->hasCurrentRegularRenderJob())
    513522        m_renderQueue->renderAllCurrentRegularRenderJobs();
     523
     524#if USE(ACCELERATED_COMPOSITING)
     525    drawLayersOnCommitIfNeeded();
     526#endif
    514527
    515528    // Let the caller yield and reschedule the timer.
     
    942955    windowBackBufferState()->addBlittedRegion(screenRect);
    943956
    944 #if USE(ACCELERATED_COMPOSITING) && ENABLE_COMPOSITING_SURFACE
     957#if USE(ACCELERATED_COMPOSITING)
     958    drawLayersOnCommitIfNeeded();
     959#if ENABLE_COMPOSITING_SURFACE
    945960    if (m_webPage->d->m_client->window()->windowUsage() != BlackBerry::Platform::Graphics::Window::GLES2Usage) {
    946961        Platform::IntRect clippedRect = intersection(dirtyRect, visibleContentsRect());
    947962        blendCompositingSurface(clippedRect);
    948963    }
     964#endif
    949965#endif
    950966
     
    980996
    981997    Platform::IntRect dirtyContentsRect;
    982     const Platform::IntRect contentsRect = Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedContentsSize());
    983     const Platform::IntRect viewportRect = Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedViewportSize());
    984998
    985999    for (size_t i = 0; i < tileRectList.size(); ++i) {
     
    11071121
    11081122    if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
     1123#if USE(ACCELERATED_COMPOSITING)
     1124        // The blit will call drawSubLayers if necessary
     1125        m_needsDrawLayersOnCommit = false;
     1126#endif
     1127
    11091128        BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage(
    11101129            BlackBerry::Platform::createMethodCallMessage(
     
    11971216
    11981217    if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
     1218#if USE(ACCELERATED_COMPOSITING)
     1219        // The blit will call drawSubLayers if necessary
     1220        m_needsDrawLayersOnCommit = false;
     1221#endif
     1222
    11991223        BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage(
    12001224            BlackBerry::Platform::createMethodCallMessage(
     
    21322156
    21332157#if USE(ACCELERATED_COMPOSITING)
    2134     m_webPage->d->commitRootLayerIfNeeded();
     2158    // When committing the pending accelerated compositing layer changes, it's
     2159    // necessary to draw the new layer appearance. This is normally done as
     2160    // part of a blit, but if no blit happens because of this rendering, for
     2161    // example because we're rendering an offscreen rectangle, someone needs to
     2162    // catch this flag and make sure those layers get drawn.
     2163    // This is just a complicated way to do
     2164    // "if (commitRootLayerIfNeeded()) drawLayersOnCommit();"
     2165    if (m_webPage->d->commitRootLayerIfNeeded())
     2166        m_needsDrawLayersOnCommit = true;
    21352167#endif
    21362168
     
    24842516    return m_webPage->d->drawSubLayers(dst, contentsRect);
    24852517}
     2518
     2519bool BackingStorePrivate::drawLayersOnCommitIfNeeded()
     2520{
     2521    // Check if rendering caused a commit and we need to redraw the layers
     2522    if (!m_needsDrawLayersOnCommit)
     2523        return false;
     2524
     2525    m_needsDrawLayersOnCommit = false;
     2526    m_webPage->d->drawLayersOnCommit();
     2527
     2528    return true;
     2529}
    24862530#endif
    24872531
  • trunk/Source/WebKit/blackberry/Api/BackingStore_p.h

    r107737 r109638  
    197197    void clearCompositingSurface();
    198198    bool drawSubLayers();
     199    bool drawLayersOnCommitIfNeeded();
     200    // WebPage will call this when drawing layers to tell us we don't need to
     201    void willDrawLayersOnCommit() { m_needsDrawLayersOnCommit = false; }
    199202#endif
    200203
     
    348351    pthread_cond_t m_blitGenerationCond;
    349352    struct timespec m_currentBlitEnd;
     353
     354#if USE(ACCELERATED_COMPOSITING)
     355    mutable bool m_needsDrawLayersOnCommit; // Not thread safe, WebKit thread only
     356#endif
    350357};
    351358} // namespace WebKit
  • trunk/Source/WebKit/blackberry/ChangeLog

    r109592 r109638  
     12012-03-02  Arvid Nilsson  <anilsson@rim.com>
     2
     3        Accelerated compositing: Checkerboard never goes away
     4        https://bugs.webkit.org/show_bug.cgi?id=79020
     5        RIM PR #134164
     6
     7        Reviewed by Adam Treat.
     8
     9        Checkerboard appears in accelerated compositing layers when there's no
     10        texture for (part of) a layer. The layer renderer queues up some render
     11        jobs and schedules a commit to make the WebKit thread process those
     12        jobs. Render jobs performed during commit cause texture upload jobs to
     13        be scheduled on the UI thread. Texture uploads are performed when next
     14        drawing the layers.
     15
     16        Unfortunately, sometimes commit operation happens without a subsequent
     17        call draw the layers.
     18
     19        In order to implement one-shot drawing sync, I added a call to
     20        commitRootLayerIfNeeded() in BackingStore::renderContents(), and
     21        I was lucky that most of the time, renderContents() is followed by
     22        blit(Visible)Contents() which in turn draws the layers.
     23        However, render is not always followed by a blit, for example when
     24        rendering offscreen tiles in BackingStore::renderOnIdle(), and in
     25        direct rendering mode.
     26
     27        Fixed by making sure that every call to commitRootLayerIfNeeded() that
     28        returns true is followed by a call to drawLayersOnCommit(), unless a
     29        blit was requested already.
     30
     31        Also tweak the logic for one-shot drawing sync to make the code in
     32        drawLayersOnCommit() reusable outside of rootLayerCommitTimerFired().
     33
     34        * Api/BackingStore.cpp:
     35        (BlackBerry::WebKit::BackingStorePrivate::BackingStorePrivate):
     36        (BlackBerry::WebKit::BackingStorePrivate::renderOnTimer):
     37        (BlackBerry::WebKit::BackingStorePrivate::renderOnIdle):
     38        (BlackBerry::WebKit::BackingStorePrivate::willFireTimer):
     39        (BlackBerry::WebKit::BackingStorePrivate::renderDirectToWindow):
     40        (BlackBerry::WebKit::BackingStorePrivate::render):
     41        (BlackBerry::WebKit::BackingStorePrivate::blitVisibleContents):
     42        (BlackBerry::WebKit::BackingStorePrivate::blitContents):
     43        (BlackBerry::WebKit::BackingStorePrivate::renderContents):
     44        (WebKit):
     45        (BlackBerry::WebKit::BackingStorePrivate::drawLayersOnCommitIfNeeded):
     46        * Api/BackingStore_p.h:
     47        (BackingStorePrivate):
     48        (BlackBerry::WebKit::BackingStorePrivate::willDrawLayersOnCommit):
     49
    1502012-03-02  Adam Treat  <atreat@rim.com>
    251
Note: See TracChangeset for help on using the changeset viewer.