| OLD | NEW |
| 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 "skia/ext/refptr.h" | 19 #include "skia/ext/refptr.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "third_party/skia/include/core/SkImageFilter.h" | 21 #include "third_party/skia/include/core/SkImageFilter.h" |
| 21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 22 #include "ui/gfx/rect_f.h" | 23 #include "ui/gfx/rect_f.h" |
| 23 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, RenderSurface>& drawProperties() { return m_drawProper
ties; } |
| 132 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC
ontentRect = visibleContentRect; } | 133 const DrawProperties<Layer, RenderSurface>& drawProperties() const { return
m_drawProperties; } |
| 134 |
| 135 // The following are shortcut accessors to get various information from m_dr
awProperties |
| 136 const gfx::Transform& drawTransform() const { return m_drawProperties.target
_space_transform; } |
| 137 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties
.screen_space_transform; } |
| 138 float drawOpacity() const { return m_drawProperties.opacity; } |
| 139 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani
mating; } |
| 140 bool drawTransformIsAnimating() const { return m_drawProperties.target_space
_transform_is_animating; } |
| 141 bool screenSpaceTransformIsAnimating() const { return m_drawProperties.scree
n_space_transform_is_animating; } |
| 142 bool isClipped() const { return m_drawProperties.is_clipped; } |
| 143 const gfx::Rect& clipRect() const { return m_drawProperties.clip_rect; } |
| 144 const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawa
ble_content_rect; } |
| 145 const gfx::Rect& visibleContentRect() const { return m_drawProperties.visibl
e_content_rect; } |
| 146 Layer* renderTarget() { DCHECK(!m_drawProperties.render_target || m_drawProp
erties.render_target->renderSurface()); return m_drawProperties.render_target; } |
| 147 const Layer* renderTarget() const { DCHECK(!m_drawProperties.render_target |
| m_drawProperties.render_target->renderSurface()); return m_drawProperties.rend
er_target; } |
| 148 RenderSurface* renderSurface() const { return m_drawProperties.render_surfac
e.get(); } |
| 133 | 149 |
| 134 void setScrollOffset(gfx::Vector2d); | 150 void setScrollOffset(gfx::Vector2d); |
| 135 gfx::Vector2d scrollOffset() const { return m_scrollOffset; } | 151 gfx::Vector2d scrollOffset() const { return m_scrollOffset; } |
| 136 | 152 |
| 137 void setMaxScrollOffset(gfx::Vector2d); | 153 void setMaxScrollOffset(gfx::Vector2d); |
| 138 gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; } | 154 gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; } |
| 139 | 155 |
| 140 void setScrollable(bool); | 156 void setScrollable(bool); |
| 141 bool scrollable() const { return m_scrollable; } | 157 bool scrollable() const { return m_scrollable; } |
| 142 | 158 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 virtual bool drawsContent() const; | 213 virtual bool drawsContent() const; |
| 198 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering
Stats&) { } | 214 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering
Stats&) { } |
| 199 virtual bool needMoreUpdates(); | 215 virtual bool needMoreUpdates(); |
| 200 virtual void setIsMask(bool) { } | 216 virtual void setIsMask(bool) { } |
| 201 virtual void bindContentsTexture() { } | 217 virtual void bindContentsTexture() { } |
| 202 | 218 |
| 203 void setDebugName(const std::string&); | 219 void setDebugName(const std::string&); |
| 204 | 220 |
| 205 virtual void pushPropertiesTo(LayerImpl*); | 221 virtual void pushPropertiesTo(LayerImpl*); |
| 206 | 222 |
| 207 void clearRenderSurface() { m_renderSurface.reset(); } | 223 void clearRenderSurface() { m_drawProperties.render_surface.reset(); } |
| 208 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) { } |
| 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. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // Layer instances have a weak pointer to their LayerTreeHost. | 331 // Layer instances have a weak pointer to their LayerTreeHost. |
| 351 // This pointer value is nil when a Layer is not in a tree and is | 332 // This pointer value is nil when a Layer is not in a tree and is |
| 352 // updated via setLayerTreeHost() if a layer moves between trees. | 333 // updated via setLayerTreeHost() if a layer moves between trees. |
| 353 LayerTreeHost* m_layerTreeHost; | 334 LayerTreeHost* m_layerTreeHost; |
| 354 | 335 |
| 355 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 336 scoped_ptr<LayerAnimationController> m_layerAnimationController; |
| 356 | 337 |
| 357 // Layer properties. | 338 // Layer properties. |
| 358 gfx::Size m_bounds; | 339 gfx::Size m_bounds; |
| 359 | 340 |
| 360 // Uses layer's content space. | |
| 361 gfx::Rect m_visibleContentRect; | |
| 362 | |
| 363 gfx::Vector2d m_scrollOffset; | 341 gfx::Vector2d m_scrollOffset; |
| 364 gfx::Vector2d m_maxScrollOffset; | 342 gfx::Vector2d m_maxScrollOffset; |
| 365 bool m_scrollable; | 343 bool m_scrollable; |
| 366 bool m_shouldScrollOnMainThread; | 344 bool m_shouldScrollOnMainThread; |
| 367 bool m_haveWheelEventHandlers; | 345 bool m_haveWheelEventHandlers; |
| 368 Region m_nonFastScrollableRegion; | 346 Region m_nonFastScrollableRegion; |
| 369 bool m_nonFastScrollableRegionChanged; | 347 bool m_nonFastScrollableRegionChanged; |
| 370 Region m_touchEventHandlerRegion; | 348 Region m_touchEventHandlerRegion; |
| 371 bool m_touchEventHandlerRegionChanged; | 349 bool m_touchEventHandlerRegionChanged; |
| 372 gfx::PointF m_position; | 350 gfx::PointF m_position; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 390 bool m_drawCheckerboardForMissingTiles; | 368 bool m_drawCheckerboardForMissingTiles; |
| 391 bool m_forceRenderSurface; | 369 bool m_forceRenderSurface; |
| 392 | 370 |
| 393 gfx::Transform m_transform; | 371 gfx::Transform m_transform; |
| 394 gfx::Transform m_sublayerTransform; | 372 gfx::Transform m_sublayerTransform; |
| 395 | 373 |
| 396 // Replica layer used for reflections. | 374 // Replica layer used for reflections. |
| 397 scoped_refptr<Layer> m_replicaLayer; | 375 scoped_refptr<Layer> m_replicaLayer; |
| 398 | 376 |
| 399 // Transient properties. | 377 // Transient properties. |
| 400 scoped_ptr<RenderSurface> m_renderSurface; | |
| 401 float m_drawOpacity; | |
| 402 bool m_drawOpacityIsAnimating; | |
| 403 | |
| 404 Layer* m_renderTarget; | |
| 405 | |
| 406 gfx::Transform m_drawTransform; | |
| 407 gfx::Transform m_screenSpaceTransform; | |
| 408 bool m_drawTransformIsAnimating; | |
| 409 bool m_screenSpaceTransformIsAnimating; | |
| 410 | |
| 411 // Uses target surface space. | |
| 412 gfx::Rect m_drawableContentRect; | |
| 413 gfx::Rect m_clipRect; | |
| 414 | |
| 415 // True if the layer is clipped by m_clipRect | |
| 416 bool m_isClipped; | |
| 417 | |
| 418 float m_rasterScale; | 378 float m_rasterScale; |
| 419 bool m_automaticallyComputeRasterScale; | 379 bool m_automaticallyComputeRasterScale; |
| 420 bool m_boundsContainPageScale; | 380 bool m_boundsContainPageScale; |
| 421 | 381 |
| 422 gfx::Transform m_implTransform; | 382 gfx::Transform m_implTransform; |
| 423 | 383 |
| 424 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; | 384 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; |
| 425 WebKit::WebLayerScrollClient* m_layerScrollClient; | 385 WebKit::WebLayerScrollClient* m_layerScrollClient; |
| 386 |
| 387 DrawProperties<Layer, RenderSurface> m_drawProperties; |
| 426 }; | 388 }; |
| 427 | 389 |
| 428 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); | 390 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); |
| 429 | 391 |
| 430 } // namespace cc | 392 } // namespace cc |
| 431 | 393 |
| 432 #endif // CC_LAYER_H_ | 394 #endif // CC_LAYER_H_ |
| OLD | NEW |