Changeset 148069 in webkit


Ignore:
Timestamp:
Apr 9, 2013 5:17:04 PM (11 years ago)
Author:
joone.hur@intel.com
Message:

[GTK][AC] Adding contentsLayer for image and video
https://bugs.webkit.org/show_bug.cgi?id=113912

Reviewed by Gustavo Noronha Silva.

contentsLayer is a ClutterActor, which is added to the main layer
as a child when GraphicsLayer needs to render an image or video.

No new tests, already covered by existing AC tests.

  • platform/graphics/clutter/GraphicsLayerActor.cpp:

(graphicsLayerActorUpdateTexture):

  • platform/graphics/clutter/GraphicsLayerClutter.cpp:

(WebCore::GraphicsLayerClutter::GraphicsLayerClutter):
(WebCore::GraphicsLayerClutter::~GraphicsLayerClutter):
(WebCore):
(WebCore::GraphicsLayerClutter::setContentsToImage): Pass a Cairo surface to GraphicsLayer.
(WebCore::GraphicsLayerClutter::setContentsNeedsDisplay):
(WebCore::GraphicsLayerClutter::setContentsRect):
(WebCore::GraphicsLayerClutter::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerClutter::setupContentsLayer):
(WebCore::GraphicsLayerClutter::updateContentsImage): Set the Cairo surface for contentsLayer
to upload it as a texture.
(WebCore::GraphicsLayerClutter::updateContentsNeedsDisplay):
(WebCore::GraphicsLayerClutter::updateContentsRect):
(WebCore::GraphicsLayerClutter::updateSublayerList):

  • platform/graphics/clutter/GraphicsLayerClutter.h:

(WebCore::GraphicsLayerClutter::hasContentsLayer):
(GraphicsLayerClutter):
(WebCore::GraphicsLayerClutter::contentsLayer):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148068 r148069  
     12013-04-09  Joone Hur  <joone.hur@intel.com>
     2
     3        [GTK][AC] Adding contentsLayer for image and video
     4        https://bugs.webkit.org/show_bug.cgi?id=113912
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        contentsLayer is a ClutterActor, which is added to the main layer
     9        as a child when GraphicsLayer needs to render an image or video.
     10
     11        No new tests, already covered by existing AC tests.
     12
     13        * platform/graphics/clutter/GraphicsLayerActor.cpp:
     14        (graphicsLayerActorUpdateTexture):
     15        * platform/graphics/clutter/GraphicsLayerClutter.cpp:
     16        (WebCore::GraphicsLayerClutter::GraphicsLayerClutter):
     17        (WebCore::GraphicsLayerClutter::~GraphicsLayerClutter):
     18        (WebCore):
     19        (WebCore::GraphicsLayerClutter::setContentsToImage): Pass a Cairo surface to GraphicsLayer.
     20        (WebCore::GraphicsLayerClutter::setContentsNeedsDisplay):
     21        (WebCore::GraphicsLayerClutter::setContentsRect):
     22        (WebCore::GraphicsLayerClutter::commitLayerChangesBeforeSublayers):
     23        (WebCore::GraphicsLayerClutter::setupContentsLayer):
     24        (WebCore::GraphicsLayerClutter::updateContentsImage): Set the Cairo surface for contentsLayer
     25        to upload it as a texture.
     26        (WebCore::GraphicsLayerClutter::updateContentsNeedsDisplay):
     27        (WebCore::GraphicsLayerClutter::updateContentsRect):
     28        (WebCore::GraphicsLayerClutter::updateSublayerList):
     29        * platform/graphics/clutter/GraphicsLayerClutter.h:
     30        (WebCore::GraphicsLayerClutter::hasContentsLayer):
     31        (GraphicsLayerClutter):
     32        (WebCore::GraphicsLayerClutter::contentsLayer):
     33
    1342013-04-09  Alexey Proskuryakov  <ap@apple.com>
    235
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp

    r147443 r148069  
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
    33 * Copyright (C) 2011, 2012, 2013 Collabora Ltd.
    4  * Copyright (C) 2012 Intel Corporation. All rights reserved.
     4 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    253253GraphicsLayerClutter::GraphicsLayerClutter(GraphicsLayerClient* client)
    254254    : GraphicsLayer(client)
     255    , m_contentsLayerPurpose(NoContentsLayer)
    255256    , m_uncommittedChanges(0)
    256257{
     
    304305        g_idle_add(idleDestroy, m_structuralLayer.leakRef());
    305306    }
     307
     308    if (m_contentsLayer) {
     309        graphicsLayerActorSetClient(m_contentsLayer.get(), 0);
     310        g_idle_add(idleDestroy, m_contentsLayer.leakRef());
     311    }
    306312}
    307313
     
    416422    GraphicsLayer::setDrawsContent(drawsContent);
    417423    noteLayerPropertyChanged(DrawsContentChanged);
     424}
     425
     426
     427void GraphicsLayerClutter::setContentsToImage(Image* image)
     428{
     429    if (image) {
     430        RefPtr<cairo_surface_t> newImage = image->nativeImageForCurrentFrame();
     431        if (!newImage)
     432            return;
     433
     434        m_pendingContentsImage = newImage;
     435
     436        m_contentsLayerPurpose = ContentsLayerForImage;
     437        if (!m_contentsLayer)
     438            noteSublayersChanged();
     439    } else {
     440        m_pendingContentsImage = 0;
     441        m_contentsLayerPurpose = NoContentsLayer;
     442        if (m_contentsLayer)
     443            noteSublayersChanged();
     444    }
     445
     446    noteLayerPropertyChanged(ContentsImageChanged);
     447}
     448
     449void GraphicsLayerClutter::setContentsNeedsDisplay()
     450{
     451    noteLayerPropertyChanged(ContentsNeedsDisplay);
     452}
     453
     454void GraphicsLayerClutter::setContentsRect(const IntRect& rect)
     455{
     456    if (rect == m_contentsRect)
     457        return;
     458
     459    GraphicsLayer::setContentsRect(rect);
     460    noteLayerPropertyChanged(ContentsRectChanged);
    418461}
    419462
     
    643686        updateStructuralLayer();
    644687
     688    if (m_uncommittedChanges & NameChanged)
     689        updateLayerNames();
     690
     691    if (m_uncommittedChanges & ContentsImageChanged) // Needs to happen before ChildrenChanged
     692        updateContentsImage();
     693
     694    if (m_uncommittedChanges & ChildrenChanged)
     695        updateSublayerList();
     696
    645697    if (m_uncommittedChanges & GeometryChanged)
    646698        updateGeometry(pageScaleFactor, positionRelativeToBase);
     
    663715    if (m_uncommittedChanges & DirtyRectsChanged)
    664716        repaintLayerDirtyRects();
     717
     718    if (m_uncommittedChanges & ContentsRectChanged)
     719        updateContentsRect();
     720
     721    if (m_uncommittedChanges & ContentsNeedsDisplay)
     722        updateContentsNeedsDisplay();
    665723
    666724    if (m_uncommittedChanges & ChildrenChanged) {
     
    670728    }
    671729}
     730
     731void GraphicsLayerClutter::setupContentsLayer(GraphicsLayerActor* contentsLayer)
     732{
     733    graphicsLayerActorSetAnchorPoint(contentsLayer, 0.0, 0.0, 0.0);
     734}
     735
     736void GraphicsLayerClutter::updateContentsImage()
     737{
     738    if (m_pendingContentsImage) {
     739        if (!m_contentsLayer) {
     740            m_contentsLayer = graphicsLayerActorNewWithClient(LayerTypeLayer, this);
     741            clutter_actor_set_name(CLUTTER_ACTOR(m_contentsLayer.get()), "Image Layer");
     742            setupContentsLayer(m_contentsLayer.get());
     743        }
     744
     745        graphicsLayerActorSetSurface(GRAPHICS_LAYER_ACTOR(m_contentsLayer.get()), m_pendingContentsImage.get());
     746        m_pendingContentsImage = 0;
     747
     748        updateContentsRect();
     749    } else {
     750        // No image.
     751        // m_contentsLayer will be removed via updateSublayerList.
     752        m_contentsLayer = 0;
     753    }
     754}
     755
     756void GraphicsLayerClutter::updateContentsNeedsDisplay()
     757{
     758    if (m_contentsLayer)
     759        graphicsLayerActorInvalidateRectangle(m_contentsLayer.get(), FloatRect(FloatPoint(0, 0), size()));
     760}
     761
     762void GraphicsLayerClutter::updateContentsRect()
     763{
     764    if (!m_contentsLayer)
     765        return;
     766
     767    FloatPoint point(m_contentsRect.x(), m_contentsRect.y());
     768    FloatRect rect(0, 0, m_contentsRect.width(), m_contentsRect.height());
     769
     770    clutter_actor_set_position(CLUTTER_ACTOR(m_contentsLayer.get()), point.x(), point.y());
     771    clutter_actor_set_size(CLUTTER_ACTOR(m_contentsLayer.get()), rect.width(), rect.height());
     772}
     773
    672774
    673775void GraphicsLayerClutter::updateGeometry(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
     
    696798    if (m_structuralLayer)
    697799        structuralLayerChildren.append(m_layer);
     800
     801    if (m_contentsLayer)
     802        primaryLayerChildren.append(m_contentsLayer);
    698803
    699804    const Vector<GraphicsLayer*>& childLayers = children();
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h

    r147443 r148069  
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
    33 * Copyright (C) 2011, 2012 Collabora Ltd.
    4  * Copyright (C) 2012 Intel Corporation. All rights reserved.
     4 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    7979    virtual void setNeedsDisplay();
    8080    virtual void setNeedsDisplayInRect(const FloatRect&);
     81    virtual void setContentsNeedsDisplay();
     82
     83    virtual void setContentsToImage(Image*);
     84    virtual void setContentsRect(const IntRect&);
     85
     86    virtual bool hasContentsLayer() const { return m_contentsLayer; }
    8187
    8288    virtual void setPreserves3D(bool);
     
    108114
    109115    void updateOpacityOnLayer();
     116    void setupContentsLayer(GraphicsLayerActor*);
     117    GraphicsLayerActor* contentsLayer() const { return m_contentsLayer.get(); }
    110118
    111119    virtual void platformClutterLayerAnimationStarted(double beginTime);
     
    183191    void updateTransform();
    184192    void updateLayerDrawsContent(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
    185 
     193    void updateContentsImage();
     194    void updateContentsRect();
     195    void updateContentsNeedsDisplay();
    186196    void updateAnimations();
    187197
     
    198208    GRefPtr<GraphicsLayerActor> m_layer;
    199209    GRefPtr<GraphicsLayerActor> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
     210    GRefPtr<GraphicsLayerActor> m_contentsLayer; // A layer used for inner content, like image and video
     211    enum ContentsLayerPurpose {
     212        NoContentsLayer = 0,
     213        ContentsLayerForImage,
     214        ContentsLayerForMedia,
     215        ContentsLayerForCanvas,
     216        ContentsLayerForBackgroundColor
     217    };
     218
     219    ContentsLayerPurpose m_contentsLayerPurpose;
     220    RefPtr<cairo_surface_t> m_pendingContentsImage;
    200221
    201222    Vector<FloatRect> m_dirtyRects;
Note: See TracChangeset for help on using the changeset viewer.