xref: /aosp_15_r20/external/skia/src/core/SkCubicClipper.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2009 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 
8 
9 #ifndef SkCubicClipper_DEFINED
10 #define SkCubicClipper_DEFINED
11 
12 #include "include/core/SkRect.h"
13 #include "include/core/SkScalar.h"
14 #include "include/core/SkTypes.h"
15 
16 struct SkPoint;
17 
18 /** This class is initialized with a clip rectangle, and then can be fed cubics,
19     which must already be monotonic in Y.
20 
21     In the future, it might return a series of segments, allowing it to clip
22     also in X, to ensure that all segments fit in a finite coordinate system.
23  */
24 class SkCubicClipper {
25 public:
26     SkCubicClipper();
27 
28     void setClip(const SkIRect& clip);
29 
30     [[nodiscard]] bool clipCubic(const SkPoint src[4], SkPoint dst[4]);
31 
32     [[nodiscard]] static bool ChopMonoAtY(const SkPoint pts[4], SkScalar y, SkScalar* t);
33 private:
34     SkRect      fClip;
35 };
36 
37 #endif  // SkCubicClipper_DEFINED
38