Changeset 137483 in webkit


Ignore:
Timestamp:
Dec 12, 2012, 10:44:29 AM (13 years ago)
Author:
joone.hur@intel.com
Message:

[GTK][AC] The non-composited content is not painted
https://bugs.webkit.org/show_bug.cgi?id=104819

Reviewed by Gustavo Noronha Silva.

When Accelerated Compositing is enabled, only GraphicsLayers are painted.
This patch allows to paint the non-composited content on the viewport with
GraphicsLayers. Most of the codes are the same as AcceleratedCompositingContextGL.cpp

  • WebCoreSupport/AcceleratedCompositingContext.h: Add m_nonCompositedContentLayer.
  • WebCoreSupport/AcceleratedCompositingContextClutter.cpp:

(WebKit::AcceleratedCompositingContext::AcceleratedCompositingContext):
(WebKit::AcceleratedCompositingContext::initialize):
(WebKit):
(WebKit::AcceleratedCompositingContext::~AcceleratedCompositingContext):
(WebKit::AcceleratedCompositingContext::renderLayersToWindow):
(WebKit::AcceleratedCompositingContext::setRootCompositingLayer):
(WebKit::AcceleratedCompositingContext::setNonCompositedContentsNeedDisplay):
(WebKit::AcceleratedCompositingContext::resizeRootLayer):
(WebKit::AcceleratedCompositingContext::scrollNonCompositedContents): Make the non-composited
content scroll.
(WebKit::AcceleratedCompositingContext::layerFlushTimerFiredCallback):
(WebKit::AcceleratedCompositingContext::flushPendingLayerChanges):
(WebKit::AcceleratedCompositingContext::flushAndRenderLayers):
(WebKit::AcceleratedCompositingContext::notifyAnimationStarted):
(WebKit::AcceleratedCompositingContext::paintContents): Paint the non-composited content.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/gtk/ChangeLog

    r137447 r137483  
     12012-12-12  Joone Hur  <joone.hur@intel.com>
     2
     3        [GTK][AC] The non-composited content is not painted
     4        https://bugs.webkit.org/show_bug.cgi?id=104819
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        When Accelerated Compositing is enabled, only GraphicsLayers are painted.
     9        This patch allows to paint the non-composited content on the viewport with
     10        GraphicsLayers. Most of the codes are the same as AcceleratedCompositingContextGL.cpp
     11
     12        * WebCoreSupport/AcceleratedCompositingContext.h: Add m_nonCompositedContentLayer.
     13        * WebCoreSupport/AcceleratedCompositingContextClutter.cpp:
     14        (WebKit::AcceleratedCompositingContext::AcceleratedCompositingContext):
     15        (WebKit::AcceleratedCompositingContext::initialize):
     16        (WebKit):
     17        (WebKit::AcceleratedCompositingContext::~AcceleratedCompositingContext):
     18        (WebKit::AcceleratedCompositingContext::renderLayersToWindow):
     19        (WebKit::AcceleratedCompositingContext::setRootCompositingLayer):
     20        (WebKit::AcceleratedCompositingContext::setNonCompositedContentsNeedDisplay):
     21        (WebKit::AcceleratedCompositingContext::resizeRootLayer):
     22        (WebKit::AcceleratedCompositingContext::scrollNonCompositedContents): Make the non-composited
     23        content scroll.
     24        (WebKit::AcceleratedCompositingContext::layerFlushTimerFiredCallback):
     25        (WebKit::AcceleratedCompositingContext::flushPendingLayerChanges):
     26        (WebKit::AcceleratedCompositingContext::flushAndRenderLayers):
     27        (WebKit::AcceleratedCompositingContext::notifyAnimationStarted):
     28        (WebKit::AcceleratedCompositingContext::paintContents): Paint the non-composited content.
     29
    1302012-12-12  Joone Hur  <joone.hur@intel.com>
    231
  • trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h

    r137447 r137483  
    7676
    7777#if USE(CLUTTER)
    78     WebCore::GraphicsLayer* m_rootGraphicsLayer;
    7978    GtkWidget* m_rootLayerEmbedder;
     79    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
     80    OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
     81
    8082    static gboolean layerFlushTimerFiredCallback(AcceleratedCompositingContext*);
    8183#elif USE(TEXTURE_MAPPER_GL)
  • trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextClutter.cpp

    r137447 r137483  
    2626#include "FrameView.h"
    2727#include "GraphicsLayer.h"
     28#include "GraphicsLayerActor.h"
    2829#include "NotImplemented.h"
     30#include "Settings.h"
    2931#include "webkitwebviewprivate.h"
    3032#include <clutter-gtk/clutter-gtk.h>
     
    3840    : m_webView(webView)
    3941    , m_layerFlushTimerCallbackId(0)
    40     , m_rootGraphicsLayer(0)
    4142    , m_rootLayerEmbedder(0)
    4243{
     44}
     45
     46void AcceleratedCompositingContext::initialize()
     47{
     48    if (m_rootLayer)
     49        return;
     50
     51    GtkAllocation allocation;
     52    gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation);
     53    IntSize pageSize(allocation.width, allocation.height);
     54
     55    m_rootLayer = GraphicsLayer::create(0, this);
     56    m_rootLayer->setDrawsContent(false);
     57    m_rootLayer->setSize(pageSize);
     58
     59    // The non-composited contents are a child of the root layer.
     60    m_nonCompositedContentLayer = GraphicsLayer::create(0, this);
     61    m_nonCompositedContentLayer->setDrawsContent(true);
     62    m_nonCompositedContentLayer->setContentsOpaque(!m_webView->priv->transparent);
     63    m_nonCompositedContentLayer->setSize(pageSize);
     64    if (core(m_webView)->settings()->acceleratedDrawingEnabled())
     65        m_nonCompositedContentLayer->setAcceleratesDrawing(true);
     66
     67#ifndef NDEBUG
     68    m_rootLayer->setName("Root layer");
     69    m_nonCompositedContentLayer->setName("Non-composited content");
     70#endif
     71
     72    m_rootLayer->addChild(m_nonCompositedContentLayer.get());
     73    m_nonCompositedContentLayer->setNeedsDisplay();
     74
     75    scheduleLayerFlush();
    4376}
    4477
     
    5184bool AcceleratedCompositingContext::enabled()
    5285{
    53     return m_rootGraphicsLayer;
     86    return m_rootLayer;
    5487}
    5588
     
    6598        gtk_container_remove(GTK_CONTAINER(m_webView), m_rootLayerEmbedder);
    6699        m_rootLayerEmbedder = 0;
    67         m_rootGraphicsLayer = 0;
     100        m_rootLayer = nullptr;
     101        m_nonCompositedContentLayer = nullptr;
    68102        return;
    69103    }
     
    80114    }
    81115
     116    // Add the accelerated layer tree hierarchy.
     117    initialize();
     118
     119    m_nonCompositedContentLayer->removeAllChildren();
     120    m_nonCompositedContentLayer->addChild(graphicsLayer);
     121
    82122    // Add a root GraphicsLayer to the stage.
    83123    if (graphicsLayer) {
    84         m_rootGraphicsLayer = graphicsLayer;
    85124        ClutterColor stageColor = { 0xFF, 0xFF, 0xFF, 0xFF };
    86125        ClutterActor* stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(m_rootLayerEmbedder));
    87126        clutter_stage_set_color(CLUTTER_STAGE(stage), &stageColor);
    88         clutter_container_add_actor(CLUTTER_CONTAINER(stage), m_rootGraphicsLayer->platformLayer());
     127        clutter_container_add_actor(CLUTTER_CONTAINER(stage), m_rootLayer->platformLayer());
    89128        clutter_actor_show_all(stage);
    90129    }
     
    95134void AcceleratedCompositingContext::setNonCompositedContentsNeedDisplay(const IntRect& rect)
    96135{
    97     if (!m_rootGraphicsLayer)
     136    if (!m_rootLayer)
    98137        return;
    99138
    100139    if (rect.isEmpty()) {
    101         m_rootGraphicsLayer->setNeedsDisplay();
    102         return;
    103     }
    104 
    105     m_rootGraphicsLayer->setNeedsDisplayInRect(rect);
    106 }
    107 
    108 void AcceleratedCompositingContext::resizeRootLayer(const IntSize& size)
     140        m_rootLayer->setNeedsDisplay();
     141        return;
     142    }
     143
     144    m_nonCompositedContentLayer->setNeedsDisplayInRect(rect);
     145    scheduleLayerFlush();
     146}
     147
     148void AcceleratedCompositingContext::resizeRootLayer(const IntSize& newSize)
    109149{
    110150    if (!m_rootLayerEmbedder)
     151        return;
     152
     153    if (m_rootLayer->size() == newSize)
    111154        return;
    112155
     
    114157    allocation.x = 0;
    115158    allocation.y = 0;
    116     allocation.width = size.width();
    117     allocation.height = size.height();
     159    allocation.width = newSize.width();
     160    allocation.height = newSize.height();
    118161    gtk_widget_size_allocate(GTK_WIDGET(m_rootLayerEmbedder), &allocation);
    119162
     163    m_rootLayer->setSize(newSize);
     164
     165    // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
     166    // for those newly exposed areas.
     167    FloatSize oldSize = m_nonCompositedContentLayer->size();
     168    m_nonCompositedContentLayer->setSize(newSize);
     169
     170    if (newSize.width() > oldSize.width()) {
     171        float height = std::min(static_cast<float>(newSize.height()), oldSize.height());
     172        m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height));
     173    }
     174
     175    if (newSize.height() > oldSize.height())
     176        m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
     177
     178    m_nonCompositedContentLayer->setNeedsDisplayInRect(IntRect(IntPoint(), newSize));
    120179    scheduleLayerFlush();
    121180}
     
    123182void AcceleratedCompositingContext::scrollNonCompositedContents(const IntRect& scrollRect, const IntSize& scrollOffset)
    124183{
    125     notImplemented();
     184    m_nonCompositedContentLayer->setNeedsDisplayInRect(scrollRect);
     185    scheduleLayerFlush();
    126186}
    127187
     
    144204bool AcceleratedCompositingContext::flushPendingLayerChanges()
    145205{
    146     if (m_rootGraphicsLayer)
    147         m_rootGraphicsLayer->flushCompositingStateForThisLayerOnly();
     206    if (m_rootLayer) {
     207        m_rootLayer->flushCompositingStateForThisLayerOnly();
     208        m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly();
     209    }
    148210
    149211    return core(m_webView)->mainFrame()->view()->flushCompositingStateIncludingSubframes();
     
    153215{
    154216    m_layerFlushTimerCallbackId = 0;
    155     flushPendingLayerChanges();
    156     if (!m_rootGraphicsLayer)
    157         return;
    158 
    159     renderLayersToWindow(0, IntRect());
     217
     218    if (!enabled())
     219        return;
     220
     221    Frame* frame = core(m_webView)->mainFrame();
     222    if (!frame || !frame->contentRenderer() || !frame->view())
     223        return;
     224
     225    if (!flushPendingLayerChanges())
     226        return;
    160227}
    161228
     
    169236}
    170237
    171 void AcceleratedCompositingContext::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&)
    172 {
    173     ASSERT_NOT_REACHED();
     238void AcceleratedCompositingContext::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& rectToPaint)
     239{
     240    context.save();
     241    context.clip(rectToPaint);
     242    core(m_webView)->mainFrame()->view()->paint(&context, rectToPaint);
     243    context.restore();
    174244}
    175245
Note: See TracChangeset for help on using the changeset viewer.