Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: Source/platform/graphics/GraphicsLayer.h

Issue 470443002: Revert of Rename WebAnimation to WebCompositorAnimation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 * Copyright (C) 2013 Intel Corporation. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 #include "platform/geometry/FloatPoint.h" 31 #include "platform/geometry/FloatPoint.h"
32 #include "platform/geometry/FloatPoint3D.h" 32 #include "platform/geometry/FloatPoint3D.h"
33 #include "platform/geometry/FloatSize.h" 33 #include "platform/geometry/FloatSize.h"
34 #include "platform/geometry/IntRect.h" 34 #include "platform/geometry/IntRect.h"
35 #include "platform/graphics/Color.h" 35 #include "platform/graphics/Color.h"
36 #include "platform/graphics/GraphicsLayerClient.h" 36 #include "platform/graphics/GraphicsLayerClient.h"
37 #include "platform/graphics/GraphicsLayerDebugInfo.h" 37 #include "platform/graphics/GraphicsLayerDebugInfo.h"
38 #include "platform/graphics/OpaqueRectTrackingContentLayerDelegate.h" 38 #include "platform/graphics/OpaqueRectTrackingContentLayerDelegate.h"
39 #include "platform/graphics/filters/FilterOperations.h" 39 #include "platform/graphics/filters/FilterOperations.h"
40 #include "platform/transforms/TransformationMatrix.h" 40 #include "platform/transforms/TransformationMatrix.h"
41 #include "public/platform/WebCompositorAnimationDelegate.h" 41 #include "public/platform/WebAnimationDelegate.h"
42 #include "public/platform/WebContentLayer.h" 42 #include "public/platform/WebContentLayer.h"
43 #include "public/platform/WebImageLayer.h" 43 #include "public/platform/WebImageLayer.h"
44 #include "public/platform/WebLayerClient.h" 44 #include "public/platform/WebLayerClient.h"
45 #include "public/platform/WebLayerScrollClient.h" 45 #include "public/platform/WebLayerScrollClient.h"
46 #include "public/platform/WebNinePatchLayer.h" 46 #include "public/platform/WebNinePatchLayer.h"
47 #include "wtf/OwnPtr.h" 47 #include "wtf/OwnPtr.h"
48 #include "wtf/PassOwnPtr.h" 48 #include "wtf/PassOwnPtr.h"
49 #include "wtf/Vector.h" 49 #include "wtf/Vector.h"
50 50
51 namespace blink { 51 namespace blink {
52 class GraphicsLayerFactoryChromium; 52 class GraphicsLayerFactoryChromium;
53 class WebCompositorAnimation; 53 class WebAnimation;
54 class WebLayer; 54 class WebLayer;
55 } 55 }
56 56
57 namespace blink { 57 namespace blink {
58 58
59 class FloatRect; 59 class FloatRect;
60 class GraphicsContext; 60 class GraphicsContext;
61 class GraphicsLayer; 61 class GraphicsLayer;
62 class GraphicsLayerFactory; 62 class GraphicsLayerFactory;
63 class Image; 63 class Image;
64 class JSONObject; 64 class JSONObject;
65 class ScrollableArea; 65 class ScrollableArea;
66 class TextStream; 66 class TextStream;
67 67
68 // FIXME: find a better home for this declaration. 68 // FIXME: find a better home for this declaration.
69 class PLATFORM_EXPORT LinkHighlightClient { 69 class PLATFORM_EXPORT LinkHighlightClient {
70 public: 70 public:
71 virtual void invalidate() = 0; 71 virtual void invalidate() = 0;
72 virtual void clearCurrentGraphicsLayer() = 0; 72 virtual void clearCurrentGraphicsLayer() = 0;
73 virtual WebLayer* layer() = 0; 73 virtual blink::WebLayer* layer() = 0;
74 74
75 protected: 75 protected:
76 virtual ~LinkHighlightClient() { } 76 virtual ~LinkHighlightClient() { }
77 }; 77 };
78 78
79 typedef Vector<GraphicsLayer*, 64> GraphicsLayerVector; 79 typedef Vector<GraphicsLayer*, 64> GraphicsLayerVector;
80 80
81 // GraphicsLayer is an abstraction for a rendering surface with backing store, 81 // GraphicsLayer is an abstraction for a rendering surface with backing store,
82 // which may have associated transformation and animations. 82 // which may have associated transformation and animations.
83 83
84 class PLATFORM_EXPORT GraphicsLayer : public GraphicsContextPainter, public WebC ompositorAnimationDelegate, public WebLayerScrollClient, public WebLayerClient { 84 class PLATFORM_EXPORT GraphicsLayer : public GraphicsContextPainter, public blin k::WebAnimationDelegate, public blink::WebLayerScrollClient, public blink::WebLa yerClient {
85 WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED; 85 WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED;
86 public: 86 public:
87 static PassOwnPtr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayer Client*); 87 static PassOwnPtr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayer Client*);
88 88
89 virtual ~GraphicsLayer(); 89 virtual ~GraphicsLayer();
90 90
91 GraphicsLayerClient* client() const { return m_client; } 91 GraphicsLayerClient* client() const { return m_client; }
92 92
93 // WebLayerClient implementation. 93 // blink::WebLayerClient implementation.
94 virtual WebGraphicsLayerDebugInfo* takeDebugInfoFor(WebLayer*) OVERRIDE; 94 virtual blink::WebGraphicsLayerDebugInfo* takeDebugInfoFor(blink::WebLayer*) OVERRIDE;
95 95
96 GraphicsLayerDebugInfo& debugInfo(); 96 GraphicsLayerDebugInfo& debugInfo();
97 97
98 void setCompositingReasons(CompositingReasons); 98 void setCompositingReasons(CompositingReasons);
99 CompositingReasons compositingReasons() const { return m_debugInfo.compositi ngReasons(); } 99 CompositingReasons compositingReasons() const { return m_debugInfo.compositi ngReasons(); }
100 void setOwnerNodeId(int); 100 void setOwnerNodeId(int);
101 101
102 GraphicsLayer* parent() const { return m_parent; }; 102 GraphicsLayer* parent() const { return m_parent; };
103 void setParent(GraphicsLayer*); // Internal use only. 103 void setParent(GraphicsLayer*); // Internal use only.
104 104
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void setShouldFlattenTransform(bool); 151 void setShouldFlattenTransform(bool);
152 void setRenderingContext(int id); 152 void setRenderingContext(int id);
153 void setMasksToBounds(bool); 153 void setMasksToBounds(bool);
154 154
155 bool drawsContent() const { return m_drawsContent; } 155 bool drawsContent() const { return m_drawsContent; }
156 void setDrawsContent(bool); 156 void setDrawsContent(bool);
157 157
158 bool contentsAreVisible() const { return m_contentsVisible; } 158 bool contentsAreVisible() const { return m_contentsVisible; }
159 void setContentsVisible(bool); 159 void setContentsVisible(bool);
160 160
161 void setScrollParent(WebLayer*); 161 void setScrollParent(blink::WebLayer*);
162 void setClipParent(WebLayer*); 162 void setClipParent(blink::WebLayer*);
163 163
164 // For special cases, e.g. drawing missing tiles on Android. 164 // For special cases, e.g. drawing missing tiles on Android.
165 // The compositor should never paint this color in normal cases because the RenderLayer 165 // The compositor should never paint this color in normal cases because the RenderLayer
166 // will paint background by itself. 166 // will paint background by itself.
167 void setBackgroundColor(const Color&); 167 void setBackgroundColor(const Color&);
168 168
169 // opaque means that we know the layer contents have no alpha 169 // opaque means that we know the layer contents have no alpha
170 bool contentsOpaque() const { return m_contentsOpaque; } 170 bool contentsOpaque() const { return m_contentsOpaque; }
171 void setContentsOpaque(bool); 171 void setContentsOpaque(bool);
172 172
173 bool backfaceVisibility() const { return m_backfaceVisibility; } 173 bool backfaceVisibility() const { return m_backfaceVisibility; }
174 void setBackfaceVisibility(bool visible); 174 void setBackfaceVisibility(bool visible);
175 175
176 float opacity() const { return m_opacity; } 176 float opacity() const { return m_opacity; }
177 void setOpacity(float); 177 void setOpacity(float);
178 178
179 void setBlendMode(WebBlendMode); 179 void setBlendMode(blink::WebBlendMode);
180 void setIsRootForIsolatedGroup(bool); 180 void setIsRootForIsolatedGroup(bool);
181 181
182 void setFilters(const FilterOperations&); 182 void setFilters(const FilterOperations&);
183 183
184 // Some GraphicsLayers paint only the foreground or the background content 184 // Some GraphicsLayers paint only the foreground or the background content
185 void setPaintingPhase(GraphicsLayerPaintingPhase); 185 void setPaintingPhase(GraphicsLayerPaintingPhase);
186 186
187 void setNeedsDisplay(); 187 void setNeedsDisplay();
188 // mark the given rect (in layer coords) as needing dispay. Never goes deep. 188 // mark the given rect (in layer coords) as needing dispay. Never goes deep.
189 void setNeedsDisplayInRect(const FloatRect&); 189 void setNeedsDisplayInRect(const FloatRect&);
190 190
191 void setContentsNeedsDisplay(); 191 void setContentsNeedsDisplay();
192 192
193 // Set that the position/size of the contents (image or video). 193 // Set that the position/size of the contents (image or video).
194 void setContentsRect(const IntRect&); 194 void setContentsRect(const IntRect&);
195 195
196 // Return true if the animation is handled by the compositing system. If thi s returns 196 // Return true if the animation is handled by the compositing system. If thi s returns
197 // false, the animation will be run by AnimationController. 197 // false, the animation will be run by AnimationController.
198 // These methods handle both transitions and keyframe animations. 198 // These methods handle both transitions and keyframe animations.
199 bool addAnimation(PassOwnPtr<WebCompositorAnimation>); 199 bool addAnimation(PassOwnPtr<blink::WebAnimation>);
200 void pauseAnimation(int animationId, double /*timeOffset*/); 200 void pauseAnimation(int animationId, double /*timeOffset*/);
201 void removeAnimation(int animationId); 201 void removeAnimation(int animationId);
202 202
203 // Layer contents 203 // Layer contents
204 void setContentsToImage(Image*); 204 void setContentsToImage(Image*);
205 void setContentsToNinePatch(Image*, const IntRect& aperture); 205 void setContentsToNinePatch(Image*, const IntRect& aperture);
206 void setContentsToPlatformLayer(WebLayer* layer) { setContentsTo(layer); } 206 void setContentsToPlatformLayer(blink::WebLayer* layer) { setContentsTo(laye r); }
207 bool hasContentsLayer() const { return m_contentsLayer; } 207 bool hasContentsLayer() const { return m_contentsLayer; }
208 208
209 // For hosting this GraphicsLayer in a native layer hierarchy. 209 // For hosting this GraphicsLayer in a native layer hierarchy.
210 WebLayer* platformLayer() const; 210 blink::WebLayer* platformLayer() const;
211 211
212 typedef HashMap<int, int> RenderingContextMap; 212 typedef HashMap<int, int> RenderingContextMap;
213 PassRefPtr<JSONObject> layerTreeAsJSON(LayerTreeFlags, RenderingContextMap&) const; 213 PassRefPtr<JSONObject> layerTreeAsJSON(LayerTreeFlags, RenderingContextMap&) const;
214 214
215 int paintCount() const { return m_paintCount; } 215 int paintCount() const { return m_paintCount; }
216 216
217 // Return a string with a human readable form of the layer tree, If debug is true 217 // Return a string with a human readable form of the layer tree, If debug is true
218 // pointers for the layers and timing data will be included in the returned string. 218 // pointers for the layers and timing data will be included in the returned string.
219 String layerTreeAsText(LayerTreeFlags = LayerTreeNormal) const; 219 String layerTreeAsText(LayerTreeFlags = LayerTreeNormal) const;
220 220
221 void resetTrackedRepaints(); 221 void resetTrackedRepaints();
222 void addRepaintRect(const FloatRect&); 222 void addRepaintRect(const FloatRect&);
223 223
224 void addLinkHighlight(LinkHighlightClient*); 224 void addLinkHighlight(LinkHighlightClient*);
225 void removeLinkHighlight(LinkHighlightClient*); 225 void removeLinkHighlight(LinkHighlightClient*);
226 // Exposed for tests 226 // Exposed for tests
227 unsigned numLinkHighlights() { return m_linkHighlights.size(); } 227 unsigned numLinkHighlights() { return m_linkHighlights.size(); }
228 LinkHighlightClient* linkHighlight(int i) { return m_linkHighlights[i]; } 228 LinkHighlightClient* linkHighlight(int i) { return m_linkHighlights[i]; }
229 229
230 void setScrollableArea(ScrollableArea*, bool isMainFrame); 230 void setScrollableArea(ScrollableArea*, bool isMainFrame);
231 ScrollableArea* scrollableArea() const { return m_scrollableArea; } 231 ScrollableArea* scrollableArea() const { return m_scrollableArea; }
232 232
233 WebContentLayer* contentLayer() const { return m_layer.get(); } 233 blink::WebContentLayer* contentLayer() const { return m_layer.get(); }
234 234
235 static void registerContentsLayer(WebLayer*); 235 static void registerContentsLayer(blink::WebLayer*);
236 static void unregisterContentsLayer(WebLayer*); 236 static void unregisterContentsLayer(blink::WebLayer*);
237 237
238 // GraphicsContextPainter implementation. 238 // GraphicsContextPainter implementation.
239 virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE; 239 virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE;
240 240
241 // WebCompositorAnimationDelegate implementation. 241 // WebAnimationDelegate implementation.
242 virtual void notifyAnimationStarted(double monotonicTime, WebCompositorAnima tion::TargetProperty) OVERRIDE; 242 virtual void notifyAnimationStarted(double monotonicTime, blink::WebAnimatio n::TargetProperty) OVERRIDE;
243 virtual void notifyAnimationFinished(double monotonicTime, WebCompositorAnim ation::TargetProperty) OVERRIDE; 243 virtual void notifyAnimationFinished(double monotonicTime, blink::WebAnimati on::TargetProperty) OVERRIDE;
244 244
245 // WebLayerScrollClient implementation. 245 // WebLayerScrollClient implementation.
246 virtual void didScroll() OVERRIDE; 246 virtual void didScroll() OVERRIDE;
247 247
248 protected: 248 protected:
249 String debugName(WebLayer*) const; 249 String debugName(blink::WebLayer*) const;
250 250
251 explicit GraphicsLayer(GraphicsLayerClient*); 251 explicit GraphicsLayer(GraphicsLayerClient*);
252 // GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends. 252 // GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends.
253 friend class GraphicsLayerFactoryChromium; 253 friend class blink::GraphicsLayerFactoryChromium;
254 254
255 // Exposed for tests. 255 // Exposed for tests.
256 virtual WebLayer* contentsLayer() const { return m_contentsLayer; } 256 virtual blink::WebLayer* contentsLayer() const { return m_contentsLayer; }
257 257
258 private: 258 private:
259 // Callback from the underlying graphics system to draw layer contents. 259 // Callback from the underlying graphics system to draw layer contents.
260 void paintGraphicsLayerContents(GraphicsContext&, const IntRect& clip); 260 void paintGraphicsLayerContents(GraphicsContext&, const IntRect& clip);
261 261
262 // Adds a child without calling updateChildList(), so that adding children 262 // Adds a child without calling updateChildList(), so that adding children
263 // can be batched before updating. 263 // can be batched before updating.
264 void addChildInternal(GraphicsLayer*); 264 void addChildInternal(GraphicsLayer*);
265 265
266 #if ENABLE(ASSERT) 266 #if ENABLE(ASSERT)
267 bool hasAncestor(GraphicsLayer*) const; 267 bool hasAncestor(GraphicsLayer*) const;
268 #endif 268 #endif
269 269
270 void setReplicatedLayer(GraphicsLayer* layer) { m_replicatedLayer = layer; } 270 void setReplicatedLayer(GraphicsLayer* layer) { m_replicatedLayer = layer; }
271 271
272 void incrementPaintCount() { ++m_paintCount; } 272 void incrementPaintCount() { ++m_paintCount; }
273 273
274 // Helper functions used by settors to keep layer's the state consistent. 274 // Helper functions used by settors to keep layer's the state consistent.
275 void updateChildList(); 275 void updateChildList();
276 void updateLayerIsDrawable(); 276 void updateLayerIsDrawable();
277 void updateContentsRect(); 277 void updateContentsRect();
278 278
279 void setContentsTo(WebLayer*); 279 void setContentsTo(blink::WebLayer*);
280 void setupContentsLayer(WebLayer*); 280 void setupContentsLayer(blink::WebLayer*);
281 void clearContentsLayerIfUnregistered(); 281 void clearContentsLayerIfUnregistered();
282 WebLayer* contentsLayerIfRegistered(); 282 blink::WebLayer* contentsLayerIfRegistered();
283 283
284 GraphicsLayerClient* m_client; 284 GraphicsLayerClient* m_client;
285 285
286 // Offset from the owning renderer 286 // Offset from the owning renderer
287 IntSize m_offsetFromRenderer; 287 IntSize m_offsetFromRenderer;
288 288
289 // Position is relative to the parent GraphicsLayer 289 // Position is relative to the parent GraphicsLayer
290 FloatPoint m_position; 290 FloatPoint m_position;
291 FloatSize m_size; 291 FloatSize m_size;
292 292
293 TransformationMatrix m_transform; 293 TransformationMatrix m_transform;
294 FloatPoint3D m_transformOrigin; 294 FloatPoint3D m_transformOrigin;
295 295
296 Color m_backgroundColor; 296 Color m_backgroundColor;
297 float m_opacity; 297 float m_opacity;
298 298
299 WebBlendMode m_blendMode; 299 blink::WebBlendMode m_blendMode;
300 300
301 bool m_hasTransformOrigin : 1; 301 bool m_hasTransformOrigin : 1;
302 bool m_contentsOpaque : 1; 302 bool m_contentsOpaque : 1;
303 bool m_shouldFlattenTransform: 1; 303 bool m_shouldFlattenTransform: 1;
304 bool m_backfaceVisibility : 1; 304 bool m_backfaceVisibility : 1;
305 bool m_masksToBounds : 1; 305 bool m_masksToBounds : 1;
306 bool m_drawsContent : 1; 306 bool m_drawsContent : 1;
307 bool m_contentsVisible : 1; 307 bool m_contentsVisible : 1;
308 bool m_isRootForIsolatedGroup : 1; 308 bool m_isRootForIsolatedGroup : 1;
309 309
(...skipping 10 matching lines...) Expand all
320 320
321 GraphicsLayer* m_replicaLayer; // A layer that replicates this layer. We onl y allow one, for now. 321 GraphicsLayer* m_replicaLayer; // A layer that replicates this layer. We onl y allow one, for now.
322 // The replica is not parented; this is the p rimary reference to it. 322 // The replica is not parented; this is the p rimary reference to it.
323 GraphicsLayer* m_replicatedLayer; // For a replica layer, a reference to the original layer. 323 GraphicsLayer* m_replicatedLayer; // For a replica layer, a reference to the original layer.
324 FloatPoint m_replicatedLayerPosition; // For a replica layer, the position o f the replica. 324 FloatPoint m_replicatedLayerPosition; // For a replica layer, the position o f the replica.
325 325
326 IntRect m_contentsRect; 326 IntRect m_contentsRect;
327 327
328 int m_paintCount; 328 int m_paintCount;
329 329
330 OwnPtr<WebContentLayer> m_layer; 330 OwnPtr<blink::WebContentLayer> m_layer;
331 OwnPtr<WebImageLayer> m_imageLayer; 331 OwnPtr<blink::WebImageLayer> m_imageLayer;
332 OwnPtr<WebNinePatchLayer> m_ninePatchLayer; 332 OwnPtr<blink::WebNinePatchLayer> m_ninePatchLayer;
333 WebLayer* m_contentsLayer; 333 blink::WebLayer* m_contentsLayer;
334 // We don't have ownership of m_contentsLayer, but we do want to know if a g iven layer is the 334 // We don't have ownership of m_contentsLayer, but we do want to know if a g iven layer is the
335 // same as our current layer in setContentsTo(). Since m_contentsLayer may b e deleted at this point, 335 // same as our current layer in setContentsTo(). Since m_contentsLayer may b e deleted at this point,
336 // we stash an ID away when we know m_contentsLayer is alive and use that fo r comparisons from that point 336 // we stash an ID away when we know m_contentsLayer is alive and use that fo r comparisons from that point
337 // on. 337 // on.
338 int m_contentsLayerId; 338 int m_contentsLayerId;
339 339
340 Vector<LinkHighlightClient*> m_linkHighlights; 340 Vector<LinkHighlightClient*> m_linkHighlights;
341 341
342 OwnPtr<OpaqueRectTrackingContentLayerDelegate> m_opaqueRectTrackingContentLa yerDelegate; 342 OwnPtr<OpaqueRectTrackingContentLayerDelegate> m_opaqueRectTrackingContentLa yerDelegate;
343 343
344 ScrollableArea* m_scrollableArea; 344 ScrollableArea* m_scrollableArea;
345 GraphicsLayerDebugInfo m_debugInfo; 345 GraphicsLayerDebugInfo m_debugInfo;
346 int m_3dRenderingContext; 346 int m_3dRenderingContext;
347 }; 347 };
348 348
349 } // namespace blink 349 } // namespace blink
350 350
351 #ifndef NDEBUG 351 #ifndef NDEBUG
352 // Outside the WebCore namespace for ease of invocation from gdb. 352 // Outside the WebCore namespace for ease of invocation from gdb.
353 void PLATFORM_EXPORT showGraphicsLayerTree(const blink::GraphicsLayer*); 353 void PLATFORM_EXPORT showGraphicsLayerTree(const blink::GraphicsLayer*);
354 #endif 354 #endif
355 355
356 #endif // GraphicsLayer_h 356 #endif // GraphicsLayer_h
OLDNEW
« no previous file with comments | « Source/core/animation/CompositorAnimationsTestHelper.h ('k') | Source/platform/graphics/GraphicsLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698