Changeset 137326 in webkit


Ignore:
Timestamp:
Dec 11, 2012 9:34:15 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Update GraphicsLayerClutter
https://bugs.webkit.org/show_bug.cgi?id=92045

Patch by Joone Hur <joone.hur@intel.com>, Gustavo Noronha Silva <gustavo.noronha@collabora.com> on 2012-12-11
Reviewed by Gustavo Noronha Silva.

Add more methods to GraphicsLayerClutter in order to run CSS 3D transforms
by using GraphicsLayerActor.

No new tests. This will be covered by pixel tests for Qt and GTK+ accelerated
compositing and 3D transforms.

  • platform/graphics/clutter/GraphicsLayerClutter.cpp:

(WebCore):
(WebCore::GraphicsLayerClutter::GraphicsLayerClutter):
(WebCore::idleDestroy):
(WebCore::GraphicsLayerClutter::~GraphicsLayerClutter):
(WebCore::GraphicsLayerClutter::setName):
(WebCore::GraphicsLayerClutter::platformLayer): Returns the platform layer(ClutterAcotr).
(WebCore::GraphicsLayerClutter::setNeedsDisplay): Update the display.
(WebCore::GraphicsLayerClutter::setNeedsDisplayInRect): Update part of the Display.
(WebCore::GraphicsLayerClutter::setAnchorPoint):
(WebCore::GraphicsLayerClutter::setPosition):
(WebCore::GraphicsLayerClutter::setSize):
(WebCore::GraphicsLayerClutter::setTransform):
(WebCore::GraphicsLayerClutter::setDrawsContent):
(WebCore::GraphicsLayerClutter::setParent):
(WebCore::GraphicsLayerClutter::setChildren):
(WebCore::GraphicsLayerClutter::addChild):
(WebCore::GraphicsLayerClutter::addChildAtIndex):
(WebCore::GraphicsLayerClutter::addChildBelow):
(WebCore::GraphicsLayerClutter::addChildAbove):
(WebCore::GraphicsLayerClutter::replaceChild):
(WebCore::GraphicsLayerClutter::removeFromParent):
(WebCore::GraphicsLayerClutter::platformClutterLayerPaintContents):
(WebCore::GraphicsLayerClutter::platformClutterLayerAnimationStarted):
(WebCore::GraphicsLayerClutter::repaintLayerDirtyRects):
(WebCore::GraphicsLayerClutter::computePositionRelativeToBase):
(WebCore::GraphicsLayerClutter::flushCompositingState): Synchronize the corresponding Actors with the current
compositing states of this GraphicsLayer and its child layers.
(WebCore::GraphicsLayerClutter::recursiveCommitChanges):
(WebCore::GraphicsLayerClutter::flushCompositingStateForThisLayerOnly): Commit batched changes non-recursively.
(WebCore::GraphicsLayerClutter::commitLayerChangesAfterSublayers): Reset layer changes after we recurse on children.
(WebCore::GraphicsLayerClutter::noteSublayersChanged):
(WebCore::GraphicsLayerClutter::noteLayerPropertyChanged):
(WebCore::GraphicsLayerClutter::commitLayerChangesBeforeSublayers): Commit layer changes before we recurse on children.
(WebCore::GraphicsLayerClutter::updateGeometry): Updated the position and size of the Actor.
(WebCore::GraphicsLayerClutter::updateSublayerList): Updated the list of child Actors.
(WebCore::GraphicsLayerClutter::updateLayerNames):
(WebCore::GraphicsLayerClutter::updateTransform):
(WebCore::GraphicsLayerClutter::updateLayerDrawsContent):
(WebCore::GraphicsLayerClutter::layerForSuperlayer):

  • platform/graphics/clutter/GraphicsLayerClutter.h:

(WebCore):
(WebCore::GraphicsLayerClutter::primaryLayer):
(GraphicsLayerClutter):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r137324 r137326  
     12012-12-11  Joone Hur  <joone.hur@intel.com>, Gustavo Noronha Silva  <gustavo.noronha@collabora.com>
     2
     3        [GTK] Update GraphicsLayerClutter
     4        https://bugs.webkit.org/show_bug.cgi?id=92045
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Add more methods to GraphicsLayerClutter in order to run CSS 3D transforms
     9        by using GraphicsLayerActor.
     10
     11        No new tests. This will be covered by pixel tests for Qt and GTK+ accelerated
     12        compositing and 3D transforms.
     13
     14        * platform/graphics/clutter/GraphicsLayerClutter.cpp:
     15        (WebCore):
     16        (WebCore::GraphicsLayerClutter::GraphicsLayerClutter):
     17        (WebCore::idleDestroy):
     18        (WebCore::GraphicsLayerClutter::~GraphicsLayerClutter):
     19        (WebCore::GraphicsLayerClutter::setName):
     20        (WebCore::GraphicsLayerClutter::platformLayer): Returns the platform layer(ClutterAcotr).
     21        (WebCore::GraphicsLayerClutter::setNeedsDisplay): Update the display.
     22        (WebCore::GraphicsLayerClutter::setNeedsDisplayInRect): Update part of the Display.
     23        (WebCore::GraphicsLayerClutter::setAnchorPoint):
     24        (WebCore::GraphicsLayerClutter::setPosition):
     25        (WebCore::GraphicsLayerClutter::setSize):
     26        (WebCore::GraphicsLayerClutter::setTransform):
     27        (WebCore::GraphicsLayerClutter::setDrawsContent):
     28        (WebCore::GraphicsLayerClutter::setParent):
     29        (WebCore::GraphicsLayerClutter::setChildren):
     30        (WebCore::GraphicsLayerClutter::addChild):
     31        (WebCore::GraphicsLayerClutter::addChildAtIndex):
     32        (WebCore::GraphicsLayerClutter::addChildBelow):
     33        (WebCore::GraphicsLayerClutter::addChildAbove):
     34        (WebCore::GraphicsLayerClutter::replaceChild):
     35        (WebCore::GraphicsLayerClutter::removeFromParent):
     36        (WebCore::GraphicsLayerClutter::platformClutterLayerPaintContents):
     37        (WebCore::GraphicsLayerClutter::platformClutterLayerAnimationStarted):
     38        (WebCore::GraphicsLayerClutter::repaintLayerDirtyRects):
     39        (WebCore::GraphicsLayerClutter::computePositionRelativeToBase):
     40        (WebCore::GraphicsLayerClutter::flushCompositingState): Synchronize the corresponding Actors with the current
     41        compositing states of this GraphicsLayer and its child layers.
     42        (WebCore::GraphicsLayerClutter::recursiveCommitChanges):
     43        (WebCore::GraphicsLayerClutter::flushCompositingStateForThisLayerOnly): Commit batched changes non-recursively.
     44        (WebCore::GraphicsLayerClutter::commitLayerChangesAfterSublayers): Reset layer changes after we recurse on children.
     45        (WebCore::GraphicsLayerClutter::noteSublayersChanged):
     46        (WebCore::GraphicsLayerClutter::noteLayerPropertyChanged):
     47        (WebCore::GraphicsLayerClutter::commitLayerChangesBeforeSublayers): Commit layer changes before we recurse on children.
     48        (WebCore::GraphicsLayerClutter::updateGeometry): Updated the position and size of the Actor.
     49        (WebCore::GraphicsLayerClutter::updateSublayerList): Updated the list of child Actors.
     50        (WebCore::GraphicsLayerClutter::updateLayerNames):
     51        (WebCore::GraphicsLayerClutter::updateTransform):
     52        (WebCore::GraphicsLayerClutter::updateLayerDrawsContent):
     53        (WebCore::GraphicsLayerClutter::layerForSuperlayer):
     54        * platform/graphics/clutter/GraphicsLayerClutter.h:
     55        (WebCore):
     56        (WebCore::GraphicsLayerClutter::primaryLayer):
     57        (GraphicsLayerClutter):
     58
    1592012-12-11  Jessie Berlin  <jberlin@apple.com>
    260
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp

    r137097 r137326  
    11/*
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
    3  * Copyright (C) 2011 Collabora Ltd.
     3 * Copyright (C) 2011, 2012 Collabora Ltd.
     4 * Copyright (C) 2012 Intel Corporation. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    3132
    3233#include "FloatRect.h"
     34#include "GraphicsLayerActor.h"
    3335#include "GraphicsLayerFactory.h"
    3436#include "NotImplemented.h"
     37#include "RefPtrCairo.h"
     38#include "TransformState.h"
     39#include <wtf/text/CString.h>
     40#include <wtf/text/WTFString.h>
    3541
    3642namespace WebCore {
    3743
     44// This is the hook for WebCore compositor to know that the webKit clutter port implements
     45// compositing with GraphicsLayerClutter.
    3846PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
    3947{
     
    5159GraphicsLayerClutter::GraphicsLayerClutter(GraphicsLayerClient* client)
    5260    : GraphicsLayer(client)
     61    , m_uncommittedChanges(0)
    5362{
    5463    // ClutterRectangle will be used to show the debug border.
    55     m_layer = adoptGRef(clutter_rectangle_new());
     64    m_layer = graphicsLayerActorNewWithClient(LayerTypeWebLayer, this);
     65}
     66
     67static gboolean idleDestroy(gpointer data)
     68{
     69    GRefPtr<ClutterActor> actor = adoptGRef(CLUTTER_ACTOR(data));
     70    ClutterActor* parent = clutter_actor_get_parent(actor.get());
     71
     72    // We should remove child actors manually because the container of Clutter
     73    // seems to have a bug to remove its child actors when it is removed.
     74    if (GRAPHICS_LAYER_IS_ACTOR(GRAPHICS_LAYER_ACTOR(actor.get())))
     75        graphicsLayerActorRemoveAll(GRAPHICS_LAYER_ACTOR(actor.get()));
     76
     77    if (parent)
     78        clutter_container_remove_actor(CLUTTER_CONTAINER(parent), actor.get());
     79
     80    // FIXME: we should assert that the actor's ref count is 1 here, but some
     81    // of them are getting here with 2!
     82    // ASSERT((G_OBJECT(actor.get()))->ref_count == 1);
     83
     84    return FALSE;
    5685}
    5786
    5887GraphicsLayerClutter::~GraphicsLayerClutter()
    5988{
    60     willBeDestroyed();
     89    if (graphicsLayerActorGetLayerType(m_layer.get()) == GraphicsLayerClutter::LayerTypeRootLayer)
     90        return;
     91
     92    // We destroy the actors on an idle so that the main loop can run enough to
     93    // repaint the background that will replace the actor.
     94    if (m_layer) {
     95        graphicsLayerActorSetClient(m_layer.get(), 0);
     96        g_idle_add(idleDestroy, m_layer.leakRef());
     97    }
     98}
     99
     100void GraphicsLayerClutter::setName(const String& name)
     101{
     102    String longName = String::format("Actor(%p) GraphicsLayer(%p) ", m_layer.get(), this) + name;
     103    GraphicsLayer::setName(longName);
     104    noteLayerPropertyChanged(NameChanged);
    61105}
    62106
    63107ClutterActor* GraphicsLayerClutter::platformLayer() const
    64108{
     109    return CLUTTER_ACTOR(m_layer.get());
     110}
     111
     112void GraphicsLayerClutter::setNeedsDisplay()
     113{
     114    FloatRect hugeRect(FloatPoint(), m_size);
     115    setNeedsDisplayInRect(hugeRect);
     116}
     117
     118void GraphicsLayerClutter::setNeedsDisplayInRect(const FloatRect& r)
     119{
     120    if (!drawsContent())
     121        return;
     122
     123    FloatRect rect(r);
     124    FloatRect layerBounds(FloatPoint(), m_size);
     125    rect.intersect(layerBounds);
     126    if (rect.isEmpty())
     127        return;
     128
     129    const size_t maxDirtyRects = 32;
     130
     131    for (size_t i = 0; i < m_dirtyRects.size(); ++i) {
     132        if (m_dirtyRects[i].contains(rect))
     133            return;
     134    }
     135
     136    if (m_dirtyRects.size() < maxDirtyRects)
     137        m_dirtyRects.append(rect);
     138    else
     139        m_dirtyRects[0].unite(rect);
     140
     141    noteLayerPropertyChanged(DirtyRectsChanged);
     142}
     143
     144void GraphicsLayerClutter::setAnchorPoint(const FloatPoint3D& point)
     145{
     146    if (point == m_anchorPoint)
     147        return;
     148
     149    GraphicsLayer::setAnchorPoint(point);
     150    noteLayerPropertyChanged(GeometryChanged);
     151}
     152
     153void GraphicsLayerClutter::setPosition(const FloatPoint& point)
     154{
     155    if (point == m_position)
     156        return;
     157
     158    GraphicsLayer::setPosition(point);
     159    noteLayerPropertyChanged(GeometryChanged);
     160}
     161
     162void GraphicsLayerClutter::setSize(const FloatSize& size)
     163{
     164    if (size == m_size)
     165        return;
     166
     167    GraphicsLayer::setSize(size);
     168    noteLayerPropertyChanged(GeometryChanged);
     169}
     170void GraphicsLayerClutter::setTransform(const TransformationMatrix& t)
     171{
     172    if (t == m_transform)
     173        return;
     174
     175    GraphicsLayer::setTransform(t);
     176    noteLayerPropertyChanged(TransformChanged);
     177}
     178
     179void GraphicsLayerClutter::setDrawsContent(bool drawsContent)
     180{
     181    if (drawsContent == m_drawsContent)
     182        return;
     183
     184    GraphicsLayer::setDrawsContent(drawsContent);
     185    noteLayerPropertyChanged(DrawsContentChanged);
     186}
     187
     188void GraphicsLayerClutter::setParent(GraphicsLayer* childLayer)
     189{
     190    notImplemented();
     191
     192    GraphicsLayer::setParent(childLayer);
     193}
     194
     195bool GraphicsLayerClutter::setChildren(const Vector<GraphicsLayer*>& children)
     196{
     197    bool childrenChanged = GraphicsLayer::setChildren(children);
     198    if (childrenChanged)
     199        noteSublayersChanged();
     200
     201    return childrenChanged;
     202}
     203
     204void GraphicsLayerClutter::addChild(GraphicsLayer* childLayer)
     205{
     206    GraphicsLayer::addChild(childLayer);
     207    noteSublayersChanged();
     208}
     209
     210void GraphicsLayerClutter::addChildAtIndex(GraphicsLayer* childLayer, int index)
     211{
     212    GraphicsLayer::addChildAtIndex(childLayer, index);
     213    noteSublayersChanged();
     214}
     215
     216void GraphicsLayerClutter::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
     217{
     218    GraphicsLayer::addChildBelow(childLayer, sibling);
     219    noteSublayersChanged();
     220}
     221
     222void GraphicsLayerClutter::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer* sibling)
     223{
     224    GraphicsLayer::addChildAbove(childLayer, sibling);
     225    noteSublayersChanged();
     226}
     227
     228bool GraphicsLayerClutter::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
     229{
     230    if (GraphicsLayer::replaceChild(oldChild, newChild)) {
     231        noteSublayersChanged();
     232        return true;
     233    }
     234    return false;
     235}
     236
     237void GraphicsLayerClutter::removeFromParent()
     238{
     239    if (m_parent)
     240        static_cast<GraphicsLayerClutter*>(m_parent)->noteSublayersChanged();
     241    GraphicsLayer::removeFromParent();
     242}
     243
     244void GraphicsLayerClutter::platformClutterLayerPaintContents(GraphicsContext& context, const IntRect& clip)
     245{
     246    paintGraphicsLayerContents(context, clip);
     247}
     248
     249void GraphicsLayerClutter::platformClutterLayerAnimationStarted(double startTime)
     250{
     251    if (m_client)
     252        m_client->notifyAnimationStarted(this, startTime);
     253}
     254
     255void GraphicsLayerClutter::repaintLayerDirtyRects()
     256{
     257    if (!m_dirtyRects.size())
     258        return;
     259
     260    for (size_t i = 0; i < m_dirtyRects.size(); ++i)
     261        graphicsLayerActorInvalidateRectangle(m_layer.get(), m_dirtyRects[i]);
     262
     263    m_dirtyRects.clear();
     264}
     265
     266FloatPoint GraphicsLayerClutter::computePositionRelativeToBase(float& pageScale) const
     267{
     268    pageScale = 1;
     269
     270    FloatPoint offset;
     271    for (const GraphicsLayer* currLayer = this; currLayer; currLayer = currLayer->parent()) {
     272        if (currLayer->appliesPageScale()) {
     273            if (currLayer->client())
     274                pageScale = currLayer->pageScaleFactor();
     275            return offset;
     276        }
     277
     278        offset += currLayer->position();
     279    }
     280
     281    return FloatPoint();
     282}
     283
     284// called from void RenderLayerCompositor::flushPendingLayerChanges
     285void GraphicsLayerClutter::flushCompositingState(const FloatRect& clipRect)
     286{
     287    TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(clipRect));
     288    recursiveCommitChanges(state);
     289}
     290
     291void GraphicsLayerClutter::recursiveCommitChanges(const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)
     292{
     293    // FIXME: Save the state before sending down to kids and restore it after
     294    TransformState localState = state;
     295
     296    if (appliesPageScale()) {
     297        pageScaleFactor = this->pageScaleFactor();
     298        affectedByPageScale = true;
     299    }
     300
     301    // Accumulate an offset from the ancestral pixel-aligned layer.
     302    FloatPoint baseRelativePosition = positionRelativeToBase;
     303    if (affectedByPageScale)
     304        baseRelativePosition += m_position;
     305
     306    commitLayerChangesBeforeSublayers(pageScaleFactor, baseRelativePosition);
     307
     308    const Vector<GraphicsLayer*>& childLayers = children();
     309    size_t numChildren = childLayers.size();
     310
     311    for (size_t i = 0; i < numChildren; ++i) {
     312        GraphicsLayerClutter* curChild = static_cast<GraphicsLayerClutter*>(childLayers[i]);
     313        curChild->recursiveCommitChanges(localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
     314    }
     315
     316    commitLayerChangesAfterSublayers();
     317}
     318
     319void GraphicsLayerClutter::flushCompositingStateForThisLayerOnly()
     320{
     321    float pageScaleFactor;
     322    FloatPoint offset = computePositionRelativeToBase(pageScaleFactor);
     323    commitLayerChangesBeforeSublayers(pageScaleFactor, offset);
     324    commitLayerChangesAfterSublayers();
     325}
     326
     327void GraphicsLayerClutter::commitLayerChangesAfterSublayers()
     328{
     329    if (!m_uncommittedChanges)
     330        return;
     331
     332    m_uncommittedChanges = NoChange;
     333}
     334void GraphicsLayerClutter::noteSublayersChanged()
     335{
     336    noteLayerPropertyChanged(ChildrenChanged);
     337}
     338
     339void GraphicsLayerClutter::noteLayerPropertyChanged(LayerChangeFlags flags)
     340{
     341    if (!m_uncommittedChanges && m_client)
     342        m_client->notifyFlushRequired(this); // call RenderLayerBacking::notifyFlushRequired
     343
     344    m_uncommittedChanges |= flags;
     345}
     346
     347void GraphicsLayerClutter::commitLayerChangesBeforeSublayers(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
     348{
     349    if (!m_uncommittedChanges)
     350        return;
     351
     352    if (m_uncommittedChanges & NameChanged)
     353        updateLayerNames();
     354
     355    if (m_uncommittedChanges & ChildrenChanged)
     356        updateSublayerList();
     357
     358    if (m_uncommittedChanges & GeometryChanged)
     359        updateGeometry(pageScaleFactor, positionRelativeToBase);
     360
     361    if (m_uncommittedChanges & TransformChanged)
     362        updateTransform();
     363
     364    if (m_uncommittedChanges & DrawsContentChanged)
     365        updateLayerDrawsContent(pageScaleFactor, positionRelativeToBase);
     366
     367    if (m_uncommittedChanges & DirtyRectsChanged)
     368        repaintLayerDirtyRects();
     369}
     370
     371void GraphicsLayerClutter::updateGeometry(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
     372{
     373    FloatPoint scaledPosition;
     374    FloatPoint3D scaledAnchorPoint;
     375    FloatSize scaledSize;
     376
     377    // FIXME: Need to support scaling
     378    scaledPosition = m_position;
     379    scaledAnchorPoint = m_anchorPoint;
     380    scaledSize = m_size;
     381
     382    FloatRect adjustedBounds(m_boundsOrigin , scaledSize);
     383    FloatPoint adjustedPosition(scaledPosition.x() + scaledAnchorPoint.x() * scaledSize.width(), scaledPosition.y() + scaledAnchorPoint.y() * scaledSize.height());
     384
     385    clutter_actor_set_size(CLUTTER_ACTOR(m_layer.get()), adjustedBounds.width(), adjustedBounds.height());
     386    clutter_actor_set_position(CLUTTER_ACTOR(m_layer.get()), adjustedPosition.x(), adjustedPosition.y());
     387    graphicsLayerActorSetAnchorPoint(m_layer.get(), scaledAnchorPoint.x(), scaledAnchorPoint.y(), scaledAnchorPoint.z());
     388}
     389
     390// Each GraphicsLayer has the corresponding layer in the platform port.
     391// So whenever the list of child layer changes, the list of GraphicsLayerActor should be updated accordingly.
     392void GraphicsLayerClutter::updateSublayerList()
     393{
     394    GraphicsLayerActorList newSublayers;
     395    const Vector<GraphicsLayer*>& childLayers = children();
     396
     397    if (childLayers.size() > 0) {
     398        size_t numChildren = childLayers.size();
     399        for (size_t i = 0; i < numChildren; ++i) {
     400            GraphicsLayerClutter* curChild = static_cast<GraphicsLayerClutter*>(childLayers[i]);
     401            GraphicsLayerActor* childLayer = curChild->layerForSuperlayer();
     402            g_assert(GRAPHICS_LAYER_IS_ACTOR(childLayer));
     403            newSublayers.append(childLayer);
     404        }
     405
     406        for (size_t i = 0; i < newSublayers.size(); i++) {
     407            ClutterActor* layerActor = CLUTTER_ACTOR(newSublayers[i].get());
     408            ClutterActor* parentActor = clutter_actor_get_parent(layerActor);
     409            if (parentActor)
     410                clutter_container_remove_actor(CLUTTER_CONTAINER(parentActor), layerActor);
     411        }
     412    }
     413
     414    graphicsLayerActorSetSublayers(m_layer.get(), newSublayers);
     415}
     416
     417void GraphicsLayerClutter::updateLayerNames()
     418{
     419    clutter_actor_set_name(CLUTTER_ACTOR(m_layer.get()), name().utf8().data());
     420}
     421
     422void GraphicsLayerClutter::updateTransform()
     423{
     424    CoglMatrix matrix = m_transform;
     425    graphicsLayerActorSetTransform(primaryLayer(), &matrix);
     426}
     427
     428void GraphicsLayerClutter::updateLayerDrawsContent(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
     429{
     430    if (m_drawsContent) {
     431        graphicsLayerActorSetDrawsContent(m_layer.get(), TRUE);
     432        setNeedsDisplay();
     433    } else {
     434        graphicsLayerActorSetDrawsContent(m_layer.get(), FALSE);
     435        graphicsLayerActorSetSurface(m_layer.get(), 0);
     436    }
     437
     438    updateDebugIndicators();
     439}
     440
     441GraphicsLayerActor* GraphicsLayerClutter::layerForSuperlayer() const
     442{
    65443    return m_layer.get();
    66444}
    67 
    68 void GraphicsLayerClutter::setNeedsDisplay()
    69 {
    70     notImplemented();
    71     addRepaintRect(FloatRect(FloatPoint(), m_size));
    72 }
    73 
    74 void GraphicsLayerClutter::setNeedsDisplayInRect(const FloatRect& rect)
    75 {
    76     notImplemented();
    77     addRepaintRect(rect);
    78 }
    79 
    80445} // namespace WebCore
    81446
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h

    r129387 r137326  
    11/*
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
    3  * Copyright (C) 2011 Collabora Ltd.
     3 * Copyright (C) 2011, 2012 Collabora Ltd.
     4 * Copyright (C) 2012 Intel Corporation. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    3132
    3233#include "GraphicsLayer.h"
     34#include "GraphicsLayerClient.h"
     35#include "Image.h"
     36#include "ImageSource.h"
     37#include "PlatformClutterLayerClient.h"
     38#include <wtf/HashMap.h>
     39#include <wtf/HashSet.h>
     40#include <wtf/text/StringHash.h>
    3341
    3442#include <clutter/clutter.h>
    3543#include <wtf/gobject/GRefPtr.h>
    3644
     45typedef struct _GraphicsLayerActor GraphicsLayerActor;
     46
    3747namespace WebCore {
    3848
    39 class GraphicsLayerClutter : public GraphicsLayer {
     49class TransformState;
     50
     51typedef Vector<GRefPtr<GraphicsLayerActor> > GraphicsLayerActorList;
     52
     53class GraphicsLayerClutter : public GraphicsLayer, public PlatformClutterLayerClient {
    4054public:
     55    enum LayerType { LayerTypeLayer, LayerTypeWebLayer, LayerTypeVideoLayer, LayerTypeTransformLayer, LayerTypeRootLayer, LayerTypeCustom };
     56
    4157    GraphicsLayerClutter(GraphicsLayerClient*);
    4258    virtual ~GraphicsLayerClutter();
    4359
    4460    virtual ClutterActor* platformLayer() const;
     61    virtual void addChild(GraphicsLayer*);
     62    virtual void addChildAtIndex(GraphicsLayer*, int index);
     63    virtual void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling);
     64    virtual void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling);
     65    virtual void removeFromParent();
     66    virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
     67    virtual bool setChildren(const Vector<GraphicsLayer*>&);
     68    virtual void setParent(GraphicsLayer*);
     69
     70    virtual void setDrawsContent(bool);
     71    virtual void setAnchorPoint(const FloatPoint3D&);
     72    virtual void setPosition(const FloatPoint&);
     73    virtual void setSize(const FloatSize&);
     74
     75    virtual void setTransform(const TransformationMatrix&);
     76    virtual void setName(const String&);
    4577    virtual void setNeedsDisplay();
    4678    virtual void setNeedsDisplayInRect(const FloatRect&);
    4779
     80    virtual void flushCompositingState(const FloatRect&);
     81    virtual void flushCompositingStateForThisLayerOnly();
     82
     83    void recursiveCommitChanges(const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
     84
    4885private:
    49     GRefPtr<ClutterActor> m_layer;
     86    FloatPoint computePositionRelativeToBase(float& pageScale) const;
     87    void commitLayerChangesBeforeSublayers(float pageScaleFactor, const FloatPoint& positionRelativeToBase);
     88    void commitLayerChangesAfterSublayers();
     89
     90    virtual void platformClutterLayerAnimationStarted(double beginTime);
     91    virtual void platformClutterLayerPaintContents(GraphicsContext&, const IntRect& clip);
     92
     93    GraphicsLayerActor* primaryLayer() const { return m_layer.get(); }
     94    GraphicsLayerActor* layerForSuperlayer() const;
     95    enum LayerChange {
     96        NoChange = 0,
     97        NameChanged = 1 << 1,
     98        ChildrenChanged = 1 << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
     99        GeometryChanged = 1 << 3,
     100        TransformChanged = 1 << 4,
     101        ChildrenTransformChanged = 1 << 5,
     102        Preserves3DChanged = 1 << 6,
     103        MasksToBoundsChanged = 1 << 7,
     104        DrawsContentChanged = 1 << 8, // need this?
     105        BackgroundColorChanged = 1 << 9,
     106        ContentsOpaqueChanged = 1 << 10,
     107        BackfaceVisibilityChanged = 1 << 11,
     108        OpacityChanged = 1 << 12,
     109        AnimationChanged = 1 << 13,
     110        DirtyRectsChanged = 1 << 14,
     111        ContentsImageChanged = 1 << 15,
     112        ContentsMediaLayerChanged = 1 << 16,
     113        ContentsCanvasLayerChanged = 1 << 17,
     114        ContentsRectChanged = 1 << 18,
     115        MaskLayerChanged = 1 << 19,
     116        ReplicatedLayerChanged = 1 << 20,
     117        ContentsNeedsDisplay = 1 << 21,
     118        AcceleratesDrawingChanged = 1 << 22,
     119        ContentsScaleChanged = 1 << 23
     120    };
     121
     122    typedef unsigned LayerChangeFlags;
     123    void noteLayerPropertyChanged(LayerChangeFlags);
     124    void noteSublayersChanged();
     125
     126    void updateBackfaceVisibility();
     127    void updateLayerNames();
     128    void updateSublayerList();
     129    void updateGeometry(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
     130    void updateTransform();
     131    void updateLayerDrawsContent(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
     132
     133    void repaintLayerDirtyRects();
     134
     135    GRefPtr<GraphicsLayerActor> m_layer;
     136
     137    Vector<FloatRect> m_dirtyRects;
     138    LayerChangeFlags m_uncommittedChanges;
    50139};
    51140
Note: See TracChangeset for help on using the changeset viewer.