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

Side by Side Diff: cc/layer.h

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_LAYER_H_ 5 #ifndef CC_LAYER_H_
6 #define CC_LAYER_H_ 6 #define CC_LAYER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 class PriorityCalculator; 42 class PriorityCalculator;
43 class ResourceUpdateQueue; 43 class ResourceUpdateQueue;
44 class ScrollbarLayer; 44 class ScrollbarLayer;
45 struct AnimationEvent; 45 struct AnimationEvent;
46 struct RenderingStats; 46 struct RenderingStats;
47 47
48 // Base class for composited layers. Special layer types are derived from 48 // Base class for composited layers. Special layer types are derived from
49 // this class. 49 // this class.
50 class CC_EXPORT Layer : public base::RefCounted<Layer>, 50 class CC_EXPORT Layer : public base::RefCounted<Layer>,
51 public LayerAnimationValueObserver { 51 public LayerAnimationValueObserver {
52 public: 52 public:
53 typedef std::vector<scoped_refptr<Layer> > LayerList; 53 typedef std::vector<scoped_refptr<Layer> > LayerList;
54 54
55 static scoped_refptr<Layer> create(); 55 static scoped_refptr<Layer> Create();
56 56
57 int id() const; 57 int id() const { return layer_id_; }
58 58
59 Layer* rootLayer(); 59 Layer* RootLayer();
60 Layer* parent() { return m_parent; } 60 Layer* parent() { return parent_; }
61 const Layer* parent() const { return m_parent; } 61 const Layer* parent() const { return parent_; }
62 void addChild(scoped_refptr<Layer>); 62 void AddChild(scoped_refptr<Layer> child);
63 void insertChild(scoped_refptr<Layer>, size_t index); 63 void InsertChild(scoped_refptr<Layer> child, size_t index);
64 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); 64 void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer);
65 void removeFromParent(); 65 void RemoveFromParent();
66 void removeAllChildren(); 66 void RemoveAllChildren();
67 void setChildren(const LayerList&); 67 void SetChildren(const LayerList& children);
68 68
69 const LayerList& children() const { return m_children; } 69 const LayerList& children() const { return children_; }
70 Layer* childAt(size_t index); 70 Layer* child_at(size_t index) { return children_[index].get(); }
71 71
72 void setAnchorPoint(const gfx::PointF&); 72 void SetAnchorPoint(gfx::PointF anchor_point);
73 gfx::PointF anchorPoint() const { return m_anchorPoint; } 73 gfx::PointF anchor_point() const { return anchor_point_; }
74 74
75 void setAnchorPointZ(float); 75 void SetAnchorPointZ(float anchor_point_z);
76 float anchorPointZ() const { return m_anchorPointZ; } 76 float anchor_point_z() const { return anchor_point_z_; }
77 77
78 virtual void setBackgroundColor(SkColor); 78 virtual void SetBackgroundColor(SkColor background_color);
79 SkColor backgroundColor() const { return m_backgroundColor; } 79 SkColor background_color() const { return background_color_; }
80 80
81 // A layer's bounds are in logical, non-page-scaled pixels (however, the 81 // A layer's bounds are in logical, non-page-scaled pixels (however, the
82 // root layer's bounds are in physical pixels). 82 // root layer's bounds are in physical pixels).
83 void setBounds(const gfx::Size&); 83 void SetBounds(gfx::Size bounds);
84 const gfx::Size& bounds() const { return m_bounds; } 84 gfx::Size bounds() const { return bounds_; }
85 85
86 void setMasksToBounds(bool); 86 void SetMasksToBounds(bool masks_to_bounds);
87 bool masksToBounds() const { return m_masksToBounds; } 87 bool masks_to_bounds() const { return masks_to_bounds_; }
88 88
89 void setMaskLayer(Layer*); 89 void SetMaskLayer(Layer* mask_layer);
90 Layer* maskLayer() { return m_maskLayer.get(); } 90 Layer* mask_layer() { return mask_layer_.get(); }
91 const Layer* maskLayer() const { return m_maskLayer.get(); } 91 const Layer* mask_layer() const { return mask_layer_.get(); }
92 92
93 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); 93 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect);
94 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound s())); } 94 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::RectF(bounds())); }
95 95
96 void setOpacity(float); 96 void SetOpacity(float opacity);
97 float opacity() const; 97 float opacity() const { return opacity_; }
98 bool opacityIsAnimating() const; 98 bool OpacityIsAnimating() const;
99 99
100 void setFilters(const WebKit::WebFilterOperations&); 100 void SetFilters(const WebKit::WebFilterOperations& filters);
101 const WebKit::WebFilterOperations& filters() const { return m_filters; } 101 const WebKit::WebFilterOperations& filters() const { return filters_; }
102 102
103 void setFilter(const skia::RefPtr<SkImageFilter>& filter); 103 void SetFilter(const skia::RefPtr<SkImageFilter>& filter);
104 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } 104 skia::RefPtr<SkImageFilter> filter() const { return filter_; }
105 105
106 // Background filters are filters applied to what is behind this layer, when they are viewed through non-opaque 106 // Background filters are filters applied to what is behind this layer, when
107 // regions in this layer. They are used through the WebLayer interface, and are not exposed to HTML. 107 // they are viewed through non-opaque regions in this layer. They are used
108 void setBackgroundFilters(const WebKit::WebFilterOperations&); 108 // through the WebLayer interface, and are not exposed to HTML.
109 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back groundFilters; } 109 void SetBackgroundFilters(const WebKit::WebFilterOperations& filters);
110 110 const WebKit::WebFilterOperations& background_filters() const {
111 virtual void setContentsOpaque(bool); 111 return background_filters_;
112 bool contentsOpaque() const { return m_contentsOpaque; } 112 }
113 113
114 void setPosition(const gfx::PointF&); 114 virtual void SetContentsOpaque(bool opaque);
115 gfx::PointF position() const { return m_position; } 115 bool contents_opaque() const { return contents_opaque_; }
116 116
117 void setIsContainerForFixedPositionLayers(bool); 117 void SetPosition(gfx::PointF position);
118 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe dPositionLayers; } 118 gfx::PointF position() const { return position_; }
119 119
120 void setFixedToContainerLayer(bool); 120 void SetIsContainerForFixedPositionLayers(bool container);
121 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } 121 bool is_container_for_fixed_position_layers() const {
122 122 return is_container_for_fixed_position_layers_;
123 void setSublayerTransform(const gfx::Transform&); 123 }
124 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform ; } 124
125 125 void SetFixedToContainerLayer(bool fixed_to_container_layer);
126 void setTransform(const gfx::Transform&); 126 bool fixed_to_container_layer() const { return fixed_to_container_layer_; }
127 const gfx::Transform& transform() const; 127
128 bool transformIsAnimating() const; 128 void SetSublayerTransform(const gfx::Transform& sublayer_transform);
129 129 const gfx::Transform& sublayer_transform() const {
130 DrawProperties<Layer, RenderSurface>& drawProperties() { return m_drawProper ties; } 130 return sublayer_transform_;
131 const DrawProperties<Layer, RenderSurface>& drawProperties() const { return m_drawProperties; } 131 }
132 132
133 // The following are shortcut accessors to get various information from m_dr awProperties 133 void SetTransform(const gfx::Transform& transform);
134 const gfx::Transform& drawTransform() const { return m_drawProperties.target _space_transform; } 134 const gfx::Transform& transform() const { return transform_; }
135 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties .screen_space_transform; } 135 bool TransformIsAnimating() const;
136 float drawOpacity() const { return m_drawProperties.opacity; } 136
137 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani mating; } 137 DrawProperties<Layer, RenderSurface>& draw_properties() {
138 bool drawTransformIsAnimating() const { return m_drawProperties.target_space _transform_is_animating; } 138 return draw_properties_;
139 bool screenSpaceTransformIsAnimating() const { return m_drawProperties.scree n_space_transform_is_animating; } 139 }
140 bool screenSpaceOpacityIsAnimating() const { return m_drawProperties.screen_ space_opacity_is_animating; } 140 const DrawProperties<Layer, RenderSurface>& draw_properties() const {
141 bool canUseLCDText() const { return m_drawProperties.can_use_lcd_text; } 141 return draw_properties_;
142 bool isClipped() const { return m_drawProperties.is_clipped; } 142 }
143 const gfx::Rect& clipRect() const { return m_drawProperties.clip_rect; } 143
144 const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawa ble_content_rect; } 144 // The following are shortcut accessors to get various information from
145 const gfx::Rect& visibleContentRect() const { return m_drawProperties.visibl e_content_rect; } 145 // draw_properties_
146 Layer* renderTarget() { DCHECK(!m_drawProperties.render_target || m_drawProp erties.render_target->renderSurface()); return m_drawProperties.render_target; } 146 const gfx::Transform& draw_transform() const {
147 const Layer* renderTarget() const { DCHECK(!m_drawProperties.render_target | | m_drawProperties.render_target->renderSurface()); return m_drawProperties.rend er_target; } 147 return draw_properties_.target_space_transform;
148 RenderSurface* renderSurface() const { return m_drawProperties.render_surfac e.get(); } 148 }
149 149 const gfx::Transform& screen_space_transform() const {
150 void setScrollOffset(gfx::Vector2d); 150 return draw_properties_.screen_space_transform;
151 gfx::Vector2d scrollOffset() const { return m_scrollOffset; } 151 }
152 152 float draw_opacity() const { return draw_properties_.opacity; }
153 void setMaxScrollOffset(gfx::Vector2d); 153 bool draw_opacity_is_animating() const {
154 gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; } 154 return draw_properties_.opacity_is_animating;
155 155 }
156 void setScrollable(bool); 156 bool draw_transform_is_animating() const {
157 bool scrollable() const { return m_scrollable; } 157 return draw_properties_.target_space_transform_is_animating;
158 158 }
159 void setShouldScrollOnMainThread(bool); 159 bool screen_space_transform_is_animating() const {
160 bool shouldScrollOnMainThread() const { return m_shouldScrollOnMainThread; } 160 return draw_properties_.screen_space_transform_is_animating;
161 161 }
162 void setHaveWheelEventHandlers(bool); 162 bool screen_space_opacity_is_animating() const {
163 bool haveWheelEventHandlers() const { return m_haveWheelEventHandlers; } 163 return draw_properties_.screen_space_opacity_is_animating;
164 164 }
165 void setNonFastScrollableRegion(const Region&); 165 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; }
166 const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRe gion; } 166 bool is_clipped() const { return draw_properties_.is_clipped; }
167 167 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
168 void setTouchEventHandlerRegion(const Region&); 168 gfx::Rect drawable_content_rect() const {
169 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe gion; } 169 return draw_properties_.drawable_content_rect;
170 170 }
171 void setLayerScrollClient(WebKit::WebLayerScrollClient* layerScrollClient) { m_layerScrollClient = layerScrollClient; } 171 gfx::Rect visible_content_rect() const {
172 172 return draw_properties_.visible_content_rect;
173 void setDrawCheckerboardForMissingTiles(bool); 173 }
174 bool drawCheckerboardForMissingTiles() const { return m_drawCheckerboardForM issingTiles; } 174 Layer* render_target() {
175 175 DCHECK(!draw_properties_.render_target ||
176 bool forceRenderSurface() const { return m_forceRenderSurface; } 176 draw_properties_.render_target->render_surface());
177 void setForceRenderSurface(bool); 177 return draw_properties_.render_target;
178 178 }
179 gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); } 179 const Layer* render_target() const {
180 180 DCHECK(!draw_properties_.render_target ||
181 void setImplTransform(const gfx::Transform&); 181 draw_properties_.render_target->render_surface());
182 const gfx::Transform& implTransform() const { return m_implTransform; } 182 return draw_properties_.render_target;
183 183 }
184 void setDoubleSided(bool); 184 RenderSurface* render_surface() const {
185 bool doubleSided() const { return m_doubleSided; } 185 return draw_properties_.render_surface.get();
186 186 }
187 void setPreserves3D(bool preserve3D) { m_preserves3D = preserve3D; } 187
188 bool preserves3D() const { return m_preserves3D; } 188 void SetScrollOffset(gfx::Vector2d scroll_offset);
189 189 gfx::Vector2d scroll_offset() const { return scroll_offset_; }
190 void setUseParentBackfaceVisibility(bool useParentBackfaceVisibility) { m_us eParentBackfaceVisibility = useParentBackfaceVisibility; } 190
191 bool useParentBackfaceVisibility() const { return m_useParentBackfaceVisibil ity; } 191 void SetMaxScrollOffset(gfx::Vector2d max_scroll_offset);
192 192 gfx::Vector2d max_scroll_offset() const { return max_scroll_offset_; }
193 virtual void setLayerTreeHost(LayerTreeHost*); 193
194 194 void SetScrollable(bool scrollable);
195 bool hasDelegatedContent() const { return false; } 195 bool scrollable() const { return scrollable_; }
196 bool hasContributingDelegatedRenderPasses() const { return false; } 196
197 197 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread);
198 void setIsDrawable(bool); 198 bool should_scroll_on_main_thread() const {
199 199 return should_scroll_on_main_thread_;
200 void setReplicaLayer(Layer*); 200 }
201 Layer* replicaLayer() { return m_replicaLayer.get(); } 201
202 const Layer* replicaLayer() const { return m_replicaLayer.get(); } 202 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers);
203 203 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
204 bool hasMask() const { return !!m_maskLayer; } 204
205 bool hasReplica() const { return !!m_replicaLayer; } 205 void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region);
206 bool replicaHasMask() const { return m_replicaLayer && (m_maskLayer || m_rep licaLayer->m_maskLayer); } 206 const Region& non_fast_scrollable_region() const {
207 207 return non_fast_scrollable_region_;
208 // These methods typically need to be overwritten by derived classes. 208 }
209 virtual bool drawsContent() const; 209
210 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering Stats*) { } 210 void SetTouchEventHandlerRegion(const Region& touch_event_handler_region);
211 virtual bool needMoreUpdates(); 211 const Region& touch_event_handler_region() const {
212 virtual void setIsMask(bool) { } 212 return touch_event_handler_region_;
213 213 }
214 void setDebugName(const std::string&); 214
215 215 void set_layer_scroll_client(WebKit::WebLayerScrollClient* client) {
216 virtual void pushPropertiesTo(LayerImpl*); 216 layer_scroll_client_ = client;
217 217 }
218 void clearRenderSurface() { m_drawProperties.render_surface.reset(); } 218
219 void createRenderSurface(); 219 void SetDrawCheckerboardForMissingTiles(bool checkerboard);
220 220 bool DrawCheckerboardForMissingTiles() const {
221 // The contentsScale converts from logical, non-page-scaled pixels to target pixels. 221 return draw_checkerboard_for_missing_tiles_;
222 // The contentsScale is 1 for the root layer as it is already in physical pi xels. 222 }
223 // By default contentsScale is forced to be 1 except for subclasses of Conte ntsScalingLayer. 223
224 float contentsScaleX() const { return m_drawProperties.contents_scale_x; } 224 void SetForceRenderSurface(bool force_render_surface);
225 float contentsScaleY() const { return m_drawProperties.contents_scale_y; } 225 bool force_render_surface() const { return force_render_surface_; }
226 gfx::Size contentBounds() const { return m_drawProperties.content_bounds; } 226
227 virtual void calculateContentsScale( 227 gfx::Vector2d scroll_delta() const { return gfx::Vector2d(); }
228 float idealContentsScale, 228
229 bool animatingTransformToScreen, 229 void SetImplTransform(const gfx::Transform& transform);
230 float* contentsScaleX, 230 const gfx::Transform& impl_transform() const { return impl_transform_; }
231 float* contentsScaleY, 231
232 gfx::Size* contentBounds); 232 void SetDoubleSided(bool double_sided);
233 233 bool double_sided() const { return double_sided_; }
234 // The scale at which contents should be rastered, to match the scale at 234
235 // which they will drawn to the screen. This scale is a component of the 235 void SetPreserves3d(bool preserves_3d) { preserves_3d_ = preserves_3d; }
236 // contentsScale() but does not include page/device scale factors. 236 bool preserves_3d() const { return preserves_3d_; }
237 float rasterScale() const { return m_rasterScale; } 237
238 void setRasterScale(float scale); 238 void set_use_parent_backface_visibility(bool use) {
239 239 use_parent_backface_visibility_ = use;
240 // When true, the rasterScale() will be set by the compositor. If false, it 240 }
241 // will use whatever value is given to it by the embedder. 241 bool use_parent_backface_visibility() const {
242 bool automaticallyComputeRasterScale() { return m_automaticallyComputeRaster Scale; } 242 return use_parent_backface_visibility_;
243 void setAutomaticallyComputeRasterScale(bool); 243 }
244 244
245 void forceAutomaticRasterScaleToBeRecomputed(); 245 virtual void SetLayerTreeHost(LayerTreeHost* host);
246 246
247 // When true, the layer's contents are not scaled by the current page scale factor. 247 bool HasDelegatedContent() const { return false; }
248 // setBoundsContainPageScale recursively sets the value on all child layers. 248 bool HasContributingDelegatedRenderPasses() const { return false; }
249 void setBoundsContainPageScale(bool); 249
250 bool boundsContainPageScale() const { return m_boundsContainPageScale; } 250 void SetIsDrawable(bool is_drawable);
251 251
252 LayerTreeHost* layerTreeHost() const { return m_layerTreeHost; } 252 void SetReplicaLayer(Layer* layer);
253 253 Layer* replica_layer() { return replica_layer_.get(); }
254 // Set the priority of all desired textures in this layer. 254 const Layer* replica_layer() const { return replica_layer_.get(); }
255 virtual void setTexturePriorities(const PriorityCalculator&) { } 255
256 256 bool has_mask() const { return !!mask_layer_; }
257 bool AddAnimation(scoped_ptr<Animation>); 257 bool has_replica() const { return !!replica_layer_; }
258 void PauseAnimation(int animationId, double timeOffset); 258 bool replica_has_mask() const {
259 void RemoveAnimation(int animationId); 259 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_);
260 260 }
261 void suspendAnimations(double monotonicTime); 261
262 void resumeAnimations(double monotonicTime); 262 // These methods typically need to be overwritten by derived classes.
263 263 virtual bool DrawsContent() const;
264 LayerAnimationController* layerAnimationController() { return m_layerAnimati onController.get(); } 264 virtual void Update(ResourceUpdateQueue* queue,
265 void setLayerAnimationController(scoped_refptr<LayerAnimationController>); 265 const OcclusionTracker* occlusion,
266 scoped_refptr<LayerAnimationController> releaseLayerAnimationController(); 266 RenderingStats* stats) {}
267 267 virtual bool NeedMoreUpdates();
268 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } 268 virtual void SetIsMask(bool is_mask) {}
269 269
270 bool hasActiveAnimation() const; 270 void SetDebugName(const std::string& debug_name);
271 271
272 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT ime); 272 virtual void PushPropertiesTo(LayerImpl* layer);
273 virtual void notifyAnimationFinished(double wallClockTime); 273
274 virtual void notifyAnimationPropertyUpdate(const AnimationEvent& event); 274 void ClearRenderSurface() { draw_properties_.render_surface.reset(); }
275 275 void CreateRenderSurface();
276 void addLayerAnimationEventObserver(LayerAnimationEventObserver* animationOb server); 276
277 void removeLayerAnimationEventObserver(LayerAnimationEventObserver* animatio nObserver); 277 // The contentsScale converts from logical, non-page-scaled pixels to target
278 278 // pixels. The contentsScale is 1 for the root layer as it is already in
279 virtual Region visibleContentOpaqueRegion() const; 279 // physical pixels. By default contentsScale is forced to be 1 except for
280 280 // subclasses of ContentsScalingLayer.
281 virtual ScrollbarLayer* toScrollbarLayer(); 281 float contents_scale_x() const { return draw_properties_.contents_scale_x; }
282 282 float contents_scale_y() const { return draw_properties_.contents_scale_y; }
283 gfx::Rect layerRectToContentRect(const gfx::RectF& layerRect) const; 283 gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
284 284
285 // In impl-side painting, this returns true if this layer type is not 285 virtual void CalculateContentsScale(float ideal_contents_scale,
286 // compatible with the main thread running freely, such as a double-buffered 286 bool animating_transform_to_screen,
287 // canvas that doesn't want to be triple-buffered across all three trees. 287 float* contents_scale_x,
288 virtual bool blocksPendingCommit() const; 288 float* contents_scale_y,
289 // Returns true if anything in this tree blocksPendingCommit. 289 gfx::Size* content_bounds);
290 bool blocksPendingCommitRecursive() const; 290
291 291 // The scale at which contents should be rastered, to match the scale at
292 virtual bool canClipSelf() const; 292 // which they will drawn to the screen. This scale is a component of the
293 293 // contentsScale() but does not include page/device scale factors.
294 // Constructs a LayerImpl of the correct runtime type for this Layer type. 294 void SetRasterScale(float scale);
295 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* treeImpl); 295 float raster_scale() const { return raster_scale_; }
296 296
297 bool needsDisplayForTesting() const { return m_needsDisplay; } 297 // When true, the RasterScale() will be set by the compositor. If false, it
298 void resetNeedsDisplayForTesting() { m_needsDisplay = false; } 298 // will use whatever value is given to it by the embedder.
299 299 bool automatically_compute_raster_scale() {
300 protected: 300 return automatically_compute_raster_scale_;
301 friend class LayerImpl; 301 }
302 friend class TreeSynchronizer; 302 void SetAutomaticallyComputeRasterScale(bool automatic);
303 virtual ~Layer(); 303
304 304 void ForceAutomaticRasterScaleToBeRecomputed();
305 Layer(); 305
306 306 // When true, the layer's contents are not scaled by the current page scale
307 void setNeedsCommit(); 307 // factor. SetBoundsContainPageScale() recursively sets the value on all
308 void setNeedsFullTreeSync(); 308 // child layers.
309 309 void SetBoundsContainPageScale(bool bounds_contain_page_scale);
310 // This flag is set when layer need repainting/updating. 310 bool bounds_contain_page_scale() const { return bounds_contain_page_scale_; }
311 bool m_needsDisplay; 311
312 312 LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
313 // Tracks whether this layer may have changed stacking order with its siblin gs. 313
314 bool m_stackingOrderChanged; 314 // Set the priority of all desired textures in this layer.
315 315 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {}
316 // The update rect is the region of the compositor resource that was actuall y updated by the compositor. 316
317 // For layers that may do updating outside the compositor's control (i.e. pl ugin layers), this information 317 bool AddAnimation(scoped_ptr<Animation> animation);
318 // is not available and the update rect will remain empty. 318 void PauseAnimation(int animation_id, double time_offset);
319 // Note this rect is in layer space (not content space). 319 void RemoveAnimation(int animation_id);
320 gfx::RectF m_updateRect; 320
321 321 void SuspendAnimations(double monotonic_time);
322 scoped_refptr<Layer> m_maskLayer; 322 void ResumeAnimations(double monotonic_time);
323 323
324 int m_layerId; 324 LayerAnimationController* layer_animation_controller() {
325 325 return layer_animation_controller_.get();
326 // When true, the layer is about to perform an update. Any commit requests 326 }
327 // will be handled implcitly after the update completes. 327 void SetLayerAnimationController(
328 bool m_ignoreSetNeedsCommit; 328 scoped_refptr<LayerAnimationController> controller);
329 329 scoped_refptr<LayerAnimationController> ReleaseLayerAnimationController();
330 private: 330
331 friend class base::RefCounted<Layer>; 331 void set_layer_animation_delegate(WebKit::WebAnimationDelegate* delegate) {
332 332 layer_animation_delegate_ = delegate;
333 void setParent(Layer*); 333 }
334 bool hasAncestor(Layer*) const; 334
335 bool descendantIsFixedToContainerLayer() const; 335 bool HasActiveAnimation() const;
336 336
337 // Returns the index of the child or -1 if not found. 337 virtual void NotifyAnimationStarted(const AnimationEvent& event,
338 int indexOfChild(const Layer*); 338 double wall_clock_time);
339 339 virtual void NotifyAnimationFinished(double wall_clock_time);
340 // This should only be called from removeFromParent. 340 virtual void NotifyAnimationPropertyUpdate(const AnimationEvent& event);
341 void removeChildOrDependent(Layer*); 341
342 342 void AddLayerAnimationEventObserver(
343 // LayerAnimationValueObserver implementation. 343 LayerAnimationEventObserver* animation_observer);
344 virtual void OnOpacityAnimated(float) OVERRIDE; 344 void RemoveLayerAnimationEventObserver(
345 virtual void OnTransformAnimated(const gfx::Transform&) OVERRIDE; 345 LayerAnimationEventObserver* animation_observer);
346 virtual bool IsActive() const OVERRIDE; 346
347 347 virtual Region VisibleContentOpaqueRegion() const;
348 LayerList m_children; 348
349 Layer* m_parent; 349 virtual ScrollbarLayer* ToScrollbarLayer();
350 350
351 // Layer instances have a weak pointer to their LayerTreeHost. 351 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
352 // This pointer value is nil when a Layer is not in a tree and is 352
353 // updated via setLayerTreeHost() if a layer moves between trees. 353 // In impl-side painting, this returns true if this layer type is not
354 LayerTreeHost* m_layerTreeHost; 354 // compatible with the main thread running freely, such as a double-buffered
355 355 // canvas that doesn't want to be triple-buffered across all three trees.
356 ObserverList<LayerAnimationEventObserver> m_layerAnimationObservers; 356 virtual bool BlocksPendingCommit() const;
357 357 // Returns true if anything in this tree blocksPendingCommit.
358 scoped_refptr<LayerAnimationController> m_layerAnimationController; 358 bool BlocksPendingCommitRecursive() const;
359 359
360 // Layer properties. 360 virtual bool CanClipSelf() const;
361 gfx::Size m_bounds; 361
362 362 // Constructs a LayerImpl of the correct runtime type for this Layer type.
363 gfx::Vector2d m_scrollOffset; 363 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
364 gfx::Vector2d m_maxScrollOffset; 364
365 bool m_scrollable; 365 bool NeedsDisplayForTesting() const { return needs_display_; }
366 bool m_shouldScrollOnMainThread; 366 void ResetNeedsDisplayForTesting() { needs_display_ = false; }
367 bool m_haveWheelEventHandlers; 367
368 Region m_nonFastScrollableRegion; 368 protected:
369 Region m_touchEventHandlerRegion; 369 friend class LayerImpl;
370 gfx::PointF m_position; 370 friend class TreeSynchronizer;
371 gfx::PointF m_anchorPoint; 371 virtual ~Layer();
372 SkColor m_backgroundColor; 372
373 std::string m_debugName; 373 Layer();
374 float m_opacity; 374
375 skia::RefPtr<SkImageFilter> m_filter; 375 void SetNeedsCommit();
376 WebKit::WebFilterOperations m_filters; 376 void SetNeedsFullTreeSync();
377 WebKit::WebFilterOperations m_backgroundFilters; 377
378 float m_anchorPointZ; 378 // This flag is set when layer need repainting/updating.
379 bool m_isContainerForFixedPositionLayers; 379 bool needs_display_;
380 bool m_fixedToContainerLayer; 380
381 bool m_isDrawable; 381 // Tracks whether this layer may have changed stacking order with its
382 bool m_masksToBounds; 382 // siblings.
383 bool m_contentsOpaque; 383 bool stacking_order_changed_;
384 bool m_doubleSided; 384
385 bool m_preserves3D; 385 // The update rect is the region of the compositor resource that was
386 bool m_useParentBackfaceVisibility; 386 // actually updated by the compositor. For layers that may do updating
387 bool m_drawCheckerboardForMissingTiles; 387 // outside the compositor's control (i.e. plugin layers), this information
388 bool m_forceRenderSurface; 388 // is not available and the update rect will remain empty.
389 389 // Note this rect is in layer space (not content space).
390 gfx::Transform m_transform; 390 gfx::RectF update_rect_;
391 gfx::Transform m_sublayerTransform; 391
392 392 scoped_refptr<Layer> mask_layer_;
393 // Replica layer used for reflections. 393
394 scoped_refptr<Layer> m_replicaLayer; 394 int layer_id_;
395 395
396 // Transient properties. 396 // When true, the layer is about to perform an update. Any commit requests
397 float m_rasterScale; 397 // will be handled implcitly after the update completes.
398 bool m_automaticallyComputeRasterScale; 398 bool ignore_set_needs_commit_;
399 bool m_boundsContainPageScale; 399
400 400 private:
401 gfx::Transform m_implTransform; 401 friend class base::RefCounted<Layer>;
402 402
403 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; 403 void SetParent(Layer* layer);
404 WebKit::WebLayerScrollClient* m_layerScrollClient; 404 bool HasAncestor(Layer* ancestor) const;
405 405 bool DescendantIsFixedToContainerLayer() const;
406 DrawProperties<Layer, RenderSurface> m_drawProperties; 406
407 // Returns the index of the child or -1 if not found.
408 int IndexOfChild(const Layer* reference);
409
410 // This should only be called from RemoveFromParent().
411 void RemoveChildOrDependent(Layer* child);
412
413 // LayerAnimationValueObserver implementation.
414 virtual void OnOpacityAnimated(float opacity) OVERRIDE;
415 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
416 virtual bool IsActive() const OVERRIDE;
417
418 LayerList children_;
419 Layer* parent_;
420
421 // Layer instances have a weak pointer to their LayerTreeHost.
422 // This pointer value is nil when a Layer is not in a tree and is
423 // updated via SetLayerTreeHost() if a layer moves between trees.
424 LayerTreeHost* layer_tree_host_;
425
426 ObserverList<LayerAnimationEventObserver> layer_animation_observers_;
427
428 scoped_refptr<LayerAnimationController> layer_animation_controller_;
429
430 // Layer properties.
431 gfx::Size bounds_;
432
433 gfx::Vector2d scroll_offset_;
434 gfx::Vector2d max_scroll_offset_;
435 bool scrollable_;
436 bool should_scroll_on_main_thread_;
437 bool have_wheel_event_handlers_;
438 Region non_fast_scrollable_region_;
439 Region touch_event_handler_region_;
440 gfx::PointF position_;
441 gfx::PointF anchor_point_;
442 SkColor background_color_;
443 std::string debug_name_;
444 float opacity_;
445 skia::RefPtr<SkImageFilter> filter_;
446 WebKit::WebFilterOperations filters_;
447 WebKit::WebFilterOperations background_filters_;
448 float anchor_point_z_;
449 bool is_container_for_fixed_position_layers_;
450 bool fixed_to_container_layer_;
451 bool is_drawable_;
452 bool masks_to_bounds_;
453 bool contents_opaque_;
454 bool double_sided_;
455 bool preserves_3d_;
456 bool use_parent_backface_visibility_;
457 bool draw_checkerboard_for_missing_tiles_;
458 bool force_render_surface_;
459
460 gfx::Transform transform_;
461 gfx::Transform sublayer_transform_;
462
463 // Replica layer used for reflections.
464 scoped_refptr<Layer> replica_layer_;
465
466 // Transient properties.
467 float raster_scale_;
468 bool automatically_compute_raster_scale_;
469 bool bounds_contain_page_scale_;
470
471 gfx::Transform impl_transform_;
472
473 WebKit::WebAnimationDelegate* layer_animation_delegate_;
474 WebKit::WebLayerScrollClient* layer_scroll_client_;
475
476 DrawProperties<Layer, RenderSurface> draw_properties_;
407 }; 477 };
enne (OOO) 2013/03/12 02:40:19 DISALLOW_COPY_AND_ASSIGN
danakj 2013/03/12 02:47:16 Done.
408 478
409 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*);
410
411 } // namespace cc 479 } // namespace cc
412 480
413 #endif // CC_LAYER_H_ 481 #endif // CC_LAYER_H_
OLDNEW
« no previous file with comments | « cc/io_surface_layer_impl.cc ('k') | cc/layer.cc » ('j') | cc/layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698