LCOV - code coverage report
Current view: top level - xenolith/renderer/basic2d - XL2dVectorSprite.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 5 40.0 %
Date: 2024-05-12 00:16:13 Functions: 3 6 50.0 %

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
       3             : 
       4             :  Permission is hereby granted, free of charge, to any person obtaining a copy
       5             :  of this software and associated documentation files (the "Software"), to deal
       6             :  in the Software without restriction, including without limitation the rights
       7             :  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       8             :  copies of the Software, and to permit persons to whom the Software is
       9             :  furnished to do so, subject to the following conditions:
      10             : 
      11             :  The above copyright notice and this permission notice shall be included in
      12             :  all copies or substantial portions of the Software.
      13             : 
      14             :  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15             :  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16             :  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      17             :  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      18             :  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      19             :  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      20             :  THE SOFTWARE.
      21             :  **/
      22             : 
      23             : #ifndef XENOLITH_RENDERER_BASIC2D_XL2DVECTORSPRITE_H_
      24             : #define XENOLITH_RENDERER_BASIC2D_XL2DVECTORSPRITE_H_
      25             : 
      26             : #include "XL2dSprite.h"
      27             : #include "XL2dVectorCanvas.h"
      28             : 
      29             : namespace STAPPLER_VERSIONIZED stappler::xenolith::basic2d {
      30             : 
      31             : class VectorSprite : public Sprite {
      32             : public:
      33             :         constexpr static float QualityWorst = 0.1f;
      34             :         constexpr static float QualityLow = 0.25f;
      35             :         constexpr static float QualityNormal = 0.75f;
      36             :         constexpr static float QualityHigh = 1.25f;
      37             :         constexpr static float QualityPerfect = 1.75f;
      38             : 
      39        7432 :         virtual ~VectorSprite() { }
      40             : 
      41             :         VectorSprite();
      42             : 
      43             :         virtual bool init(Rc<VectorImage> &&);
      44             :         virtual bool init(Size2, StringView);
      45             :         virtual bool init(Size2, VectorPath &&);
      46             :         virtual bool init(Size2);
      47             :         virtual bool init(StringView) override;
      48             :         virtual bool init(BytesView);
      49             :         virtual bool init(FilePath);
      50             : 
      51             :     virtual Rc<VectorPathRef> addPath(StringView id = StringView(), StringView cache = StringView(), Mat4 = Mat4::IDENTITY);
      52             :     virtual Rc<VectorPathRef> addPath(const VectorPath & path, StringView id = StringView(), StringView cache = StringView(), Mat4 = Mat4::IDENTITY);
      53             :     virtual Rc<VectorPathRef> addPath(VectorPath && path, StringView id = StringView(), StringView cache = StringView(), Mat4 = Mat4::IDENTITY);
      54             : 
      55             :     virtual Rc<VectorPathRef> getPath(StringView);
      56             : 
      57             :     virtual void removePath(const Rc<VectorPathRef> &);
      58             :     virtual void removePath(StringView);
      59             : 
      60             :     virtual void clear();
      61             : 
      62             :     virtual void setImage(Rc<VectorImage> &&);
      63             :     virtual const Rc<VectorImage> &getImage() const;
      64             : 
      65             :     virtual void setQuality(float);
      66           0 :     virtual float getQuality() const { return _quality; }
      67             : 
      68             :         virtual void onTransformDirty(const Mat4 &) override;
      69             : 
      70             :         virtual bool visitDraw(FrameInfo &, NodeFlags parentFlags) override;
      71             : 
      72             :         virtual uint32_t getTrianglesCount() const;
      73             :         virtual uint32_t getVertexesCount() const;
      74             : 
      75             :         virtual void setDeferred(bool);
      76           0 :         virtual bool isDeferred() const { return _deferred; }
      77             : 
      78        3550 :         virtual void setWaitDeferred(bool value) { _waitDeferred = value; }
      79           0 :         virtual bool isWaitDeferred() const { return _waitDeferred; }
      80             : 
      81             : protected:
      82             :         using Sprite::init;
      83             : 
      84             :         virtual void pushShadowCommands(FrameInfo &, NodeFlags flags, const Mat4 &,
      85             :                         SpanView<TransformVertexData> = SpanView<TransformVertexData>()) override;
      86             :         virtual void pushCommands(FrameInfo &, NodeFlags flags) override;
      87             : 
      88             :         virtual void initVertexes() override;
      89             :         virtual void updateVertexes() override;
      90             :         virtual void updateVertexesColor() override;
      91             : 
      92             :         virtual RenderingLevel getRealRenderingLevel() const override;
      93             : 
      94             :         bool _deferred = true;
      95             :         bool _waitDeferred = true;
      96             :         bool _imageIsSolid = false;
      97             :         uint64_t _asyncJobId = 0;
      98             :         Size2 _targetSize;
      99             :         Mat4 _targetTransform;
     100             :         Rc<VectorImage> _image;
     101             :         float _quality = QualityNormal;
     102             :         Rc<VectorCanvasResult> _result;
     103             :         Rc<VectorCanvasDeferredResult> _deferredResult;
     104             : };
     105             : 
     106             : }
     107             : 
     108             : #endif /* XENOLITH_RENDERER_BASIC2D_XL2DVECTORSPRITE_H_ */

Generated by: LCOV version 1.14