• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef GraphicsLayerAndroid_h
18 #define GraphicsLayerAndroid_h
19 
20 #if USE(ACCELERATED_COMPOSITING)
21 
22 #include "FloatRect.h"
23 #include "Frame.h"
24 #include "GraphicsLayer.h"
25 #include "GraphicsLayerClient.h"
26 #include "LayerContent.h"
27 #include "RefPtr.h"
28 #include "ScrollableLayerAndroid.h"
29 #include "SkBitmapRef.h"
30 #include "Vector.h"
31 
32 class SkBitmapRef;
33 class SkRegion;
34 
35 namespace WebCore {
36 
37 class FloatPoint3D;
38 class Image;
39 class LayerAndroid;
40 class FixedBackgroundImageLayerAndroid;
41 class ScrollableLayerAndroid;
42 
43 class GraphicsLayerAndroid : public GraphicsLayer {
44 public:
45 
46     GraphicsLayerAndroid(GraphicsLayerClient*);
47     virtual ~GraphicsLayerAndroid();
48 
49     virtual void setName(const String&);
50 
51     // for hosting this GraphicsLayer in a native layer hierarchy
52     virtual NativeLayer nativeLayer() const;
53 
54     virtual bool setChildren(const Vector<GraphicsLayer*>&);
55     virtual void addChild(GraphicsLayer*);
56     virtual void addChildAtIndex(GraphicsLayer*, int index);
57     virtual void addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling);
58     virtual void addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling);
59     virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
60     virtual void setReplicatedLayer(GraphicsLayer* layer);
61 
62     virtual void removeFromParent();
63 
64     virtual void setPosition(const FloatPoint&);
65     virtual void setPreserves3D(bool b);
66     virtual void setAnchorPoint(const FloatPoint3D&);
67     virtual void setSize(const FloatSize&);
68 
69     virtual void setBackfaceVisibility(bool b);
70     virtual void setTransform(const TransformationMatrix&);
71 
72     virtual void setChildrenTransform(const TransformationMatrix&);
73 
74     virtual void setMaskLayer(GraphicsLayer*);
75     virtual void setMasksToBounds(bool);
76     virtual void setDrawsContent(bool);
77 
78     virtual void setBackgroundColor(const Color&);
79     virtual void clearBackgroundColor();
80 
81     virtual void setContentsOpaque(bool);
82 
83     virtual void setOpacity(float);
84 
85     virtual void setNeedsDisplay();
86     virtual void setNeedsDisplayInRect(const FloatRect&);
87 
88     virtual bool addAnimation(const KeyframeValueList& valueList,
89                               const IntSize& boxSize,
90                               const Animation* anim,
91                               const String& keyframesName,
92                               double beginTime);
93     bool createTransformAnimationsFromKeyframes(const KeyframeValueList&,
94                                                 const Animation*,
95                                                 const String& keyframesName,
96                                                 double beginTime,
97                                                 const IntSize& boxSize);
98     bool createAnimationFromKeyframes(const KeyframeValueList&,
99                                       const Animation*,
100                                       const String& keyframesName,
101                                       double beginTime);
102 
103     virtual void removeAnimationsForProperty(AnimatedPropertyID);
104     virtual void removeAnimationsForKeyframes(const String& keyframesName);
105     virtual void pauseAnimation(const String& keyframesName);
106 
107     virtual void suspendAnimations(double time);
108     virtual void resumeAnimations();
109 
110     virtual void setContentsToImage(Image*);
111     virtual void setContentsToMedia(PlatformLayer*);
112     virtual PlatformLayer* platformLayer() const;
113 
114     void pauseDisplay(bool state);
115 
116 #ifndef NDEBUG
117     virtual void setDebugBackgroundColor(const Color&);
118     virtual void setDebugBorder(const Color&, float borderWidth);
119 #endif
120 
121     virtual void setZPosition(float);
122 
123     void gatherRootLayers(Vector<const RenderLayer*>&);
124     virtual void syncCompositingState();
125     virtual void syncCompositingStateForThisLayerOnly();
126     void notifyClientAnimationStarted();
127 
contentLayer()128     LayerAndroid* contentLayer() { return m_contentLayer; }
foregroundLayer()129     LayerAndroid* foregroundLayer() { return m_foregroundLayer; }
130 
131     static int instancesCount();
132 
133     virtual void updateScrollOffset();
134 
135 private:
136 
137     void askForSync();
138     void syncPositionState();
139     void syncChildren();
140     void syncMask();
141 
142     void updatePositionedLayers();
143     void updateScrollingLayers();
144     void updateFixedBackgroundLayers();
145 
146     // with SkPicture, we always repaint the entire layer's content.
147     bool repaint();
148     void needsNotifyClient();
149 
150     SkPicture* paintPicture(const IntRect& rect);
151     bool paintContext(LayerAndroid* layer,
152                       const IntRect& rect,
153                       bool checkOptimisations = true);
154 
155     bool m_needsSyncChildren;
156     bool m_needsSyncMask;
157     bool m_needsRepaint;
158     bool m_needsNotifyClient;
159 
160     bool m_haveContents;
161     bool m_newImage;
162     Image* m_image;
163 
164     SkRegion m_dirtyRegion;
165 
166     LayerAndroid* m_contentLayer;
167     FixedBackgroundImageLayerAndroid* m_fixedBackgroundLayer;
168     LayerAndroid* m_foregroundLayer;
169     LayerAndroid* m_foregroundClipLayer;
170 };
171 
172 } // namespace WebCore
173 
174 
175 #endif // USE(ACCELERATED_COMPOSITING)
176 
177 #endif // GraphicsLayerAndroid_h
178