15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2009 Apple Inc. All rights reserved.
38abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * Copyright (C) 2013 Intel Corporation. All rights reserved.
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met:
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    documentation and/or other materials provided with the distribution.
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef GraphicsLayer_h
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define GraphicsLayer_h
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
30a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/PlatformExport.h"
311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/FloatPoint.h"
321e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/FloatPoint3D.h"
331e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/FloatSize.h"
341e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/IntRect.h"
35f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)#include "platform/graphics/Color.h"
367242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#include "platform/graphics/ContentLayerDelegate.h"
37a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/graphics/GraphicsLayerClient.h"
3809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "platform/graphics/GraphicsLayerDebugInfo.h"
39a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/graphics/filters/FilterOperations.h"
401e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/transforms/TransformationMatrix.h"
419e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)#include "public/platform/WebCompositorAnimationDelegate.h"
425267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "public/platform/WebContentLayer.h"
435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "public/platform/WebImageLayer.h"
447242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#include "public/platform/WebInvalidationDebugAnnotations.h"
45e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)#include "public/platform/WebLayerClient.h"
465267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "public/platform/WebLayerScrollClient.h"
47c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)#include "public/platform/WebNinePatchLayer.h"
48a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "wtf/OwnPtr.h"
49a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "wtf/PassOwnPtr.h"
50a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "wtf/Vector.h"
5181a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
5251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class FloatRect;
555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class GraphicsContext;
56d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class GraphicsLayer;
575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class GraphicsLayerFactory;
58e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)class GraphicsLayerFactoryChromium;
595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class Image;
60197021e6b966cfb06891637935ef33fff06433d1Ben Murdochclass JSONObject;
6181a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)class ScrollableArea;
629e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)class WebCompositorAnimation;
63e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)class WebLayer;
645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
6581a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)// FIXME: find a better home for this declaration.
66a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)class PLATFORM_EXPORT LinkHighlightClient {
6781a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)public:
6881a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    virtual void invalidate() = 0;
6981a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    virtual void clearCurrentGraphicsLayer() = 0;
70e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    virtual WebLayer* layer() = 0;
715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
7281a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)protected:
7381a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    virtual ~LinkHighlightClient() { }
7481a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)};
755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
76d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)typedef Vector<GraphicsLayer*, 64> GraphicsLayerVector;
77d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// GraphicsLayer is an abstraction for a rendering surface with backing store,
795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// which may have associated transformation and animations.
805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
819e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)class PLATFORM_EXPORT GraphicsLayer : public GraphicsContextPainter, public WebCompositorAnimationDelegate, public WebLayerScrollClient, public WebLayerClient {
825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED;
835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    static PassOwnPtr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient*);
855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    virtual ~GraphicsLayer();
875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayerClient* client() const { return m_client; }
895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
90e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    // WebLayerClient implementation.
91e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    virtual WebGraphicsLayerDebugInfo* takeDebugInfoFor(WebLayer*) OVERRIDE;
925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
9309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    GraphicsLayerDebugInfo& debugInfo();
9409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
9509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setCompositingReasons(CompositingReasons);
9609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    CompositingReasons compositingReasons() const { return m_debugInfo.compositingReasons(); }
97d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    void setOwnerNodeId(int);
9893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayer* parent() const { return m_parent; };
1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void setParent(GraphicsLayer*); // Internal use only.
10102772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    const Vector<GraphicsLayer*>& children() const { return m_children; }
1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Returns true if the child list changed.
104d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    bool setChildren(const GraphicsLayerVector&);
1055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Add child layers. If the child is already parented, it will be removed from its old parent.
107e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void addChild(GraphicsLayer*);
108e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling);
1095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void removeAllChildren();
111e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void removeFromParent();
1125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayer* maskLayer() const { return m_maskLayer; }
114e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setMaskLayer(GraphicsLayer*);
11502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
11606f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    GraphicsLayer* contentsClippingMaskLayer() const { return m_contentsClippingMaskLayer; }
11706f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    void setContentsClippingMaskLayer(GraphicsLayer*);
11806f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)
1195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // The given layer will replicate this layer and its children; the replica renders behind this layer.
120e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setReplicatedByLayer(GraphicsLayer*);
1215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // The layer that replicates this layer (if any).
1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayer* replicaLayer() const { return m_replicaLayer; }
123c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // The layer being replicated.
124c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    GraphicsLayer* replicatedLayer() const { return m_replicatedLayer; }
1255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
126926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    enum ShouldSetNeedsDisplay {
127926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        DontSetNeedsDisplay,
128926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        SetNeedsDisplay
129926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    };
130926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Offset is origin of the renderer minus origin of the graphics layer (so either zero or negative).
1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    IntSize offsetFromRenderer() const { return m_offsetFromRenderer; }
133926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setOffsetFromRenderer(const IntSize&, ShouldSetNeedsDisplay = SetNeedsDisplay);
1345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // The position of the layer (the location of its top-left corner in its parent)
1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    const FloatPoint& position() const { return m_position; }
137e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setPosition(const FloatPoint&);
1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
139d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    const FloatPoint3D& transformOrigin() const { return m_transformOrigin; }
140d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    void setTransformOrigin(const FloatPoint3D&);
141d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)
1425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // The size of the layer.
1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    const FloatSize& size() const { return m_size; }
144e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setSize(const FloatSize&);
1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    const TransformationMatrix& transform() const { return m_transform; }
147e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setTransform(const TransformationMatrix&);
14809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setShouldFlattenTransform(bool);
14909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setRenderingContext(int id);
150e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setMasksToBounds(bool);
151e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)
1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool drawsContent() const { return m_drawsContent; }
153e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setDrawsContent(bool);
1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool contentsAreVisible() const { return m_contentsVisible; }
156e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setContentsVisible(bool);
1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
158e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    void setScrollParent(WebLayer*);
159e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    void setClipParent(WebLayer*);
16006f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)
16153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // For special cases, e.g. drawing missing tiles on Android.
16253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // The compositor should never paint this color in normal cases because the RenderLayer
16353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // will paint background by itself.
164e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setBackgroundColor(const Color&);
1655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // opaque means that we know the layer contents have no alpha
1675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool contentsOpaque() const { return m_contentsOpaque; }
168e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setContentsOpaque(bool);
1695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool backfaceVisibility() const { return m_backfaceVisibility; }
171e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setBackfaceVisibility(bool visible);
1725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    float opacity() const { return m_opacity; }
174e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setOpacity(float);
1755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
176e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    void setBlendMode(WebBlendMode);
177a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    void setIsRootForIsolatedGroup(bool);
178a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)
179197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    void setFilters(const FilterOperations&);
1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Some GraphicsLayers paint only the foreground or the background content
182f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    void setPaintingPhase(GraphicsLayerPaintingPhase);
1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
184e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setNeedsDisplay();
1855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // mark the given rect (in layer coords) as needing dispay. Never goes deep.
1867242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    void setNeedsDisplayInRect(const FloatRect&, WebInvalidationDebugAnnotations);
1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
188e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setContentsNeedsDisplay();
1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Set that the position/size of the contents (image or video).
191e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setContentsRect(const IntRect&);
192e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)
1935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Return true if the animation is handled by the compositing system. If this returns
1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // false, the animation will be run by AnimationController.
1955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // These methods handle both transitions and keyframe animations.
1969e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)    bool addAnimation(PassOwnPtr<WebCompositorAnimation>);
19706f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    void pauseAnimation(int animationId, double /*timeOffset*/);
19806f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    void removeAnimation(int animationId);
1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Layer contents
201e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setContentsToImage(Image*);
202c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    void setContentsToNinePatch(Image*, const IntRect& aperture);
203e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    void setContentsToPlatformLayer(WebLayer* layer) { setContentsTo(layer); }
204e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    bool hasContentsLayer() const { return m_contentsLayer; }
2055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // For hosting this GraphicsLayer in a native layer hierarchy.
207e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebLayer* platformLayer() const;
208e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)
20909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    typedef HashMap<int, int> RenderingContextMap;
210197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    PassRefPtr<JSONObject> layerTreeAsJSON(LayerTreeFlags, RenderingContextMap&) const;
2115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
212c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    int paintCount() const { return m_paintCount; }
2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
21453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // Return a string with a human readable form of the layer tree, If debug is true
2155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // pointers for the layers and timing data will be included in the returned string.
216521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    String layerTreeAsText(LayerTreeFlags = LayerTreeNormal) const;
2175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
218e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    void resetTrackedPaintInvalidations();
2195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void addRepaintRect(const FloatRect&);
2205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2219bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    void addLinkHighlight(LinkHighlightClient*);
2229bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    void removeLinkHighlight(LinkHighlightClient*);
223e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    // Exposed for tests
2249bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    unsigned numLinkHighlights() { return m_linkHighlights.size(); }
2259bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    LinkHighlightClient* linkHighlight(int i) { return m_linkHighlights[i]; }
226e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)
227e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    void setScrollableArea(ScrollableArea*, bool isMainFrame);
228e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    ScrollableArea* scrollableArea() const { return m_scrollableArea; }
229e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)
230e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebContentLayer* contentLayer() const { return m_layer.get(); }
231e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)
232e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    static void registerContentsLayer(WebLayer*);
233e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    static void unregisterContentsLayer(WebLayer*);
23481a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
2355267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // GraphicsContextPainter implementation.
2365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE;
2375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
2389e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)    // WebCompositorAnimationDelegate implementation.
2399e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)    virtual void notifyAnimationStarted(double monotonicTime, WebCompositorAnimation::TargetProperty) OVERRIDE;
2409e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)    virtual void notifyAnimationFinished(double monotonicTime, WebCompositorAnimation::TargetProperty) OVERRIDE;
2415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
2425267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // WebLayerScrollClient implementation.
2435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void didScroll() OVERRIDE;
2445267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
2455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)protected:
246e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    String debugName(WebLayer*) const;
247c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)
2488abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    explicit GraphicsLayer(GraphicsLayerClient*);
2498abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    // GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends.
250e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    friend class GraphicsLayerFactoryChromium;
25151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
25251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    // Exposed for tests.
253e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    virtual WebLayer* contentsLayer() const { return m_contentsLayer; }
2548abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
2558abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)private:
256c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    // Callback from the underlying graphics system to draw layer contents.
257c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    void paintGraphicsLayerContents(GraphicsContext&, const IntRect& clip);
258c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)
2595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Adds a child without calling updateChildList(), so that adding children
2605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // can be batched before updating.
2615267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    void addChildInternal(GraphicsLayer*);
2625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
263197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#if ENABLE(ASSERT)
2645d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    bool hasAncestor(GraphicsLayer*) const;
2655d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#endif
2665d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)
267e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    void setReplicatedLayer(GraphicsLayer* layer) { m_replicatedLayer = layer; }
2685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
269c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    void incrementPaintCount() { ++m_paintCount; }
270c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)
27181a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    // Helper functions used by settors to keep layer's the state consistent.
27281a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    void updateChildList();
27381a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    void updateLayerIsDrawable();
27481a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    void updateContentsRect();
27581a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
276e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    void setContentsTo(WebLayer*);
277e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    void setupContentsLayer(WebLayer*);
27881a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    void clearContentsLayerIfUnregistered();
279e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebLayer* contentsLayerIfRegistered();
28081a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
2815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayerClient* m_client;
28202772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
2835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Offset from the owning renderer
2845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    IntSize m_offsetFromRenderer;
28502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
2865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Position is relative to the parent GraphicsLayer
2875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    FloatPoint m_position;
2885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    FloatSize m_size;
2895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    TransformationMatrix m_transform;
291d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    FloatPoint3D m_transformOrigin;
2925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    Color m_backgroundColor;
2945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    float m_opacity;
29502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
296e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebBlendMode m_blendMode;
297a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)
2985d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    bool m_hasTransformOrigin : 1;
2995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_contentsOpaque : 1;
30009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_shouldFlattenTransform: 1;
3015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_backfaceVisibility : 1;
3025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_masksToBounds : 1;
3035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_drawsContent : 1;
3045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_contentsVisible : 1;
305a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    bool m_isRootForIsolatedGroup : 1;
30602772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
30706f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    bool m_hasScrollParent : 1;
30806f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    bool m_hasClipParent : 1;
30906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)
3105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayerPaintingPhase m_paintingPhase;
3115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    Vector<GraphicsLayer*> m_children;
3135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayer* m_parent;
3145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayer* m_maskLayer; // Reference to mask layer. We don't own this.
31606f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    GraphicsLayer* m_contentsClippingMaskLayer; // Reference to clipping mask layer. We don't own this.
3175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayer* m_replicaLayer; // A layer that replicates this layer. We only allow one, for now.
3195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                                   // The replica is not parented; this is the primary reference to it.
3205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GraphicsLayer* m_replicatedLayer; // For a replica layer, a reference to the original layer.
3215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    FloatPoint m_replicatedLayerPosition; // For a replica layer, the position of the replica.
3225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    IntRect m_contentsRect;
3245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
325c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    int m_paintCount;
32681a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
327e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    OwnPtr<WebContentLayer> m_layer;
328e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    OwnPtr<WebImageLayer> m_imageLayer;
329e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    OwnPtr<WebNinePatchLayer> m_ninePatchLayer;
330e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebLayer* m_contentsLayer;
33181a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    // We don't have ownership of m_contentsLayer, but we do want to know if a given layer is the
33281a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    // same as our current layer in setContentsTo(). Since m_contentsLayer may be deleted at this point,
33381a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    // we stash an ID away when we know m_contentsLayer is alive and use that for comparisons from that point
33481a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    // on.
33581a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    int m_contentsLayerId;
33681a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
3379bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    Vector<LinkHighlightClient*> m_linkHighlights;
33881a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
3397242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    OwnPtr<ContentLayerDelegate> m_contentLayerDelegate;
34081a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)
34181a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    ScrollableArea* m_scrollableArea;
34209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    GraphicsLayerDebugInfo m_debugInfo;
34309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    int m_3dRenderingContext;
3445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
3455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
346c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
3475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef NDEBUG
3495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Outside the WebCore namespace for ease of invocation from gdb.
350c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)void PLATFORM_EXPORT showGraphicsLayerTree(const blink::GraphicsLayer*);
3515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif
3525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // GraphicsLayer_h
354