LCOV - code coverage report
Current view: top level - core/bitmap - SPBitmap.scu.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 10 100.0 %
Date: 2024-05-12 00:16:13 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /**
       2             : Copyright (c) 2022 Roman Katuntsev <sbkarr@stappler.org>
       3             : Copyright (c) 2023 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             : #include "SPCommon.h"
      25             : #include "SPBitmapCustom.cc"
      26             : #include "SPBitmapGif.cc"
      27             : #include "SPBitmapJpeg.cc"
      28             : #include "SPBitmapPng.cc"
      29             : #include "SPBitmapWebp.cc"
      30             : 
      31             : namespace STAPPLER_VERSIONIZED stappler::bitmap {
      32             : 
      33             : static BitmapFormat s_defaultFormats[toInt(FileFormat::Custom)] = {
      34             :         BitmapFormat(FileFormat::Png, &png::isPng, &png::getPngImageSize
      35             :                         , &png::infoPng, &png::loadPng, &png::writePng, &png::savePng
      36             :         ),
      37             :         BitmapFormat(FileFormat::Jpeg, &jpeg::isJpg, &jpeg::getJpegImageSize
      38             :                         , &jpeg::infoJpg, &jpeg::loadJpg, &jpeg::writeJpeg, &jpeg::saveJpeg
      39             :         ),
      40             :         BitmapFormat(FileFormat::WebpLossless, &webp::isWebpLossless, &webp::getWebpLosslessImageSize
      41             :                         , &webp::infoWebp, &webp::loadWebp, &webp::writeWebpLossless, &webp::saveWebpLossless
      42             :         ),
      43             :         BitmapFormat(FileFormat::WebpLossy, &webp::isWebp, &webp::getWebpImageSize
      44             :                         , &webp::infoWebp, &webp::loadWebp, &webp::writeWebpLossy, &webp::saveWebpLossy
      45             :         ),
      46             :         BitmapFormat(FileFormat::Svg, &custom::isSvg, &custom::getSvgImageSize),
      47             :         BitmapFormat(FileFormat::Gif, &gif::isGif, &gif::getGifImageSize
      48             :                         , &gif::infoGif, &gif::loadGif
      49             :         ),
      50             :         BitmapFormat(FileFormat::Tiff, &custom::isTiff, &custom::getTiffImageSize),
      51             : };
      52             : 
      53             : static std::mutex _formatListMutex;
      54             : static std::vector<BitmapFormat *> _formatList;
      55             : 
      56       71623 : SPUNUSED static const BitmapFormat &getDefaultFormat(uint32_t i) {
      57       71623 :         return s_defaultFormats[i];
      58             : }
      59             : 
      60        1425 : SPUNUSED static std::unique_lock<std::mutex> lockFormatList() {
      61        1425 :         return std::unique_lock<std::mutex>(_formatListMutex);
      62             : }
      63             : 
      64          25 : SPUNUSED static void addCustomFormat(BitmapFormat &&fmt) {
      65          25 :         auto lock = lockFormatList();
      66          25 :         _formatList.emplace_back(new BitmapFormat(move(fmt)));
      67          25 : }
      68             : 
      69        2675 : SPUNUSED static const std::vector<BitmapFormat *> &getCustomFormats() {
      70        2675 :         return _formatList;
      71             : }
      72             : 
      73             : }
      74             : 
      75             : #include "SPBitmapFormat.cc"
      76             : #include "SPBitmap.cc"
      77             : #include "SPBitmapResample.cc"

Generated by: LCOV version 1.14