diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-12-13 17:07:44 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-01-06 11:12:04 +0100 |
commit | aab9dafdae868b9e55c143cdc08598895f19f63d (patch) | |
tree | 744be99a517b1854bff0ae8b7b85174e2601d13e /vcl/opengl | |
parent | c9253b9007059496521f24ef8348e80bb120e1e6 (diff) |
convert SkImage -> SkBitmap only on demand
This should possibly save some unneeded conversions.
Change-Id: Ice8a186f13a0e61bee260cf910f8a4d0538ef974
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85542
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/opengl')
-rw-r--r-- | vcl/opengl/salbmp.cxx | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 3a033c4afef0..3b500b0945dc 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -32,6 +32,7 @@ #include <salgdi.hxx> #include <vcleventlisteners.hxx> #include <vcl/lazydelete.hxx> +#include <scanlinewriter.hxx> #include <o3tl/make_shared.hxx> @@ -333,47 +334,6 @@ void lclInstantiateTexture(OpenGLTexture& rTexture, const int nWidth, const int rTexture = OpenGLTexture (nWidth, nHeight, nFormat, nType, pData); } -// Write color information for 1 and 4 bit palette bitmap scanlines. -class ScanlineWriter -{ - BitmapPalette& maPalette; - sal_uInt8 const mnColorsPerByte; // number of colors that are stored in one byte - sal_uInt8 const mnColorBitSize; // number of bits a color takes - sal_uInt8 const mnColorBitMask; // bit mask used to isolate the color - sal_uInt8* mpCurrentScanline; - long mnX; - -public: - ScanlineWriter(BitmapPalette& aPalette, sal_Int8 nColorsPerByte) - : maPalette(aPalette) - , mnColorsPerByte(nColorsPerByte) - , mnColorBitSize(8 / mnColorsPerByte) // bit size is number of bit in a byte divided by number of colors per byte (8 / 2 = 4 for 4-bit) - , mnColorBitMask((1 << mnColorBitSize) - 1) // calculate the bit mask from the bit size - , mpCurrentScanline(nullptr) - , mnX(0) - {} - - void writeRGB(sal_uInt8 nR, sal_uInt8 nG, sal_uInt8 nB) - { - // calculate to which index we will write - long nScanlineIndex = mnX / mnColorsPerByte; - - // calculate the number of shifts to get the color information to the right place - long nShift = (8 - mnColorBitSize) - ((mnX % mnColorsPerByte) * mnColorBitSize); - - sal_uInt16 nColorIndex = maPalette.GetBestIndex(BitmapColor(nR, nG, nB)); - mpCurrentScanline[nScanlineIndex] &= ~(mnColorBitMask << nShift); // clear - mpCurrentScanline[nScanlineIndex] |= (nColorIndex & mnColorBitMask) << nShift; // set - mnX++; - } - - void nextLine(sal_uInt8* pScanline) - { - mnX = 0; - mpCurrentScanline = pScanline; - } -}; - } // end anonymous namespace Size OpenGLSalBitmap::GetSize() const @@ -475,22 +435,7 @@ bool OpenGLSalBitmap::ReadTexture() maTexture.Read(nFormat, nType, pBuffer); sal_uInt32 nSourceBytesPerRow = lclBytesPerRow(24, mnWidth); - std::unique_ptr<ScanlineWriter> pWriter; - switch(mnBits) - { - case 1: - pWriter.reset(new ScanlineWriter(maPalette, 8)); - break; - case 4: - pWriter.reset(new ScanlineWriter(maPalette, 2)); - break; - case 8: - pWriter.reset(new ScanlineWriter(maPalette, 1)); - break; - default: - abort(); - } - + std::unique_ptr<vcl::ScanlineWriter> pWriter = vcl::ScanlineWriter::Create(mnBits, maPalette); for (int y = 0; y < mnHeight; ++y) { sal_uInt8* pSource = &pBuffer[y * nSourceBytesPerRow]; |