basebmp/inc/colorblendaccessoradapter.hxx | 123 ------- basebmp/inc/fillimage.hxx | 63 --- basebmp/inc/scaleimage.hxx | 189 ---------- basebmp/source/bitmapdevice.cxx | 526 ++++-------------------------- basebmp/source/intconversion.hxx | 88 ----- basebmp/test/basictest.cxx | 4 include/basebmp/bitmapdevice.hxx | 54 --- vcl/headless/svpbmp.cxx | 5 vcl/headless/svpgdi.cxx | 3 vcl/unx/gtk3/gtk3gtkframe.cxx | 7 10 files changed, 92 insertions(+), 970 deletions(-)
New commits: commit 011ce226e89ecabaf621603d692547c88061eaba Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 13:22:10 2016 +0000 Resolves: tdf#99604 ungrab modal dialogs Change-Id: I6735913c371968745da3ad6bf61e6ae3287c19a6 diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 6012f58..803542d 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -2367,6 +2367,13 @@ void GtkSalFrame::SetModal(bool bModal) if (!m_pWindow) return; gtk_window_set_modal(GTK_WINDOW(m_pWindow), bModal); + if (bModal) + { + //gtk_window_set_modal bTrue adds a grab, so ungrab here. Quite + //possibly we should alternatively call grab_add grab_ungrab on + //show/hide of menus ? + gtk_grab_remove(m_pWindow); + } } gboolean GtkSalFrame::signalTooltipQuery(GtkWidget*, gint /*x*/, gint /*y*/, commit e187217222ba3be497f45a7d1e72a1a25b2fb9d6 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 12:49:11 2016 +0000 drop some more unused pieces now Change-Id: Icd2497f0befad0a3221230fe82cb100cddbd7764 diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index 211f16b..1e1c14e 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -117,31 +117,21 @@ namespace typedef typename AccessorSelector::template wrap_accessor< raw_accessor_type >::type dest_accessor_type; - typedef AccessorTraits< dest_accessor_type > accessor_traits; - - typedef AccessorTraits< raw_accessor_type > raw_accessor_traits; - dest_iterator_type maBegin; dest_accessor_type maAccessor; - raw_accessor_type maRawAccessor; - - - BitmapRenderer( const basegfx::B2IBox& rBounds, Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, dest_iterator_type begin, - raw_accessor_type rawAccessor, dest_accessor_type accessor, const RawMemorySharedArray& rMem, const PaletteMemorySharedVector& rPalette ) : BitmapDevice( rBounds, nScanlineFormat, nScanlineStride, pFirstScanline, rMem, rPalette ), maBegin( begin ), - maAccessor( accessor ), - maRawAccessor( rawAccessor ) + maAccessor( accessor ) {} private: @@ -275,7 +265,6 @@ BitmapDeviceSharedPtr createRenderer( Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, - typename FormatTraits::raw_accessor_type const& rRawAccessor, typename FormatTraits::accessor_selector::template wrap_accessor< typename FormatTraits::raw_accessor_type>::type const& rAccessor, boost::shared_array< sal_uInt8 > pMem, @@ -296,7 +285,6 @@ BitmapDeviceSharedPtr createRenderer( reinterpret_cast<typename Iterator::value_type*>( pFirstScanline), nScanlineStride), - rRawAccessor, rAccessor, pMem, pPal )); @@ -336,7 +324,6 @@ BitmapDeviceSharedPtr createRenderer( nScanlineFormat, nScanlineStride, pFirstScanline, - typename FormatTraits::raw_accessor_type(), typename FormatTraits::accessor_selector::template wrap_accessor< typename FormatTraits::raw_accessor_type>::type(), @@ -362,7 +349,6 @@ BitmapDeviceSharedPtr createRenderer( nScanlineFormat, nScanlineStride, pFirstScanline, - typename FormatTraits::raw_accessor_type(), typename FormatTraits::accessor_selector::template wrap_accessor< typename FormatTraits::raw_accessor_type>::type( commit dd16d34a6ebfbe60cee1d01752f167069ddb2848 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 12:42:58 2016 +0000 either copy the whole thing exactly, or convert between types Change-Id: Ied1b4f81e2e851b639cc9a514659160b8571e92f diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index 3ca3bdf..211f16b 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -146,18 +146,6 @@ namespace private: - static std::shared_ptr<BitmapRenderer> getCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) - { - return std::dynamic_pointer_cast< BitmapRenderer >( bmp ); - } - - virtual bool isCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const override - { - // TODO(P1): dynamic_cast usually called twice for - // compatible formats - return getCompatibleBitmap(bmp).get() != nullptr; - } - virtual Color getPixel_i(const basegfx::B2IPoint& rPt ) override { const DestIterator pixel( maBegin + @@ -166,21 +154,6 @@ namespace return maAccessor(pixel); } - template< typename Iterator, typename RawAcc > - void implDrawBitmap(const BitmapDeviceSharedPtr& rSrcBitmap, - const Iterator& begin, - const RawAcc& acc) - { - const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() ); - const basegfx::B2IBox aRect(0, 0, rSrcSize.getX(),rSrcSize.getY()); - - std::shared_ptr<BitmapRenderer> pSrcBmp( getCompatibleBitmap(rSrcBitmap) ); - OSL_ASSERT( pSrcBmp ); - - vigra::copyImage( pSrcBmp->maBegin, pSrcBmp->maBegin + bottomRight(aRect), pSrcBmp->maRawAccessor, - begin, acc ); - } - template< typename Iterator, typename Acc > static void implDrawBitmapGeneric(const BitmapDeviceSharedPtr& rSrcBitmap, const Iterator& begin, @@ -195,49 +168,9 @@ namespace begin, acc ); } - void implDrawBitmapDirect(const BitmapDeviceSharedPtr& rSrcBitmap) - { - const basegfx::B2IVector& rSrcSize(rSrcBitmap->getSize()); - - sal_Int32 nSrcWidth = rSrcSize.getX(); - sal_Int32 nSrcHeight = rSrcSize.getY(); - - char* dstBuf = reinterpret_cast<char*>(getBuffer().get()); - char* srcBuf = reinterpret_cast<char*>(rSrcBitmap->getBuffer().get()); - sal_Int32 dstStride = getScanlineStride(); - sal_Int32 srcStride = rSrcBitmap->getScanlineStride(); - sal_Int32 bytesPerPixel = (bitsPerPixel[getScanlineFormat()] + 7) >> 3; // round up to bytes - - char* dstline = dstBuf; - char* srcline = srcBuf; - sal_Int32 lineBytes = nSrcWidth * bytesPerPixel; - - for(; 0 < nSrcHeight; nSrcHeight--) - { - memmove(dstline, srcline, lineBytes); - dstline += dstStride; - srcline += srcStride; - } - } - - virtual void copyBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap) override + virtual void convertBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap) override { - if( isCompatibleBitmap( rSrcBitmap ) ) - { - if (bitsPerPixel[getScanlineFormat()] >= 8 - && rSrcBitmap->getScanlineFormat() == getScanlineFormat()) - implDrawBitmapDirect(rSrcBitmap); - else - implDrawBitmap(rSrcBitmap, - maBegin, - maRawAccessor); - } - else - { - implDrawBitmapGeneric(rSrcBitmap, - maBegin, - maAccessor); - } + implDrawBitmapGeneric(rSrcBitmap, maBegin, maAccessor); } }; } // namespace @@ -330,12 +263,11 @@ Color BitmapDevice::getPixel( const basegfx::B2IPoint& rPt ) return Color(); } -void BitmapDevice::copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ) +void BitmapDevice::convertBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ) { - copyBitmap_i( rSrcBitmap ); + convertBitmap_i(rSrcBitmap); } - /// Produces a specialized renderer for the given pixel format template< class FormatTraits > BitmapDeviceSharedPtr createRenderer( @@ -670,11 +602,19 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize BitmapDeviceSharedPtr cloneBitmapDevice(const BitmapDeviceSharedPtr& rProto) { - BitmapDeviceSharedPtr aCopy = createBitmapDeviceImpl(rProto->getSize(), + const basegfx::B2IVector& rSrcSize(rProto->getSize()); + + BitmapDeviceSharedPtr aCopy = createBitmapDeviceImpl(rSrcSize, rProto->getScanlineFormat(), boost::shared_array< sal_uInt8 >(), rProto->getPalette() ); - aCopy->copyBitmap(rProto); + + const sal_Int32 nSrcHeight = rSrcSize.getY(); + char* dstBuf = reinterpret_cast<char*>(aCopy->getBuffer().get()); + char* srcBuf = reinterpret_cast<char*>(rProto->getBuffer().get()); + const sal_Int32 nStride = rProto->getScanlineStride(); + memcpy(dstBuf, srcBuf, nStride * nSrcHeight); + return aCopy; } diff --git a/include/basebmp/bitmapdevice.hxx b/include/basebmp/bitmapdevice.hxx index 1ad089d..aa1cc6a 100644 --- a/include/basebmp/bitmapdevice.hxx +++ b/include/basebmp/bitmapdevice.hxx @@ -102,7 +102,7 @@ public: @param rSrcBitmap Bitmap to render into this one. */ - void copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ); + void convertBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ); protected: BASEBMP_DLLPRIVATE BitmapDevice( const basegfx::B2IBox& rBounds, @@ -116,13 +116,10 @@ protected: BitmapDevice& operator=( const BitmapDevice& ) = delete; private: - BASEBMP_DLLPRIVATE virtual bool isCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const = 0; BASEBMP_DLLPRIVATE virtual Color getPixel_i( const basegfx::B2IPoint& rPt ) = 0; - BASEBMP_DLLPRIVATE virtual void copyBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap ) = 0; - - BitmapDeviceSharedPtr getGenericRenderer() const; + BASEBMP_DLLPRIVATE virtual void convertBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap ) = 0; std::unique_ptr< ImplBitmapDevice > mpImpl; }; diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index eb96693..59e8947 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -131,7 +131,7 @@ namespace aTmpBmp.Create(aSize, 0, BitmapPalette()); assert(aTmpBmp.GetBitCount() == 32); const basebmp::BitmapDeviceSharedPtr& rTmpSrc = aTmpBmp.getBitmap(); - rTmpSrc->copyBitmap(rSrcBmp); + rTmpSrc->convertBitmap(rSrcBmp); source = SvpSalGraphics::createCairoSurface(rTmpSrc); } else commit f73e72fb33f111c2eda12aa359b96dad680e6848 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 11:40:32 2016 +0000 only use of clone is to copy, so do that Change-Id: I75cfb96e4afd69fd0f6a6716ce4be282aa8d3b14 diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index 6c84860..3ca3bdf 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -668,13 +668,14 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize rPalette ); } -BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize, - const BitmapDeviceSharedPtr& rProto ) +BitmapDeviceSharedPtr cloneBitmapDevice(const BitmapDeviceSharedPtr& rProto) { - return createBitmapDeviceImpl( rSize, + BitmapDeviceSharedPtr aCopy = createBitmapDeviceImpl(rProto->getSize(), rProto->getScanlineFormat(), boost::shared_array< sal_uInt8 >(), rProto->getPalette() ); + aCopy->copyBitmap(rProto); + return aCopy; } } // namespace basebmp diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx index 05da4f5..763e85a 100644 --- a/basebmp/test/basictest.cxx +++ b/basebmp/test/basictest.cxx @@ -131,15 +131,13 @@ public: void testClone() { const basegfx::B2ISize aSize(101,101); - basegfx::B2ISize aSize2(3,3); BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize, Format::OneBitMsbPal ) ); BitmapDeviceSharedPtr pClone( cloneBitmapDevice( - aSize2, pDevice )); CPPUNIT_ASSERT_EQUAL_MESSAGE("right size", - aSize2, pClone->getSize() ); + aSize, pClone->getSize() ); } // Change the following lines only, if you add, remove or rename diff --git a/include/basebmp/bitmapdevice.hxx b/include/basebmp/bitmapdevice.hxx index a3b4bb0..1ad089d 100644 --- a/include/basebmp/bitmapdevice.hxx +++ b/include/basebmp/bitmapdevice.hxx @@ -161,13 +161,8 @@ BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVe /** Function to clone a BitmapDevice from a given prototype. - - All attributes (like scanline format and top-down state) are - copied, only the size can be varied. Note that the prototype's - bitmap content is <em>not</em> copied, only a palette (if any). */ -BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC cloneBitmapDevice(const basegfx::B2IVector& rSize, - const BitmapDeviceSharedPtr& rProto); +BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC cloneBitmapDevice(const BitmapDeviceSharedPtr& rProto); } diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index e0b1afb..05545b6 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -77,9 +77,7 @@ bool SvpSalBitmap::Create( const SalBitmap& rSalBmp ) const BitmapDeviceSharedPtr& rSrcBmp = rSrc.getBitmap(); if( rSrcBmp.get() ) { - B2IVector aSize = rSrcBmp->getSize(); - m_aBitmap = cloneBitmapDevice( aSize, rSrcBmp ); - m_aBitmap->copyBitmap(rSrcBmp); + m_aBitmap = cloneBitmapDevice(rSrcBmp); } else m_aBitmap.reset(); commit 8b5e8dfed7c7c3c6669062a3db04961fe5eb1855 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 10:44:23 2016 +0000 drop some more stuff Change-Id: I92eb6d136fc117f4694aa2cf88d93d4486855618 diff --git a/basebmp/inc/colorblendaccessoradapter.hxx b/basebmp/inc/colorblendaccessoradapter.hxx deleted file mode 100644 index 767d55e..0000000 --- a/basebmp/inc/colorblendaccessoradapter.hxx +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- 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/. - * - * 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 . - */ - -#ifndef INCLUDED_BASEBMP_INC_COLORBLENDACCESSORADAPTER_HXX -#define INCLUDED_BASEBMP_INC_COLORBLENDACCESSORADAPTER_HXX - -#include <colortraits.hxx> - -namespace basebmp -{ - -/** Accessor adapter that blends input value against fixed color value - - Used to blend an alpha mask 'through' a fixed color value into the - destination. - - The getter functors return a constant value (usually the zero of - the value type, this preserves the original destination content - when blitting through a mask) - there really isn't no other - sensible default behaviour for these methods. - */ -template< class WrappedAccessor, - typename AlphaType, - bool polarity > class ConstantColorBlendSetterAccessorAdapter -{ -public: - typedef AlphaType alpha_type; - typedef AlphaType value_type; - typedef typename WrappedAccessor::value_type color_type; - -private: - typename ColorTraits< color_type >:: - template blend_functor<alpha_type,polarity>::type maFunctor; - WrappedAccessor maWrappee; - color_type maBlendColor; - value_type maGetterValue; - -public: - ConstantColorBlendSetterAccessorAdapter() : - maFunctor(), - maWrappee(), - maBlendColor(), - maGetterValue() - {} - - template< class T > explicit ConstantColorBlendSetterAccessorAdapter( T acc ) : - maFunctor(), - maWrappee(acc), - maBlendColor(), - maGetterValue() - {} - - template< class T > ConstantColorBlendSetterAccessorAdapter( T acc, - color_type col ) : - maFunctor(), - maWrappee(acc), - maBlendColor(col), - maGetterValue() - {} - - template< class T > ConstantColorBlendSetterAccessorAdapter( T acc, - color_type col, - value_type val ) : - maFunctor(), - maWrappee(acc), - maBlendColor(col), - maGetterValue(val) - {} - - - - void setColor( color_type col ) { maBlendColor=col; } - - - - /// @return constant value, regardless of iterator content - template< typename IteratorType > value_type operator()(SAL_UNUSED_PARAMETER IteratorType const& ) const - { - return maGetterValue; - } - /// @return constant value, regardless of iterator content - template< typename IteratorType, class Difference > - value_type operator()(SAL_UNUSED_PARAMETER IteratorType const& , SAL_UNUSED_PARAMETER Difference const& ) const - { - return maGetterValue; - } - - - - template< typename V, typename IteratorType > - void set(V const& value, IteratorType const& i) const - { - maWrappee.set( - maFunctor( - vigra::detail::RequiresExplicitCast<alpha_type>::cast(value), - maWrappee(i), - maBlendColor), - i ); - } - -}; - -} // namespace basebmp - -#endif /* INCLUDED_BASEBMP_INC_COLORBLENDACCESSORADAPTER_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index 32abb05..6c84860 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -30,11 +30,9 @@ #include <accessor.hxx> #include <accessortraits.hxx> #include <accessoradapters.hxx> -#include <colorblendaccessoradapter.hxx> #include <basebmp/color.hxx> #include <colormisc.hxx> -#include <colortraits.hxx> #include <greylevelformats.hxx> #include <paletteformats.hxx> @@ -46,7 +44,6 @@ #include <genericcolorimageaccessor.hxx> #include <tools.hxx> -#include "intconversion.hxx" #include <rtl/alloc.h> #include <sal/log.hxx> @@ -64,11 +61,6 @@ #include <basegfx/point/b2ipoint.hxx> #include <basegfx/vector/b2ivector.hxx> -#include <vigra/iteratortraits.hxx> -#include <vigra/rgbvalue.hxx> -#include <vigra/copyimage.hxx> -#include <vigra/tuple.hxx> - namespace basebmp { @@ -96,38 +88,6 @@ static const o3tl::enumarray<Format,sal_uInt8> bitsPerPixel = namespace { - /** Create the type for an accessor that takes the (mask,bitmap) - input value generated from a JoinImageAccessorAdapter, and - pipe that through a mask functor. - - @tpl DestAccessor - Destination bitmap accessor - - @tpl JoinedAccessor - Input accessor, is expected to generate a std::pair as the - value type - - @tpl MaskFunctorMode - Either FastMask or NoFastMask, depending on whether the mask - is guaranteed to contain only 0s and 1s. - */ - template< class DestAccessor, - class JoinedAccessor, - bool polarity, - typename MaskFunctorMode > struct masked_input_splitting_accessor - { - typedef BinarySetterFunctionAccessorAdapter< - DestAccessor, - BinaryFunctorSplittingWrapper< - typename outputMaskFunctorSelector< - typename JoinedAccessor::value_type::first_type, - typename JoinedAccessor::value_type::second_type, - polarity, - MaskFunctorMode >::type > > type; - }; - - - // Actual BitmapDevice implementation (templatized by accessor and iterator) /** Implementation of the BitmapDevice interface @@ -160,13 +120,8 @@ namespace typedef AccessorTraits< dest_accessor_type > accessor_traits; typedef AccessorTraits< raw_accessor_type > raw_accessor_traits; - typedef typename uInt32Converter< - typename raw_accessor_type::value_type>::to to_uint32_functor; - dest_iterator_type maBegin; - typename accessor_traits::color_lookup maColorLookup; - to_uint32_functor maToUInt32Converter; dest_accessor_type maAccessor; raw_accessor_type maRawAccessor; @@ -185,8 +140,6 @@ namespace BitmapDevice( rBounds, nScanlineFormat, nScanlineStride, pFirstScanline, rMem, rPalette ), maBegin( begin ), - maColorLookup(), - maToUInt32Converter(), maAccessor( accessor ), maRawAccessor( rawAccessor ) {} @@ -213,14 +166,6 @@ namespace return maAccessor(pixel); } - virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt ) override - { - const DestIterator pixel( maBegin + - vigra::Diff2D(rPt.getX(), - rPt.getY()) ); - return maToUInt32Converter(maRawAccessor(pixel)); - } - template< typename Iterator, typename RawAcc > void implDrawBitmap(const BitmapDeviceSharedPtr& rSrcBitmap, const Iterator& begin, @@ -325,22 +270,6 @@ struct ImplBitmapDevice /// raw ptr to 0th scanline. used for cloning a generic renderer sal_uInt8* mpFirstScanline; - - /** (Optional) device sharing the same memory, and used for input - clip masks/alpha masks/bitmaps that don't match our exact - bitmap format. - - This is to avoid the combinatorial explosion when dealing - with n bitmap formats, which could be combined with n clip - masks, alpha masks and bitmap masks (yielding a total of n^4 - combinations). Since each BitmapRenderer is specialized for - one specific combination of said formats, a lot of duplicate - code would be generated, most of which probably never - used. Therefore, only the most common combinations are - specialized templates, the remainder gets handled by this - generic renderer (via runtime polymorphism). - */ - BitmapDeviceSharedPtr mpGenericRenderer; }; @@ -401,14 +330,6 @@ Color BitmapDevice::getPixel( const basegfx::B2IPoint& rPt ) return Color(); } -sal_uInt32 BitmapDevice::getPixelData( const basegfx::B2IPoint& rPt ) -{ - if( mpImpl->maBounds.isInside(rPt) ) - return getPixelData_i(rPt); - - return 0; -} - void BitmapDevice::copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ) { copyBitmap_i( rSrcBitmap ); @@ -756,13 +677,6 @@ BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize, rProto->getPalette() ); } - -/// Clone our device, with GenericImageAccessor to handle all formats -BitmapDeviceSharedPtr BitmapDevice::getGenericRenderer() const -{ - return mpImpl->mpGenericRenderer; -} - } // namespace basebmp /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basebmp/source/intconversion.hxx b/basebmp/source/intconversion.hxx deleted file mode 100644 index a536041..0000000 --- a/basebmp/source/intconversion.hxx +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- 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/. - * - * 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 . - */ - -#ifndef INCLUDED_BASEBMP_SOURCE_INTCONVERSION_HXX -#define INCLUDED_BASEBMP_SOURCE_INTCONVERSION_HXX - -#include <vigra/rgbvalue.hxx> -#include <functional> - -namespace basebmp -{ - // metafunctions to retrieve correct POD from/to basebmp::Color - - /// type-safe conversion from RgbValue to packed int32 - template< class RgbVal > struct UInt32FromRgbValue - { - sal_uInt32 operator()( RgbVal const& c ) const - { - return (c[0] << 16) | (c[1] << 8) | c[2]; - } - }; - - /// type-safe conversion from packed int32 to RgbValue - template< class RgbVal > struct RgbValueFromUInt32 - { - RgbVal operator()( sal_uInt32 c ) const - { - return RgbVal((c >> 16) & 0xFF, - (c >> 8) & 0xFF, - c & 0xFF); - } - }; - - //Current c++0x draft (apparently) has std::identity, but not operator() - template<typename T> struct SGI_identity : public std::unary_function<T,T> - { - T& operator()(T& x) const { return x; } - const T& operator()(const T& x) const { return x; } - }; - - /// Get converter from given data type to sal_uInt32 - template< typename DataType > struct uInt32Converter - { - typedef SGI_identity<DataType> to; - typedef SGI_identity<DataType> from; - }; - template< unsigned int RedIndex, - unsigned int GreenIndex, - unsigned int BlueIndex > struct uInt32Converter< - vigra::RGBValue< sal_uInt8, - RedIndex, - GreenIndex, - BlueIndex > > - { - typedef UInt32FromRgbValue< - vigra::RGBValue< sal_uInt8, - RedIndex, - GreenIndex, - BlueIndex > > - to; - typedef RgbValueFromUInt32< - vigra::RGBValue< sal_uInt8, - RedIndex, - GreenIndex, - BlueIndex > > - from; - }; -} - -#endif // INCLUDED_BASEBMP_SOURCE_INTCONVERSION_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basebmp/bitmapdevice.hxx b/include/basebmp/bitmapdevice.hxx index 8087adf..a3b4bb0 100644 --- a/include/basebmp/bitmapdevice.hxx +++ b/include/basebmp/bitmapdevice.hxx @@ -97,14 +97,6 @@ public: */ Color getPixel( const basegfx::B2IPoint& rPt ); - /** Get underlying pixel data value at given position - - This method returns the raw pixel data. In the case of - paletted bitmaps, this is the palette index, not the final - color value. - */ - sal_uInt32 getPixelData( const basegfx::B2IPoint& rPt ); - /** Draw another bitmap into this device @param rSrcBitmap @@ -128,8 +120,6 @@ private: BASEBMP_DLLPRIVATE virtual Color getPixel_i( const basegfx::B2IPoint& rPt ) = 0; - BASEBMP_DLLPRIVATE virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt ) = 0; - BASEBMP_DLLPRIVATE virtual void copyBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap ) = 0; BitmapDeviceSharedPtr getGenericRenderer() const; commit 29ce905f8e8642d87780282184f9cf7991c82c36 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 10:27:32 2016 +0000 scanline is always positive now and drop unused args Change-Id: I39276ccea5c4b3ecdc89c77f35722883221b560f diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index 0eb5f47..32abb05 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -380,8 +380,7 @@ Format BitmapDevice::getScanlineFormat() const sal_Int32 BitmapDevice::getScanlineStride() const { - return mpImpl->mnScanlineStride < 0 ? - -mpImpl->mnScanlineStride : mpImpl->mnScanlineStride; + return mpImpl->mnScanlineStride; } RawMemorySharedArray BitmapDevice::getBuffer() const @@ -525,9 +524,7 @@ namespace BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& rSize, Format nScanlineFormat, boost::shared_array< sal_uInt8 > pMem, - PaletteMemorySharedVector pPal, - const basegfx::B2IBox* pSubset, - bool bBlack = true) + PaletteMemorySharedVector pPal ) { OSL_ASSERT(rSize.getX() > 0 && rSize.getY() > 0); @@ -543,18 +540,17 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& return BitmapDeviceSharedPtr(); } - sal_Int32 nScanlineStride = getBitmapDeviceStrideForWidth(nScanlineFormat, rSize.getX()); + const sal_uInt32 nScanlineStride = getBitmapDeviceStrideForWidth(nScanlineFormat, rSize.getX()); - const sal_uInt32 nWidth(nScanlineStride < 0 ? -nScanlineStride : nScanlineStride); const sal_uInt32 nHeight(rSize.getY()); - if (nHeight && nWidth && nWidth > SAL_MAX_INT32 / nHeight) + if (nHeight && nScanlineStride && nScanlineStride > SAL_MAX_INT32 / nHeight) { - SAL_WARN( "basebmp", "suspicious massive alloc " << nWidth << " * " << nHeight); + SAL_WARN( "basebmp", "suspicious massive alloc " << nScanlineStride << " * " << nHeight); return BitmapDeviceSharedPtr(); } - const std::size_t nMemSize(nWidth * nHeight); + const std::size_t nMemSize(nScanlineStride * nHeight); if( !pMem ) { @@ -563,19 +559,12 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& &rtl_freeMemory ); if (pMem.get() == nullptr && nMemSize != 0) return BitmapDeviceSharedPtr(); - if (bBlack) - memset(pMem.get(), 0, nMemSize); - else - memset(pMem.get(), 0xFF, nMemSize); + memset(pMem.get(), 0, nMemSize); } - sal_uInt8* pFirstScanline = nScanlineStride < 0 ? - pMem.get() + nMemSize + nScanlineStride : pMem.get(); + sal_uInt8* pFirstScanline = pMem.get(); - // shrink render area to given subset, if given basegfx::B2IBox aBounds(0,0,rSize.getX(),rSize.getY()); - if( pSubset ) - aBounds.intersect( *pSubset ); switch( nScanlineFormat ) { @@ -698,18 +687,13 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& rSize, Format nScanlineFormat, boost::shared_array< sal_uInt8 > pMem, - PaletteMemorySharedVector pPal, - const basegfx::B2IBox* pSubset, - bool bBlack = true) + PaletteMemorySharedVector pPal ) { - BitmapDeviceSharedPtr result( createBitmapDeviceImplInner( rSize, nScanlineFormat, pMem, pPal, pSubset, bBlack ) ); + BitmapDeviceSharedPtr result( createBitmapDeviceImplInner( rSize, nScanlineFormat, pMem, pPal ) ); #ifdef SAL_LOG_INFO std::ostringstream subset; - if (pSubset) - subset << " subset=" << pSubset->getWidth() << "x" << pSubset->getHeight() << "@(" << pSubset->getMinX() << "," << pSubset->getMinY() << ")"; - SAL_INFO( "basebmp.bitmapdevice", "createBitmapDevice: " << rSize.getX() << "x" << rSize.getY() @@ -739,8 +723,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize, return createBitmapDeviceImpl( rSize, nScanlineFormat, boost::shared_array< sal_uInt8 >(), - PaletteMemorySharedVector(), - nullptr ); + PaletteMemorySharedVector() ); } BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize, @@ -750,8 +733,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize return createBitmapDeviceImpl( rSize, nScanlineFormat, boost::shared_array< sal_uInt8 >(), - rPalette, - nullptr ); + rPalette ); } BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize, @@ -762,8 +744,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize return createBitmapDeviceImpl( rSize, nScanlineFormat, rMem, - rPalette, - nullptr ); + rPalette ); } BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize, @@ -772,8 +753,7 @@ BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize, return createBitmapDeviceImpl( rSize, rProto->getScanlineFormat(), boost::shared_array< sal_uInt8 >(), - rProto->getPalette(), - nullptr ); + rProto->getPalette() ); } commit c686f29e1e2e1ebf19ad711028135bf557702fd0 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 10:22:28 2016 +0000 drop unused argument Change-Id: I0333f65f67cdd93f9773e6d738289e36353ef359 diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index 5fc7386..0eb5f47 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -174,7 +174,6 @@ namespace BitmapRenderer( const basegfx::B2IBox& rBounds, - const basegfx::B2IVector& rBufferSize, Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -183,7 +182,7 @@ namespace dest_accessor_type accessor, const RawMemorySharedArray& rMem, const PaletteMemorySharedVector& rPalette ) : - BitmapDevice( rBounds, rBufferSize, nScanlineFormat, + BitmapDevice( rBounds, nScanlineFormat, nScanlineStride, pFirstScanline, rMem, rPalette ), maBegin( begin ), maColorLookup(), @@ -318,9 +317,6 @@ struct ImplBitmapDevice */ basegfx::B2IBox maBounds; - //// Size of the actual frame buffer - basegfx::B2IVector maBufferSize; - /// Scanline format, as provided at the constructor Format mnScanlineFormat; @@ -349,7 +345,6 @@ struct ImplBitmapDevice BitmapDevice::BitmapDevice( const basegfx::B2IBox& rBounds, - const basegfx::B2IVector& rBufferSize, Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -360,7 +355,6 @@ BitmapDevice::BitmapDevice( const basegfx::B2IBox& rBounds, mpImpl->mpMem = rMem; mpImpl->mpPalette = rPalette; mpImpl->maBounds = rBounds; - mpImpl->maBufferSize = rBufferSize; mpImpl->mnScanlineFormat = nScanlineFormat; mpImpl->mnScanlineStride = nScanlineStride; mpImpl->mpFirstScanline = pFirstScanline; @@ -379,11 +373,6 @@ basegfx::B2IVector BitmapDevice::getSize() const mpImpl->maBounds.getMaxY() - mpImpl->maBounds.getMinY() ); } -basegfx::B2IVector BitmapDevice::getBufferSize() const -{ - return mpImpl->maBufferSize; -} - Format BitmapDevice::getScanlineFormat() const { return mpImpl->mnScanlineFormat; @@ -431,7 +420,6 @@ void BitmapDevice::copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ) template< class FormatTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, - const basegfx::B2IVector& rBufferSize, Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -449,7 +437,6 @@ BitmapDeviceSharedPtr createRenderer( return BitmapDeviceSharedPtr( new Renderer( rBounds, - rBufferSize, nScanlineFormat, nScanlineStride, pFirstScanline, @@ -487,7 +474,6 @@ PaletteMemorySharedVector createStandardPalette( template< class FormatTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, - const basegfx::B2IVector& rBufferSize, Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -495,7 +481,6 @@ BitmapDeviceSharedPtr createRenderer( const PaletteMemorySharedVector& pPal ) { return createRenderer<FormatTraits>(rBounds, - rBufferSize, nScanlineFormat, nScanlineStride, pFirstScanline, @@ -510,7 +495,6 @@ BitmapDeviceSharedPtr createRenderer( template< class FormatTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, - const basegfx::B2IVector& rBufferSize, Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -523,7 +507,6 @@ BitmapDeviceSharedPtr createRenderer( OSL_ASSERT(pPal); return createRenderer<FormatTraits>(rBounds, - rBufferSize, nScanlineFormat, nScanlineStride, pFirstScanline, @@ -601,23 +584,23 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::OneBitMsbGrey: return createRenderer<PixelFormatTraits_GREY1_MSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::OneBitLsbGrey: return createRenderer<PixelFormatTraits_GREY1_LSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::OneBitMsbPal: return createRenderer<PixelFormatTraits_PAL1_MSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); case Format::OneBitLsbPal: return createRenderer<PixelFormatTraits_PAL1_LSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); @@ -627,23 +610,23 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::FourBitMsbGrey: return createRenderer<PixelFormatTraits_GREY4_MSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::FourBitLsbGrey: return createRenderer<PixelFormatTraits_GREY4_LSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::FourBitMsbPal: return createRenderer<PixelFormatTraits_PAL4_MSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); case Format::FourBitLsbPal: return createRenderer<PixelFormatTraits_PAL4_LSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); @@ -653,12 +636,12 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::EightBitGrey: return createRenderer<PixelFormatTraits_GREY8>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::EightBitPal: return createRenderer<PixelFormatTraits_PAL8>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); @@ -668,40 +651,40 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::SixteenBitLsbTcMask: return createRenderer<PixelFormatTraits_RGB16_565_LSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::SixteenBitMsbTcMask: return createRenderer<PixelFormatTraits_RGB16_565_MSB>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); // twentyfour bit formats case Format::TwentyFourBitTcMask: return createRenderer<PixelFormatTraits_BGR24>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); // thirtytwo bit formats case Format::ThirtyTwoBitTcMaskBGRA: return createRenderer<PixelFormatTraits_BGRA32_8888>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::ThirtyTwoBitTcMaskARGB: return createRenderer<PixelFormatTraits_ARGB32_8888>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::ThirtyTwoBitTcMaskABGR: return createRenderer<PixelFormatTraits_ABGR32_8888>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::ThirtyTwoBitTcMaskRGBA: return createRenderer<PixelFormatTraits_RGBA32_8888>( - aBounds, rSize, nScanlineFormat, nScanlineStride, + aBounds, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); default: diff --git a/include/basebmp/bitmapdevice.hxx b/include/basebmp/bitmapdevice.hxx index 85dc153..8087adf 100644 --- a/include/basebmp/bitmapdevice.hxx +++ b/include/basebmp/bitmapdevice.hxx @@ -64,13 +64,6 @@ public: */ basegfx::B2IVector getSize() const; - /** Query the size of the whole frame buffer - - @ return the size of the whole frame buffer, the same as - getSize() unless this is a "subset" device. - */ - basegfx::B2IVector getBufferSize() const; - /** Query type of scanline memory format */ Format getScanlineFormat() const; @@ -121,7 +114,6 @@ public: protected: BASEBMP_DLLPRIVATE BitmapDevice( const basegfx::B2IBox& rBounds, - const basegfx::B2IVector& rBufferSize, Format nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, commit 3dc114108fda780f2bc46c35c2ef01c941caaca8 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 10:01:42 2016 +0000 MaskTraits unused now Change-Id: I1e3bd12a8b264ca15e733ff15d8522fc2c156483 diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index ce7b35a..5fc7386 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -143,18 +143,10 @@ namespace template metafunction wrap_accessor to one of the raw bitmap accessors, yields a member type named 'type', which is a wrapped accessor that map color values. - - @tpl Masks - Traits template, containing nested traits - clipmask_format_traits and alphamask_format_traits, which - determine what specialized formats are to be used for clip and - alpha masks. With those mask formats, clipping and alpha - blending is handled natively. */ template< class DestIterator, class RawAccessor, - class AccessorSelector, - class Masks > class BitmapRenderer : + class AccessorSelector > class BitmapRenderer : public BitmapDevice { public: @@ -434,23 +426,9 @@ void BitmapDevice::copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ) copyBitmap_i( rSrcBitmap ); } -/** Standard clip and alpha masks - */ -struct StdMasks -{ - typedef PixelFormatTraits_GREY1_MSB clipmask_format_traits; - typedef PixelFormatTraits_GREY8 alphamask_format_traits; - - /// Clipmask: 0 means opaque - static const bool clipmask_polarity = false; - - /// Alpha mask: 0 means fully transparent - static const bool alphamask_polarity = true; -}; - /// Produces a specialized renderer for the given pixel format -template< class FormatTraits, class MaskTraits > +template< class FormatTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, const basegfx::B2IVector& rBufferSize, @@ -466,8 +444,8 @@ BitmapDeviceSharedPtr createRenderer( typedef typename FormatTraits::iterator_type Iterator; typedef BitmapRenderer< Iterator, typename FormatTraits::raw_accessor_type, - typename FormatTraits::accessor_selector, - MaskTraits > Renderer; + typename FormatTraits::accessor_selector + > Renderer; return BitmapDeviceSharedPtr( new Renderer( rBounds, @@ -506,7 +484,7 @@ PaletteMemorySharedVector createStandardPalette( return pLocalPal; } -template< class FormatTraits, class MaskTraits > +template< class FormatTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, const basegfx::B2IVector& rBufferSize, @@ -516,8 +494,7 @@ BitmapDeviceSharedPtr createRenderer( boost::shared_array< sal_uInt8 > pMem, const PaletteMemorySharedVector& pPal ) { - return createRenderer<FormatTraits, - MaskTraits>(rBounds, + return createRenderer<FormatTraits>(rBounds, rBufferSize, nScanlineFormat, nScanlineStride, @@ -530,7 +507,7 @@ BitmapDeviceSharedPtr createRenderer( pPal ); } -template< class FormatTraits, class MaskTraits > +template< class FormatTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, const basegfx::B2IVector& rBufferSize, @@ -545,8 +522,7 @@ BitmapDeviceSharedPtr createRenderer( 1UL << nBitsPerPixel); OSL_ASSERT(pPal); - return createRenderer<FormatTraits, - MaskTraits>(rBounds, + return createRenderer<FormatTraits>(rBounds, rBufferSize, nScanlineFormat, nScanlineStride, @@ -624,23 +600,23 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& // one bit formats case Format::OneBitMsbGrey: - return createRenderer<PixelFormatTraits_GREY1_MSB,StdMasks>( + return createRenderer<PixelFormatTraits_GREY1_MSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::OneBitLsbGrey: - return createRenderer<PixelFormatTraits_GREY1_LSB,StdMasks>( + return createRenderer<PixelFormatTraits_GREY1_LSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::OneBitMsbPal: - return createRenderer<PixelFormatTraits_PAL1_MSB,StdMasks>( + return createRenderer<PixelFormatTraits_PAL1_MSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); case Format::OneBitLsbPal: - return createRenderer<PixelFormatTraits_PAL1_LSB,StdMasks>( + return createRenderer<PixelFormatTraits_PAL1_LSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); @@ -650,23 +626,23 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& // four bit formats case Format::FourBitMsbGrey: - return createRenderer<PixelFormatTraits_GREY4_MSB,StdMasks>( + return createRenderer<PixelFormatTraits_GREY4_MSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::FourBitLsbGrey: - return createRenderer<PixelFormatTraits_GREY4_LSB,StdMasks>( + return createRenderer<PixelFormatTraits_GREY4_LSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::FourBitMsbPal: - return createRenderer<PixelFormatTraits_PAL4_MSB,StdMasks>( + return createRenderer<PixelFormatTraits_PAL4_MSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); case Format::FourBitLsbPal: - return createRenderer<PixelFormatTraits_PAL4_LSB,StdMasks>( + return createRenderer<PixelFormatTraits_PAL4_LSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); @@ -676,12 +652,12 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& // eight bit formats case Format::EightBitGrey: - return createRenderer<PixelFormatTraits_GREY8,StdMasks>( + return createRenderer<PixelFormatTraits_GREY8>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::EightBitPal: - return createRenderer<PixelFormatTraits_PAL8,StdMasks>( + return createRenderer<PixelFormatTraits_PAL8>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat] ); @@ -691,40 +667,40 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& // sixteen bit formats case Format::SixteenBitLsbTcMask: - return createRenderer<PixelFormatTraits_RGB16_565_LSB,StdMasks>( + return createRenderer<PixelFormatTraits_RGB16_565_LSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::SixteenBitMsbTcMask: - return createRenderer<PixelFormatTraits_RGB16_565_MSB,StdMasks>( + return createRenderer<PixelFormatTraits_RGB16_565_MSB>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); // twentyfour bit formats case Format::TwentyFourBitTcMask: - return createRenderer<PixelFormatTraits_BGR24,StdMasks>( + return createRenderer<PixelFormatTraits_BGR24>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); // thirtytwo bit formats case Format::ThirtyTwoBitTcMaskBGRA: - return createRenderer<PixelFormatTraits_BGRA32_8888,StdMasks>( + return createRenderer<PixelFormatTraits_BGRA32_8888>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::ThirtyTwoBitTcMaskARGB: - return createRenderer<PixelFormatTraits_ARGB32_8888,StdMasks>( + return createRenderer<PixelFormatTraits_ARGB32_8888>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::ThirtyTwoBitTcMaskABGR: - return createRenderer<PixelFormatTraits_ABGR32_8888,StdMasks>( + return createRenderer<PixelFormatTraits_ABGR32_8888>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); case Format::ThirtyTwoBitTcMaskRGBA: - return createRenderer<PixelFormatTraits_RGBA32_8888,StdMasks>( + return createRenderer<PixelFormatTraits_RGBA32_8888>( aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal ); commit 22a9f5c90e3060a835bb56079bf71093d898196f Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 09:55:18 2016 +0000 never scaling now Change-Id: Iaa8afb2c642c9108eb1b3be4737b74285d064cf3 diff --git a/basebmp/inc/fillimage.hxx b/basebmp/inc/fillimage.hxx deleted file mode 100644 index 7acd901..0000000 --- a/basebmp/inc/fillimage.hxx +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- 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/. - * - * 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 . - */ - -#ifndef INCLUDED_BASEBMP_INC_FILLIMAGE_HXX -#define INCLUDED_BASEBMP_INC_FILLIMAGE_HXX - -#include <vigra/tuple.hxx> -#include <vigra/iteratortraits.hxx> - -namespace basebmp -{ - -template< class DestIterator, class DestAccessor, typename T > -void fillImage( DestIterator begin, - const DestIterator& end, - DestAccessor ad, - const T& fillVal ) -{ - const int width ( end.x - begin.x ); - const int height( end.y - begin.y ); - - for( int y=0; y<height; ++y, ++begin.y ) - { - typename vigra::IteratorTraits<DestIterator>::row_iterator - rowIter( begin.rowIterator() ); - const typename vigra::IteratorTraits<DestIterator>::row_iterator - rowEnd( rowIter + width ); - - // TODO(P2): Provide specialized span fill methods on the - // iterator/accessor - while( rowIter != rowEnd ) - ad.set(fillVal, rowIter++); - } -} - -template< class DestIterator, class DestAccessor, typename T > -inline void fillImage( vigra::triple<DestIterator,DestIterator,DestAccessor> const& src, - const T& fillVal ) -{ - fillImage(src.first,src.second,src.third,fillVal); -} - -} // namespace basebmp - -#endif /* INCLUDED_BASEBMP_INC_FILLIMAGE_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basebmp/inc/scaleimage.hxx b/basebmp/inc/scaleimage.hxx deleted file mode 100644 index f3975e9..0000000 --- a/basebmp/inc/scaleimage.hxx +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- 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/. - * - * 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 . - */ - -#ifndef INCLUDED_BASEBMP_INC_SCALEIMAGE_HXX -#define INCLUDED_BASEBMP_INC_SCALEIMAGE_HXX - -#include <osl/diagnose.h> - -#include <vigra/tuple.hxx> -#include <vigra/copyimage.hxx> -#include <vigra/basicimage.hxx> -#include <vigra/iteratortraits.hxx> - -namespace basebmp -{ - -template< class SourceIter, class SourceAcc, - class DestIter, class DestAcc > -void scaleLine( SourceIter s_begin, - SourceIter s_end, - SourceAcc s_acc, - DestIter d_begin, - DestIter d_end, - DestAcc d_acc ) -{ - const int src_width = s_end - s_begin; - const int dest_width = d_end - d_begin; - - OSL_ASSERT( src_width > 0 && dest_width > 0 ); - - if( src_width >= dest_width ) - { - // shrink - int rem = 0; - while( s_begin != s_end ) - { - if( rem >= 0 ) - { - d_acc.set( s_acc(s_begin), d_begin ); - - rem -= src_width; - ++d_begin; - } - - rem += dest_width; - ++s_begin; - } - } - else - { - // enlarge - int rem = -dest_width; - while( d_begin != d_end ) - { - if( rem >= 0 ) - { - rem -= dest_width; - ++s_begin; - } - - d_acc.set( s_acc(s_begin), d_begin ); - - rem += src_width; - ++d_begin; - } - } -} - -/** Scale an image using zero order interpolation (pixel replication) - - Source and destination range must be at least one pixel wide and - high. - - @param s_begin - Start iterator for source image - - @param s_end - End iterator for source image - - @param s_acc - Source accessor - - @param d_begin - Start iterator for destination image - - @param d_end - End iterator for destination image - - @param d_acc - Destination accessor - */ -template< class SourceIter, class SourceAcc, - class DestIter, class DestAcc > -void scaleImage( SourceIter s_begin, - SourceIter s_end, - SourceAcc s_acc, - DestIter d_begin, - DestIter d_end, - DestAcc d_acc ) -{ - const int src_width ( s_end.x - s_begin.x ); - const int src_height( s_end.y - s_begin.y ); - - const int dest_width ( d_end.x - d_begin.x ); - const int dest_height( d_end.y - d_begin.y ); - - if ( src_width == dest_width && - src_height == dest_height ) - { - // no scaling involved, can simply copy - vigra::copyImage( s_begin, s_end, s_acc, - d_begin, d_acc ); - return; - } - - typedef vigra::BasicImage<typename SourceAcc::value_type> TmpImage; - typedef typename TmpImage::traverser TmpImageIter; - - TmpImage tmp_image(src_width, - dest_height); - TmpImageIter t_begin = tmp_image.upperLeft(); - - // scale in y direction - for( int x=0; x<src_width; ++x, ++s_begin.x, ++t_begin.x ) - { - typename SourceIter::column_iterator s_cbegin = s_begin.columnIterator(); - typename TmpImageIter::column_iterator t_cbegin = t_begin.columnIterator(); - - scaleLine(s_cbegin, s_cbegin+src_height, s_acc, - t_cbegin, t_cbegin+dest_height, tmp_image.accessor()); - } - - t_begin = tmp_image.upperLeft(); - - // scale in x direction - for( int y=0; y<dest_height; ++y, ++d_begin.y, ++t_begin.y ) - { - typename DestIter::row_iterator d_rbegin = d_begin.rowIterator(); - typename TmpImageIter::row_iterator t_rbegin = t_begin.rowIterator(); - - scaleLine(t_rbegin, t_rbegin+src_width, tmp_image.accessor(), - d_rbegin, d_rbegin+dest_width, d_acc); - } -} - -/** Scale an image, range tuple version - */ -template< class SourceIter, class SourceAcc, - class DestIter, class DestAcc > -inline void scaleImage( vigra::triple<SourceIter,SourceIter,SourceAcc> const& src, - vigra::triple<DestIter,DestIter,DestAcc> const& dst ) -{ - scaleImage(src.first,src.second,src.third, - dst.first,dst.second,dst.third); -} - -} - -#endif /* INCLUDED_BASEBMP_INC_SCALEIMAGE_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index c0afe86..ce7b35a 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -42,8 +42,7 @@ #include <rgb24pixelformats.hxx> #include <basebmp/scanlineformats.hxx> -#include <fillimage.hxx> -#include <scaleimage.hxx> +#include <vigra/copyimage.hxx> #include <genericcolorimageaccessor.hxx> #include <tools.hxx> @@ -242,13 +241,8 @@ namespace std::shared_ptr<BitmapRenderer> pSrcBmp( getCompatibleBitmap(rSrcBitmap) ); OSL_ASSERT( pSrcBmp ); - scaleImage( - srcIterRange(pSrcBmp->maBegin, - pSrcBmp->maRawAccessor, - aRect), - destIterRange(begin, - acc, - aRect)); + vigra::copyImage( pSrcBmp->maBegin, pSrcBmp->maBegin + bottomRight(aRect), pSrcBmp->maRawAccessor, + begin, acc ); } template< typename Iterator, typename Acc > static @@ -261,13 +255,8 @@ namespace GenericColorImageAccessor aSrcAcc( rSrcBitmap ); - scaleImage( - srcIterRange(vigra::Diff2D(), - aSrcAcc, - aRect), - destIterRange(begin, - acc, - aRect)); + vigra::copyImage( vigra::Diff2D(), vigra::Diff2D() + bottomRight(aRect), aSrcAcc, + begin, acc ); } void implDrawBitmapDirect(const BitmapDeviceSharedPtr& rSrcBitmap) commit d3b0f6bcd464c84052ca2af36ea2649aeef57b74 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 09:40:49 2016 +0000 always copying to a different bitmap Change-Id: I90b205bef1b01e6c4c43788fc5c95391b7842e83 diff --git a/basebmp/inc/scaleimage.hxx b/basebmp/inc/scaleimage.hxx index 69beaf6..f3975e9 100644 --- a/basebmp/inc/scaleimage.hxx +++ b/basebmp/inc/scaleimage.hxx @@ -104,10 +104,6 @@ void scaleLine( SourceIter s_begin, @param d_acc Destination accessor - - @param bMustCopy - When true, scaleImage always copies source, even when doing 1:1 - copy */ template< class SourceIter, class SourceAcc, class DestIter, class DestAcc > @@ -116,8 +112,7 @@ void scaleImage( SourceIter s_begin, SourceAcc s_acc, DestIter d_begin, DestIter d_end, - DestAcc d_acc, - bool bMustCopy=false ) + DestAcc d_acc ) { const int src_width ( s_end.x - s_begin.x ); const int src_height( s_end.y - s_begin.y ); @@ -125,9 +120,8 @@ void scaleImage( SourceIter s_begin, const int dest_width ( d_end.x - d_begin.x ); const int dest_height( d_end.y - d_begin.y ); - if( !bMustCopy && - src_width == dest_width && - src_height == dest_height ) + if ( src_width == dest_width && + src_height == dest_height ) { // no scaling involved, can simply copy vigra::copyImage( s_begin, s_end, s_acc, @@ -166,20 +160,14 @@ void scaleImage( SourceIter s_begin, } /** Scale an image, range tuple version - - @param bMustCopy - When true, scaleImage always copies source, even when doing 1:1 - copy */ template< class SourceIter, class SourceAcc, class DestIter, class DestAcc > inline void scaleImage( vigra::triple<SourceIter,SourceIter,SourceAcc> const& src, - vigra::triple<DestIter,DestIter,DestAcc> const& dst, - bool bMustCopy=false ) + vigra::triple<DestIter,DestIter,DestAcc> const& dst ) { scaleImage(src.first,src.second,src.third, - dst.first,dst.second,dst.third, - bMustCopy); + dst.first,dst.second,dst.third); } } diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index 1e582e7..c0afe86 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -248,8 +248,7 @@ namespace aRect), destIterRange(begin, acc, - aRect), - isSharedBuffer(rSrcBitmap) ); + aRect)); } template< typename Iterator, typename Acc > static @@ -425,11 +424,6 @@ PaletteMemorySharedVector BitmapDevice::getPalette() const return mpImpl->mpPalette; } -bool BitmapDevice::isSharedBuffer( const BitmapDeviceSharedPtr& rOther ) const -{ - return rOther.get()->getBuffer().get() == getBuffer().get(); -} - Color BitmapDevice::getPixel( const basegfx::B2IPoint& rPt ) { if( mpImpl->maBounds.isInside(rPt) ) diff --git a/include/basebmp/bitmapdevice.hxx b/include/basebmp/bitmapdevice.hxx index 5f2756c..85dc153 100644 --- a/include/basebmp/bitmapdevice.hxx +++ b/include/basebmp/bitmapdevice.hxx @@ -100,9 +100,6 @@ public: */ PaletteMemorySharedVector getPalette() const; - /// Check if this and the other BitmapDevice share a buffer - bool isSharedBuffer( const BitmapDeviceSharedPtr& rOther ) const; - /** Get color value at given pixel */ Color getPixel( const basegfx::B2IPoint& rPt ); commit 1c217968b609de4484388719427366e7ddbc48d0 Author: Caolán McNamara <[email protected]> Date: Tue Jan 19 09:33:56 2016 +0000 always copying the full bitmap, not just a portion of it Change-Id: Ib3e10d188c3f0d1bde40653d783f98ebfaed423c diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index f40d931..1e582e7 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -233,83 +233,59 @@ namespace template< typename Iterator, typename RawAcc > void implDrawBitmap(const BitmapDeviceSharedPtr& rSrcBitmap, - const basegfx::B2IBox& rSrcRect, - const basegfx::B2IBox& rDstRect, const Iterator& begin, const RawAcc& acc) { + const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() ); + const basegfx::B2IBox aRect(0, 0, rSrcSize.getX(),rSrcSize.getY()); + std::shared_ptr<BitmapRenderer> pSrcBmp( getCompatibleBitmap(rSrcBitmap) ); OSL_ASSERT( pSrcBmp ); scaleImage( srcIterRange(pSrcBmp->maBegin, pSrcBmp->maRawAccessor, - rSrcRect), + aRect), destIterRange(begin, acc, - rDstRect), + aRect), isSharedBuffer(rSrcBitmap) ); } template< typename Iterator, typename Acc > static void implDrawBitmapGeneric(const BitmapDeviceSharedPtr& rSrcBitmap, - const basegfx::B2IBox& rSrcRect, - const basegfx::B2IBox& rDstRect, const Iterator& begin, const Acc& acc) { + const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() ); + const basegfx::B2IBox aRect(0, 0, rSrcSize.getX(),rSrcSize.getY()); + GenericColorImageAccessor aSrcAcc( rSrcBitmap ); scaleImage( srcIterRange(vigra::Diff2D(), aSrcAcc, - rSrcRect), + aRect), destIterRange(begin, acc, - rDstRect)); + aRect)); } - void implDrawBitmapDirect(const BitmapDeviceSharedPtr& rSrcBitmap, - const basegfx::B2IBox& rSrcRect, - const basegfx::B2IBox& rDstRect) + void implDrawBitmapDirect(const BitmapDeviceSharedPtr& rSrcBitmap) { - sal_Int32 nSrcX = rSrcRect.getMinX(); - sal_Int32 nSrcY = rSrcRect.getMinY(); - sal_Int32 nSrcWidth = rSrcRect.getWidth(); - sal_Int32 nSrcHeight = rSrcRect.getHeight(); - sal_Int32 nDestX = rDstRect.getMinX(); - sal_Int32 nDestY = rDstRect.getMinY(); + const basegfx::B2IVector& rSrcSize(rSrcBitmap->getSize()); + + sal_Int32 nSrcWidth = rSrcSize.getX(); + sal_Int32 nSrcHeight = rSrcSize.getY(); char* dstBuf = reinterpret_cast<char*>(getBuffer().get()); char* srcBuf = reinterpret_cast<char*>(rSrcBitmap->getBuffer().get()); sal_Int32 dstStride = getScanlineStride(); sal_Int32 srcStride = rSrcBitmap->getScanlineStride(); sal_Int32 bytesPerPixel = (bitsPerPixel[getScanlineFormat()] + 7) >> 3; // round up to bytes - bool dstTopDown = true; - bool srcTopDown = true; - - if (dstBuf == srcBuf && nSrcY < nDestY) // reverse copy order to avoid overlapping - { - nSrcY = getBufferSize().getY() - nSrcY - nSrcHeight; - nDestY = getBufferSize().getY() - nDestY - nSrcHeight; - srcTopDown = !srcTopDown; - dstTopDown = !dstTopDown; - } - if (!dstTopDown) - { - dstBuf += dstStride * (getBufferSize().getY() - 1); - dstStride = -dstStride; - } - - if (!srcTopDown) - { - srcBuf += srcStride * (rSrcBitmap->getBufferSize().getY() - 1); - srcStride = -srcStride; - } - - char* dstline = dstBuf + dstStride * nDestY + nDestX * bytesPerPixel; - char* srcline = srcBuf + srcStride * nSrcY + nSrcX * bytesPerPixel; + char* dstline = dstBuf; + char* srcline = srcBuf; sal_Int32 lineBytes = nSrcWidth * bytesPerPixel; for(; 0 < nSrcHeight; nSrcHeight--) @@ -320,24 +296,21 @@ namespace } } - virtual void drawBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap, - const basegfx::B2IBox& rSrcRect, - const basegfx::B2IBox& rDstRect ) override + virtual void copyBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap) override { if( isCompatibleBitmap( rSrcBitmap ) ) { if (bitsPerPixel[getScanlineFormat()] >= 8 - && rSrcRect.getWidth() == rDstRect.getWidth() && rSrcRect.getHeight() == rDstRect.getHeight() && rSrcBitmap->getScanlineFormat() == getScanlineFormat()) - implDrawBitmapDirect(rSrcBitmap, rSrcRect, rDstRect); + implDrawBitmapDirect(rSrcBitmap); else - implDrawBitmap(rSrcBitmap, rSrcRect, rDstRect, + implDrawBitmap(rSrcBitmap, maBegin, maRawAccessor); } else { - implDrawBitmapGeneric(rSrcBitmap, rSrcRect, rDstRect, + implDrawBitmapGeneric(rSrcBitmap, maBegin, maAccessor); } @@ -473,115 +446,9 @@ sal_uInt32 BitmapDevice::getPixelData( const basegfx::B2IPoint& rPt ) return 0; } -namespace -{ - void assertImageRange( const basegfx::B2IBox& rRange, - const basegfx::B2IBox& rPermittedRange ) - { -#if OSL_DEBUG_LEVEL > 0 - basegfx::B2IBox aRange( rRange ); - aRange.intersect( rPermittedRange ); - - OSL_ASSERT( aRange == rRange ); -#else - (void)rRange; (void)rPermittedRange; -#endif - } - - // TODO(Q3): Move canvas/canvastools.hxx clipBlit() down - // to basegfx, and use here! - bool clipAreaImpl( ::basegfx::B2IBox& io_rDestArea, - ::basegfx::B2IBox& io_rSourceArea, - const ::basegfx::B2IBox& rDestBounds, - const ::basegfx::B2IBox& rSourceBounds ) - { - // extract inherent scale - double fWidth = io_rSourceArea.getWidth(); - if (fWidth == 0.0) - return false; - - double fHeight = io_rSourceArea.getHeight(); - if (fHeight == 0.0) - return false; - - const double nScaleX( io_rDestArea.getWidth() / fWidth ); - const double nScaleY( io_rDestArea.getHeight() / fHeight ); - - // extract range origins - const basegfx::B2IPoint aDestTopLeft( - io_rDestArea.getMinimum() ); - const ::basegfx::B2IPoint aSourceTopLeft( - io_rSourceArea.getMinimum() ); - - ::basegfx::B2IBox aLocalSourceArea( io_rSourceArea ); - - // clip source area (which must be inside rSourceBounds) - aLocalSourceArea.intersect( rSourceBounds ); - - if( aLocalSourceArea.isEmpty() ) - return false; - - // calc relative new source area points (relative to orig - // source area) - const ::basegfx::B2IVector aUpperLeftOffset( - aLocalSourceArea.getMinimum()-aSourceTopLeft ); - const ::basegfx::B2IVector aLowerRightOffset( - aLocalSourceArea.getMaximum()-aSourceTopLeft ); - - ::basegfx::B2IBox aLocalDestArea( basegfx::fround(aDestTopLeft.getX() + nScaleX*aUpperLeftOffset.getX()), - basegfx::fround(aDestTopLeft.getY() + nScaleY*aUpperLeftOffset.getY()), - basegfx::fround(aDestTopLeft.getX() + nScaleX*aLowerRightOffset.getX()), - basegfx::fround(aDestTopLeft.getY() + nScaleY*aLowerRightOffset.getY()) ); - - // clip dest area (which must be inside rDestBounds) - aLocalDestArea.intersect( rDestBounds ); - - if( aLocalDestArea.isEmpty() ) - return false; - - // calc relative new dest area points (relative to orig - // source area) - const ::basegfx::B2IVector aDestUpperLeftOffset( - aLocalDestArea.getMinimum()-aDestTopLeft ); - const ::basegfx::B2IVector aDestLowerRightOffset( - aLocalDestArea.getMaximum()-aDestTopLeft ); - - io_rSourceArea = ::basegfx::B2IBox( basegfx::fround(aSourceTopLeft.getX() + aDestUpperLeftOffset.getX()/nScaleX), - basegfx::fround(aSourceTopLeft.getY() + aDestUpperLeftOffset.getY()/nScaleY), - basegfx::fround(aSourceTopLeft.getX() + aDestLowerRightOffset.getX()/nScaleX), - basegfx::fround(aSourceTopLeft.getY() + aDestLowerRightOffset.getY()/nScaleY) ); - io_rDestArea = aLocalDestArea; - - // final source area clip (chopping round-offs) - io_rSourceArea.intersect( rSourceBounds ); - - if( io_rSourceArea.isEmpty() ) - return false; - - - return true; - } -} - -void BitmapDevice::drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap, - const basegfx::B2IBox& rSrcRect, - const basegfx::B2IBox& rDstRect ) +void BitmapDevice::copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ) { - const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() ); - const basegfx::B2IBox aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() ); - basegfx::B2IBox aSrcRange( rSrcRect ); - basegfx::B2IBox aDestRange( rDstRect ); - - if( clipAreaImpl( aDestRange, - aSrcRange, - mpImpl->maBounds, - aSrcBounds )) - { - assertImageRange(aDestRange,mpImpl->maBounds); - assertImageRange(aSrcRange,aSrcBounds); - - drawBitmap_i( rSrcBitmap, aSrcRange, aDestRange ); - } + copyBitmap_i( rSrcBitmap ); } /** Standard clip and alpha masks diff --git a/include/basebmp/bitmapdevice.hxx b/include/basebmp/bitmapdevice.hxx index 16c89aa..5f2756c 100644 --- a/include/basebmp/bitmapdevice.hxx +++ b/include/basebmp/bitmapdevice.hxx @@ -118,23 +118,9 @@ public: /** Draw another bitmap into this device @param rSrcBitmap - Bitmap to render into this one. It is permitted that source - and destination bitmap are the same. - - @param rSrcRect - Rectangle within the source bitmap to take the pixel from. - - @param rDstRect - Rectangle in the destination bitmap to put the pixel - into. Source and destination rectangle are permitted to have - differing sizes; this method will scale the source pixel - accordingly. Please note that both source and destination - rectangle are interpreted excluding the rightmost pixel column - and the bottommost pixel row + Bitmap to render into this one. */ - void drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap, - const basegfx::B2IBox& rSrcRect, - const basegfx::B2IBox& rDstRect ); + void copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap ); protected: BASEBMP_DLLPRIVATE BitmapDevice( const basegfx::B2IBox& rBounds, @@ -155,10 +141,7 @@ private: BASEBMP_DLLPRIVATE virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt ) = 0; - // must work with *this == rSrcBitmap! - BASEBMP_DLLPRIVATE virtual void drawBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap, - const basegfx::B2IBox& rSrcRect, - const basegfx::B2IBox& rDstRect ) = 0; + BASEBMP_DLLPRIVATE virtual void copyBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap ) = 0; BitmapDeviceSharedPtr getGenericRenderer() const; diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 6ef5684..e0b1afb 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -79,8 +79,7 @@ bool SvpSalBitmap::Create( const SalBitmap& rSalBmp ) { B2IVector aSize = rSrcBmp->getSize(); m_aBitmap = cloneBitmapDevice( aSize, rSrcBmp ); - B2IBox aRect( 0, 0, aSize.getX(), aSize.getY() ); - m_aBitmap->drawBitmap(rSrcBmp, aRect, aRect); + m_aBitmap->copyBitmap(rSrcBmp); } else m_aBitmap.reset(); diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 390ed8f..eb96693 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -130,9 +130,8 @@ namespace Size aSize = rSourceBitmap.GetSize(); aTmpBmp.Create(aSize, 0, BitmapPalette()); assert(aTmpBmp.GetBitCount() == 32); - basegfx::B2IBox aRect(0, 0, aSize.Width(), aSize.Height()); const basebmp::BitmapDeviceSharedPtr& rTmpSrc = aTmpBmp.getBitmap(); - rTmpSrc->drawBitmap(rSrcBmp, aRect, aRect); + rTmpSrc->copyBitmap(rSrcBmp); source = SvpSalGraphics::createCairoSurface(rTmpSrc); } else
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
