diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-02 19:33:57 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-05-04 08:40:50 +0200 |
commit | e5889bb63a20061b3986afff5e64062c8db3fd64 (patch) | |
tree | 1a573a09d8ba5a2cae3998218934d41711412989 /drawinglayer | |
parent | 1a86c041cd9eaefd5869df984c780b84f847e6fd (diff) |
remove vclhelperbufferdevice.{cxx,hxx} from clang-format blacklist
Change-Id: I0ab6572ab700756322f96b982f7faeb6d8dc9fb6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93362
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/processor2d/vclhelperbufferdevice.cxx | 612 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclhelperbufferdevice.hxx | 43 |
2 files changed, 332 insertions, 323 deletions
diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index f362559d12bf..53ecdd4ee685 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -35,422 +35,430 @@ #include <vcl/lazydelete.hxx> #include <vcl/dibtools.hxx> - // buffered VDev usage namespace { - typedef std::vector< VclPtr<VirtualDevice> > aBuffers; - - class VDevBuffer : public Timer, protected cppu::BaseMutex - { - private: - // available buffers - aBuffers maFreeBuffers; - - // allocated/used buffers (remembered to allow deleting them in destructor) - aBuffers maUsedBuffers; - - // remember what outputdevice was the template passed to VirtualDevice::Create - // so we can test if that OutputDevice was disposed before reusing a - // virtualdevice because that isn't safe to do at least for Gtk2 - std::map< VclPtr<VirtualDevice>, VclPtr<OutputDevice> > maDeviceTemplates; +typedef std::vector<VclPtr<VirtualDevice>> aBuffers; - public: - VDevBuffer(); - virtual ~VDevBuffer() override; - - VclPtr<VirtualDevice> alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome); - void free(VirtualDevice& rDevice); +class VDevBuffer : public Timer, protected cppu::BaseMutex +{ +private: + // available buffers + aBuffers maFreeBuffers; + + // allocated/used buffers (remembered to allow deleting them in destructor) + aBuffers maUsedBuffers; + + // remember what outputdevice was the template passed to VirtualDevice::Create + // so we can test if that OutputDevice was disposed before reusing a + // virtualdevice because that isn't safe to do at least for Gtk2 + std::map<VclPtr<VirtualDevice>, VclPtr<OutputDevice>> maDeviceTemplates; + +public: + VDevBuffer(); + virtual ~VDevBuffer() override; + + VclPtr<VirtualDevice> alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, + bool bMonoChrome); + void free(VirtualDevice& rDevice); + + // Timer virtuals + virtual void Invoke() override; +}; + +VDevBuffer::VDevBuffer() + : Timer("VDevBuffer timer") + , maFreeBuffers() + , maUsedBuffers() +{ + SetTimeout(10L * 1000L); // ten seconds + SetDebugName("drawinglayer::VDevBuffer via Invoke()"); +} - // Timer virtuals - virtual void Invoke() override; - }; +VDevBuffer::~VDevBuffer() +{ + ::osl::MutexGuard aGuard(m_aMutex); + Stop(); - VDevBuffer::VDevBuffer() - : Timer("VDevBuffer timer"), - maFreeBuffers(), - maUsedBuffers() + while (!maFreeBuffers.empty()) { - SetTimeout(10L * 1000L); // ten seconds - SetDebugName("drawinglayer::VDevBuffer via Invoke()"); + (*(maFreeBuffers.end() - 1)).disposeAndClear(); + maFreeBuffers.pop_back(); } - VDevBuffer::~VDevBuffer() + while (!maUsedBuffers.empty()) { - ::osl::MutexGuard aGuard(m_aMutex); - Stop(); + (*(maUsedBuffers.end() - 1)).disposeAndClear(); + maUsedBuffers.pop_back(); + } +} - while(!maFreeBuffers.empty()) - { - (*(maFreeBuffers.end() - 1)).disposeAndClear(); - maFreeBuffers.pop_back(); - } +VclPtr<VirtualDevice> VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, + bool bMonoChrome) +{ + ::osl::MutexGuard aGuard(m_aMutex); + VclPtr<VirtualDevice> pRetval; - while(!maUsedBuffers.empty()) - { - (*(maUsedBuffers.end() - 1)).disposeAndClear(); - maUsedBuffers.pop_back(); - } - } + sal_Int32 nBits = bMonoChrome ? 1 : rOutDev.GetBitCount(); - VclPtr<VirtualDevice> VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome) + bool bOkay(false); + if (!maFreeBuffers.empty()) { - ::osl::MutexGuard aGuard(m_aMutex); - VclPtr<VirtualDevice> pRetval; + aBuffers::iterator aFound(maFreeBuffers.end()); - sal_Int32 nBits = bMonoChrome ? 1 : rOutDev.GetBitCount(); - - bool bOkay(false); - if(!maFreeBuffers.empty()) + for (aBuffers::iterator a(maFreeBuffers.begin()); a != maFreeBuffers.end(); ++a) { - aBuffers::iterator aFound(maFreeBuffers.end()); + assert(*a && "Empty pointer in VDevBuffer (!)"); - for(aBuffers::iterator a(maFreeBuffers.begin()); a != maFreeBuffers.end(); ++a) + if (nBits == (*a)->GetBitCount()) { - assert(*a && "Empty pointer in VDevBuffer (!)"); - - if (nBits == (*a)->GetBitCount()) + // candidate is valid due to bit depth + if (aFound != maFreeBuffers.end()) { - // candidate is valid due to bit depth - if(aFound != maFreeBuffers.end()) + // already found + if (bOkay) { - // already found - if(bOkay) + // found is valid + const bool bCandidateOkay( + (*a)->GetOutputWidthPixel() >= rSizePixel.getWidth() + && (*a)->GetOutputHeightPixel() >= rSizePixel.getHeight()); + + if (bCandidateOkay) { - // found is valid - const bool bCandidateOkay((*a)->GetOutputWidthPixel() >= rSizePixel.getWidth() && (*a)->GetOutputHeightPixel() >= rSizePixel.getHeight()); + // found and candidate are valid + const sal_uLong aSquare((*aFound)->GetOutputWidthPixel() + * (*aFound)->GetOutputHeightPixel()); + const sal_uLong aCandidateSquare((*a)->GetOutputWidthPixel() + * (*a)->GetOutputHeightPixel()); - if(bCandidateOkay) - { - // found and candidate are valid - const sal_uLong aSquare((*aFound)->GetOutputWidthPixel() * (*aFound)->GetOutputHeightPixel()); - const sal_uLong aCandidateSquare((*a)->GetOutputWidthPixel() * (*a)->GetOutputHeightPixel()); - - if(aCandidateSquare < aSquare) - { - // candidate is valid and smaller, use it - aFound = a; - } - } - else + if (aCandidateSquare < aSquare) { - // found is valid, candidate is not. Keep found + // candidate is valid and smaller, use it + aFound = a; } } else { - // found is invalid, use candidate - aFound = a; - bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); + // found is valid, candidate is not. Keep found } } else { - // none yet, use candidate + // found is invalid, use candidate aFound = a; - bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); - } - } - } - - if(aFound != maFreeBuffers.end()) - { - pRetval = *aFound; - maFreeBuffers.erase(aFound); - } - } - - if (pRetval) - { - // found a suitable cached virtual device, but the - // outputdevice it was based on has been disposed, - // drop it and create a new one instead as reusing - // such devices is unsafe under at least Gtk2 - if (maDeviceTemplates[pRetval]->isDisposed()) - { - maDeviceTemplates.erase(pRetval); - pRetval.disposeAndClear(); - } - else - { - if (bOkay) - { - if (bClear) - { - pRetval->Erase(::tools::Rectangle(0, 0, rSizePixel.getWidth(), rSizePixel.getHeight())); + bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() + && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); } } else { - pRetval->SetOutputSizePixel(rSizePixel, bClear); + // none yet, use candidate + aFound = a; + bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() + && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); } } } - // no success yet, create new buffer - if(!pRetval) + if (aFound != maFreeBuffers.end()) { - pRetval = VclPtr<VirtualDevice>::Create(rOutDev, bMonoChrome ? DeviceFormat::BITMASK : DeviceFormat::DEFAULT); - maDeviceTemplates[pRetval] = &rOutDev; - pRetval->SetOutputSizePixel(rSizePixel, bClear); + pRetval = *aFound; + maFreeBuffers.erase(aFound); + } + } + + if (pRetval) + { + // found a suitable cached virtual device, but the + // outputdevice it was based on has been disposed, + // drop it and create a new one instead as reusing + // such devices is unsafe under at least Gtk2 + if (maDeviceTemplates[pRetval]->isDisposed()) + { + maDeviceTemplates.erase(pRetval); + pRetval.disposeAndClear(); } else { - // reused, reset some values - pRetval->SetMapMode(); - pRetval->SetRasterOp(RasterOp::OverPaint); + if (bOkay) + { + if (bClear) + { + pRetval->Erase( + ::tools::Rectangle(0, 0, rSizePixel.getWidth(), rSizePixel.getHeight())); + } + } + else + { + pRetval->SetOutputSizePixel(rSizePixel, bClear); + } } - - // remember allocated buffer - maUsedBuffers.push_back(pRetval); - - return pRetval; } - void VDevBuffer::free(VirtualDevice& rDevice) + // no success yet, create new buffer + if (!pRetval) { - ::osl::MutexGuard aGuard(m_aMutex); - const aBuffers::iterator aUsedFound(std::find(maUsedBuffers.begin(), maUsedBuffers.end(), &rDevice)); - OSL_ENSURE(aUsedFound != maUsedBuffers.end(), "OOps, non-registered buffer freed (!)"); - - maUsedBuffers.erase(aUsedFound); - maFreeBuffers.emplace_back(&rDevice); - SAL_WARN_IF(maFreeBuffers.size() > 1000, "drawinglayer", "excessive cached buffers, " - << maFreeBuffers.size() << " entries!"); - Start(); + pRetval = VclPtr<VirtualDevice>::Create(rOutDev, bMonoChrome ? DeviceFormat::BITMASK + : DeviceFormat::DEFAULT); + maDeviceTemplates[pRetval] = &rOutDev; + pRetval->SetOutputSizePixel(rSizePixel, bClear); } - - void VDevBuffer::Invoke() + else { - ::osl::MutexGuard aGuard(m_aMutex); - - while(!maFreeBuffers.empty()) - { - aBuffers::iterator aLastOne(maFreeBuffers.end() - 1); - maDeviceTemplates.erase(*aLastOne); - aLastOne->disposeAndClear(); - maFreeBuffers.pop_back(); - } + // reused, reset some values + pRetval->SetMapMode(); + pRetval->SetRasterOp(RasterOp::OverPaint); } + + // remember allocated buffer + maUsedBuffers.push_back(pRetval); + + return pRetval; } +void VDevBuffer::free(VirtualDevice& rDevice) +{ + ::osl::MutexGuard aGuard(m_aMutex); + const aBuffers::iterator aUsedFound( + std::find(maUsedBuffers.begin(), maUsedBuffers.end(), &rDevice)); + OSL_ENSURE(aUsedFound != maUsedBuffers.end(), "OOps, non-registered buffer freed (!)"); + + maUsedBuffers.erase(aUsedFound); + maFreeBuffers.emplace_back(&rDevice); + SAL_WARN_IF(maFreeBuffers.size() > 1000, "drawinglayer", + "excessive cached buffers, " << maFreeBuffers.size() << " entries!"); + Start(); +} + +void VDevBuffer::Invoke() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + while (!maFreeBuffers.empty()) + { + aBuffers::iterator aLastOne(maFreeBuffers.end() - 1); + maDeviceTemplates.erase(*aLastOne); + aLastOne->disposeAndClear(); + maFreeBuffers.pop_back(); + } +} +} // support for rendering Bitmap and BitmapEx contents namespace drawinglayer { - // static global VDev buffer for the VclProcessor2D's (VclMetafileProcessor2D and VclPixelProcessor2D) - VDevBuffer& getVDevBuffer() - { - // secure global instance with Vcl's safe destroyer of external (seen by - // library base) stuff, the remembered VDevs need to be deleted before - // Vcl's deinit - static vcl::DeleteOnDeinit< VDevBuffer > aVDevBuffer(new VDevBuffer()); - return *aVDevBuffer.get(); - } +// static global VDev buffer for the VclProcessor2D's (VclMetafileProcessor2D and VclPixelProcessor2D) +VDevBuffer& getVDevBuffer() +{ + // secure global instance with Vcl's safe destroyer of external (seen by + // library base) stuff, the remembered VDevs need to be deleted before + // Vcl's deinit + static vcl::DeleteOnDeinit<VDevBuffer> aVDevBuffer(new VDevBuffer()); + return *aVDevBuffer.get(); +} - impBufferDevice::impBufferDevice( - OutputDevice& rOutDev, - const basegfx::B2DRange& rRange) - : mrOutDev(rOutDev), - mpContent(nullptr), - mpMask(nullptr), - mpAlpha(nullptr) - { - basegfx::B2DRange aRangePixel(rRange); - aRangePixel.transform(mrOutDev.GetViewTransformation()); - const ::tools::Rectangle aRectPixel( - static_cast<sal_Int32>(floor(aRangePixel.getMinX())), static_cast<sal_Int32>(floor(aRangePixel.getMinY())), - static_cast<sal_Int32>(ceil(aRangePixel.getMaxX())), static_cast<sal_Int32>(ceil(aRangePixel.getMaxY()))); - const Point aEmptyPoint; - maDestPixel = ::tools::Rectangle(aEmptyPoint, mrOutDev.GetOutputSizePixel()); - maDestPixel.Intersection(aRectPixel); - - if(!isVisible()) - return; +impBufferDevice::impBufferDevice(OutputDevice& rOutDev, const basegfx::B2DRange& rRange) + : mrOutDev(rOutDev) + , mpContent(nullptr) + , mpMask(nullptr) + , mpAlpha(nullptr) +{ + basegfx::B2DRange aRangePixel(rRange); + aRangePixel.transform(mrOutDev.GetViewTransformation()); + const ::tools::Rectangle aRectPixel(static_cast<sal_Int32>(floor(aRangePixel.getMinX())), + static_cast<sal_Int32>(floor(aRangePixel.getMinY())), + static_cast<sal_Int32>(ceil(aRangePixel.getMaxX())), + static_cast<sal_Int32>(ceil(aRangePixel.getMaxY()))); + const Point aEmptyPoint; + maDestPixel = ::tools::Rectangle(aEmptyPoint, mrOutDev.GetOutputSizePixel()); + maDestPixel.Intersection(aRectPixel); + + if (!isVisible()) + return; #ifdef IOS - // Exact mechanism unknown, but for some reason SmartArt - // rendering, especially shadows, is broken on iOS unless - // we pass 'true' here. Are virtual devices always de - // facto cleared when created on other platforms? - mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); + // Exact mechanism unknown, but for some reason SmartArt + // rendering, especially shadows, is broken on iOS unless + // we pass 'true' here. Are virtual devices always de + // facto cleared when created on other platforms? + mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); #else - mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), false, false); + mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), false, false); #endif - // #i93485# assert when copying from window to VDev is used - OSL_ENSURE(mrOutDev.GetOutDevType() != OUTDEV_WINDOW, - "impBufferDevice render helper: Copying from Window to VDev, this should be avoided (!)"); + // #i93485# assert when copying from window to VDev is used + OSL_ENSURE( + mrOutDev.GetOutDevType() != OUTDEV_WINDOW, + "impBufferDevice render helper: Copying from Window to VDev, this should be avoided (!)"); - const bool bWasEnabledSrc(mrOutDev.IsMapModeEnabled()); - mrOutDev.EnableMapMode(false); - mpContent->DrawOutDev(aEmptyPoint, maDestPixel.GetSize(), maDestPixel.TopLeft(), maDestPixel.GetSize(), mrOutDev); - mrOutDev.EnableMapMode(bWasEnabledSrc); + const bool bWasEnabledSrc(mrOutDev.IsMapModeEnabled()); + mrOutDev.EnableMapMode(false); + mpContent->DrawOutDev(aEmptyPoint, maDestPixel.GetSize(), maDestPixel.TopLeft(), + maDestPixel.GetSize(), mrOutDev); + mrOutDev.EnableMapMode(bWasEnabledSrc); - MapMode aNewMapMode(mrOutDev.GetMapMode()); + MapMode aNewMapMode(mrOutDev.GetMapMode()); - const Point aLogicTopLeft(mrOutDev.PixelToLogic(maDestPixel.TopLeft())); - aNewMapMode.SetOrigin(Point(-aLogicTopLeft.X(), -aLogicTopLeft.Y())); + const Point aLogicTopLeft(mrOutDev.PixelToLogic(maDestPixel.TopLeft())); + aNewMapMode.SetOrigin(Point(-aLogicTopLeft.X(), -aLogicTopLeft.Y())); - mpContent->SetMapMode(aNewMapMode); + mpContent->SetMapMode(aNewMapMode); - // copy AA flag for new target - mpContent->SetAntialiasing(mrOutDev.GetAntialiasing()); + // copy AA flag for new target + mpContent->SetAntialiasing(mrOutDev.GetAntialiasing()); - // copy RasterOp (e.g. may be RasterOp::Xor on destination) - mpContent->SetRasterOp(mrOutDev.GetRasterOp()); - } + // copy RasterOp (e.g. may be RasterOp::Xor on destination) + mpContent->SetRasterOp(mrOutDev.GetRasterOp()); +} - impBufferDevice::~impBufferDevice() +impBufferDevice::~impBufferDevice() +{ + if (mpContent) { - if(mpContent) - { - getVDevBuffer().free(*mpContent); - } - - if(mpMask) - { - getVDevBuffer().free(*mpMask); - } + getVDevBuffer().free(*mpContent); + } - if(mpAlpha) - { - getVDevBuffer().free(*mpAlpha); - } + if (mpMask) + { + getVDevBuffer().free(*mpMask); } - void impBufferDevice::paint(double fTrans) + if (mpAlpha) { - if(!isVisible()) - return; + getVDevBuffer().free(*mpAlpha); + } +} + +void impBufferDevice::paint(double fTrans) +{ + if (!isVisible()) + return; - const Point aEmptyPoint; - const Size aSizePixel(maDestPixel.GetSize()); - const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled()); + const Point aEmptyPoint; + const Size aSizePixel(maDestPixel.GetSize()); + const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled()); #ifdef DBG_UTIL - static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore + static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore #endif - mrOutDev.EnableMapMode(false); - mpContent->EnableMapMode(false); + mrOutDev.EnableMapMode(false); + mpContent->EnableMapMode(false); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew( + if (bDoSaveForVisualControl) + { + SvFileStream aNew( #ifdef _WIN32 - "c:\\content.bmp", + "c:\\content.bmp", #else - "~/content.bmp", + "~/content.bmp", #endif - StreamMode::WRITE|StreamMode::TRUNC); - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - WriteDIB(aContent, aNew, false, true); - } + StreamMode::WRITE | StreamMode::TRUNC); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + WriteDIB(aContent, aNew, false, true); + } #endif - // during painting the buffer, disable evtl. set RasterOp (may be RasterOp::Xor) - const RasterOp aOrigRasterOp(mrOutDev.GetRasterOp()); - mrOutDev.SetRasterOp(RasterOp::OverPaint); + // during painting the buffer, disable evtl. set RasterOp (may be RasterOp::Xor) + const RasterOp aOrigRasterOp(mrOutDev.GetRasterOp()); + mrOutDev.SetRasterOp(RasterOp::OverPaint); - if(mpAlpha) - { - mpAlpha->EnableMapMode(false); - const AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel)); + if (mpAlpha) + { + mpAlpha->EnableMapMode(false); + const AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew( + if (bDoSaveForVisualControl) + { + SvFileStream aNew( #ifdef _WIN32 - "c:\\transparence.bmp", + "c:\\transparence.bmp", #else - "~/transparence.bmp", + "~/transparence.bmp", #endif - StreamMode::WRITE|StreamMode::TRUNC); - WriteDIB(aAlphaMask.GetBitmap(), aNew, false, true); - } + StreamMode::WRITE | StreamMode::TRUNC); + WriteDIB(aAlphaMask.GetBitmap(), aNew, false, true); + } #endif - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); - } - else if(mpMask) - { - mpMask->EnableMapMode(false); - const Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel)); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); + } + else if (mpMask) + { + mpMask->EnableMapMode(false); + const Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew( + if (bDoSaveForVisualControl) + { + SvFileStream aNew( #ifdef _WIN32 - "c:\\mask.bmp", + "c:\\mask.bmp", #else - "~/mask.bmp", + "~/mask.bmp", #endif - StreamMode::WRITE|StreamMode::TRUNC); - WriteDIB(aMask, aNew, false, true); - } -#endif - - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask)); - } - else if(0.0 != fTrans) - { - sal_uInt8 nMaskValue(static_cast<sal_uInt8>(basegfx::fround(fTrans * 255.0))); - const AlphaMask aAlphaMask(aSizePixel, &nMaskValue); - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); - } - else - { - mrOutDev.DrawOutDev(maDestPixel.TopLeft(), aSizePixel, - aEmptyPoint, aSizePixel, - *mpContent); + StreamMode::WRITE | StreamMode::TRUNC); + WriteDIB(aMask, aNew, false, true); } +#endif - mrOutDev.SetRasterOp(aOrigRasterOp); - mrOutDev.EnableMapMode(bWasEnabledDst); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask)); } - - VirtualDevice& impBufferDevice::getContent() + else if (0.0 != fTrans) { - assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); - return *mpContent; + sal_uInt8 nMaskValue(static_cast<sal_uInt8>(basegfx::fround(fTrans * 255.0))); + const AlphaMask aAlphaMask(aSizePixel, &nMaskValue); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); } - - VirtualDevice& impBufferDevice::getMask() + else { - assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); - if (!mpMask) - { - mpMask = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, true); - mpMask->SetMapMode(mpContent->GetMapMode()); + mrOutDev.DrawOutDev(maDestPixel.TopLeft(), aSizePixel, aEmptyPoint, aSizePixel, *mpContent); + } - // do NOT copy AA flag for mask! - } + mrOutDev.SetRasterOp(aOrigRasterOp); + mrOutDev.EnableMapMode(bWasEnabledDst); +} - return *mpMask; - } +VirtualDevice& impBufferDevice::getContent() +{ + assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); + return *mpContent; +} - VirtualDevice& impBufferDevice::getTransparence() +VirtualDevice& impBufferDevice::getMask() +{ + assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); + if (!mpMask) { - OSL_ENSURE(mpContent, "impBufferDevice: No content, check isVisible() before accessing (!)"); - if(!mpAlpha) - { - mpAlpha = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); - mpAlpha->SetMapMode(mpContent->GetMapMode()); + mpMask = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, true); + mpMask->SetMapMode(mpContent->GetMapMode()); - // copy AA flag for new target; masking needs to be smooth - mpAlpha->SetAntialiasing(mpContent->GetAntialiasing()); - } + // do NOT copy AA flag for mask! + } + + return *mpMask; +} + +VirtualDevice& impBufferDevice::getTransparence() +{ + OSL_ENSURE(mpContent, "impBufferDevice: No content, check isVisible() before accessing (!)"); + if (!mpAlpha) + { + mpAlpha = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); + mpAlpha->SetMapMode(mpContent->GetMapMode()); - return *mpAlpha; + // copy AA flag for new target; masking needs to be smooth + mpAlpha->SetAntialiasing(mpContent->GetAntialiasing()); } + + return *mpAlpha; +} } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx index 5305b1c0541e..90d351eac50f 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx @@ -21,32 +21,33 @@ #include <vcl/virdev.hxx> -namespace basegfx { class B2DRange; } +namespace basegfx +{ +class B2DRange; +} // support methods for vcl direct gradient rendering namespace drawinglayer { - class impBufferDevice - { - OutputDevice& mrOutDev; - VclPtr<VirtualDevice> mpContent; - VclPtr<VirtualDevice> mpMask; - VclPtr<VirtualDevice> mpAlpha; - ::tools::Rectangle maDestPixel; - - public: - impBufferDevice( - OutputDevice& rOutDev, - const basegfx::B2DRange& rRange); - ~impBufferDevice(); - - void paint(double fTrans = 0.0); - bool isVisible() const { return !maDestPixel.IsEmpty(); } - VirtualDevice& getContent(); - VirtualDevice& getMask(); - VirtualDevice& getTransparence(); - }; +class impBufferDevice +{ + OutputDevice& mrOutDev; + VclPtr<VirtualDevice> mpContent; + VclPtr<VirtualDevice> mpMask; + VclPtr<VirtualDevice> mpAlpha; + tools::Rectangle maDestPixel; + +public: + impBufferDevice(OutputDevice& rOutDev, const basegfx::B2DRange& rRange); + ~impBufferDevice(); + + void paint(double fTrans = 0.0); + bool isVisible() const { return !maDestPixel.IsEmpty(); } + VirtualDevice& getContent(); + VirtualDevice& getMask(); + VirtualDevice& getTransparence(); +}; } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |