layer_delegate.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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
  3. // found in the LICENSE file.
  4. #ifndef UI_COMPOSITOR_LAYER_DELEGATE_H_
  5. #define UI_COMPOSITOR_LAYER_DELEGATE_H_
  6. #include "ui/compositor/compositor_export.h"
  7. #include "ui/compositor/property_change_reason.h"
  8. namespace gfx {
  9. class Rect;
  10. class Transform;
  11. }
  12. namespace ui {
  13. class PaintContext;
  14. // A delegate interface implemented by an object that renders to a Layer.
  15. class COMPOSITOR_EXPORT LayerDelegate {
  16. public:
  17. // Paint content for the layer to the specified context.
  18. virtual void OnPaintLayer(const PaintContext& context) = 0;
  19. // Called when the layer's device scale factor has changed.
  20. virtual void OnDeviceScaleFactorChanged(float old_device_scale_factor,
  21. float new_device_scale_factor) = 0;
  22. // Invoked when the bounds are set. |reason| indicates whether the bounds were
  23. // set directly or by an animation. This will be called at every step of a
  24. // bounds animation.
  25. virtual void OnLayerBoundsChanged(const gfx::Rect& old_bounds,
  26. PropertyChangeReason reason);
  27. // Invoked when the transform or opacity is set. |reason| indicates whether
  28. // the property was set directly or by an animation. This will be called
  29. // before the first frame of an animation is rendered and when the animation
  30. // ends, but not necessarily at every frame of the animation.
  31. virtual void OnLayerTransformed(const gfx::Transform& old_transform,
  32. PropertyChangeReason reason);
  33. virtual void OnLayerOpacityChanged(PropertyChangeReason reason);
  34. // Invoked when the alpha shape is set.
  35. virtual void OnLayerAlphaShapeChanged();
  36. // Invoked when whether the layer fills its bounds opaquely or not changed.
  37. // |reason| indicates whether the property was changed directly or by an
  38. // animation.
  39. virtual void OnLayerFillsBoundsOpaquelyChanged(PropertyChangeReason reason);
  40. // Invoked when the clip rect is set. |reason| indicates whether the clip rect
  41. // was set directly or by an animation. This will be called at every step of a
  42. // clip rect animation.
  43. virtual void OnLayerClipRectChanged(const gfx::Rect& old_rect,
  44. PropertyChangeReason reason);
  45. // Called when it is a good opportunity for the delegate to update any visual
  46. // state or schedule any additional regions to be painted. Soon after this is
  47. // called OnPaintLayer() is called.
  48. virtual void UpdateVisualState();
  49. protected:
  50. virtual ~LayerDelegate() {}
  51. };
  52. } // namespace ui
  53. #endif // UI_COMPOSITOR_LAYER_DELEGATE_H_