tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SkPathRaw.h (1701B)


      1 /*
      2 * Copyright 2025 Google LLC.
      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 #ifndef SkPathRaw_DEFINED
      9 #define SkPathRaw_DEFINED
     10 
     11 #include "include/core/SkPathIter.h"
     12 #include "include/core/SkPathTypes.h"
     13 #include "include/core/SkPoint.h"
     14 #include "include/core/SkRect.h"
     15 #include "include/core/SkSpan.h"
     16 
     17 #include <array>
     18 #include <cstddef>
     19 #include <optional>
     20 
     21 /**
     22 *  SkPathRaw is a non-owning, immutable view of the path geometry.
     23 *
     24 *  It allows us to have stack-allocated paths, see SkPathRawShapes.h
     25 *
     26 *  It is the responsibility of the creator to ensure that the spans in SkPathRaw point to valid
     27 *  data that outlives the SkPathRaw instance.
     28 */
     29 struct SkPathRaw {
     30    SkSpan<const SkPoint>    fPoints;
     31    SkSpan<const SkPathVerb> fVerbs;
     32    SkSpan<const float>      fConics;
     33    SkRect                   fBounds;
     34    SkPathFillType           fFillType;
     35    bool                     fIsConvex;
     36    // See SkPath::SegmentMask
     37    uint8_t                  fSegmentMask;
     38 
     39    SkSpan<const SkPoint> points() const { return fPoints; }
     40    SkSpan<const SkPathVerb> verbs() const { return fVerbs; }
     41    SkSpan<const float> conics() const { return fConics; }
     42    SkRect bounds() const { return fBounds; }
     43    SkPathFillType fillType() const { return fFillType; }
     44    bool isConvex() const { return fIsConvex; }
     45    unsigned segmentMasks() const { return fSegmentMask; }
     46 
     47    bool empty() const { return fVerbs.empty(); }
     48    bool isInverseFillType() const { return SkPathFillType_IsInverse(fFillType); }
     49 
     50    std::optional<SkRect> isRect() const;
     51 
     52    SkPathIter iter() const { return {fPoints, fVerbs, fConics}; }
     53 };
     54 
     55 #endif