diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-12-30 00:24:44 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-01-05 04:36:44 +0100 |
commit | c138cfa104ec0cd7f6e97885553b08f98d9f5848 (patch) | |
tree | 2b9125bbd1884baa0b20c6c92a19f84a9203dfe4 /vcl | |
parent | 507ca0eb16707917eab3608674243ed0eeacda72 (diff) |
vcl: move getBitmap to SvpGraphicsBackend
Change-Id: Ic72e1fdd3994a5bffef40bb70b713f10c1112903
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127982
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/SvpGraphicsBackend.cxx | 44 | ||||
-rw-r--r-- | vcl/headless/svpgdi.cxx | 42 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 2 |
3 files changed, 40 insertions, 48 deletions
diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 2ac40e8e7b20..f564b7e78958 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -480,11 +480,47 @@ void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBi m_rCairoCommon.releaseCairoContext(cr, false, extents); } -std::shared_ptr<SalBitmap> SvpGraphicsBackend::getBitmap(tools::Long /*nX*/, tools::Long /*nY*/, - tools::Long /*nWidth*/, - tools::Long /*nHeight*/) +std::shared_ptr<SalBitmap> SvpGraphicsBackend::getBitmap(tools::Long nX, tools::Long nY, + tools::Long nWidth, tools::Long nHeight) { - return std::shared_ptr<SalBitmap>(); + std::shared_ptr<SvpSalBitmap> pBitmap = std::make_shared<SvpSalBitmap>(); + BitmapPalette aPal; + vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; + if (GetBitCount() == 1) + { + ePixelFormat = vcl::PixelFormat::N1_BPP; + aPal.SetEntryCount(2); + aPal[0] = COL_BLACK; + aPal[1] = COL_WHITE; + } + else + { + ePixelFormat = vcl::PixelFormat::N32_BPP; + } + + if (!pBitmap->Create(Size(nWidth, nHeight), ePixelFormat, aPal)) + { + SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create bitmap"); + return nullptr; + } + + cairo_surface_t* target = CairoCommon::createCairoSurface(pBitmap->GetBuffer()); + if (!target) + { + SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create cairo surface"); + return nullptr; + } + cairo_t* cr = cairo_create(target); + + SalTwoRect aTR(nX, nY, nWidth, nHeight, 0, 0, nWidth, nHeight); + CairoCommon::renderSource(cr, aTR, m_rCairoCommon.m_pSurface); + + cairo_destroy(cr); + cairo_surface_destroy(target); + + Toggle1BitTransparency(*pBitmap->GetBuffer()); + + return pBitmap; } void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect& rTR, const BitmapBuffer* pBuffer, diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index b9c4cabee2bc..23f68c80fe3c 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -83,48 +83,6 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) rDPIX = rDPIY = 96; } -std::shared_ptr<SalBitmap> SvpSalGraphics::getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) -{ - std::shared_ptr<SvpSalBitmap> pBitmap = std::make_shared<SvpSalBitmap>(); - BitmapPalette aPal; - vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; - if (GetBitCount() == 1) - { - ePixelFormat = vcl::PixelFormat::N1_BPP; - aPal.SetEntryCount(2); - aPal[0] = COL_BLACK; - aPal[1] = COL_WHITE; - } - else - { - ePixelFormat = vcl::PixelFormat::N32_BPP; - } - - if (!pBitmap->Create(Size(nWidth, nHeight), ePixelFormat, aPal)) - { - SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create bitmap"); - return nullptr; - } - - cairo_surface_t* target = CairoCommon::createCairoSurface(pBitmap->GetBuffer()); - if (!target) - { - SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create cairo surface"); - return nullptr; - } - cairo_t* cr = cairo_create(target); - - SalTwoRect aTR(nX, nY, nWidth, nHeight, 0, 0, nWidth, nHeight); - CairoCommon::renderSource(cr, aTR, m_aCairoCommon.m_pSurface); - - cairo_destroy(cr); - cairo_surface_destroy(target); - - Toggle1BitTransparency(*pBitmap->GetBuffer()); - - return pBitmap; -} - #if ENABLE_CAIRO_CANVAS bool SvpSalGraphics::SupportsCairo() const { diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index eb15f1563a62..b3b932cc3d73 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -95,8 +95,6 @@ public: GetTextLayout(int nFallbackLevel) override; virtual void DrawTextLayout( const GenericSalLayout& ) override; - virtual std::shared_ptr<SalBitmap> getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; - virtual SystemGraphicsData GetGraphicsData() const override; #if ENABLE_CAIRO_CANVAS |