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

Side by Side Diff: cc/layer.h

Issue 11280263: Organize internal properties of cc/ layer types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Complete patch Created 8 years 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 <public/WebFilterOperations.h> 8 #include <public/WebFilterOperations.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "cc/cc_export.h" 13 #include "cc/cc_export.h"
14 #include "cc/draw_properties.h"
14 #include "cc/layer_animation_controller.h" 15 #include "cc/layer_animation_controller.h"
15 #include "cc/occlusion_tracker.h" 16 #include "cc/occlusion_tracker.h"
16 #include "cc/region.h" 17 #include "cc/region.h"
17 #include "cc/render_surface.h" 18 #include "cc/render_surface.h"
18 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 #include "ui/gfx/rect_f.h" 21 #include "ui/gfx/rect_f.h"
21 #include "ui/gfx/transform.h" 22 #include "ui/gfx/transform.h"
22 23
23 namespace WebKit { 24 namespace WebKit {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 122
122 void setFixedToContainerLayer(bool); 123 void setFixedToContainerLayer(bool);
123 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } 124 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; }
124 125
125 void setSublayerTransform(const gfx::Transform&); 126 void setSublayerTransform(const gfx::Transform&);
126 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform ; } 127 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform ; }
127 128
128 void setTransform(const gfx::Transform&); 129 void setTransform(const gfx::Transform&);
129 bool transformIsAnimating() const; 130 bool transformIsAnimating() const;
130 131
131 const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } 132 DrawProperties<Layer>& drawProperties() { return m_drawProperties; }
132 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC ontentRect = visibleContentRect; } 133 const DrawProperties<Layer>& drawProperties() const { return m_drawPropertie s; }
134
135 // The following are shortcut accessors to get various information from m_dr awProperties
136 const gfx::Transform& drawTransform() const { return m_drawProperties.drawTr ansform; }
137 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties .screenSpaceTransform; }
138 float drawOpacity() const { return m_drawProperties.drawOpacity; }
139 bool drawOpacityIsAnimating() const { return m_drawProperties.drawOpacityIsA nimating; }
140 bool drawTransformIsAnimating() const { return m_drawProperties.drawTransfor mIsAnimating; }
141 bool screenSpaceTransformIsAnimating() const { return m_drawProperties.scree nSpaceTransformIsAnimating; }
142 bool isClipped() const { return m_drawProperties.isClipped; }
143 const gfx::Rect& clipRect() const { return m_drawProperties.clipRect; }
144 const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawa bleContentRect; }
145 const gfx::Rect& visibleContentRect() const { return m_drawProperties.visibl eContentRect; }
146 Layer* renderTarget() { DCHECK(!m_drawProperties.renderTarget || m_drawPrope rties.renderTarget->renderSurface()); return m_drawProperties.renderTarget; }
147 const Layer* renderTarget() const { DCHECK(!m_drawProperties.renderTarget || m_drawProperties.renderTarget->renderSurface()); return m_drawProperties.render Target; }
133 148
134 void setScrollOffset(gfx::Vector2d); 149 void setScrollOffset(gfx::Vector2d);
135 gfx::Vector2d scrollOffset() const { return m_scrollOffset; } 150 gfx::Vector2d scrollOffset() const { return m_scrollOffset; }
136 151
137 void setMaxScrollOffset(gfx::Vector2d); 152 void setMaxScrollOffset(gfx::Vector2d);
138 gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; } 153 gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; }
139 154
140 void setScrollable(bool); 155 void setScrollable(bool);
141 bool scrollable() const { return m_scrollable; } 156 bool scrollable() const { return m_scrollable; }
142 157
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 virtual void bindContentsTexture() { } 216 virtual void bindContentsTexture() { }
202 217
203 void setDebugName(const std::string&); 218 void setDebugName(const std::string&);
204 219
205 virtual void pushPropertiesTo(LayerImpl*); 220 virtual void pushPropertiesTo(LayerImpl*);
206 221
207 void clearRenderSurface() { m_renderSurface.reset(); } 222 void clearRenderSurface() { m_renderSurface.reset(); }
208 RenderSurface* renderSurface() const { return m_renderSurface.get(); } 223 RenderSurface* renderSurface() const { return m_renderSurface.get(); }
209 void createRenderSurface(); 224 void createRenderSurface();
210 225
211 float drawOpacity() const { return m_drawOpacity; }
212 void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
213
214 bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; }
215 void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityI sAnimating = drawOpacityIsAnimating; }
216
217 void setRenderTarget(Layer* target) { m_renderTarget = target; }
218 Layer* renderTarget() { DCHECK(!m_renderTarget || m_renderTarget->renderSurf ace()); return m_renderTarget; }
219 const Layer* renderTarget() const { DCHECK(!m_renderTarget || m_renderTarget ->renderSurface()); return m_renderTarget; }
220
221 bool drawTransformIsAnimating() const { return m_drawTransformIsAnimating; }
222 void setDrawTransformIsAnimating(bool animating) { m_drawTransformIsAnimatin g = animating; }
223 bool screenSpaceTransformIsAnimating() const { return m_screenSpaceTransform IsAnimating; }
224 void setScreenSpaceTransformIsAnimating(bool animating) { m_screenSpaceTrans formIsAnimating = animating; }
225
226 // This moves from layer space, with origin in the center to target space wi th origin in the top left.
227 // That is, it converts from logical, non-page-scaled, to target pixels (and if the target is the
228 // root render surface, then this converts to physical pixels).
229 const gfx::Transform& drawTransform() const { return m_drawTransform; }
230 void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matr ix; }
231 // This moves from content space, with origin the top left to screen space w ith origin in the top left.
232 // It converts logical, non-page-scaled pixels to physical pixels.
233 const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTra nsform; }
234 void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTr ansform = matrix; }
235
236 bool isClipped() const { return m_isClipped; }
237 void setIsClipped(bool isClipped) { m_isClipped = isClipped; }
238
239 const gfx::Rect& clipRect() const { return m_clipRect; }
240 void setClipRect(const gfx::Rect& clipRect) { m_clipRect = clipRect; }
241
242 const gfx::Rect& drawableContentRect() const { return m_drawableContentRect; }
243 void setDrawableContentRect(const gfx::Rect& rect) { m_drawableContentRect = rect; }
244
245 // The contentsScale converts from logical, non-page-scaled pixels to target pixels. 226 // The contentsScale converts from logical, non-page-scaled pixels to target pixels.
246 // The contentsScale is 1 for the root layer as it is already in physical pi xels. 227 // The contentsScale is 1 for the root layer as it is already in physical pi xels.
247 // By default contentsScale is forced to be 1 except for subclasses of Conte ntsScalingLayer. 228 // By default contentsScale is forced to be 1 except for subclasses of Conte ntsScalingLayer.
248 virtual float contentsScaleX() const; 229 virtual float contentsScaleX() const;
249 virtual float contentsScaleY() const; 230 virtual float contentsScaleY() const;
250 virtual void setContentsScale(float contentsScale) { } 231 virtual void setContentsScale(float contentsScale) { }
danakj 2012/12/03 18:54:36 setContentsScale is called from calcDrawEtc on the
shawnsingh 2012/12/03 19:27:44 Been meaning to discuss this with you offline =)
enne (OOO) 2012/12/03 21:18:14 Given that contentsScale isn't stored on Layer in
danakj 2012/12/03 21:29:45 Oh, good point! Putting it in the struct is a bit
251 232
252 // The scale at which contents should be rastered, to match the scale at 233 // The scale at which contents should be rastered, to match the scale at
253 // which they will drawn to the screen. This scale is a component of the 234 // which they will drawn to the screen. This scale is a component of the
254 // contentsScale() but does not include page/device scale factors. 235 // contentsScale() but does not include page/device scale factors.
255 float rasterScale() const { return m_rasterScale; } 236 float rasterScale() const { return m_rasterScale; }
256 void setRasterScale(float scale); 237 void setRasterScale(float scale);
257 238
258 // When true, the rasterScale() will be set by the compositor. If false, it 239 // When true, the rasterScale() will be set by the compositor. If false, it
259 // will use whatever value is given to it by the embedder. 240 // will use whatever value is given to it by the embedder.
260 bool automaticallyComputeRasterScale() { return m_automaticallyComputeRaster Scale; } 241 bool automaticallyComputeRasterScale() { return m_automaticallyComputeRaster Scale; }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Layer instances have a weak pointer to their LayerTreeHost. 330 // Layer instances have a weak pointer to their LayerTreeHost.
350 // This pointer value is nil when a Layer is not in a tree and is 331 // This pointer value is nil when a Layer is not in a tree and is
351 // updated via setLayerTreeHost() if a layer moves between trees. 332 // updated via setLayerTreeHost() if a layer moves between trees.
352 LayerTreeHost* m_layerTreeHost; 333 LayerTreeHost* m_layerTreeHost;
353 334
354 scoped_ptr<LayerAnimationController> m_layerAnimationController; 335 scoped_ptr<LayerAnimationController> m_layerAnimationController;
355 336
356 // Layer properties. 337 // Layer properties.
357 gfx::Size m_bounds; 338 gfx::Size m_bounds;
358 339
359 // Uses layer's content space.
360 gfx::Rect m_visibleContentRect;
361
362 gfx::Vector2d m_scrollOffset; 340 gfx::Vector2d m_scrollOffset;
363 gfx::Vector2d m_maxScrollOffset; 341 gfx::Vector2d m_maxScrollOffset;
364 bool m_scrollable; 342 bool m_scrollable;
365 bool m_shouldScrollOnMainThread; 343 bool m_shouldScrollOnMainThread;
366 bool m_haveWheelEventHandlers; 344 bool m_haveWheelEventHandlers;
367 Region m_nonFastScrollableRegion; 345 Region m_nonFastScrollableRegion;
368 bool m_nonFastScrollableRegionChanged; 346 bool m_nonFastScrollableRegionChanged;
369 Region m_touchEventHandlerRegion; 347 Region m_touchEventHandlerRegion;
370 bool m_touchEventHandlerRegionChanged; 348 bool m_touchEventHandlerRegionChanged;
371 gfx::PointF m_position; 349 gfx::PointF m_position;
(...skipping 17 matching lines...) Expand all
389 bool m_drawCheckerboardForMissingTiles; 367 bool m_drawCheckerboardForMissingTiles;
390 bool m_forceRenderSurface; 368 bool m_forceRenderSurface;
391 369
392 gfx::Transform m_transform; 370 gfx::Transform m_transform;
393 gfx::Transform m_sublayerTransform; 371 gfx::Transform m_sublayerTransform;
394 372
395 // Replica layer used for reflections. 373 // Replica layer used for reflections.
396 scoped_refptr<Layer> m_replicaLayer; 374 scoped_refptr<Layer> m_replicaLayer;
397 375
398 // Transient properties. 376 // Transient properties.
399 scoped_ptr<RenderSurface> m_renderSurface; 377 scoped_ptr<RenderSurface> m_renderSurface;
danakj 2012/12/03 18:54:36 render surface is created/assigned in calcDraw. Sh
shawnsingh 2012/12/03 19:27:44 Agreed, I'll move it over
400 float m_drawOpacity;
401 bool m_drawOpacityIsAnimating;
402
403 Layer* m_renderTarget;
404
405 gfx::Transform m_drawTransform;
406 gfx::Transform m_screenSpaceTransform;
407 bool m_drawTransformIsAnimating;
408 bool m_screenSpaceTransformIsAnimating;
409
410 // Uses target surface space.
411 gfx::Rect m_drawableContentRect;
412 gfx::Rect m_clipRect;
413
414 // True if the layer is clipped by m_clipRect
415 bool m_isClipped;
416 378
417 float m_rasterScale; 379 float m_rasterScale;
418 bool m_automaticallyComputeRasterScale; 380 bool m_automaticallyComputeRasterScale;
419 bool m_boundsContainPageScale; 381 bool m_boundsContainPageScale;
420 382
421 gfx::Transform m_implTransform; 383 gfx::Transform m_implTransform;
422 384
423 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; 385 WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
424 WebKit::WebLayerScrollClient* m_layerScrollClient; 386 WebKit::WebLayerScrollClient* m_layerScrollClient;
387
388 DrawProperties<Layer> m_drawProperties;
425 }; 389 };
426 390
427 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*); 391 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*);
428 392
429 } // namespace cc 393 } // namespace cc
430 394
431 #endif // CC_LAYER_H_ 395 #endif // CC_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698