ink_drop_mask.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2016 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_VIEWS_ANIMATION_INK_DROP_MASK_H_
  5. #define UI_VIEWS_ANIMATION_INK_DROP_MASK_H_
  6. #include "base/gtest_prod_util.h"
  7. #include "ui/compositor/layer.h"
  8. #include "ui/compositor/layer_delegate.h"
  9. #include "ui/views/views_export.h"
  10. class SkPath;
  11. namespace views {
  12. // Base class for different ink drop masks. It is responsible for creating the
  13. // ui::Layer that can be set as the mask layer for ink drop layer. Note that the
  14. // mask's layer size (passed in the constructor) should always match size of the
  15. // layer it is masking.
  16. class VIEWS_EXPORT InkDropMask : public ui::LayerDelegate {
  17. public:
  18. InkDropMask(const InkDropMask&) = delete;
  19. InkDropMask& operator=(const InkDropMask&) = delete;
  20. ~InkDropMask() override;
  21. ui::Layer* layer() { return &layer_; }
  22. protected:
  23. explicit InkDropMask(const gfx::Size& layer_size);
  24. private:
  25. // ui::LayerDelegate:
  26. void OnDeviceScaleFactorChanged(float old_device_scale_factor,
  27. float new_device_scale_factor) override;
  28. ui::Layer layer_;
  29. };
  30. // An ink-drop mask that paints a specified path.
  31. class VIEWS_EXPORT PathInkDropMask : public InkDropMask {
  32. public:
  33. PathInkDropMask(const gfx::Size& layer_size, const SkPath& path);
  34. PathInkDropMask(const PathInkDropMask&) = delete;
  35. PathInkDropMask& operator=(const PathInkDropMask&) = delete;
  36. private:
  37. FRIEND_TEST_ALL_PREFIXES(InkDropMaskTest, PathInkDropMaskPaintsTriangle);
  38. // InkDropMask:
  39. void OnPaintLayer(const ui::PaintContext& context) override;
  40. SkPath path_;
  41. };
  42. } // namespace views
  43. #endif // UI_VIEWS_ANIMATION_INK_DROP_MASK_H_