2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-18 11:16:40 +01:00
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-05-31 08:49:45 +00:00
|
|
|
|
2015-10-01 08:31:24 +02:00
|
|
|
#ifndef INCLUDED_BASEBMP_INC_METAFUNCTIONS_HXX
|
|
|
|
#define INCLUDED_BASEBMP_INC_METAFUNCTIONS_HXX
|
2006-05-31 08:49:45 +00:00
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
#include <boost/mpl/integral_c.hpp>
|
2006-06-09 03:21:01 +00:00
|
|
|
#include <vigra/metaprogramming.hxx>
|
|
|
|
#include <vigra/numerictraits.hxx>
|
|
|
|
|
2011-02-08 11:28:22 +01:00
|
|
|
#include <functional>
|
-fsanitize=shift-exponent
Through test code added with d30f5bc3e65463f28c3087acad6f88e12d60e53b
"lok::Document::paintTile: fix non-rectangular tiles wrt. transparency,"
CppunitTest_desktop_lib started to exhibit
> basebmp/inc/metafunctions.hxx:210:26: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'
> unsigned int basebmp::shiftRight<unsigned int>(unsigned int, int) basebmp/inc/metafunctions.hxx:210:26
> basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>::operator()(unsigned int) const basebmp/inc/rgbmaskpixelformats.hxx:123:25
> basebmp::Color basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >::operator()<basebmp::PixelIterator<unsigned int> >(basebmp::PixelIterator<unsigned int> const&) const basebmp/inc/accessoradapters.hxx:115:16
> basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >, basebmp::StdMasks>::getPixel_i(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:472:20
> basebmp::BitmapDevice::getPixel(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:1289:16
> basebmp::Color basebmp::GenericColorImageAccessor::operator()<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > const&) const basebmp/inc/genericcolorimageaccessor.hxx:54:18
> void vigra::copyLine<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:65:18
> void vigra::copyImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:158:9
> void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, bool) basebmp/inc/scaleimage.hxx:133:9
> void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::triple<vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor> const&, vigra::triple<basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > > const&, bool) basebmp/inc/scaleimage.hxx:180:5
> void basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::implDrawBitmapGeneric<basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::PixelIterator<unsigned int> const&, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > const&) basebmp/source/bitmapdevice.cxx:739:13
> basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::drawBitmap_i(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:827:21
> basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:1562:9
> basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode, std::shared_ptr<basebmp::BitmapDevice> const&) basebmp/source/bitmapdevice.cxx:1574:9
> SvpSalGraphics::copyBits(SalTwoRect const&, SalGraphics*) vcl/headless/svpgdi.cxx:687:9
> SalGraphics::CopyBits(SalTwoRect const&, SalGraphics*, OutputDevice const*, OutputDevice const*) vcl/source/gdi/salgdilayout.cxx:589:9
> OutputDevice::GetBitmap(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:443:29
> OutputDevice::GetBitmapEx(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:487:25
> OutputDevice::DrawOutDev(Point const&, Size const&, Point const&, Size const&, OutputDevice const&) vcl/source/outdev/outdev.cxx:587:47
> sdr::overlay::OverlayManagerBuffered::ImpSaveBackground(vcl::Region const&, OutputDevice*) svx/source/sdr/overlay/overlaymanagerbuffered.cxx:198:17
> sdr::overlay::OverlayManagerBuffered::completeRedraw(vcl::Region const&, OutputDevice*) const svx/source/sdr/overlay/overlaymanagerbuffered.cxx:418:17
> (anonymous namespace)::RenderContextGuard::~RenderContextGuard() sw/source/core/view/viewsh.cxx:1714:21
> SwViewShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/view/viewsh.cxx:1856:1
> SwCrsrShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/crsr/crsrsh.cxx:1278:5
> SwViewShell::PaintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/core/view/viewsh.cxx:1901:5
> SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3139:5
> non-virtual thunk to SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3132:23
> doc_paintTile desktop/source/lib/init.cxx:784:5
> DesktopLOKTest::testPaintTile() desktop/qa/desktop_lib/test_desktop_lib.cxx:299:5
Change-Id: Iadda5d7bb3f7f15706d16b813e11e6d145818f6c
2015-10-16 16:57:38 +02:00
|
|
|
#include <limits>
|
|
|
|
#include <type_traits>
|
2011-02-08 11:28:22 +01:00
|
|
|
|
2006-05-31 08:49:45 +00:00
|
|
|
namespace basebmp
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO(Q3): move to generic place (o3tl?)
|
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
/** template meta function: add const qualifier to 2nd type, if given
|
|
|
|
1st type has it
|
|
|
|
*/
|
2006-05-31 08:49:45 +00:00
|
|
|
template<typename A, typename B> struct clone_const
|
|
|
|
{
|
|
|
|
typedef B type;
|
|
|
|
};
|
|
|
|
template<typename A, typename B> struct clone_const<const A,B>
|
|
|
|
{
|
|
|
|
typedef const B type;
|
|
|
|
};
|
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
/** template meta function: add const qualifier to plain type (if not
|
|
|
|
already there)
|
|
|
|
*/
|
|
|
|
template <typename T> struct add_const
|
|
|
|
{
|
|
|
|
typedef const T type;
|
|
|
|
};
|
|
|
|
template <typename T> struct add_const<const T>
|
|
|
|
{
|
|
|
|
typedef const T type;
|
|
|
|
};
|
|
|
|
|
2006-05-31 08:49:45 +00:00
|
|
|
/// template meta function: remove const qualifier from plain type
|
|
|
|
template <typename T> struct remove_const
|
|
|
|
{
|
|
|
|
typedef T type;
|
|
|
|
};
|
|
|
|
template <typename T> struct remove_const<const T>
|
|
|
|
{
|
|
|
|
typedef T type;
|
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
|
2006-07-13 11:03:26 +00:00
|
|
|
/// Base class for an adaptable ternary functor
|
|
|
|
template< typename A1, typename A2, typename A3, typename R > struct TernaryFunctorBase
|
|
|
|
{
|
|
|
|
typedef A1 first_argument_type;
|
|
|
|
typedef A2 second_argument_type;
|
|
|
|
typedef A3 third_argument_type;
|
|
|
|
typedef R result_type;
|
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2006-07-13 11:03:26 +00:00
|
|
|
|
2006-06-28 15:50:20 +00:00
|
|
|
/** template meta function: ensure that given integer type is unsigned
|
|
|
|
|
|
|
|
If given integer type is already unsigned, return as-is -
|
|
|
|
otherwise, convert to unsigned type of same or greater range.
|
|
|
|
*/
|
|
|
|
template< typename T > struct make_unsigned;
|
|
|
|
|
|
|
|
#define BASEBMP_MAKE_UNSIGNED(T,U) \
|
|
|
|
template<> struct make_unsigned<T> { \
|
|
|
|
typedef U type; \
|
|
|
|
};
|
|
|
|
|
|
|
|
BASEBMP_MAKE_UNSIGNED(signed char,unsigned char)
|
|
|
|
BASEBMP_MAKE_UNSIGNED(unsigned char,unsigned char)
|
|
|
|
BASEBMP_MAKE_UNSIGNED(short,unsigned short)
|
|
|
|
BASEBMP_MAKE_UNSIGNED(unsigned short,unsigned short)
|
|
|
|
BASEBMP_MAKE_UNSIGNED(int,unsigned int)
|
|
|
|
BASEBMP_MAKE_UNSIGNED(unsigned int,unsigned int)
|
|
|
|
BASEBMP_MAKE_UNSIGNED(long,unsigned long)
|
|
|
|
BASEBMP_MAKE_UNSIGNED(unsigned long,unsigned long)
|
|
|
|
|
|
|
|
#undef BASEBMP_MAKE_UNSIGNED
|
|
|
|
|
|
|
|
/// cast integer to unsigned type of similar size
|
|
|
|
template< typename T > inline typename make_unsigned<T>::type unsigned_cast( T value )
|
|
|
|
{
|
|
|
|
return static_cast< typename make_unsigned<T>::type >(value);
|
|
|
|
}
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
|
2006-05-31 08:49:45 +00:00
|
|
|
/// returns true, if given number is strictly less than 0
|
|
|
|
template< typename T > inline bool is_negative( T x )
|
|
|
|
{
|
|
|
|
return x < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Overload for ints (branch-free)
|
|
|
|
inline bool is_negative( int x )
|
|
|
|
{
|
|
|
|
// force logic shift (result for signed shift right is undefined)
|
|
|
|
return static_cast<unsigned int>(x) >> (sizeof(int)*8-1);
|
|
|
|
}
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
|
2006-06-09 03:21:01 +00:00
|
|
|
/// Results in VigraTrueType, if T is of integer type and scalar
|
|
|
|
template< typename T, typename trueCase, typename falseCase >
|
|
|
|
struct ifScalarIntegral
|
|
|
|
{
|
|
|
|
typedef
|
|
|
|
typename vigra::If<
|
|
|
|
typename vigra::NumericTraits< T >::isIntegral,
|
|
|
|
typename vigra::If<
|
|
|
|
typename vigra::NumericTraits< T >::isScalar,
|
|
|
|
trueCase,
|
|
|
|
falseCase >::type,
|
|
|
|
falseCase >::type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Results in VigraTrueType, if T is of non-integer type and scalar
|
|
|
|
template< typename T, typename trueCase, typename falseCase >
|
|
|
|
struct ifScalarNonIntegral
|
|
|
|
{
|
|
|
|
typedef
|
|
|
|
typename vigra::If<
|
|
|
|
typename vigra::NumericTraits< T >::isIntegral,
|
|
|
|
falseCase,
|
|
|
|
typename vigra::If<
|
|
|
|
typename vigra::NumericTraits< T >::isScalar,
|
|
|
|
trueCase,
|
|
|
|
falseCase >::type >::type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Results in VigraTrueType, if both T1 and T2 are of integer type and scalar
|
|
|
|
template< typename T1, typename T2, typename trueCase, typename falseCase >
|
|
|
|
struct ifBothScalarIntegral
|
|
|
|
{
|
|
|
|
typedef
|
|
|
|
typename ifScalarIntegral<
|
|
|
|
T1,
|
|
|
|
typename ifScalarIntegral<
|
|
|
|
T2,
|
|
|
|
trueCase,
|
|
|
|
falseCase >::type,
|
|
|
|
falseCase >::type type;
|
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
|
|
|
|
/// Count number of trailing zeros
|
2007-07-05 07:54:06 +00:00
|
|
|
template< unsigned int val > struct numberOfTrailingZeros
|
2006-07-06 09:02:07 +00:00
|
|
|
{
|
|
|
|
enum { next = val >> 1 };
|
|
|
|
enum { value = vigra::IfBool< (val & 1) == 0,
|
|
|
|
numberOfTrailingZeros<next>,
|
|
|
|
boost::mpl::integral_c< int,-1 > > ::type::value + 1 };
|
|
|
|
};
|
|
|
|
|
|
|
|
template<> struct numberOfTrailingZeros<0>
|
|
|
|
{
|
|
|
|
enum { value = 0 };
|
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2006-07-06 09:02:07 +00:00
|
|
|
|
|
|
|
/// Count number of one bits
|
2007-07-05 07:54:06 +00:00
|
|
|
template< unsigned int val > struct bitcount
|
2006-07-06 09:02:07 +00:00
|
|
|
{
|
|
|
|
enum { next = val >> 1 };
|
|
|
|
enum { value = bitcount<next>::value + (val & 1) };
|
|
|
|
};
|
|
|
|
|
|
|
|
template<> struct bitcount<0>
|
|
|
|
{
|
|
|
|
enum { value = 0 };
|
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2006-07-11 10:39:41 +00:00
|
|
|
|
|
|
|
/// Shift left for positive shift value, and right otherwise
|
|
|
|
template< typename T > inline T shiftLeft( T v, int shift )
|
|
|
|
{
|
|
|
|
return shift > 0 ? v << shift : v >> (-shift);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Shift right for positive shift value, and left otherwise
|
|
|
|
template< typename T > inline T shiftRight( T v, int shift )
|
|
|
|
{
|
-fsanitize=shift-exponent
Through test code added with d30f5bc3e65463f28c3087acad6f88e12d60e53b
"lok::Document::paintTile: fix non-rectangular tiles wrt. transparency,"
CppunitTest_desktop_lib started to exhibit
> basebmp/inc/metafunctions.hxx:210:26: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'
> unsigned int basebmp::shiftRight<unsigned int>(unsigned int, int) basebmp/inc/metafunctions.hxx:210:26
> basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>::operator()(unsigned int) const basebmp/inc/rgbmaskpixelformats.hxx:123:25
> basebmp::Color basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >::operator()<basebmp::PixelIterator<unsigned int> >(basebmp::PixelIterator<unsigned int> const&) const basebmp/inc/accessoradapters.hxx:115:16
> basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >, basebmp::StdMasks>::getPixel_i(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:472:20
> basebmp::BitmapDevice::getPixel(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:1289:16
> basebmp::Color basebmp::GenericColorImageAccessor::operator()<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > const&) const basebmp/inc/genericcolorimageaccessor.hxx:54:18
> void vigra::copyLine<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:65:18
> void vigra::copyImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:158:9
> void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, bool) basebmp/inc/scaleimage.hxx:133:9
> void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::triple<vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor> const&, vigra::triple<basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > > const&, bool) basebmp/inc/scaleimage.hxx:180:5
> void basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::implDrawBitmapGeneric<basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::PixelIterator<unsigned int> const&, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > const&) basebmp/source/bitmapdevice.cxx:739:13
> basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::drawBitmap_i(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:827:21
> basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:1562:9
> basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode, std::shared_ptr<basebmp::BitmapDevice> const&) basebmp/source/bitmapdevice.cxx:1574:9
> SvpSalGraphics::copyBits(SalTwoRect const&, SalGraphics*) vcl/headless/svpgdi.cxx:687:9
> SalGraphics::CopyBits(SalTwoRect const&, SalGraphics*, OutputDevice const*, OutputDevice const*) vcl/source/gdi/salgdilayout.cxx:589:9
> OutputDevice::GetBitmap(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:443:29
> OutputDevice::GetBitmapEx(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:487:25
> OutputDevice::DrawOutDev(Point const&, Size const&, Point const&, Size const&, OutputDevice const&) vcl/source/outdev/outdev.cxx:587:47
> sdr::overlay::OverlayManagerBuffered::ImpSaveBackground(vcl::Region const&, OutputDevice*) svx/source/sdr/overlay/overlaymanagerbuffered.cxx:198:17
> sdr::overlay::OverlayManagerBuffered::completeRedraw(vcl::Region const&, OutputDevice*) const svx/source/sdr/overlay/overlaymanagerbuffered.cxx:418:17
> (anonymous namespace)::RenderContextGuard::~RenderContextGuard() sw/source/core/view/viewsh.cxx:1714:21
> SwViewShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/view/viewsh.cxx:1856:1
> SwCrsrShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/crsr/crsrsh.cxx:1278:5
> SwViewShell::PaintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/core/view/viewsh.cxx:1901:5
> SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3139:5
> non-virtual thunk to SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3132:23
> doc_paintTile desktop/source/lib/init.cxx:784:5
> DesktopLOKTest::testPaintTile() desktop/qa/desktop_lib/test_desktop_lib.cxx:299:5
Change-Id: Iadda5d7bb3f7f15706d16b813e11e6d145818f6c
2015-10-16 16:57:38 +02:00
|
|
|
// Avoid undefined behavior and only shift by less than the length in bits
|
|
|
|
// of the promoted left operand:
|
|
|
|
static_assert(
|
|
|
|
std::is_unsigned<T>::value,
|
|
|
|
"must be unsigned for promotedBits and the below ': 0' to be correct");
|
2015-10-22 09:40:08 +02:00
|
|
|
using Promoted = decltype(+T());
|
|
|
|
auto const promotedBits = std::numeric_limits<Promoted>::digits;
|
-fsanitize=shift-exponent
Through test code added with d30f5bc3e65463f28c3087acad6f88e12d60e53b
"lok::Document::paintTile: fix non-rectangular tiles wrt. transparency,"
CppunitTest_desktop_lib started to exhibit
> basebmp/inc/metafunctions.hxx:210:26: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'
> unsigned int basebmp::shiftRight<unsigned int>(unsigned int, int) basebmp/inc/metafunctions.hxx:210:26
> basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>::operator()(unsigned int) const basebmp/inc/rgbmaskpixelformats.hxx:123:25
> basebmp::Color basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >::operator()<basebmp::PixelIterator<unsigned int> >(basebmp::PixelIterator<unsigned int> const&) const basebmp/inc/accessoradapters.hxx:115:16
> basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >, basebmp::StdMasks>::getPixel_i(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:472:20
> basebmp::BitmapDevice::getPixel(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:1289:16
> basebmp::Color basebmp::GenericColorImageAccessor::operator()<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > const&) const basebmp/inc/genericcolorimageaccessor.hxx:54:18
> void vigra::copyLine<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:65:18
> void vigra::copyImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:158:9
> void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, bool) basebmp/inc/scaleimage.hxx:133:9
> void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::triple<vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor> const&, vigra::triple<basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > > const&, bool) basebmp/inc/scaleimage.hxx:180:5
> void basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::implDrawBitmapGeneric<basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::PixelIterator<unsigned int> const&, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > const&) basebmp/source/bitmapdevice.cxx:739:13
> basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::drawBitmap_i(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:827:21
> basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:1562:9
> basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode, std::shared_ptr<basebmp::BitmapDevice> const&) basebmp/source/bitmapdevice.cxx:1574:9
> SvpSalGraphics::copyBits(SalTwoRect const&, SalGraphics*) vcl/headless/svpgdi.cxx:687:9
> SalGraphics::CopyBits(SalTwoRect const&, SalGraphics*, OutputDevice const*, OutputDevice const*) vcl/source/gdi/salgdilayout.cxx:589:9
> OutputDevice::GetBitmap(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:443:29
> OutputDevice::GetBitmapEx(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:487:25
> OutputDevice::DrawOutDev(Point const&, Size const&, Point const&, Size const&, OutputDevice const&) vcl/source/outdev/outdev.cxx:587:47
> sdr::overlay::OverlayManagerBuffered::ImpSaveBackground(vcl::Region const&, OutputDevice*) svx/source/sdr/overlay/overlaymanagerbuffered.cxx:198:17
> sdr::overlay::OverlayManagerBuffered::completeRedraw(vcl::Region const&, OutputDevice*) const svx/source/sdr/overlay/overlaymanagerbuffered.cxx:418:17
> (anonymous namespace)::RenderContextGuard::~RenderContextGuard() sw/source/core/view/viewsh.cxx:1714:21
> SwViewShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/view/viewsh.cxx:1856:1
> SwCrsrShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/crsr/crsrsh.cxx:1278:5
> SwViewShell::PaintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/core/view/viewsh.cxx:1901:5
> SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3139:5
> non-virtual thunk to SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3132:23
> doc_paintTile desktop/source/lib/init.cxx:784:5
> DesktopLOKTest::testPaintTile() desktop/qa/desktop_lib/test_desktop_lib.cxx:299:5
Change-Id: Iadda5d7bb3f7f15706d16b813e11e6d145818f6c
2015-10-16 16:57:38 +02:00
|
|
|
return shift >= 0
|
2015-10-22 09:40:08 +02:00
|
|
|
? shift < promotedBits ? Promoted(v) >> shift : 0
|
|
|
|
: -shift < promotedBits ? Promoted(v) << (-shift) : 0;
|
2006-07-11 10:39:41 +00:00
|
|
|
}
|
|
|
|
|
2006-05-31 08:49:45 +00:00
|
|
|
} // namespace basebmp
|
|
|
|
|
2015-10-01 08:31:24 +02:00
|
|
|
#endif /* INCLUDED_BASEBMP_INC_METAFUNCTIONS_HXX */
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|