LCOV - code coverage report
Current view: top level - core/vg - SPVectorPath.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2024-05-12 00:16:13 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**
       2             : Copyright (c) 2022 Roman Katuntsev <sbkarr@stappler.org>
       3             : Copyright (c) 2023-2024 Stappler LLC <admin@stappler.dev>
       4             : 
       5             : Permission is hereby granted, free of charge, to any person obtaining a copy
       6             : of this software and associated documentation files (the "Software"), to deal
       7             : in the Software without restriction, including without limitation the rights
       8             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       9             : copies of the Software, and to permit persons to whom the Software is
      10             : furnished to do so, subject to the following conditions:
      11             : 
      12             : The above copyright notice and this permission notice shall be included in
      13             : all copies or substantial portions of the Software.
      14             : 
      15             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      16             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      17             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      18             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      19             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      20             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      21             : THE SOFTWARE.
      22             : **/
      23             : 
      24             : #ifndef CORE_VG_SPVECTORPATH_H_
      25             : #define CORE_VG_SPVECTORPATH_H_
      26             : 
      27             : #include "SPRef.h"
      28             : #include "SPVectorPathData.h"
      29             : 
      30             : namespace STAPPLER_VERSIONIZED stappler::vg {
      31             : 
      32             : using Interface = memory::StandartInterface;
      33             : 
      34             : struct PathXRef {
      35             :         Interface::StringType id;
      36             :         Interface::StringType cacheId;
      37             :         Mat4 mat;
      38             : };
      39             : 
      40             : class VectorPath : public RefBase<Interface> {
      41             : public:
      42             :         using DrawStyle = geom::DrawStyle;
      43             :         using Winding = geom::Winding;
      44             :         using LineCup = geom::LineCup;
      45             :         using LineJoin = geom::LineJoin;
      46             : 
      47             :         VectorPath();
      48             :         VectorPath(size_t);
      49             : 
      50             :         VectorPath(const VectorPath &);
      51             :         VectorPath &operator=(const VectorPath &);
      52             : 
      53             :         VectorPath(VectorPath &&);
      54             :         VectorPath &operator=(VectorPath &&);
      55             : 
      56             :         bool init();
      57             :         bool init(StringView);
      58             :         bool init(FilePath &&);
      59             :         bool init(BytesView);
      60             : 
      61             :         bool init(const PathData<memory::StandartInterface> &);
      62             :         bool init(const PathData<memory::PoolInterface> &);
      63             : 
      64             :         VectorPath & addPath(const VectorPath &);
      65             :         VectorPath & addPath(BytesView);
      66             :         VectorPath & addPath(StringView);
      67             : 
      68             :         size_t count() const;
      69             : 
      70             :         VectorPath & openForWriting(const Callback<void(PathWriter &)> &);
      71             : 
      72             :         VectorPath & setFillColor(const Color4B &color);
      73             :         VectorPath & setFillColor(const Color3B &color, bool preserveOpacity = false);
      74             :         VectorPath & setFillColor(const Color &color, bool preserveOpacity = false);
      75             :         const Color4B &getFillColor() const;
      76             : 
      77             :         VectorPath & setStrokeColor(const Color4B &color);
      78             :         VectorPath & setStrokeColor(const Color3B &color, bool preserveOpacity = false);
      79             :         VectorPath & setStrokeColor(const Color &color, bool preserveOpacity = false);
      80             :         const Color4B &getStrokeColor() const;
      81             : 
      82             :         VectorPath & setFillOpacity(uint8_t value);
      83             :         uint8_t getFillOpacity() const;
      84             : 
      85             :         VectorPath & setStrokeOpacity(uint8_t value);
      86             :         uint8_t getStrokeOpacity() const;
      87             : 
      88             :         VectorPath & setStrokeWidth(float width);
      89             :         float getStrokeWidth() const;
      90             : 
      91             :         VectorPath &setWindingRule(Winding);
      92             :         Winding getWindingRule() const;
      93             : 
      94             :         VectorPath &setLineCup(LineCup);
      95             :         LineCup getLineCup() const;
      96             : 
      97             :         VectorPath &setLineJoin(LineJoin);
      98             :         LineJoin getLineJoin() const;
      99             : 
     100             :         VectorPath &setMiterLimit(float);
     101             :         float getMiterLimit() const;
     102             : 
     103             :         VectorPath & setStyle(DrawStyle s);
     104             :         DrawStyle getStyle() const;
     105             : 
     106             :         VectorPath &setAntialiased(bool);
     107             :         bool isAntialiased() const;
     108             : 
     109             :         // transform should be applied in reverse order
     110             :         VectorPath & setTransform(const Mat4 &);
     111             :         VectorPath & applyTransform(const Mat4 &);
     112             :         const Mat4 &getTransform() const;
     113             : 
     114             :         VectorPath & clear();
     115             : 
     116             :         VectorPath & setParams(const PathParams &);
     117             :         PathParams getParams() const;
     118             : 
     119             :         bool empty() const;
     120             : 
     121             :         void reserve(size_t);
     122             : 
     123             :         const Interface::VectorType<Command> &getCommands() const;
     124             :         const Interface::VectorType<CommandData> &getPoints() const;
     125             : 
     126         775 :         explicit operator bool() const { return !empty(); }
     127             : 
     128             :         size_t commandsCount() const;
     129             :         size_t dataCount() const;
     130             : 
     131             :         Interface::BytesType encode() const;
     132             :         Interface::StringType toString(bool newline) const;
     133             : 
     134             : protected:
     135             :         friend class Image;
     136             :         friend struct SvgTag;
     137             : 
     138             :         PathWriter getWriter();
     139             : 
     140             :         PathData<Interface> _data;
     141             : };
     142             : 
     143             : }
     144             : 
     145             : #endif /* STAPPLER_VG_SPVECTORPATH_H_ */

Generated by: LCOV version 1.14