LCOV - code coverage report
Current view: top level - xenolith/core - XLCoreFrameHandle.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 11 90.9 %
Date: 2024-05-12 00:16:13 Functions: 10 11 90.9 %

          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_CORE_XLCOREFRAMEHANDLE_H_
      24             : #define XENOLITH_CORE_XLCOREFRAMEHANDLE_H_
      25             : 
      26             : #include "XLCoreQueue.h"
      27             : #include "XLCoreAttachment.h"
      28             : 
      29             : namespace STAPPLER_VERSIONIZED stappler::xenolith::core {
      30             : 
      31             : class FrameHandle : public Ref {
      32             : public:
      33             :         using FrameRequest = core::FrameRequest;
      34             : 
      35             :         static uint32_t GetActiveFramesCount();
      36             :         static void DescribeActiveFrames();
      37             : 
      38             :         virtual ~FrameHandle();
      39             : 
      40             :         bool init(Loop &, Device &, Rc<FrameRequest> &&, uint64_t gen);
      41             : 
      42             :         void update(bool init = false);
      43             : 
      44       14676 :         uint64_t getTimeStart() const { return _timeStart; }
      45       14676 :         uint64_t getTimeEnd() const { return _timeEnd; }
      46      201235 :         uint64_t getOrder() const { return _order; }
      47        7323 :         uint64_t getGen() const { return _gen; }
      48        7338 :         uint64_t getSubmissionTime() const { return _submissionTime; }
      49       47812 :         Loop *getLoop() const { return _loop; }
      50      348983 :         Device *getDevice() const { return _device; }
      51             :         const Rc<FrameEmitter> &getEmitter() const;
      52             :         const Rc<Queue> &getQueue() const;
      53             :         const FrameContraints &getFrameConstraints() const;
      54        4640 :         const Rc<PoolRef> &getPool() const { return _pool; }
      55        4640 :         const Rc<FrameRequest> &getRequest() const { return _request; }
      56             : 
      57             :         const ImageInfoData *getImageSpecialization(const ImageAttachment *) const;
      58             : 
      59             :         const FrameOutputBinding *getOutputBinding(const Attachment *a) const;
      60             :         const FrameOutputBinding *getOutputBinding(const AttachmentData *a) const;
      61             :         Rc<ImageStorage> getRenderTarget(const Attachment *a) const;
      62             :         Rc<ImageStorage> getRenderTarget(const AttachmentData *a) const;
      63             :         const Vector<Rc<DependencyEvent>> &getSignalDependencies() const;
      64             : 
      65             :         const Vector<Rc<FrameQueue>> &getFrameQueues() const { return _queues; }
      66             :         FrameQueue *getFrameQueue(Queue *) const;
      67             : 
      68             :         // spinners within frame should not spin directly on loop to preserve FrameHandle object
      69             :         virtual void schedule(Function<bool(FrameHandle &)> &&, StringView tag);
      70             : 
      71             :         // thread tasks within frame should not be performed directly on loop's queue to preserve FrameHandle object
      72             :         virtual void performInQueue(Function<void(FrameHandle &)> &&, Ref *, StringView tag);
      73             :         virtual void performInQueue(Function<bool(FrameHandle &)> &&, Function<void(FrameHandle &, bool)> &&, Ref *, StringView tag);
      74             : 
      75             :         // thread tasks within frame should not be performed directly on loop's queue to preserve FrameHandle object
      76             :         virtual void performOnGlThread(Function<void(FrameHandle &)> &&, Ref *, bool immediate, StringView tag);
      77             : 
      78             :         // required tasks should be completed before onComplete call
      79             :         virtual void performRequiredTask(Function<bool(FrameHandle &)> &&, Ref *, StringView tag);
      80             :         virtual void performRequiredTask(Function<bool(FrameHandle &)> &&, Function<void(FrameHandle &, bool)> &&, Ref *, StringView tag);
      81             : 
      82           0 :         virtual bool isSubmitted() const { return _submitted; }
      83             :         virtual bool isValid() const;
      84       57358 :         virtual bool isValidFlag() const { return _valid; }
      85             : 
      86             :         virtual bool isPersistentMapping() const;
      87             : 
      88             :         virtual Rc<AttachmentInputData> getInputData(const AttachmentData *);
      89             : 
      90             :         virtual bool isReadyForSubmit() const;
      91             :         virtual void setReadyForSubmit(bool);
      92             : 
      93             :         virtual void invalidate();
      94             : 
      95             :         virtual void setCompleteCallback(Function<void(FrameHandle &)> &&);
      96             : 
      97             :         virtual void onQueueSubmitted(FrameQueue &);
      98             :         virtual void onQueueComplete(FrameQueue &);
      99             :         virtual void onQueueInvalidated(FrameQueue &);
     100             :         virtual void onOutputAttachment(FrameAttachmentData &);
     101             :         virtual void onOutputAttachmentInvalidated(FrameAttachmentData &);
     102             : 
     103             :         virtual void waitForDependencies(const Vector<Rc<DependencyEvent>> &, Function<void(FrameHandle &, bool)> &&);
     104             : 
     105             :         virtual void waitForInput(FrameQueue &queue, const Rc<AttachmentHandle> &a, Function<void(bool)> &&cb);
     106             : 
     107             :         virtual void signalDependencies(bool success);
     108             : 
     109             : protected:
     110             :         virtual bool setup();
     111             : 
     112             :         virtual void onRequiredTaskCompleted(StringView tag);
     113             : 
     114             :         virtual void tryComplete();
     115             :         virtual void onComplete();
     116             : 
     117             : #if SP_REF_DEBUG
     118             :         virtual bool isRetainTrackerEnabled() const override {
     119             :                 return false;
     120             :         }
     121             : #endif
     122             : 
     123             :         Loop *_loop = nullptr; // loop can not die until frames are performed
     124             :         Device *_device = nullptr;
     125             :         Rc<PoolRef> _pool;
     126             :         Rc<FrameRequest> _request;
     127             : 
     128             :         uint64_t _timeStart = 0;
     129             :         uint64_t _timeEnd = 0;
     130             :         uint64_t _gen = 0;
     131             :         uint64_t _order = 0;
     132             :         uint64_t _submissionTime = 0;
     133             :         std::atomic<uint32_t> _tasksRequired = 0;
     134             :         uint32_t _tasksCompleted = 0;
     135             :         uint32_t _queuesSubmitted = 0;
     136             :         uint32_t _queuesCompleted = 0;
     137             : 
     138             :         bool _submitted = false;
     139             :         bool _completed = false;
     140             :         bool _valid = true;
     141             : 
     142             :         Vector<Rc<FrameQueue>> _queues;
     143             :         Function<void(FrameHandle &)> _complete;
     144             : };
     145             : 
     146             : }
     147             : 
     148             : #endif /* XENOLITH_CORE_XLCOREFRAMEHANDLE_H_ */

Generated by: LCOV version 1.14