diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-15 10:24:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-15 12:37:35 +0100 |
commit | 953a5cb1c8c750df24ed0316349a5916c384296d (patch) | |
tree | 26a76707725fad73d9e71486f0723406bae52065 /vcl/inc/bitmapwriteaccess.hxx | |
parent | bca14a7126a8cea12eecd248ae84e3d07db9609b (diff) |
move Bitmap::ScopedWriteAccess inside vcl
would have liked to make the AcquireWriteAccess methods DLLPRIVATE, but
they are needed by the workbench and testing code
Change-Id: I22497788eb68dfb84b7e542e5ef53322892a5274
Reviewed-on: https://gerrit.libreoffice.org/51310
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/inc/bitmapwriteaccess.hxx')
-rw-r--r-- | vcl/inc/bitmapwriteaccess.hxx | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/vcl/inc/bitmapwriteaccess.hxx b/vcl/inc/bitmapwriteaccess.hxx new file mode 100644 index 000000000000..0223ad778f10 --- /dev/null +++ b/vcl/inc/bitmapwriteaccess.hxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef INCLUDED_VCL_INC_BITMAPWRITEACCESS_HXX +#define INCLUDED_VCL_INC_BITMAPWRITEACCESS_HXX + +#include <vcl/alpha.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/bitmapaccess.hxx> + +typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess> + BitmapScopedWriteAccess; + +typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireWriteAccess> + AlphaScopedWriteAccess; + +class VCL_DLLPUBLIC BitmapWriteAccess : public BitmapReadAccess +{ +public: + BitmapWriteAccess(Bitmap& rBitmap); + virtual ~BitmapWriteAccess() override; + + void CopyScanline(long nY, const BitmapReadAccess& rReadAcc); + void CopyScanline(long nY, ConstScanline aSrcScanline, ScanlineFormat nSrcScanlineFormat, + sal_uLong nSrcScanlineSize); + + void CopyBuffer(const BitmapReadAccess& rReadAcc); + + void SetPalette(const BitmapPalette& rPalette) + { + assert(mpBuffer && "Access is not valid!"); + + mpBuffer->maPalette = rPalette; + } + + void SetPaletteEntryCount(sal_uInt16 nCount) + { + assert(mpBuffer && "Access is not valid!"); + + mpBuffer->maPalette.SetEntryCount(nCount); + } + + void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor) + { + assert(mpBuffer && "Access is not valid!"); + assert(HasPalette() && "Bitmap has no palette!"); + + mpBuffer->maPalette[nColor] = rBitmapColor; + } + + void SetPixel(long nY, long nX, const BitmapColor& rBitmapColor) + { + assert(mpBuffer && "Access is not valid!"); + assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!"); + assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!"); + + mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask); + } + + void SetPixelIndex(long nY, long nX, sal_uInt8 cIndex) + { + SetPixel(nY, nX, BitmapColor(cIndex)); + } + + void SetLineColor(const Color& rColor); + + void SetFillColor(); + void SetFillColor(const Color& rColor); + + void Erase(const Color& rColor); + + void DrawLine(const Point& rStart, const Point& rEnd); + + void FillRect(const tools::Rectangle& rRect); + void DrawRect(const tools::Rectangle& rRect); + +private: + std::unique_ptr<BitmapColor> mpLineColor; + std::unique_ptr<BitmapColor> mpFillColor; + + BitmapWriteAccess() = delete; + BitmapWriteAccess(const BitmapWriteAccess&) = delete; + BitmapWriteAccess& operator=(const BitmapWriteAccess&) = delete; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |