19f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 59f62ea84SAndrew Rist * distributed with this work for additional information 69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 149f62ea84SAndrew Rist * software distributed under the License is distributed on an 159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 179f62ea84SAndrew Rist * specific language governing permissions and limitations 189f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 209f62ea84SAndrew Rist *************************************************************/ 219f62ea84SAndrew Rist 229f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <bmpfast.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #ifndef NO_OPTIMIZED_BITMAP_ACCESS 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <tools/debug.hxx> 32cdf0e10cSrcweir #include <vcl/bmpacc.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #define FAST_ARGB_BGRA 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <stdlib.h> 37cdf0e10cSrcweir static bool bDisableFastBitops = (getenv( "SAL_DISABLE_BITMAPS_OPTS" ) != NULL); 38cdf0e10cSrcweir 39cdf0e10cSrcweir typedef unsigned char PIXBYTE; 40cdf0e10cSrcweir 41cdf0e10cSrcweir class BasePixelPtr 42cdf0e10cSrcweir { 43cdf0e10cSrcweir public: 44cdf0e10cSrcweir BasePixelPtr( PIXBYTE* p = NULL ) : mpPixel( p ) {} 45cdf0e10cSrcweir void SetRawPtr( PIXBYTE* pRawPtr ) { mpPixel = pRawPtr; } 46cdf0e10cSrcweir PIXBYTE* GetRawPtr( void ) const { return mpPixel; } 47cdf0e10cSrcweir void AddByteOffset( int nByteOffset ) { mpPixel += nByteOffset; } 48cdf0e10cSrcweir bool operator<( const BasePixelPtr& rCmp ) const { return (mpPixel < rCmp.mpPixel); } 49cdf0e10cSrcweir 50cdf0e10cSrcweir protected: 51cdf0e10cSrcweir PIXBYTE* mpPixel; 52cdf0e10cSrcweir }; 53cdf0e10cSrcweir 54cdf0e10cSrcweir template <sal_uLong PIXFMT> 55cdf0e10cSrcweir class TrueColorPixelPtr : public BasePixelPtr 56cdf0e10cSrcweir { 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir PIXBYTE GetRed() const; 59cdf0e10cSrcweir PIXBYTE GetGreen() const; 60cdf0e10cSrcweir PIXBYTE GetBlue() const; 61cdf0e10cSrcweir PIXBYTE GetAlpha() const; 62cdf0e10cSrcweir 63cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const; 64cdf0e10cSrcweir void SetAlpha( PIXBYTE a ) const; 65cdf0e10cSrcweir void operator++(int); 66cdf0e10cSrcweir }; 67cdf0e10cSrcweir 68cdf0e10cSrcweir // ======================================================================= 69cdf0e10cSrcweir // template specializations for truecolor pixel formats 70cdf0e10cSrcweir 71cdf0e10cSrcweir template <> 72cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_24BIT_TC_RGB> : public BasePixelPtr 73cdf0e10cSrcweir { 74cdf0e10cSrcweir public: 75cdf0e10cSrcweir void operator++() { mpPixel += 3; } 76cdf0e10cSrcweir 77cdf0e10cSrcweir PIXBYTE GetRed() const { return mpPixel[0]; } 78cdf0e10cSrcweir PIXBYTE GetGreen() const { return mpPixel[1]; } 79cdf0e10cSrcweir PIXBYTE GetBlue() const { return mpPixel[2]; } 80cdf0e10cSrcweir PIXBYTE GetAlpha() const { return 0; } 81cdf0e10cSrcweir void SetAlpha( PIXBYTE ) const {} 82cdf0e10cSrcweir 83cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 84cdf0e10cSrcweir { 85cdf0e10cSrcweir mpPixel[0] = r; 86cdf0e10cSrcweir mpPixel[1] = g; 87cdf0e10cSrcweir mpPixel[2] = b; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir template <> 92cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_24BIT_TC_BGR> : public BasePixelPtr 93cdf0e10cSrcweir { 94cdf0e10cSrcweir public: 95cdf0e10cSrcweir void operator++() { mpPixel += 3; } 96cdf0e10cSrcweir 97cdf0e10cSrcweir PIXBYTE GetRed() const { return mpPixel[2]; } 98cdf0e10cSrcweir PIXBYTE GetGreen() const { return mpPixel[1]; } 99cdf0e10cSrcweir PIXBYTE GetBlue() const { return mpPixel[0]; } 100cdf0e10cSrcweir PIXBYTE GetAlpha() const { return 0; } 101cdf0e10cSrcweir void SetAlpha( PIXBYTE ) const {} 102cdf0e10cSrcweir 103cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 104cdf0e10cSrcweir { 105cdf0e10cSrcweir mpPixel[0] = b; 106cdf0e10cSrcweir mpPixel[1] = g; 107cdf0e10cSrcweir mpPixel[2] = r; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir }; 110cdf0e10cSrcweir 111cdf0e10cSrcweir template <> 112cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_ARGB> : public BasePixelPtr 113cdf0e10cSrcweir { 114cdf0e10cSrcweir public: 115cdf0e10cSrcweir void operator++() { mpPixel += 4; } 116cdf0e10cSrcweir 117cdf0e10cSrcweir PIXBYTE GetRed() const { return mpPixel[1]; } 118cdf0e10cSrcweir PIXBYTE GetGreen() const { return mpPixel[2]; } 119cdf0e10cSrcweir PIXBYTE GetBlue() const { return mpPixel[3]; } 120cdf0e10cSrcweir PIXBYTE GetAlpha() const { return mpPixel[0]; } 121cdf0e10cSrcweir void SetAlpha( PIXBYTE a ) const { mpPixel[0] = a; } 122cdf0e10cSrcweir 123cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 124cdf0e10cSrcweir { 125cdf0e10cSrcweir mpPixel[1] = r; 126cdf0e10cSrcweir mpPixel[2] = g; 127cdf0e10cSrcweir mpPixel[3] = b; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir }; 130cdf0e10cSrcweir 131cdf0e10cSrcweir template <> 132cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_ABGR> : public BasePixelPtr 133cdf0e10cSrcweir { 134cdf0e10cSrcweir public: 135cdf0e10cSrcweir void operator++() { mpPixel += 4; } 136cdf0e10cSrcweir 137cdf0e10cSrcweir PIXBYTE GetRed() const { return mpPixel[3]; } 138cdf0e10cSrcweir PIXBYTE GetGreen() const { return mpPixel[2]; } 139cdf0e10cSrcweir PIXBYTE GetBlue() const { return mpPixel[1]; } 140cdf0e10cSrcweir PIXBYTE GetAlpha() const { return mpPixel[0]; } 141cdf0e10cSrcweir void SetAlpha( PIXBYTE a ) const { mpPixel[0] = a; } 142cdf0e10cSrcweir 143cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 144cdf0e10cSrcweir { 145cdf0e10cSrcweir mpPixel[1] = b; 146cdf0e10cSrcweir mpPixel[2] = g; 147cdf0e10cSrcweir mpPixel[3] = r; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir }; 150cdf0e10cSrcweir 151cdf0e10cSrcweir template <> 152cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_RGBA> : public BasePixelPtr 153cdf0e10cSrcweir { 154cdf0e10cSrcweir public: 155cdf0e10cSrcweir void operator++() { mpPixel += 4; } 156cdf0e10cSrcweir 157cdf0e10cSrcweir PIXBYTE GetRed() const { return mpPixel[0]; } 158cdf0e10cSrcweir PIXBYTE GetGreen() const { return mpPixel[1]; } 159cdf0e10cSrcweir PIXBYTE GetBlue() const { return mpPixel[2]; } 160cdf0e10cSrcweir PIXBYTE GetAlpha() const { return mpPixel[3]; } 161cdf0e10cSrcweir void SetAlpha( PIXBYTE a ) const{ mpPixel[3] = a; } 162cdf0e10cSrcweir 163cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 164cdf0e10cSrcweir { 165cdf0e10cSrcweir mpPixel[0] = r; 166cdf0e10cSrcweir mpPixel[1] = g; 167cdf0e10cSrcweir mpPixel[2] = b; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir }; 170cdf0e10cSrcweir 171cdf0e10cSrcweir template <> 172cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_BGRA> : public BasePixelPtr 173cdf0e10cSrcweir { 174cdf0e10cSrcweir public: 175cdf0e10cSrcweir void operator++() { mpPixel += 4; } 176cdf0e10cSrcweir 177cdf0e10cSrcweir PIXBYTE GetRed() const { return mpPixel[2]; } 178cdf0e10cSrcweir PIXBYTE GetGreen() const { return mpPixel[1]; } 179cdf0e10cSrcweir PIXBYTE GetBlue() const { return mpPixel[0]; } 180cdf0e10cSrcweir PIXBYTE GetAlpha() const { return mpPixel[3]; } 181cdf0e10cSrcweir void SetAlpha( PIXBYTE a ) const{ mpPixel[3] = a; } 182cdf0e10cSrcweir 183cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 184cdf0e10cSrcweir { 185cdf0e10cSrcweir mpPixel[0] = b; 186cdf0e10cSrcweir mpPixel[1] = g; 187cdf0e10cSrcweir mpPixel[2] = r; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir }; 190cdf0e10cSrcweir 191cdf0e10cSrcweir template <> 192cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_16BIT_TC_MSB_MASK> : public BasePixelPtr 193cdf0e10cSrcweir { 194cdf0e10cSrcweir public: 195cdf0e10cSrcweir void operator++() { mpPixel += 2; } 196cdf0e10cSrcweir 197cdf0e10cSrcweir // TODO: non565-RGB 198cdf0e10cSrcweir PIXBYTE GetRed() const { return (mpPixel[0] & 0xF8U); } 199cdf0e10cSrcweir PIXBYTE GetGreen() const { return (mpPixel[0]<<5U) | ((mpPixel[1]>>3U)&28U); } 200cdf0e10cSrcweir PIXBYTE GetBlue() const { return (mpPixel[1]<<3U); } 201cdf0e10cSrcweir PIXBYTE GetAlpha() const { return 0; } 202cdf0e10cSrcweir void SetAlpha( PIXBYTE ) const {} 203cdf0e10cSrcweir 204cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 205cdf0e10cSrcweir { 206cdf0e10cSrcweir mpPixel[0] = ((g >> 5U) & 7U) | (r & 0xF8U); 207cdf0e10cSrcweir mpPixel[1] = ((g & 28U)<< 3U) | (b >> 3U); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir }; 210cdf0e10cSrcweir 211cdf0e10cSrcweir template <> 212cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_16BIT_TC_LSB_MASK> : public BasePixelPtr 213cdf0e10cSrcweir { 214cdf0e10cSrcweir public: 215cdf0e10cSrcweir void operator++() { mpPixel += 2; } 216cdf0e10cSrcweir 217cdf0e10cSrcweir // TODO: non565-RGB 218cdf0e10cSrcweir PIXBYTE GetRed() const { return (mpPixel[1] & 0xF8U); } 219cdf0e10cSrcweir PIXBYTE GetGreen() const { return (mpPixel[1]<<5U) | ((mpPixel[0]>>3U)&28U); } 220cdf0e10cSrcweir PIXBYTE GetBlue() const { return (mpPixel[0]<<3U); } 221cdf0e10cSrcweir PIXBYTE GetAlpha() const { return 0; } 222cdf0e10cSrcweir void SetAlpha( PIXBYTE ) const {} 223cdf0e10cSrcweir 224cdf0e10cSrcweir void SetColor( PIXBYTE r, PIXBYTE g, PIXBYTE b ) const 225cdf0e10cSrcweir { 226cdf0e10cSrcweir mpPixel[0] = ((g & 28U)<< 3U) | (b >> 3U); 227cdf0e10cSrcweir mpPixel[1] = ((g >> 5U) & 7U) | (r & 0xF8U); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir }; 230cdf0e10cSrcweir 231cdf0e10cSrcweir // ----------------------------------------------------------------------- 232cdf0e10cSrcweir 233cdf0e10cSrcweir template <> 234cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_8BIT_TC_MASK> : public BasePixelPtr 235cdf0e10cSrcweir { 236cdf0e10cSrcweir public: 237cdf0e10cSrcweir void operator++() { mpPixel += 1; } 238cdf0e10cSrcweir PIXBYTE GetAlpha() const { return mpPixel[0]; } 239cdf0e10cSrcweir void SetAlpha( PIXBYTE a ) const { mpPixel[0] = a; } 240cdf0e10cSrcweir void SetColor( PIXBYTE, PIXBYTE, PIXBYTE ) const {} 241cdf0e10cSrcweir }; 242cdf0e10cSrcweir 243cdf0e10cSrcweir // TODO: for some reason many Alpha maps are BMP_FORMAT_8BIT_PAL 244cdf0e10cSrcweir // they should be BMP_FORMAT_8BIT_TC_MASK 245cdf0e10cSrcweir template <> 246cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_8BIT_PAL> 247cdf0e10cSrcweir : public TrueColorPixelPtr<BMP_FORMAT_8BIT_TC_MASK> 248cdf0e10cSrcweir {}; 249cdf0e10cSrcweir 250cdf0e10cSrcweir #if 0 251cdf0e10cSrcweir template <> 252cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_24BIT_TC_MASK> : public BasePixelPtr 253cdf0e10cSrcweir { 254cdf0e10cSrcweir public: 255cdf0e10cSrcweir void operator++() { mpPixel += 3; } 256cdf0e10cSrcweir 257cdf0e10cSrcweir unsigned GetAlpha() const 258cdf0e10cSrcweir { 259cdf0e10cSrcweir unsigned nAlpha = mpPixel[0]; 260cdf0e10cSrcweir nAlpha |= mpPixel[1] << 8U; 261cdf0e10cSrcweir nAlpha |= mpPixel[2] << 16U; 262cdf0e10cSrcweir return nAlpha; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir void SetAlpha( unsigned nAlpha ) const 266cdf0e10cSrcweir { 267cdf0e10cSrcweir mpPixel[0] = nAlpha; 268cdf0e10cSrcweir mpPixel[1] = nAlpha >> 8U; 269cdf0e10cSrcweir mpPixel[2] = nAlpha >> 16U; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir }; 272cdf0e10cSrcweir 273cdf0e10cSrcweir template <> 274cdf0e10cSrcweir class TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_MASK> : public BasePixelPtr 275cdf0e10cSrcweir { 276cdf0e10cSrcweir public: 277cdf0e10cSrcweir void operator++() { mpPixel += 4; } 278cdf0e10cSrcweir 279cdf0e10cSrcweir unsigned GetAlpha() const 280cdf0e10cSrcweir { 281cdf0e10cSrcweir #ifdef OSL_BIGENDIAN 282cdf0e10cSrcweir unsigned nAlpha = *reinterpret_cast<unsigned*>( mpPixel ); 283cdf0e10cSrcweir #else 284cdf0e10cSrcweir unsigned nAlpha = mpPixel[0]; 285cdf0e10cSrcweir nAlpha |= mpPixel[1] << 8U; 286cdf0e10cSrcweir nAlpha |= mpPixel[2] << 16U; 287cdf0e10cSrcweir nAlpha |= mpPixel[3] << 24U; 288cdf0e10cSrcweir #endif 289cdf0e10cSrcweir return nAlpha; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir void SetAlpha( unsigned nAlpha ) const 293cdf0e10cSrcweir { 294cdf0e10cSrcweir #ifdef OSL_BIGENDIAN 295cdf0e10cSrcweir *reinterpret_cast<unsigned*>( mpPixel ) = nAlpha; 296cdf0e10cSrcweir #else 297cdf0e10cSrcweir mpPixel[0] = nAlpha; 298cdf0e10cSrcweir mpPixel[1] = nAlpha >> 8U; 299cdf0e10cSrcweir mpPixel[2] = nAlpha >> 16U; 300cdf0e10cSrcweir mpPixel[3] = nAlpha >> 24U; 301cdf0e10cSrcweir #endif 302cdf0e10cSrcweir } 303cdf0e10cSrcweir }; 304cdf0e10cSrcweir 305cdf0e10cSrcweir #endif 306cdf0e10cSrcweir 307cdf0e10cSrcweir // ======================================================================= 308cdf0e10cSrcweir // converting truecolor formats 309cdf0e10cSrcweir 310cdf0e10cSrcweir template <sal_uLong SRCFMT, sal_uLong DSTFMT> 311cdf0e10cSrcweir inline void ImplConvertPixel( const TrueColorPixelPtr<DSTFMT>& rDst, 312cdf0e10cSrcweir const TrueColorPixelPtr<SRCFMT>& rSrc ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir rDst.SetColor( rSrc.GetRed(), rSrc.GetGreen(), rSrc.GetBlue() ); 315cdf0e10cSrcweir rDst.SetAlpha( rSrc.GetAlpha() ); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir // ----------------------------------------------------------------------- 319cdf0e10cSrcweir 320cdf0e10cSrcweir template <> 321cdf0e10cSrcweir inline void ImplConvertPixel<BMP_FORMAT_16BIT_TC_LSB_MASK, BMP_FORMAT_16BIT_TC_MSB_MASK> ( 322cdf0e10cSrcweir const TrueColorPixelPtr<BMP_FORMAT_16BIT_TC_MSB_MASK>& rDst, 323cdf0e10cSrcweir const TrueColorPixelPtr<BMP_FORMAT_16BIT_TC_LSB_MASK>& rSrc ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir // byte swapping 326cdf0e10cSrcweir const PIXBYTE* pSrc = rSrc.GetRawPtr(); 327cdf0e10cSrcweir PIXBYTE* pDst = rDst.GetRawPtr(); 328cdf0e10cSrcweir pDst[1] = pSrc[0]; 329cdf0e10cSrcweir pDst[0] = pSrc[1]; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir // ----------------------------------------------------------------------- 333cdf0e10cSrcweir 334cdf0e10cSrcweir template <sal_uLong SRCFMT, sal_uLong DSTFMT> 335cdf0e10cSrcweir inline void ImplConvertLine( const TrueColorPixelPtr<DSTFMT>& rDst, 336cdf0e10cSrcweir const TrueColorPixelPtr<SRCFMT>& rSrc, int nPixelCount ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir TrueColorPixelPtr<DSTFMT> aDst( rDst ); 339cdf0e10cSrcweir TrueColorPixelPtr<SRCFMT> aSrc( rSrc ); 340cdf0e10cSrcweir while( --nPixelCount >= 0 ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir ImplConvertPixel( aDst, aSrc ); 343cdf0e10cSrcweir ++aSrc; 344cdf0e10cSrcweir ++aDst; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir // ======================================================================= 349cdf0e10cSrcweir // alpha blending truecolor pixels 350cdf0e10cSrcweir 351cdf0e10cSrcweir template <unsigned ALPHABITS, sal_uLong SRCFMT, sal_uLong DSTFMT> 352cdf0e10cSrcweir inline void ImplBlendPixels( const TrueColorPixelPtr<DSTFMT>& rDst, 353cdf0e10cSrcweir const TrueColorPixelPtr<SRCFMT>& rSrc, unsigned nAlphaVal ) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir if( !nAlphaVal ) 356cdf0e10cSrcweir ImplConvertPixel( rDst, rSrc ); 357*b296461cStruckman else if( nAlphaVal != ~(~0u << ALPHABITS) ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir static const unsigned nAlphaShift = (ALPHABITS > 8) ? 8 : ALPHABITS; 360cdf0e10cSrcweir if( ALPHABITS > nAlphaShift ) 361cdf0e10cSrcweir nAlphaVal >>= ALPHABITS - nAlphaShift; 362cdf0e10cSrcweir 363cdf0e10cSrcweir int nR = rDst.GetRed(); 364cdf0e10cSrcweir int nS = rSrc.GetRed(); 365cdf0e10cSrcweir nR = nS + (((nR - nS) * nAlphaVal) >> nAlphaShift); 366cdf0e10cSrcweir 367cdf0e10cSrcweir int nG = rDst.GetGreen(); 368cdf0e10cSrcweir nS = rSrc.GetGreen(); 369cdf0e10cSrcweir nG = nS + (((nG - nS) * nAlphaVal) >> nAlphaShift); 370cdf0e10cSrcweir 371cdf0e10cSrcweir int nB = rDst.GetBlue(); 372cdf0e10cSrcweir nS = rSrc.GetBlue(); 373cdf0e10cSrcweir nB = nS + (((nB - nS) * nAlphaVal) >> nAlphaShift); 374cdf0e10cSrcweir 375cdf0e10cSrcweir rDst.SetColor( sal::static_int_cast<PIXBYTE>(nR), 376cdf0e10cSrcweir sal::static_int_cast<PIXBYTE>(nG), 377cdf0e10cSrcweir sal::static_int_cast<PIXBYTE>(nB) ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir // ----------------------------------------------------------------------- 382cdf0e10cSrcweir 383cdf0e10cSrcweir template <unsigned ALPHABITS, sal_uLong MASKFMT, sal_uLong SRCFMT, sal_uLong DSTFMT> 384cdf0e10cSrcweir inline void ImplBlendLines( const TrueColorPixelPtr<DSTFMT>& rDst, 385cdf0e10cSrcweir const TrueColorPixelPtr<SRCFMT>& rSrc, const TrueColorPixelPtr<MASKFMT>& rMsk, 386cdf0e10cSrcweir int nPixelCount ) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir TrueColorPixelPtr<MASKFMT> aMsk( rMsk ); 389cdf0e10cSrcweir TrueColorPixelPtr<DSTFMT> aDst( rDst ); 390cdf0e10cSrcweir TrueColorPixelPtr<SRCFMT> aSrc( rSrc ); 391cdf0e10cSrcweir while( --nPixelCount >= 0 ) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir ImplBlendPixels<ALPHABITS>( aDst, aSrc, aMsk.GetAlpha() ); 394cdf0e10cSrcweir ++aDst; 395cdf0e10cSrcweir ++aSrc; 396cdf0e10cSrcweir ++aMsk; 397cdf0e10cSrcweir } 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir // ----------------------------------------------------------------------- 401cdf0e10cSrcweir 402cdf0e10cSrcweir template <unsigned ALPHABITS, sal_uLong SRCFMT, sal_uLong DSTFMT> 403cdf0e10cSrcweir inline void ImplBlendLines( const TrueColorPixelPtr<DSTFMT>& rDst, 404cdf0e10cSrcweir const TrueColorPixelPtr<SRCFMT>& rSrc, unsigned nAlphaVal, 405cdf0e10cSrcweir int nPixelCount ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir if( nAlphaVal == ~(~0 << ALPHABITS) ) 408cdf0e10cSrcweir ImplConvertLine( rDst, rSrc, nPixelCount ); 409cdf0e10cSrcweir else if( nAlphaVal ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir TrueColorPixelPtr<SRCFMT> aSrc( rSrc ); 412cdf0e10cSrcweir TrueColorPixelPtr<DSTFMT> aDst( rDst ); 413cdf0e10cSrcweir while( --nPixelCount >= 0 ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir ImplBlendPixels<ALPHABITS>( aDst, aSrc, nAlphaVal ); 416cdf0e10cSrcweir ++aDst; 417cdf0e10cSrcweir ++aSrc; 418cdf0e10cSrcweir } 419cdf0e10cSrcweir } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir // ======================================================================= 423cdf0e10cSrcweir 424cdf0e10cSrcweir static bool ImplCopyImage( BitmapBuffer& rDstBuffer, const BitmapBuffer& rSrcBuffer ) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir const int nSrcLinestep = rSrcBuffer.mnScanlineSize; 427cdf0e10cSrcweir int nDstLinestep = rDstBuffer.mnScanlineSize; 428cdf0e10cSrcweir 429cdf0e10cSrcweir const PIXBYTE* pRawSrc = rSrcBuffer.mpBits; 430cdf0e10cSrcweir PIXBYTE* pRawDst = rDstBuffer.mpBits; 431cdf0e10cSrcweir 432cdf0e10cSrcweir // source and destination don't match upside down 433cdf0e10cSrcweir if( BMP_FORMAT_TOP_DOWN & (rSrcBuffer.mnFormat ^ rDstBuffer.mnFormat) ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir pRawDst += (rSrcBuffer.mnHeight - 1) * nDstLinestep; 436cdf0e10cSrcweir nDstLinestep = -rDstBuffer.mnScanlineSize; 437cdf0e10cSrcweir } 438cdf0e10cSrcweir else if( nSrcLinestep == nDstLinestep ) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir memcpy( pRawDst, pRawSrc, rSrcBuffer.mnHeight * nDstLinestep ); 441cdf0e10cSrcweir return true; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir int nByteWidth = nSrcLinestep; 445cdf0e10cSrcweir if( nByteWidth > rDstBuffer.mnScanlineSize ) 446cdf0e10cSrcweir nByteWidth = rDstBuffer.mnScanlineSize; 447cdf0e10cSrcweir 448cdf0e10cSrcweir for( int y = rSrcBuffer.mnHeight; --y >= 0; ) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir memcpy( pRawDst, pRawSrc, nByteWidth ); 451cdf0e10cSrcweir pRawSrc += nSrcLinestep; 452cdf0e10cSrcweir pRawDst += nDstLinestep; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir return true; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir // ----------------------------------------------------------------------- 459cdf0e10cSrcweir 460cdf0e10cSrcweir template <sal_uLong DSTFMT,sal_uLong SRCFMT> 461cdf0e10cSrcweir bool ImplConvertToBitmap( TrueColorPixelPtr<SRCFMT>& rSrcLine, 462cdf0e10cSrcweir BitmapBuffer& rDstBuffer, const BitmapBuffer& rSrcBuffer ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir // help the compiler to avoid instantiations of unneeded conversions 465cdf0e10cSrcweir DBG_ASSERT( SRCFMT != DSTFMT, "ImplConvertToBitmap into same format"); 466cdf0e10cSrcweir if( SRCFMT == DSTFMT ) 467cdf0e10cSrcweir return false; 468cdf0e10cSrcweir 469cdf0e10cSrcweir const int nSrcLinestep = rSrcBuffer.mnScanlineSize; 470cdf0e10cSrcweir int nDstLinestep = rDstBuffer.mnScanlineSize; 471cdf0e10cSrcweir 472cdf0e10cSrcweir TrueColorPixelPtr<DSTFMT> aDstLine; aDstLine.SetRawPtr( rDstBuffer.mpBits ); 473cdf0e10cSrcweir 474cdf0e10cSrcweir // source and destination don't match upside down 475cdf0e10cSrcweir if( BMP_FORMAT_TOP_DOWN & (rSrcBuffer.mnFormat ^ rDstBuffer.mnFormat) ) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir aDstLine.AddByteOffset( (rSrcBuffer.mnHeight - 1) * nDstLinestep ); 478cdf0e10cSrcweir nDstLinestep = -nDstLinestep; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir for( int y = rSrcBuffer.mnHeight; --y >= 0; ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir ImplConvertLine( aDstLine, rSrcLine, rSrcBuffer.mnWidth ); 484cdf0e10cSrcweir rSrcLine.AddByteOffset( nSrcLinestep ); 485cdf0e10cSrcweir aDstLine.AddByteOffset( nDstLinestep ); 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir return true; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir // ----------------------------------------------------------------------- 492cdf0e10cSrcweir 493cdf0e10cSrcweir template <sal_uLong SRCFMT> 494cdf0e10cSrcweir inline bool ImplConvertFromBitmap( BitmapBuffer& rDst, const BitmapBuffer& rSrc ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir TrueColorPixelPtr<SRCFMT> aSrcType; aSrcType.SetRawPtr( rSrc.mpBits ); 497cdf0e10cSrcweir 498cdf0e10cSrcweir // select the matching instantiation for the destination's bitmap format 499cdf0e10cSrcweir switch( rDst.mnFormat & ~BMP_FORMAT_TOP_DOWN ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir case BMP_FORMAT_1BIT_MSB_PAL: 502cdf0e10cSrcweir case BMP_FORMAT_1BIT_LSB_PAL: 503cdf0e10cSrcweir case BMP_FORMAT_4BIT_MSN_PAL: 504cdf0e10cSrcweir case BMP_FORMAT_4BIT_LSN_PAL: 505cdf0e10cSrcweir case BMP_FORMAT_8BIT_PAL: 506cdf0e10cSrcweir break; 507cdf0e10cSrcweir 508cdf0e10cSrcweir case BMP_FORMAT_8BIT_TC_MASK: 509cdf0e10cSrcweir // return ImplConvertToBitmap<BMP_FORMAT_8BIT_TC_MASK>( aSrcType, rDst, rSrc ); 510cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_MASK: 511cdf0e10cSrcweir // return ImplConvertToBitmap<BMP_FORMAT_24BIT_TC_MASK>( aSrcType, rDst, rSrc ); 512cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_MASK: 513cdf0e10cSrcweir // return ImplConvertToBitmap<BMP_FORMAT_32BIT_TC_MASK>( aSrcType, rDst, rSrc ); 514cdf0e10cSrcweir break; 515cdf0e10cSrcweir 516cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_MSB_MASK: 517cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_16BIT_TC_MSB_MASK>( aSrcType, rDst, rSrc ); 518cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_LSB_MASK: 519cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_16BIT_TC_LSB_MASK>( aSrcType, rDst, rSrc ); 520cdf0e10cSrcweir 521cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_BGR: 522cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_24BIT_TC_BGR>( aSrcType, rDst, rSrc ); 523cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_RGB: 524cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_24BIT_TC_RGB>( aSrcType, rDst, rSrc ); 525cdf0e10cSrcweir 526cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ABGR: 527cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_32BIT_TC_ABGR>( aSrcType, rDst, rSrc ); 528cdf0e10cSrcweir #ifdef FAST_ARGB_BGRA 529cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ARGB: 530cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_32BIT_TC_ARGB>( aSrcType, rDst, rSrc ); 531cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_BGRA: 532cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_32BIT_TC_BGRA>( aSrcType, rDst, rSrc ); 533cdf0e10cSrcweir #endif 534cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_RGBA: 535cdf0e10cSrcweir return ImplConvertToBitmap<BMP_FORMAT_32BIT_TC_RGBA>( aSrcType, rDst, rSrc ); 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir #ifdef DEBUG 539cdf0e10cSrcweir static int nNotAccelerated = 0; 540cdf0e10cSrcweir if( rSrc.mnWidth * rSrc.mnHeight >= 4000 ) 541cdf0e10cSrcweir if( ++nNotAccelerated == 100 ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir int foo = 0; (void)foo; // so no warning is created when building on pro with debug 544cdf0e10cSrcweir DBG_WARNING2( "ImplConvertFromBitmap for not accelerated case (0x%04X->0x%04X)", 545cdf0e10cSrcweir rSrc.mnFormat, rDst.mnFormat ); 546cdf0e10cSrcweir } 547cdf0e10cSrcweir #endif 548cdf0e10cSrcweir 549cdf0e10cSrcweir return false; 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir // ======================================================================= 553cdf0e10cSrcweir 554cdf0e10cSrcweir // an universal stretching conversion is overkill in most common situations 555cdf0e10cSrcweir // => performance benefits for speeding up the non-stretching cases 556cdf0e10cSrcweir bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc, 557cdf0e10cSrcweir const SalTwoRect& rTR ) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir if( bDisableFastBitops ) 560cdf0e10cSrcweir return false; 561cdf0e10cSrcweir 562cdf0e10cSrcweir // horizontal mirroring not implemented yet 563cdf0e10cSrcweir if( rTR.mnDestWidth < 0 ) 564cdf0e10cSrcweir return false; 565cdf0e10cSrcweir // vertical mirroring 566cdf0e10cSrcweir if( rTR.mnDestHeight < 0 ) 567cdf0e10cSrcweir // TODO: rDst.mnFormat ^= BMP_FORMAT_TOP_DOWN; 568cdf0e10cSrcweir return false; 569cdf0e10cSrcweir 570cdf0e10cSrcweir // offseted conversion is not implemented yet 571cdf0e10cSrcweir if( rTR.mnSrcX || rTR.mnSrcY ) 572cdf0e10cSrcweir return false; 573cdf0e10cSrcweir if( rTR.mnDestX || rTR.mnDestY ) 574cdf0e10cSrcweir return false; 575cdf0e10cSrcweir 576cdf0e10cSrcweir // stretched conversion is not implemented yet 577cdf0e10cSrcweir if( rTR.mnDestWidth != rTR.mnSrcWidth ) 578cdf0e10cSrcweir return false; 579cdf0e10cSrcweir if( rTR.mnDestHeight!= rTR.mnSrcHeight ) 580cdf0e10cSrcweir return false; 581cdf0e10cSrcweir 582cdf0e10cSrcweir // check source image size 583cdf0e10cSrcweir if( rSrc.mnWidth < rTR.mnSrcX + rTR.mnSrcWidth ) 584cdf0e10cSrcweir return false; 585cdf0e10cSrcweir if( rSrc.mnHeight < rTR.mnSrcY + rTR.mnSrcHeight ) 586cdf0e10cSrcweir return false; 587cdf0e10cSrcweir 588cdf0e10cSrcweir // check dest image size 589cdf0e10cSrcweir if( rDst.mnWidth < rTR.mnDestX + rTR.mnDestWidth ) 590cdf0e10cSrcweir return false; 591cdf0e10cSrcweir if( rDst.mnHeight < rTR.mnDestY + rTR.mnDestHeight ) 592cdf0e10cSrcweir return false; 593cdf0e10cSrcweir 594cdf0e10cSrcweir const sal_uLong nSrcFormat = rSrc.mnFormat & ~BMP_FORMAT_TOP_DOWN; 595cdf0e10cSrcweir const sal_uLong nDstFormat = rDst.mnFormat & ~BMP_FORMAT_TOP_DOWN; 596cdf0e10cSrcweir 597cdf0e10cSrcweir // TODO: also implement conversions for 16bit colormasks with non-565 format 598cdf0e10cSrcweir if( nSrcFormat & (BMP_FORMAT_16BIT_TC_LSB_MASK | BMP_FORMAT_16BIT_TC_MSB_MASK) ) 599cdf0e10cSrcweir if( rSrc.maColorMask.GetRedMask() != 0xF800 600cdf0e10cSrcweir || rSrc.maColorMask.GetGreenMask()!= 0x07E0 601cdf0e10cSrcweir || rSrc.maColorMask.GetBlueMask() != 0x001F ) 602cdf0e10cSrcweir return false; 603cdf0e10cSrcweir if( nDstFormat & (BMP_FORMAT_16BIT_TC_LSB_MASK | BMP_FORMAT_16BIT_TC_MSB_MASK) ) 604cdf0e10cSrcweir if( rDst.maColorMask.GetRedMask() != 0xF800 605cdf0e10cSrcweir || rDst.maColorMask.GetGreenMask()!= 0x07E0 606cdf0e10cSrcweir || rDst.maColorMask.GetBlueMask() != 0x001F ) 607cdf0e10cSrcweir return false; 608cdf0e10cSrcweir 609cdf0e10cSrcweir // special handling of trivial cases 610cdf0e10cSrcweir if( nSrcFormat == nDstFormat ) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir // accelerated palette conversions not yet implemented 613cdf0e10cSrcweir if( rSrc.maPalette != rDst.maPalette ) 614cdf0e10cSrcweir return false; 615cdf0e10cSrcweir return ImplCopyImage( rDst, rSrc ); 616cdf0e10cSrcweir } 617cdf0e10cSrcweir 618cdf0e10cSrcweir // select the matching instantiation for the source's bitmap format 619cdf0e10cSrcweir switch( nSrcFormat ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir case BMP_FORMAT_1BIT_MSB_PAL: 622cdf0e10cSrcweir case BMP_FORMAT_1BIT_LSB_PAL: 623cdf0e10cSrcweir case BMP_FORMAT_4BIT_MSN_PAL: 624cdf0e10cSrcweir case BMP_FORMAT_4BIT_LSN_PAL: 625cdf0e10cSrcweir case BMP_FORMAT_8BIT_PAL: 626cdf0e10cSrcweir break; 627cdf0e10cSrcweir 628cdf0e10cSrcweir case BMP_FORMAT_8BIT_TC_MASK: 629cdf0e10cSrcweir // return ImplConvertFromBitmap<BMP_FORMAT_8BIT_TC_MASK>( rDst, rSrc ); 630cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_MASK: 631cdf0e10cSrcweir // return ImplConvertFromBitmap<BMP_FORMAT_24BIT_TC_MASK>( rDst, rSrc ); 632cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_MASK: 633cdf0e10cSrcweir // return ImplConvertFromBitmap<BMP_FORMAT_32BIT_TC_MASK>( rDst, rSrc ); 634cdf0e10cSrcweir break; 635cdf0e10cSrcweir 636cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_MSB_MASK: 637cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_16BIT_TC_MSB_MASK>( rDst, rSrc ); 638cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_LSB_MASK: 639cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_16BIT_TC_LSB_MASK>( rDst, rSrc ); 640cdf0e10cSrcweir 641cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_BGR: 642cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_24BIT_TC_BGR>( rDst, rSrc ); 643cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_RGB: 644cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_24BIT_TC_RGB>( rDst, rSrc ); 645cdf0e10cSrcweir 646cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ABGR: 647cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_32BIT_TC_ABGR>( rDst, rSrc ); 648cdf0e10cSrcweir #ifdef FAST_ARGB_BGRA 649cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ARGB: 650cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_32BIT_TC_ARGB>( rDst, rSrc ); 651cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_BGRA: 652cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_32BIT_TC_BGRA>( rDst, rSrc ); 653cdf0e10cSrcweir #endif 654cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_RGBA: 655cdf0e10cSrcweir return ImplConvertFromBitmap<BMP_FORMAT_32BIT_TC_RGBA>( rDst, rSrc ); 656cdf0e10cSrcweir } 657cdf0e10cSrcweir 658cdf0e10cSrcweir #ifdef DEBUG 659cdf0e10cSrcweir static int nNotAccelerated = 0; 660cdf0e10cSrcweir if( rSrc.mnWidth * rSrc.mnHeight >= 4000 ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir if( ++nNotAccelerated == 100 ) 663cdf0e10cSrcweir { 664cdf0e10cSrcweir int foo = 0; (void)foo; // so no warning is created when building on pro with debug 665cdf0e10cSrcweir DBG_WARNING2( "ImplFastBitmapConversion for not accelerated case (0x%04X->0x%04X)", rSrc.mnFormat, rDst.mnFormat ); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir } 668cdf0e10cSrcweir #endif 669cdf0e10cSrcweir 670cdf0e10cSrcweir return false; 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir // ======================================================================= 674cdf0e10cSrcweir 675cdf0e10cSrcweir template <sal_uLong DSTFMT,sal_uLong SRCFMT> //,sal_uLong MSKFMT> 676cdf0e10cSrcweir bool ImplBlendToBitmap( TrueColorPixelPtr<SRCFMT>& rSrcLine, 677cdf0e10cSrcweir BitmapBuffer& rDstBuffer, const BitmapBuffer& rSrcBuffer, 678cdf0e10cSrcweir const BitmapBuffer& rMskBuffer ) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir //DBG_ASSERT( rMskBuffer.mnFormat == MSKFMT, "FastBmp BlendImage: wrong MSKFMT" ); 681cdf0e10cSrcweir DBG_ASSERT( rMskBuffer.mnFormat == BMP_FORMAT_8BIT_PAL, "FastBmp BlendImage: unusual MSKFMT" ); 682cdf0e10cSrcweir 683cdf0e10cSrcweir const int nSrcLinestep = rSrcBuffer.mnScanlineSize; 684cdf0e10cSrcweir int nMskLinestep = rMskBuffer.mnScanlineSize; 685cdf0e10cSrcweir int nDstLinestep = rDstBuffer.mnScanlineSize; 686cdf0e10cSrcweir 687cdf0e10cSrcweir TrueColorPixelPtr<BMP_FORMAT_8BIT_PAL> aMskLine; aMskLine.SetRawPtr( rMskBuffer.mpBits ); 688cdf0e10cSrcweir TrueColorPixelPtr<DSTFMT> aDstLine; aDstLine.SetRawPtr( rDstBuffer.mpBits ); 689cdf0e10cSrcweir 690cdf0e10cSrcweir // special case for single line masks 691cdf0e10cSrcweir if( rMskBuffer.mnHeight == 1 ) 692cdf0e10cSrcweir nMskLinestep = 0; 693cdf0e10cSrcweir 694cdf0e10cSrcweir // source and mask don't match: upside down 695cdf0e10cSrcweir if( (rSrcBuffer.mnFormat ^ rMskBuffer.mnFormat) & BMP_FORMAT_TOP_DOWN ) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir aMskLine.AddByteOffset( (rSrcBuffer.mnHeight - 1) * nMskLinestep ); 698cdf0e10cSrcweir nMskLinestep = -nMskLinestep; 699cdf0e10cSrcweir } 700cdf0e10cSrcweir 701cdf0e10cSrcweir // source and destination don't match: upside down 702cdf0e10cSrcweir if( (rSrcBuffer.mnFormat ^ rDstBuffer.mnFormat) & BMP_FORMAT_TOP_DOWN ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir aDstLine.AddByteOffset( (rSrcBuffer.mnHeight - 1) * nDstLinestep ); 705cdf0e10cSrcweir nDstLinestep = -nDstLinestep; 706cdf0e10cSrcweir } 707cdf0e10cSrcweir 708cdf0e10cSrcweir for( int y = rSrcBuffer.mnHeight; --y >= 0; ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir ImplBlendLines<8>( aDstLine, rSrcLine, aMskLine, rDstBuffer.mnWidth ); 711cdf0e10cSrcweir aDstLine.AddByteOffset( nDstLinestep ); 712cdf0e10cSrcweir rSrcLine.AddByteOffset( nSrcLinestep ); 713cdf0e10cSrcweir aMskLine.AddByteOffset( nMskLinestep ); 714cdf0e10cSrcweir } 715cdf0e10cSrcweir 716cdf0e10cSrcweir return true; 717cdf0e10cSrcweir } 718cdf0e10cSrcweir 719cdf0e10cSrcweir // some specializations to reduce the code size 720cdf0e10cSrcweir template <> 721cdf0e10cSrcweir inline bool ImplBlendToBitmap<BMP_FORMAT_24BIT_TC_BGR,BMP_FORMAT_24BIT_TC_BGR>( 722cdf0e10cSrcweir TrueColorPixelPtr<BMP_FORMAT_24BIT_TC_BGR>&, 723cdf0e10cSrcweir BitmapBuffer& rDstBuffer, const BitmapBuffer& rSrcBuffer, 724cdf0e10cSrcweir const BitmapBuffer& rMskBuffer ) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir TrueColorPixelPtr<BMP_FORMAT_24BIT_TC_RGB> aSrcType; aSrcType.SetRawPtr( rSrcBuffer.mpBits ); 727cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_24BIT_TC_RGB>( aSrcType, rDstBuffer, rSrcBuffer, rMskBuffer ); 728cdf0e10cSrcweir } 729cdf0e10cSrcweir 730cdf0e10cSrcweir template <> 731cdf0e10cSrcweir inline bool ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_ABGR,BMP_FORMAT_32BIT_TC_ABGR>( 732cdf0e10cSrcweir TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_ABGR>&, 733cdf0e10cSrcweir BitmapBuffer& rDstBuffer, const BitmapBuffer& rSrcBuffer, 734cdf0e10cSrcweir const BitmapBuffer& rMskBuffer ) 735cdf0e10cSrcweir { 736cdf0e10cSrcweir TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_ARGB> aSrcType; aSrcType.SetRawPtr( rSrcBuffer.mpBits ); 737cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_ARGB>( aSrcType, rDstBuffer, rSrcBuffer, rMskBuffer ); 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir template <> 741cdf0e10cSrcweir inline bool ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_BGRA,BMP_FORMAT_32BIT_TC_BGRA>( 742cdf0e10cSrcweir TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_BGRA>&, 743cdf0e10cSrcweir BitmapBuffer& rDstBuffer, const BitmapBuffer& rSrcBuffer, 744cdf0e10cSrcweir const BitmapBuffer& rMskBuffer ) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir TrueColorPixelPtr<BMP_FORMAT_32BIT_TC_RGBA> aSrcType; aSrcType.SetRawPtr( rSrcBuffer.mpBits ); 747cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_RGBA>( aSrcType, rDstBuffer, rSrcBuffer, rMskBuffer ); 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir // ----------------------------------------------------------------------- 751cdf0e10cSrcweir 752cdf0e10cSrcweir template <sal_uLong SRCFMT> 753cdf0e10cSrcweir bool ImplBlendFromBitmap( BitmapBuffer& rDst, const BitmapBuffer& rSrc, const BitmapBuffer& rMsk ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir TrueColorPixelPtr<SRCFMT> aSrcType; aSrcType.SetRawPtr( rSrc.mpBits ); 756cdf0e10cSrcweir 757cdf0e10cSrcweir // select the matching instantiation for the destination's bitmap format 758cdf0e10cSrcweir switch( rDst.mnFormat & ~BMP_FORMAT_TOP_DOWN ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir case BMP_FORMAT_1BIT_MSB_PAL: 761cdf0e10cSrcweir case BMP_FORMAT_1BIT_LSB_PAL: 762cdf0e10cSrcweir case BMP_FORMAT_4BIT_MSN_PAL: 763cdf0e10cSrcweir case BMP_FORMAT_4BIT_LSN_PAL: 764cdf0e10cSrcweir case BMP_FORMAT_8BIT_PAL: 765cdf0e10cSrcweir break; 766cdf0e10cSrcweir 767cdf0e10cSrcweir case BMP_FORMAT_8BIT_TC_MASK: 768cdf0e10cSrcweir // return ImplBlendToBitmap<BMP_FORMAT_8BIT_TC_MASK>( aSrcType, rDst, rSrc, rMsk ); 769cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_MASK: 770cdf0e10cSrcweir // return ImplBlendToBitmap<BMP_FORMAT_24BIT_TC_MASK>( aSrcType, rDst, rSrc, rMsk ); 771cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_MASK: 772cdf0e10cSrcweir // return ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_MASK>( aSrcType, rDst, rSrc, rMsk ); 773cdf0e10cSrcweir break; 774cdf0e10cSrcweir 775cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_MSB_MASK: 776cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_16BIT_TC_MSB_MASK>( aSrcType, rDst, rSrc, rMsk ); 777cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_LSB_MASK: 778cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_16BIT_TC_LSB_MASK>( aSrcType, rDst, rSrc, rMsk ); 779cdf0e10cSrcweir 780cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_BGR: 781cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_24BIT_TC_BGR>( aSrcType, rDst, rSrc, rMsk ); 782cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_RGB: 783cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_24BIT_TC_RGB>( aSrcType, rDst, rSrc, rMsk ); 784cdf0e10cSrcweir 785cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ABGR: 786cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_ABGR>( aSrcType, rDst, rSrc, rMsk ); 787cdf0e10cSrcweir #ifdef FAST_ARGB_BGRA 788cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ARGB: 789cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_ARGB>( aSrcType, rDst, rSrc, rMsk ); 790cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_BGRA: 791cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_BGRA>( aSrcType, rDst, rSrc, rMsk ); 792cdf0e10cSrcweir #endif 793cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_RGBA: 794cdf0e10cSrcweir return ImplBlendToBitmap<BMP_FORMAT_32BIT_TC_RGBA>( aSrcType, rDst, rSrc, rMsk ); 795cdf0e10cSrcweir } 796cdf0e10cSrcweir 797cdf0e10cSrcweir #ifdef DEBUG 798cdf0e10cSrcweir static int nNotAccelerated = 0; 799cdf0e10cSrcweir if( rSrc.mnWidth * rSrc.mnHeight >= 4000 ) 800cdf0e10cSrcweir if( ++nNotAccelerated == 100 ) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir int foo = 0; (void)foo; // so no warning is created when building on pro with debug 803cdf0e10cSrcweir DBG_WARNING3( "ImplBlendFromBitmap for not accelerated case (0x%04X*0x%04X->0x%04X)", 804cdf0e10cSrcweir rSrc.mnFormat, rMsk.mnFormat, rDst.mnFormat ); 805cdf0e10cSrcweir } 806cdf0e10cSrcweir #endif 807cdf0e10cSrcweir 808cdf0e10cSrcweir return false; 809cdf0e10cSrcweir } 810cdf0e10cSrcweir 811cdf0e10cSrcweir // ----------------------------------------------------------------------- 812cdf0e10cSrcweir 813cdf0e10cSrcweir bool ImplFastBitmapBlending( BitmapWriteAccess& rDstWA, 814cdf0e10cSrcweir const BitmapReadAccess& rSrcRA, const BitmapReadAccess& rMskRA, 815cdf0e10cSrcweir const SalTwoRect& rTR ) 816cdf0e10cSrcweir { 817cdf0e10cSrcweir if( bDisableFastBitops ) 818cdf0e10cSrcweir return false; 819cdf0e10cSrcweir 820cdf0e10cSrcweir // accelerated blending of paletted bitmaps not implemented yet 821cdf0e10cSrcweir if( rSrcRA.HasPalette() ) 822cdf0e10cSrcweir return false; 823cdf0e10cSrcweir if( rDstWA.HasPalette() ) 824cdf0e10cSrcweir return false; 825cdf0e10cSrcweir // TODO: either get rid of mask's use of 8BIT_PAL or check the palette 826cdf0e10cSrcweir 827cdf0e10cSrcweir // horizontal mirroring not implemented yet 828cdf0e10cSrcweir if( rTR.mnDestWidth < 0 ) 829cdf0e10cSrcweir return false; 830cdf0e10cSrcweir // vertical mirroring 831cdf0e10cSrcweir if( rTR.mnDestHeight < 0 ) 832cdf0e10cSrcweir // TODO: rDst.mnFormat ^= BMP_FORMAT_TOP_DOWN; 833cdf0e10cSrcweir return false; 834cdf0e10cSrcweir 835cdf0e10cSrcweir // offseted blending is not implemented yet 836cdf0e10cSrcweir if( rTR.mnSrcX || rTR.mnSrcY ) 837cdf0e10cSrcweir return false; 838cdf0e10cSrcweir if( rTR.mnDestX || rTR.mnDestY ) 839cdf0e10cSrcweir return false; 840cdf0e10cSrcweir 841cdf0e10cSrcweir // stretched blending is not implemented yet 842cdf0e10cSrcweir if( rTR.mnDestWidth != rTR.mnSrcWidth ) 843cdf0e10cSrcweir return false; 844cdf0e10cSrcweir if( rTR.mnDestHeight!= rTR.mnSrcHeight ) 845cdf0e10cSrcweir return false; 846cdf0e10cSrcweir 847cdf0e10cSrcweir // check source image size 848cdf0e10cSrcweir if( rSrcRA.Width() < rTR.mnSrcX + rTR.mnSrcWidth ) 849cdf0e10cSrcweir return false; 850cdf0e10cSrcweir if( rSrcRA.Height() < rTR.mnSrcY + rTR.mnSrcHeight ) 851cdf0e10cSrcweir return false; 852cdf0e10cSrcweir 853cdf0e10cSrcweir // check mask image size 854cdf0e10cSrcweir if( rMskRA.Width() < rTR.mnSrcX + rTR.mnSrcWidth ) 855cdf0e10cSrcweir return false; 856cdf0e10cSrcweir if( rMskRA.Height() < rTR.mnSrcY + rTR.mnSrcHeight ) 857cdf0e10cSrcweir if( rMskRA.Height() != 1 ) 858cdf0e10cSrcweir return false; 859cdf0e10cSrcweir 860cdf0e10cSrcweir // check dest image size 861cdf0e10cSrcweir if( rDstWA.Width() < rTR.mnDestX + rTR.mnDestWidth ) 862cdf0e10cSrcweir return false; 863cdf0e10cSrcweir if( rDstWA.Height() < rTR.mnDestY + rTR.mnDestHeight ) 864cdf0e10cSrcweir return false; 865cdf0e10cSrcweir 866cdf0e10cSrcweir BitmapBuffer& rDst = *rDstWA.ImplGetBitmapBuffer(); 867cdf0e10cSrcweir const BitmapBuffer& rSrc = *rSrcRA.ImplGetBitmapBuffer(); 868cdf0e10cSrcweir const BitmapBuffer& rMsk = *rMskRA.ImplGetBitmapBuffer(); 869cdf0e10cSrcweir 870cdf0e10cSrcweir const sal_uLong nSrcFormat = rSrc.mnFormat & ~BMP_FORMAT_TOP_DOWN; 871cdf0e10cSrcweir const sal_uLong nDstFormat = rDst.mnFormat & ~BMP_FORMAT_TOP_DOWN; 872cdf0e10cSrcweir 873cdf0e10cSrcweir // accelerated conversions for 16bit colormasks with non-565 format are not yet implemented 874cdf0e10cSrcweir if( nSrcFormat & (BMP_FORMAT_16BIT_TC_LSB_MASK | BMP_FORMAT_16BIT_TC_MSB_MASK) ) 875cdf0e10cSrcweir if( rSrc.maColorMask.GetRedMask() != 0xF800 876cdf0e10cSrcweir || rSrc.maColorMask.GetGreenMask()!= 0x07E0 877cdf0e10cSrcweir || rSrc.maColorMask.GetBlueMask() != 0x001F) 878cdf0e10cSrcweir return false; 879cdf0e10cSrcweir if( nDstFormat & (BMP_FORMAT_16BIT_TC_LSB_MASK | BMP_FORMAT_16BIT_TC_MSB_MASK) ) 880cdf0e10cSrcweir if( rDst.maColorMask.GetRedMask() != 0xF800 881cdf0e10cSrcweir || rDst.maColorMask.GetGreenMask()!= 0x07E0 882cdf0e10cSrcweir || rDst.maColorMask.GetBlueMask() != 0x001F) 883cdf0e10cSrcweir return false; 884cdf0e10cSrcweir 885cdf0e10cSrcweir // select the matching instantiation for the source's bitmap format 886cdf0e10cSrcweir switch( nSrcFormat ) 887cdf0e10cSrcweir { 888cdf0e10cSrcweir case BMP_FORMAT_1BIT_MSB_PAL: 889cdf0e10cSrcweir case BMP_FORMAT_1BIT_LSB_PAL: 890cdf0e10cSrcweir case BMP_FORMAT_4BIT_MSN_PAL: 891cdf0e10cSrcweir case BMP_FORMAT_4BIT_LSN_PAL: 892cdf0e10cSrcweir case BMP_FORMAT_8BIT_PAL: 893cdf0e10cSrcweir break; 894cdf0e10cSrcweir 895cdf0e10cSrcweir case BMP_FORMAT_8BIT_TC_MASK: 896cdf0e10cSrcweir // return ImplBlendFromBitmap<BMP_FORMAT_8BIT_TC_MASK>( rDst, rSrc ); 897cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_MASK: 898cdf0e10cSrcweir // return ImplBlendFromBitmap<BMP_FORMAT_24BIT_TC_MASK>( rDst, rSrc ); 899cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_MASK: 900cdf0e10cSrcweir // return ImplBlendFromBitmap<BMP_FORMAT_32BIT_TC_MASK>( rDst, rSrc ); 901cdf0e10cSrcweir break; 902cdf0e10cSrcweir 903cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_MSB_MASK: 904cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_16BIT_TC_MSB_MASK>( rDst, rSrc, rMsk ); 905cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_LSB_MASK: 906cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_16BIT_TC_LSB_MASK>( rDst, rSrc, rMsk ); 907cdf0e10cSrcweir 908cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_BGR: 909cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_24BIT_TC_BGR>( rDst, rSrc, rMsk ); 910cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_RGB: 911cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_24BIT_TC_RGB>( rDst, rSrc, rMsk ); 912cdf0e10cSrcweir 913cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ABGR: 914cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_32BIT_TC_ABGR>( rDst, rSrc, rMsk ); 915cdf0e10cSrcweir #ifdef FAST_ARGB_BGRA 916cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ARGB: 917cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_32BIT_TC_ARGB>( rDst, rSrc, rMsk ); 918cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_BGRA: 919cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_32BIT_TC_BGRA>( rDst, rSrc, rMsk ); 920cdf0e10cSrcweir #endif 921cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_RGBA: 922cdf0e10cSrcweir return ImplBlendFromBitmap<BMP_FORMAT_32BIT_TC_RGBA>( rDst, rSrc, rMsk ); 923cdf0e10cSrcweir } 924cdf0e10cSrcweir 925cdf0e10cSrcweir #ifdef DEBUG 926cdf0e10cSrcweir static int nNotAccelerated = 0; 927cdf0e10cSrcweir if( rSrc.mnWidth * rSrc.mnHeight >= 4000 ) 928cdf0e10cSrcweir if( ++nNotAccelerated == 100 ) 929cdf0e10cSrcweir { 930cdf0e10cSrcweir int foo = 0; (void)foo; // so no warning is created when building on pro with debug 931cdf0e10cSrcweir DBG_WARNING3( "ImplFastBlend for not accelerated case (0x%04X*0x%04X->0x%04X)", 932cdf0e10cSrcweir rSrc.mnFormat, rMsk.mnFormat, rDst.mnFormat ); 933cdf0e10cSrcweir } 934cdf0e10cSrcweir #endif 935cdf0e10cSrcweir 936cdf0e10cSrcweir return false; 937cdf0e10cSrcweir } 938cdf0e10cSrcweir 939cdf0e10cSrcweir bool ImplFastEraseBitmap( BitmapBuffer& rDst, const BitmapColor& rColor ) 940cdf0e10cSrcweir { 941cdf0e10cSrcweir if( bDisableFastBitops ) 942cdf0e10cSrcweir return false; 943cdf0e10cSrcweir 944cdf0e10cSrcweir const sal_uLong nDstFormat = rDst.mnFormat & ~BMP_FORMAT_TOP_DOWN; 945cdf0e10cSrcweir 946cdf0e10cSrcweir // erasing a bitmap is often just a byte-wise memory fill 947cdf0e10cSrcweir bool bByteFill = true; 948cdf0e10cSrcweir sal_uInt8 nFillByte; 949cdf0e10cSrcweir 950cdf0e10cSrcweir switch( nDstFormat ) 951cdf0e10cSrcweir { 952cdf0e10cSrcweir case BMP_FORMAT_1BIT_MSB_PAL: 953cdf0e10cSrcweir case BMP_FORMAT_1BIT_LSB_PAL: 954cdf0e10cSrcweir nFillByte = rColor.GetIndex(); 955cdf0e10cSrcweir nFillByte = static_cast<sal_uInt8>( -(nFillByte & 1) ); // 0x00 or 0xFF 956cdf0e10cSrcweir break; 957cdf0e10cSrcweir case BMP_FORMAT_4BIT_MSN_PAL: 958cdf0e10cSrcweir case BMP_FORMAT_4BIT_LSN_PAL: 959cdf0e10cSrcweir nFillByte = rColor.GetIndex(); 960cdf0e10cSrcweir nFillByte &= 0x0F; 961cdf0e10cSrcweir nFillByte |= (nFillByte << 4); 962cdf0e10cSrcweir break; 963cdf0e10cSrcweir case BMP_FORMAT_8BIT_PAL: 964cdf0e10cSrcweir case BMP_FORMAT_8BIT_TC_MASK: 965cdf0e10cSrcweir nFillByte = rColor.GetIndex(); 966cdf0e10cSrcweir break; 967cdf0e10cSrcweir 968cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_MASK: 969cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_BGR: 970cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_RGB: 971cdf0e10cSrcweir nFillByte = rColor.GetRed(); 972cdf0e10cSrcweir if( (nFillByte != rColor.GetGreen()) 973cdf0e10cSrcweir || (nFillByte != rColor.GetBlue()) ) 974cdf0e10cSrcweir bByteFill = false; 975cdf0e10cSrcweir break; 976cdf0e10cSrcweir 977cdf0e10cSrcweir default: 978cdf0e10cSrcweir bByteFill = false; 979cdf0e10cSrcweir nFillByte = 0x00; 980cdf0e10cSrcweir break; 981cdf0e10cSrcweir } 982cdf0e10cSrcweir 983cdf0e10cSrcweir if( bByteFill ) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir long nByteCount = rDst.mnHeight * rDst.mnScanlineSize; 986cdf0e10cSrcweir rtl_fillMemory( rDst.mpBits, nByteCount, nFillByte ); 987cdf0e10cSrcweir return true; 988cdf0e10cSrcweir } 989cdf0e10cSrcweir 990cdf0e10cSrcweir // TODO: handle other bitmap formats 991cdf0e10cSrcweir switch( nDstFormat ) 992cdf0e10cSrcweir { 993cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_MASK: 994cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_MSB_MASK: 995cdf0e10cSrcweir case BMP_FORMAT_16BIT_TC_LSB_MASK: 996cdf0e10cSrcweir 997cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_BGR: 998cdf0e10cSrcweir case BMP_FORMAT_24BIT_TC_RGB: 999cdf0e10cSrcweir 1000cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ABGR: 1001cdf0e10cSrcweir #ifdef FAST_ARGB_BGRA 1002cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_ARGB: 1003cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_BGRA: 1004cdf0e10cSrcweir #endif 1005cdf0e10cSrcweir case BMP_FORMAT_32BIT_TC_RGBA: 1006cdf0e10cSrcweir break; 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir default: 1009cdf0e10cSrcweir break; 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir 1012cdf0e10cSrcweir return false; 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir // ======================================================================= 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir #else // NO_OPTIMIZED_BITMAP_ACCESS 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir bool ImplFastBitmapConversion( BitmapBuffer&, const BitmapBuffer& ) 1020cdf0e10cSrcweir { 1021cdf0e10cSrcweir return false; 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir bool ImplFastBitmapBlending( BitmapWriteAccess&, 1025cdf0e10cSrcweir const BitmapReadAccess&, const BitmapReadAccess&, 1026cdf0e10cSrcweir const Size&, const Point& ) 1027cdf0e10cSrcweir { 1028cdf0e10cSrcweir return false; 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir 1031cdf0e10cSrcweir bool ImplFastEraseBitmap( BitmapBuffer&, const BitmapColor& ) 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir return false; 1034cdf0e10cSrcweir } 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir #endif 1037