SkCornerPathEffect.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright 2006 The Android Open Source Project
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef SkCornerPathEffect_DEFINED
  8. #define SkCornerPathEffect_DEFINED
  9. #include "include/core/SkFlattenable.h"
  10. #include "include/core/SkPathEffect.h"
  11. /** \class SkCornerPathEffect
  12. SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
  13. into various treatments (e.g. rounded corners)
  14. */
  15. class SK_API SkCornerPathEffect : public SkPathEffect {
  16. public:
  17. /** radius must be > 0 to have an effect. It specifies the distance from each corner
  18. that should be "rounded".
  19. */
  20. static sk_sp<SkPathEffect> Make(SkScalar radius) {
  21. return radius > 0 ? sk_sp<SkPathEffect>(new SkCornerPathEffect(radius)) : nullptr;
  22. }
  23. protected:
  24. ~SkCornerPathEffect() override;
  25. explicit SkCornerPathEffect(SkScalar radius);
  26. void flatten(SkWriteBuffer&) const override;
  27. bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
  28. private:
  29. SK_FLATTENABLE_HOOKS(SkCornerPathEffect)
  30. SkScalar fRadius;
  31. typedef SkPathEffect INHERITED;
  32. };
  33. #endif