OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are |
| 6 * met: |
| 7 * |
| 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ |
| 30 |
| 31 #ifndef GraphicsLayerChromium_h |
| 32 #define GraphicsLayerChromium_h |
| 33 |
| 34 #if USE(ACCELERATED_COMPOSITING) |
| 35 |
| 36 #include "GraphicsContext.h" |
| 37 #include "GraphicsLayer.h" |
| 38 #include "OpaqueRectTrackingContentLayerDelegate.h" |
| 39 #include "cc/CCLayerAnimationDelegate.h" |
| 40 |
| 41 #include <public/WebContentLayer.h> |
| 42 #include <public/WebLayer.h> |
| 43 #include <wtf/HashMap.h> |
| 44 |
| 45 namespace WebCore { |
| 46 |
| 47 class LayerChromium; |
| 48 class LinkHighlight; |
| 49 class Path; |
| 50 |
| 51 class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainte
r, public CCLayerAnimationDelegate { |
| 52 public: |
| 53 GraphicsLayerChromium(GraphicsLayerClient*); |
| 54 virtual ~GraphicsLayerChromium(); |
| 55 |
| 56 virtual void setName(const String&); |
| 57 |
| 58 virtual bool setChildren(const Vector<GraphicsLayer*>&); |
| 59 virtual void addChild(GraphicsLayer*); |
| 60 virtual void addChildAtIndex(GraphicsLayer*, int index); |
| 61 virtual void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling); |
| 62 virtual void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling); |
| 63 virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild); |
| 64 |
| 65 virtual void removeFromParent(); |
| 66 |
| 67 virtual void setPosition(const FloatPoint&); |
| 68 virtual void setAnchorPoint(const FloatPoint3D&); |
| 69 virtual void setSize(const FloatSize&); |
| 70 |
| 71 virtual void setTransform(const TransformationMatrix&); |
| 72 |
| 73 virtual void setChildrenTransform(const TransformationMatrix&); |
| 74 |
| 75 virtual void setPreserves3D(bool); |
| 76 virtual void setMasksToBounds(bool); |
| 77 virtual void setDrawsContent(bool); |
| 78 virtual void setContentsVisible(bool); |
| 79 virtual void setMaskLayer(GraphicsLayer*); |
| 80 |
| 81 virtual void setBackgroundColor(const Color&); |
| 82 virtual void clearBackgroundColor(); |
| 83 |
| 84 virtual void setContentsOpaque(bool); |
| 85 virtual void setBackfaceVisibility(bool); |
| 86 |
| 87 virtual void setReplicatedByLayer(GraphicsLayer*); |
| 88 |
| 89 virtual void setOpacity(float); |
| 90 |
| 91 // Returns true if filter can be rendered by the compositor |
| 92 virtual bool setFilters(const FilterOperations&); |
| 93 void setBackgroundFilters(const FilterOperations&); |
| 94 |
| 95 virtual void setNeedsDisplay(); |
| 96 virtual void setNeedsDisplayInRect(const FloatRect&); |
| 97 virtual void setContentsNeedsDisplay(); |
| 98 |
| 99 virtual void setContentsRect(const IntRect&); |
| 100 |
| 101 virtual void setContentsToImage(Image*); |
| 102 virtual void setContentsToMedia(PlatformLayer*); |
| 103 virtual void setContentsToCanvas(PlatformLayer*); |
| 104 virtual bool hasContentsLayer() const { return !m_contentsLayer.isNull(); } |
| 105 |
| 106 virtual bool addAnimation(const KeyframeValueList&, const IntSize& boxSize,
const Animation*, const String&, double timeOffset); |
| 107 virtual void pauseAnimation(const String& animationName, double timeOffset); |
| 108 virtual void removeAnimation(const String& animationName); |
| 109 virtual void suspendAnimations(double wallClockTime); |
| 110 virtual void resumeAnimations(); |
| 111 |
| 112 virtual void addLinkHighlight(const Path&); |
| 113 virtual void didFinishLinkHighlight(); |
| 114 |
| 115 virtual PlatformLayer* platformLayer() const; |
| 116 |
| 117 virtual void setDebugBackgroundColor(const Color&); |
| 118 virtual void setDebugBorder(const Color&, float borderWidth); |
| 119 virtual void deviceOrPageScaleFactorChanged(); |
| 120 |
| 121 // GraphicsContextPainter implementation. |
| 122 virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE; |
| 123 |
| 124 // CCLayerAnimationDelegate implementation. |
| 125 virtual void notifyAnimationStarted(double startTime); |
| 126 virtual void notifyAnimationFinished(double finishTime); |
| 127 |
| 128 // Exposed for tests. |
| 129 WebKit::WebLayer contentsLayer() const { return m_contentsLayer; } |
| 130 |
| 131 private: |
| 132 virtual void willBeDestroyed(); |
| 133 |
| 134 WebKit::WebLayer primaryLayer() const { return m_transformLayer.isNull() ?
m_layer : m_transformLayer; } |
| 135 WebKit::WebLayer hostLayerForChildren() const; |
| 136 WebKit::WebLayer layerForParent() const; |
| 137 |
| 138 void updateNames(); |
| 139 void updateChildList(); |
| 140 void updateLayerPosition(); |
| 141 void updateLayerSize(); |
| 142 void updateAnchorPoint(); |
| 143 void updateTransform(); |
| 144 void updateChildrenTransform(); |
| 145 void updateMasksToBounds(); |
| 146 void updateLayerPreserves3D(); |
| 147 void updateLayerIsDrawable(); |
| 148 void updateLayerBackgroundColor(); |
| 149 |
| 150 void updateContentsImage(); |
| 151 void updateContentsVideo(); |
| 152 void updateContentsRect(); |
| 153 void updateContentsScale(); |
| 154 |
| 155 void setupContentsLayer(LayerChromium*); |
| 156 float contentsScale() const; |
| 157 |
| 158 int mapAnimationNameToId(const String& animationName); |
| 159 |
| 160 String m_nameBase; |
| 161 |
| 162 WebKit::WebContentLayer m_layer; |
| 163 WebKit::WebLayer m_transformLayer; |
| 164 WebKit::WebLayer m_contentsLayer; |
| 165 |
| 166 OwnPtr<OpaqueRectTrackingContentLayerDelegate> m_opaqueRectTrackingContentLa
yerDelegate; |
| 167 |
| 168 enum ContentsLayerPurpose { |
| 169 NoContentsLayer = 0, |
| 170 ContentsLayerForImage, |
| 171 ContentsLayerForVideo, |
| 172 ContentsLayerForCanvas, |
| 173 }; |
| 174 |
| 175 ContentsLayerPurpose m_contentsLayerPurpose; |
| 176 bool m_contentsLayerHasBackgroundColor : 1; |
| 177 bool m_inSetChildren; |
| 178 bool m_pageScaleChanged; |
| 179 |
| 180 RefPtr<LinkHighlight> m_linkHighlight; |
| 181 |
| 182 typedef HashMap<String, int> AnimationIdMap; |
| 183 AnimationIdMap m_animationIdMap; |
| 184 }; |
| 185 |
| 186 } // namespace WebCore |
| 187 |
| 188 #endif // USE(ACCELERATED_COMPOSITING) |
| 189 |
| 190 #endif |
OLD | NEW |