odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

fetchutilscoverage_p.h (2459B)


      1 // This file is part of Blend2D project <https://blend2d.com>
      2 //
      3 // See blend2d.h or LICENSE.md for license and copyright information
      4 // SPDX-License-Identifier: Zlib
      5 
      6 #ifndef BLEND2D_PIPELINE_JIT_FETCHUTILSCOVERAGE_P_H_INCLUDED
      7 #define BLEND2D_PIPELINE_JIT_FETCHUTILSCOVERAGE_P_H_INCLUDED
      8 
      9 #include "../../pipeline/jit/pipecompiler_p.h"
     10 #include "../../pipeline/jit/pipeprimitives_p.h"
     11 
     12 //! \cond INTERNAL
     13 //! \addtogroup blend2d_pipeline_jit
     14 //! \{
     15 
     16 namespace bl::Pipeline::JIT {
     17 
     18 // bl::Pipeline::JIT - GlobalAlpha
     19 // ===============================
     20 
     21 //! Provides a global alpha mask in a format that is requested by during the lifetime of `GlobalAlpha.
     22 //!
     23 //! Can be used by \ref FillPart and \ref CompOpPart as a global alpha abstraction and by othe functions as a global
     24 //! alpha provider.
     25 class GlobalAlpha {
     26 public:
     27   //! \name Members
     28   //! \{
     29 
     30   //! Pipeline compiler.
     31   PipeCompiler* _pc = nullptr;
     32   //! Node where to emit additional code in case `sm` is not initialized, but required.
     33   asmjit::BaseNode* _hook = nullptr;
     34 
     35   //! Memory location from which to fetch the mask. This is only used when `init_from_mem()` is used. It's retained
     36   //! and then when wither \ref sa(), \ref pa(), or \ref ua() is used the respective members would be initialized
     37   //! on demand.
     38   Mem _mem {};
     39 
     40   //! Scalar global alpha (only used by scalar alpha-only processing operations that do 1 pixel at a time).
     41   Gp _sa {};
     42   //! Packed global alpha vector.
     43   Vec _pa {};
     44   //! Unpacked global alpha vector.
     45   Vec _ua {};
     46 
     47   //! \}
     48 
     49   //! \name Initialization
     50   //! \{
     51 
     52 private:
     53   void _init_internal(PipeCompiler* pc) noexcept;
     54 
     55 public:
     56   void init_from_mem(PipeCompiler* pc, const Mem& mem) noexcept;
     57   void init_from_scalar(PipeCompiler* pc, const Gp& sa) noexcept;
     58   void init_from_packed(PipeCompiler* pc, const Vec& pa) noexcept;
     59   void init_from_unpacked(PipeCompiler* pc, const Vec& ua) noexcept;
     60 
     61   //! \}
     62 
     63   //! \name Accessors
     64   //! \{
     65 
     66   //! Returns whether global alpha is initialized and should be applied
     67   BL_INLINE_NODEBUG bool is_initialized() const noexcept { return _hook != nullptr; }
     68 
     69   //! Returns scalar alpha (in a GP register).
     70   const Gp& sa() noexcept;
     71   //! Returns packed alpha (in a SIMD register).
     72   const Vec& pa() noexcept;
     73   //! Returns unpacked alpha (in a SIMD register).
     74   const Vec& ua() noexcept;
     75 
     76   //! \}
     77 };
     78 
     79 } // {bl::Pipeline::JIT}
     80 
     81 //! \}
     82 //! \endcond
     83 
     84 #endif // BLEND2D_PIPELINE_JIT_FETCHUTILSCOVERAGE_P_H_INCLUDED