diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-12-28 14:21:03 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-01-04 15:16:30 +0100 |
commit | eee703970581545b56f3b2faa5b5911923ec28ea (patch) | |
tree | ec2b4c5ae87a6afe32ffda265af7368688abf2b2 /vcl/inc | |
parent | 3e9786b4dcbf342aab469940710e8a01be62d694 (diff) |
vcl: move SurfaceHelper class to CairoCommon
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 <quikee@gmail.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/headless/CairoCommon.hxx | 27 |
1 files changed, 27 insertions, 0 deletions
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 <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx> +#include <unordered_map> + //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<sal_uInt64, cairo_surface_t*> 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: */ |