| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_IMPL_H_ | 5 #ifndef CC_LAYER_IMPL_H_ |
| 6 #define CC_LAYER_IMPL_H_ | 6 #define CC_LAYER_IMPL_H_ |
| 7 | 7 |
| 8 #include <public/WebFilterOperations.h> | 8 #include <public/WebFilterOperations.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "cc/cc_export.h" | 13 #include "cc/cc_export.h" |
| 14 #include "cc/draw_properties.h" |
| 14 #include "cc/input_handler.h" | 15 #include "cc/input_handler.h" |
| 15 #include "cc/layer_animation_controller.h" | 16 #include "cc/layer_animation_controller.h" |
| 16 #include "cc/region.h" | 17 #include "cc/region.h" |
| 17 #include "cc/render_pass.h" | 18 #include "cc/render_pass.h" |
| 18 #include "cc/render_surface_impl.h" | 19 #include "cc/render_surface_impl.h" |
| 19 #include "cc/resource_provider.h" | 20 #include "cc/resource_provider.h" |
| 20 #include "cc/scoped_ptr_vector.h" | 21 #include "cc/scoped_ptr_vector.h" |
| 21 #include "cc/shared_quad_state.h" | 22 #include "cc/shared_quad_state.h" |
| 22 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
| 23 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Debug layer name. | 156 // Debug layer name. |
| 156 void setDebugName(const std::string& debugName) { m_debugName = debugName; } | 157 void setDebugName(const std::string& debugName) { m_debugName = debugName; } |
| 157 std::string debugName() const { return m_debugName; } | 158 std::string debugName() const { return m_debugName; } |
| 158 | 159 |
| 159 bool showDebugBorders() const; | 160 bool showDebugBorders() const; |
| 160 | 161 |
| 161 RenderSurfaceImpl* renderSurface() const { return m_renderSurface.get(); } | 162 RenderSurfaceImpl* renderSurface() const { return m_renderSurface.get(); } |
| 162 void createRenderSurface(); | 163 void createRenderSurface(); |
| 163 void clearRenderSurface() { m_renderSurface.reset(); } | 164 void clearRenderSurface() { m_renderSurface.reset(); } |
| 164 | 165 |
| 165 float drawOpacity() const { return m_drawOpacity; } | 166 DrawProperties<LayerImpl>& drawProperties() { return m_drawProperties; } |
| 166 void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } | 167 const DrawProperties<LayerImpl>& drawProperties() const { return m_drawPrope
rties; } |
| 167 | 168 |
| 168 bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; } | 169 // The following are shortcut accessors to get various information from m_dr
awProperties |
| 169 void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityI
sAnimating = drawOpacityIsAnimating; } | 170 const gfx::Transform& drawTransform() const { return m_drawProperties.drawTr
ansform; } |
| 170 | 171 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties
.screenSpaceTransform; } |
| 171 void setRenderTarget(LayerImpl* target) { m_renderTarget = target; } | 172 float drawOpacity() const { return m_drawProperties.drawOpacity; } |
| 172 LayerImpl* renderTarget() { DCHECK(!m_renderTarget || m_renderTarget->render
Surface()); return m_renderTarget; } | 173 bool drawOpacityIsAnimating() const { return m_drawProperties.drawOpacityIsA
nimating; } |
| 173 const LayerImpl* renderTarget() const { DCHECK(!m_renderTarget || m_renderTa
rget->renderSurface()); return m_renderTarget; } | 174 bool drawTransformIsAnimating() const { return m_drawProperties.drawTransfor
mIsAnimating; } |
| 175 bool screenSpaceTransformIsAnimating() const { return m_drawProperties.scree
nSpaceTransformIsAnimating; } |
| 176 bool isClipped() const { return m_drawProperties.isClipped; } |
| 177 const gfx::Rect& clipRect() const { return m_drawProperties.clipRect; } |
| 178 const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawa
bleContentRect; } |
| 179 const gfx::Rect& visibleContentRect() const { return m_drawProperties.visibl
eContentRect; } |
| 180 LayerImpl* renderTarget() { DCHECK(!m_drawProperties.renderTarget || m_drawP
roperties.renderTarget->renderSurface()); return m_drawProperties.renderTarget;
} |
| 181 const LayerImpl* renderTarget() const { DCHECK(!m_drawProperties.renderTarge
t || m_drawProperties.renderTarget->renderSurface()); return m_drawProperties.re
nderTarget; } |
| 174 | 182 |
| 175 // The client should be responsible for setting bounds, contentBounds and | 183 // The client should be responsible for setting bounds, contentBounds and |
| 176 // contentsScale to appropriate values. LayerImpl doesn't calculate any of | 184 // contentsScale to appropriate values. LayerImpl doesn't calculate any of |
| 177 // them from the other values. | 185 // them from the other values. |
| 178 | 186 |
| 179 void setBounds(const gfx::Size&); | 187 void setBounds(const gfx::Size&); |
| 180 const gfx::Size& bounds() const { return m_bounds; } | 188 const gfx::Size& bounds() const { return m_bounds; } |
| 181 | 189 |
| 182 // ContentBounds may be [0, 1) pixels larger than bounds * contentsScale. | 190 // ContentBounds may be [0, 1) pixels larger than bounds * contentsScale. |
| 183 // Don't calculate scale from it. Use contentsScale instead for accuracy. | 191 // Don't calculate scale from it. Use contentsScale instead for accuracy. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableR
egion = region; } | 227 void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableR
egion = region; } |
| 220 | 228 |
| 221 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe
gion; } | 229 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe
gion; } |
| 222 void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerR
egion = region; } | 230 void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerR
egion = region; } |
| 223 | 231 |
| 224 void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerbo
ardForMissingTiles = checkerboard; } | 232 void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerbo
ardForMissingTiles = checkerboard; } |
| 225 bool drawCheckerboardForMissingTiles() const; | 233 bool drawCheckerboardForMissingTiles() const; |
| 226 | 234 |
| 227 InputHandlerClient::ScrollStatus tryScroll(const gfx::PointF& screenSpacePoi
nt, InputHandlerClient::ScrollInputType) const; | 235 InputHandlerClient::ScrollStatus tryScroll(const gfx::PointF& screenSpacePoi
nt, InputHandlerClient::ScrollInputType) const; |
| 228 | 236 |
| 229 const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } | |
| 230 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC
ontentRect = visibleContentRect; } | |
| 231 | |
| 232 bool doubleSided() const { return m_doubleSided; } | 237 bool doubleSided() const { return m_doubleSided; } |
| 233 void setDoubleSided(bool); | 238 void setDoubleSided(bool); |
| 234 | 239 |
| 235 void setTransform(const gfx::Transform&); | 240 void setTransform(const gfx::Transform&); |
| 236 bool transformIsAnimating() const; | 241 bool transformIsAnimating() const; |
| 237 | 242 |
| 238 const gfx::Transform& drawTransform() const { return m_drawTransform; } | |
| 239 void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matr
ix; } | |
| 240 const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTra
nsform; } | |
| 241 void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTr
ansform = matrix; } | |
| 242 | |
| 243 bool drawTransformIsAnimating() const { return m_drawTransformIsAnimating; } | |
| 244 void setDrawTransformIsAnimating(bool animating) { m_drawTransformIsAnimatin
g = animating; } | |
| 245 bool screenSpaceTransformIsAnimating() const { return m_screenSpaceTransform
IsAnimating; } | |
| 246 void setScreenSpaceTransformIsAnimating(bool animating) { m_screenSpaceTrans
formIsAnimating = animating; } | |
| 247 | |
| 248 bool isClipped() const { return m_isClipped; } | |
| 249 void setIsClipped(bool isClipped) { m_isClipped = isClipped; } | |
| 250 | |
| 251 const gfx::Rect& clipRect() const { return m_clipRect; } | |
| 252 void setClipRect(const gfx::Rect& clipRect) { m_clipRect = clipRect; } | |
| 253 | |
| 254 const gfx::Rect& drawableContentRect() const { return m_drawableContentRect;
} | |
| 255 void setDrawableContentRect(const gfx::Rect& rect) { m_drawableContentRect =
rect; } | |
| 256 | |
| 257 const gfx::RectF& updateRect() const { return m_updateRect; } | 243 const gfx::RectF& updateRect() const { return m_updateRect; } |
| 258 void setUpdateRect(const gfx::RectF& updateRect) { m_updateRect = updateRect
; } | 244 void setUpdateRect(const gfx::RectF& updateRect) { m_updateRect = updateRect
; } |
| 259 | 245 |
| 260 std::string layerTreeAsText() const; | 246 std::string layerTreeAsText() const; |
| 261 | 247 |
| 262 void setStackingOrderChanged(bool); | 248 void setStackingOrderChanged(bool); |
| 263 | 249 |
| 264 bool layerPropertyChanged() const { return m_layerPropertyChanged || layerIs
AlwaysDamaged(); } | 250 bool layerPropertyChanged() const { return m_layerPropertyChanged || layerIs
AlwaysDamaged(); } |
| 265 bool layerSurfacePropertyChanged() const; | 251 bool layerSurfacePropertyChanged() const; |
| 266 | 252 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 333 |
| 348 // Tracks if drawing-related properties have changed since last redraw. | 334 // Tracks if drawing-related properties have changed since last redraw. |
| 349 bool m_layerPropertyChanged; | 335 bool m_layerPropertyChanged; |
| 350 | 336 |
| 351 // Indicates that a property has changed on this layer that would not | 337 // Indicates that a property has changed on this layer that would not |
| 352 // affect the pixels on its target surface, but would require redrawing | 338 // affect the pixels on its target surface, but would require redrawing |
| 353 // but would require redrawing the targetSurface onto its ancestor targetSur
face. | 339 // but would require redrawing the targetSurface onto its ancestor targetSur
face. |
| 354 // For layers that do not own a surface this flag acts as m_layerPropertyCha
nged. | 340 // For layers that do not own a surface this flag acts as m_layerPropertyCha
nged. |
| 355 bool m_layerSurfacePropertyChanged; | 341 bool m_layerSurfacePropertyChanged; |
| 356 | 342 |
| 357 // Uses layer's content space. | |
| 358 gfx::Rect m_visibleContentRect; | |
| 359 bool m_masksToBounds; | 343 bool m_masksToBounds; |
| 360 bool m_contentsOpaque; | 344 bool m_contentsOpaque; |
| 361 float m_opacity; | 345 float m_opacity; |
| 362 gfx::PointF m_position; | 346 gfx::PointF m_position; |
| 363 bool m_preserves3D; | 347 bool m_preserves3D; |
| 364 bool m_useParentBackfaceVisibility; | 348 bool m_useParentBackfaceVisibility; |
| 365 bool m_drawCheckerboardForMissingTiles; | 349 bool m_drawCheckerboardForMissingTiles; |
| 366 gfx::Transform m_sublayerTransform; | 350 gfx::Transform m_sublayerTransform; |
| 367 gfx::Transform m_transform; | 351 gfx::Transform m_transform; |
| 368 bool m_useLCDText; | 352 bool m_useLCDText; |
| 369 | 353 |
| 370 bool m_drawsContent; | 354 bool m_drawsContent; |
| 371 bool m_forceRenderSurface; | 355 bool m_forceRenderSurface; |
| 372 | 356 |
| 373 // Set for the layer that other layers are fixed to. | 357 // Set for the layer that other layers are fixed to. |
| 374 bool m_isContainerForFixedPositionLayers; | 358 bool m_isContainerForFixedPositionLayers; |
| 375 // This is true if the layer should be fixed to the closest ancestor contain
er. | 359 // This is true if the layer should be fixed to the closest ancestor contain
er. |
| 376 bool m_fixedToContainerLayer; | 360 bool m_fixedToContainerLayer; |
| 377 | 361 |
| 378 gfx::Vector2dF m_scrollDelta; | 362 gfx::Vector2dF m_scrollDelta; |
| 379 gfx::Vector2d m_sentScrollDelta; | 363 gfx::Vector2d m_sentScrollDelta; |
| 380 gfx::Vector2d m_maxScrollOffset; | 364 gfx::Vector2d m_maxScrollOffset; |
| 381 gfx::Transform m_implTransform; | 365 gfx::Transform m_implTransform; |
| 382 | 366 |
| 383 // The layer whose coordinate space this layer draws into. This can be | |
| 384 // either the same layer (m_renderTarget == this) or an ancestor of this | |
| 385 // layer. | |
| 386 LayerImpl* m_renderTarget; | |
| 387 | |
| 388 // The global depth value of the center of the layer. This value is used | 367 // The global depth value of the center of the layer. This value is used |
| 389 // to sort layers from back to front. | 368 // to sort layers from back to front. |
| 390 float m_drawDepth; | 369 float m_drawDepth; |
| 391 float m_drawOpacity; | |
| 392 bool m_drawOpacityIsAnimating; | |
| 393 | 370 |
| 394 // Debug layer name. | 371 // Debug layer name. |
| 395 std::string m_debugName; | 372 std::string m_debugName; |
| 396 | 373 |
| 397 WebKit::WebFilterOperations m_filters; | 374 WebKit::WebFilterOperations m_filters; |
| 398 WebKit::WebFilterOperations m_backgroundFilters; | 375 WebKit::WebFilterOperations m_backgroundFilters; |
| 399 SkImageFilter* m_filter; | 376 SkImageFilter* m_filter; |
| 400 | 377 |
| 401 gfx::Transform m_drawTransform; | |
| 402 gfx::Transform m_screenSpaceTransform; | |
| 403 bool m_drawTransformIsAnimating; | |
| 404 bool m_screenSpaceTransformIsAnimating; | |
| 405 | |
| 406 #ifndef NDEBUG | 378 #ifndef NDEBUG |
| 407 bool m_betweenWillDrawAndDidDraw; | 379 bool m_betweenWillDrawAndDidDraw; |
| 408 #endif | 380 #endif |
| 409 | 381 |
| 410 // Render surface associated with this layer. The layer and its descendants | 382 // Render surface associated with this layer. The layer and its descendants |
| 411 // will render to this surface. | 383 // will render to this surface. |
| 412 scoped_ptr<RenderSurfaceImpl> m_renderSurface; | 384 scoped_ptr<RenderSurfaceImpl> m_renderSurface; |
| 413 | 385 |
| 414 // Uses target surface's space. | |
| 415 gfx::Rect m_drawableContentRect; | |
| 416 gfx::Rect m_clipRect; | |
| 417 | |
| 418 // True if the layer is clipped by m_clipRect. | |
| 419 bool m_isClipped; | |
| 420 | |
| 421 // Rect indicating what was repainted/updated during update. | 386 // Rect indicating what was repainted/updated during update. |
| 422 // Note that plugin layers bypass this and leave it empty. | 387 // Note that plugin layers bypass this and leave it empty. |
| 423 // Uses layer's content space. | 388 // Uses layer's content space. |
| 424 gfx::RectF m_updateRect; | 389 gfx::RectF m_updateRect; |
| 425 | 390 |
| 426 // Manages animations for this layer. | 391 // Manages animations for this layer. |
| 427 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 392 scoped_ptr<LayerAnimationController> m_layerAnimationController; |
| 428 | 393 |
| 429 // Manages scrollbars for this layer | 394 // Manages scrollbars for this layer |
| 430 scoped_ptr<ScrollbarAnimationController> m_scrollbarAnimationController; | 395 scoped_ptr<ScrollbarAnimationController> m_scrollbarAnimationController; |
| 431 | 396 |
| 397 // Group of properties that need to be computed based on the layer tree |
| 398 // hierarchy before layers can be drawn. |
| 399 DrawProperties<LayerImpl> m_drawProperties; |
| 400 |
| 432 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 401 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
| 433 }; | 402 }; |
| 434 | 403 |
| 435 void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*>
::iterator end, LayerSorter*); | 404 void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*>
::iterator end, LayerSorter*); |
| 436 | 405 |
| 437 } | 406 } |
| 438 | 407 |
| 439 #endif // CC_LAYER_IMPL_H_ | 408 #endif // CC_LAYER_IMPL_H_ |
| OLD | NEW |