LCOV - code coverage report
Current view: top level - xenolith/font - XLFontExtension.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 3 100.0 %
Date: 2024-05-12 00:16:13 Functions: 3 3 100.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_FONT_XLFONTLIBRARY_H_
      24             : #define XENOLITH_FONT_XLFONTLIBRARY_H_
      25             : 
      26             : #include "XLFontController.h"
      27             : #include "XLCoreAttachment.h"
      28             : #include "SPFontLibrary.h"
      29             : 
      30             : namespace STAPPLER_VERSIONIZED stappler::xenolith::font {
      31             : 
      32             : class FontExtension;
      33             : 
      34             : struct RenderFontInput : public core::AttachmentInputData {
      35             :         Rc<thread::TaskQueue> queue;
      36             :         Rc<core::DynamicImage> image;
      37             :         Rc<FontExtension> ext;
      38             :         Vector<FontUpdateRequest> requests;
      39             :         Function<void(const core::ImageInfoData &, BytesView)> output;
      40             : };
      41             : 
      42             : class FontExtension : public ApplicationExtension {
      43             : public:
      44             :         using DefaultFontName = FontLibrary::DefaultFontName;
      45             : 
      46             :         virtual ~FontExtension();
      47             : 
      48             :         bool init(Rc<Application> &&, Rc<core::Queue> &&);
      49             : 
      50          24 :         Application *getMainLoop() const { return _mainLoop; }
      51             :         const core::Loop *getGlLoop() const { return _glLoop; }
      52         600 :         const Rc<core::Queue> &getQueue() const { return _queue; }
      53       10119 :         FontLibrary *getLibrary() const { return _library; }
      54             : 
      55             :         virtual void initialize(Application *) override;
      56             :         virtual void invalidate(Application *) override;
      57             :         virtual void update(Application *, const UpdateTime &clock) override;
      58             : 
      59             :         FontController::Builder makeDefaultControllerBuilder(StringView);
      60             : 
      61             :         Rc<FontController> acquireController(FontController::Builder &&);
      62             : 
      63             :         void updateImage(const Rc<core::DynamicImage> &, Vector<FontUpdateRequest> &&,
      64             :                         Rc<core::DependencyEvent> &&);
      65             : 
      66             : protected:
      67             :         void onActivated();
      68             : 
      69             :         struct ImageQuery {
      70             :                 Rc<core::DynamicImage> image;
      71             :                 Vector<FontUpdateRequest> chars;
      72             :                 Rc<core::DependencyEvent> dependency;
      73             :         };
      74             : 
      75             :         bool _active = false;
      76             :         Rc<FontLibrary> _library;
      77             :         Rc<Application> _mainLoop;
      78             :         Rc<core::Loop> _glLoop;
      79             :         Rc<core::Queue> _queue;
      80             :         Vector<ImageQuery> _pendingImageQueries;
      81             : };
      82             : 
      83             : }
      84             : 
      85             : #endif /* XENOLITH_FONT_XLFONTLIBRARY_H_ */

Generated by: LCOV version 1.14