bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / win / salbmp.h
blobc8fe3d851011ac3cb9243c0bc23290ae79cd85b3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_WIN_SALBMP_H
21 #define INCLUDED_VCL_INC_WIN_SALBMP_H
23 #include <tools/gen.hxx>
24 #include <win/wincomp.hxx>
25 #include <salbmp.hxx>
26 #include <basegfx/utils/systemdependentdata.hxx>
27 #include <memory>
30 struct BitmapBuffer;
31 class BitmapColor;
32 class BitmapPalette;
33 class SalGraphics;
34 namespace Gdiplus { class Bitmap; }
36 class WinSalBitmap final: public SalBitmap, public basegfx::SystemDependentDataHolder
38 private:
39 Size maSize;
40 HGLOBAL mhDIB;
41 HBITMAP mhDDB;
43 sal_uInt16 mnBitCount;
45 std::shared_ptr<Gdiplus::Bitmap> ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
46 std::shared_ptr<Gdiplus::Bitmap> ImplCreateGdiPlusBitmap();
48 public:
50 HGLOBAL ImplGethDIB() const { return mhDIB; }
51 HBITMAP ImplGethDDB() const { return mhDDB; }
53 std::shared_ptr< Gdiplus::Bitmap > ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = nullptr) const;
55 static HGLOBAL ImplCreateDIB( const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal );
56 static HANDLE ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB );
57 static sal_uInt16 ImplGetDIBColorCount( HGLOBAL hDIB );
59 public:
61 WinSalBitmap();
62 virtual ~WinSalBitmap() override;
64 public:
66 bool Create( HANDLE hBitmap );
67 virtual bool Create( const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal ) override;
68 virtual bool Create( const SalBitmap& rSalBmpImpl ) override;
69 virtual bool Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics ) override;
70 virtual bool Create( const SalBitmap& rSalBmpImpl, vcl::PixelFormat eNewPixelFormat ) override;
71 virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
72 Size& rSize,
73 bool bMask = false ) override;
75 virtual void Destroy() override;
77 virtual Size GetSize() const override { return maSize; }
78 virtual sal_uInt16 GetBitCount() const override { return mnBitCount; }
80 virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
81 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
82 virtual bool GetSystemData( BitmapSystemData& rData ) override;
84 virtual bool ScalingSupported() const override;
85 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
86 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override;
88 // exclusive management op's for SystemDependentData at WinSalBitmap
89 template<class T>
90 std::shared_ptr<T> getSystemDependentData() const
92 return std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code()));
95 template<class T, class... Args>
96 std::shared_ptr<T> addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const
98 std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
100 // tdf#129845 only add to buffer if a relevant buffer time is estimated
101 if(r->calculateCombinedHoldCyclesInSeconds() > 0)
103 basegfx::SystemDependentData_SharedPtr r2(r);
104 const_cast< WinSalBitmap* >(this)->basegfx::SystemDependentDataHolder::addOrReplaceSystemDependentData(r2);
107 return r;
111 #endif // INCLUDED_VCL_INC_WIN_SALBMP_H
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */