From eee703970581545b56f3b2faa5b5911923ec28ea Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Tue, 28 Dec 2021 14:21:03 +0900 Subject: vcl: move SurfaceHelper class to CairoCommon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intermediate step beore moving bitmap related members. Change-Id: Icf2d4cfb787dfb029f299cba4b4ffabae563bf6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127923 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/inc/headless/CairoCommon.hxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'vcl/inc') diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index b1f6a8198a60..159714c558d8 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -38,6 +38,8 @@ #include #include +#include + //Using formats that match cairo's formats. For android we patch cairo, //which is internal in that case, to swap the rgb components so that //cairo then matches the OpenGL GL_RGBA format so we can use it there @@ -199,4 +201,29 @@ struct VCL_DLLPUBLIC CairoCommon static cairo_surface_t* createCairoSurface(const BitmapBuffer* pBuffer); }; +class SurfaceHelper +{ +private: + cairo_surface_t* pSurface; + std::unordered_map maDownscaled; + + SurfaceHelper(const SurfaceHelper&) = delete; + SurfaceHelper& operator=(const SurfaceHelper&) = delete; + + cairo_surface_t* implCreateOrReuseDownscale(unsigned long nTargetWidth, + unsigned long nTargetHeight); + +protected: + cairo_surface_t* implGetSurface() const { return pSurface; } + void implSetSurface(cairo_surface_t* pNew) { pSurface = pNew; } + + bool isTrivial() const; + +public: + explicit SurfaceHelper(); + ~SurfaceHelper(); + + cairo_surface_t* getSurface(unsigned long nTargetWidth = 0, + unsigned long nTargetHeight = 0) const; +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit