| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_COMPOSITOR_LAYER_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_H_ |
| 6 #define UI_COMPOSITOR_LAYER_H_ | 6 #define UI_COMPOSITOR_LAYER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // Note that this _does not_ invalidate any region of this layer; use | 280 // Note that this _does not_ invalidate any region of this layer; use |
| 281 // SchedulePaint() for that. | 281 // SchedulePaint() for that. |
| 282 void ScheduleDraw(); | 282 void ScheduleDraw(); |
| 283 | 283 |
| 284 // Uses damaged rectangles recorded in |damaged_region_| to invalidate the | 284 // Uses damaged rectangles recorded in |damaged_region_| to invalidate the |
| 285 // |cc_layer_|. | 285 // |cc_layer_|. |
| 286 void SendDamagedRects(); | 286 void SendDamagedRects(); |
| 287 | 287 |
| 288 const SkRegion& damaged_region() const { return damaged_region_; } | 288 const SkRegion& damaged_region() const { return damaged_region_; } |
| 289 | 289 |
| 290 void CompleteAllAnimations(); |
| 291 |
| 290 // Suppresses painting the content by disconnecting |delegate_|. | 292 // Suppresses painting the content by disconnecting |delegate_|. |
| 291 void SuppressPaint(); | 293 void SuppressPaint(); |
| 292 | 294 |
| 293 // Notifies the layer that the device scale factor has changed. | 295 // Notifies the layer that the device scale factor has changed. |
| 294 void OnDeviceScaleFactorChanged(float device_scale_factor); | 296 void OnDeviceScaleFactorChanged(float device_scale_factor); |
| 295 | 297 |
| 296 // Requets a copy of the layer's output as a texture or bitmap. | 298 // Requets a copy of the layer's output as a texture or bitmap. |
| 297 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); | 299 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); |
| 298 | 300 |
| 299 // ContentLayerClient | 301 // ContentLayerClient |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 bool HasPendingThreadedAnimations() { | 333 bool HasPendingThreadedAnimations() { |
| 332 return pending_threaded_animations_.size() != 0; | 334 return pending_threaded_animations_.size() != 0; |
| 333 } | 335 } |
| 334 | 336 |
| 335 // Triggers a call to SwitchToLayer. | 337 // Triggers a call to SwitchToLayer. |
| 336 void SwitchCCLayerForTest(); | 338 void SwitchCCLayerForTest(); |
| 337 | 339 |
| 338 private: | 340 private: |
| 339 friend class LayerOwner; | 341 friend class LayerOwner; |
| 340 | 342 |
| 343 void CollectAnimators(std::vector<scoped_refptr<LayerAnimator> >* animators); |
| 344 |
| 341 // Stacks |child| above or below |other|. Helper method for StackAbove() and | 345 // Stacks |child| above or below |other|. Helper method for StackAbove() and |
| 342 // StackBelow(). | 346 // StackBelow(). |
| 343 void StackRelativeTo(Layer* child, Layer* other, bool above); | 347 void StackRelativeTo(Layer* child, Layer* other, bool above); |
| 344 | 348 |
| 345 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; | 349 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 346 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; | 350 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 347 | 351 |
| 348 // Implementation of LayerAnimatorDelegate | 352 // Implementation of LayerAnimatorDelegate |
| 349 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; | 353 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; |
| 350 virtual void SetTransformFromAnimation( | 354 virtual void SetTransformFromAnimation( |
| 351 const gfx::Transform& transform) OVERRIDE; | 355 const gfx::Transform& transform) OVERRIDE; |
| 352 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; | 356 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; |
| 353 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; | 357 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; |
| 354 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; | 358 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; |
| 355 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; | 359 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; |
| 356 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; | 360 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; |
| 357 virtual void ScheduleDrawForAnimation() OVERRIDE; | 361 virtual void ScheduleDrawForAnimation() OVERRIDE; |
| 358 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; | 362 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; |
| 359 virtual gfx::Transform GetTransformForAnimation() const OVERRIDE; | 363 virtual gfx::Transform GetTransformForAnimation() const OVERRIDE; |
| 360 virtual float GetOpacityForAnimation() const OVERRIDE; | 364 virtual float GetOpacityForAnimation() const OVERRIDE; |
| 361 virtual bool GetVisibilityForAnimation() const OVERRIDE; | 365 virtual bool GetVisibilityForAnimation() const OVERRIDE; |
| 362 virtual float GetBrightnessForAnimation() const OVERRIDE; | 366 virtual float GetBrightnessForAnimation() const OVERRIDE; |
| 363 virtual float GetGrayscaleForAnimation() const OVERRIDE; | 367 virtual float GetGrayscaleForAnimation() const OVERRIDE; |
| 364 virtual SkColor GetColorForAnimation() const OVERRIDE; | 368 virtual SkColor GetColorForAnimation() const OVERRIDE; |
| 365 virtual float GetDeviceScaleFactor() const OVERRIDE; | 369 virtual float GetDeviceScaleFactor() const OVERRIDE; |
| 366 virtual void AddThreadedAnimation( | 370 virtual void AddThreadedAnimation( |
| 367 scoped_ptr<cc::Animation> animation) OVERRIDE; | 371 scoped_ptr<cc::Animation> animation) OVERRIDE; |
| 368 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; | 372 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; |
| 373 virtual LayerAnimatorCollection* GetLayerAnimatorCollection() OVERRIDE; |
| 369 | 374 |
| 370 // Creates a corresponding composited layer for |type_|. | 375 // Creates a corresponding composited layer for |type_|. |
| 371 void CreateWebLayer(); | 376 void CreateWebLayer(); |
| 372 | 377 |
| 373 // Recomputes and sets to |cc_layer_|. | 378 // Recomputes and sets to |cc_layer_|. |
| 374 void RecomputeDrawsContentAndUVRect(); | 379 void RecomputeDrawsContentAndUVRect(); |
| 375 void RecomputePosition(); | 380 void RecomputePosition(); |
| 376 | 381 |
| 377 // Set all filters which got applied to the layer. | 382 // Set all filters which got applied to the layer. |
| 378 void SetLayerFilters(); | 383 void SetLayerFilters(); |
| 379 | 384 |
| 380 // Set all filters which got applied to the layer background. | 385 // Set all filters which got applied to the layer background. |
| 381 void SetLayerBackgroundFilters(); | 386 void SetLayerBackgroundFilters(); |
| 382 | 387 |
| 383 // Cleanup |cc_layer_| and replaces it with |new_layer|. | 388 // Cleanup |cc_layer_| and replaces it with |new_layer|. |
| 384 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); | 389 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); |
| 385 | 390 |
| 386 // We cannot send animations to our cc_layer_ until we have been added to a | 391 // We cannot send animations to our cc_layer_ until we have been added to a |
| 387 // layer tree. Instead, we hold on to these animations in | 392 // layer tree. Instead, we hold on to these animations in |
| 388 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to | 393 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to |
| 389 // be called once we have been added to a tree. | 394 // be called once we have been added to a tree. |
| 390 void SendPendingThreadedAnimations(); | 395 void SendPendingThreadedAnimations(); |
| 391 | 396 |
| 397 void AddAnimatorsInTreeToCollection(LayerAnimatorCollection* collection); |
| 398 void RemoveAnimatorsInTreeFromCollection(LayerAnimatorCollection* collection); |
| 399 |
| 400 // Returns whether the layer has an animating LayerAnimator. |
| 401 bool IsAnimating() const; |
| 402 |
| 392 const LayerType type_; | 403 const LayerType type_; |
| 393 | 404 |
| 394 Compositor* compositor_; | 405 Compositor* compositor_; |
| 395 | 406 |
| 396 Layer* parent_; | 407 Layer* parent_; |
| 397 | 408 |
| 398 // This layer's children, in bottom-to-top stacking order. | 409 // This layer's children, in bottom-to-top stacking order. |
| 399 std::vector<Layer*> children_; | 410 std::vector<Layer*> children_; |
| 400 | 411 |
| 401 gfx::Rect bounds_; | 412 gfx::Rect bounds_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // The size of the frame or texture in DIP, set when SetShowDelegatedContent | 482 // The size of the frame or texture in DIP, set when SetShowDelegatedContent |
| 472 // or SetTextureMailbox was called. | 483 // or SetTextureMailbox was called. |
| 473 gfx::Size frame_size_in_dip_; | 484 gfx::Size frame_size_in_dip_; |
| 474 | 485 |
| 475 DISALLOW_COPY_AND_ASSIGN(Layer); | 486 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 476 }; | 487 }; |
| 477 | 488 |
| 478 } // namespace ui | 489 } // namespace ui |
| 479 | 490 |
| 480 #endif // UI_COMPOSITOR_LAYER_H_ | 491 #endif // UI_COMPOSITOR_LAYER_H_ |
| OLD | NEW |