summaryrefslogtreecommitdiff
path: root/vcl/quartz
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-01-17 21:29:10 +0200
committerTor Lillqvist <tml@collabora.com>2021-01-17 21:40:07 +0100
commite7ace1d043cc8bdf6c03097932a00cbbdc3cf557 (patch)
treedc9b8ef965dbe2f0752d9427a20ca606ab0b0f72 /vcl/quartz
parent058ad4b900b5e0ee902f3e89ed121c2b5f8c58f1 (diff)
tdf#138122: Fix vcl for iOS after 1a167625314bf36b735176ed488e6ba9b5e9b675
Make vcl compile again for iOS and make the Collabora Office iOS app work again when built against a master build of core. For now, keep the old versions of the functions touched by 1a167625314bf36b735176ed488e6ba9b5e9b675 in vcl/ios/salios.cxx, and move the modified versions to the new file vcl/osx/salmacos.cxx. Keep the functions as they were except that ifdefs for MACOSX or IOS are expanded. Keep the formatting as it was to make comparisons easier. Thus add the new files to the clang-format exclusion list. While at it, also move vcl/quartz/salgdiutils.cxx to vcl/osx as it is compiled only for macOS anyway. Change-Id: I990ef678f2263031d4a5af8cc547fffe185d17c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109480 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'vcl/quartz')
-rw-r--r--vcl/quartz/salbmp.cxx58
-rw-r--r--vcl/quartz/salgdicommon.cxx181
-rw-r--r--vcl/quartz/salgdiutils.cxx288
-rw-r--r--vcl/quartz/salvd.cxx104
4 files changed, 0 insertions, 631 deletions
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index cf1f26648b7f..a1570dd04ffb 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -69,64 +69,6 @@ QuartzSalBitmap::~QuartzSalBitmap()
doDestroy();
}
-bool QuartzSalBitmap::Create(CGLayerHolder const & rLayerHolder, int nBitmapBits, int nX, int nY, int nWidth, int nHeight, bool bFlipped)
-{
-
- // TODO: Bitmaps from scaled layers are reverted to single precision. This is a workaround only unless bitmaps with precision of
- // source layer are implemented.
-
- SAL_WARN_IF(!rLayerHolder.isSet(), "vcl", "QuartzSalBitmap::Create() from non-layered context");
-
- // sanitize input parameters
- if( nX < 0 ) {
- nWidth += nX;
- nX = 0;
- }
-
- if( nY < 0 ) {
- nHeight += nY;
- nY = 0;
- }
-
- CGSize aLayerSize = CGLayerGetSize(rLayerHolder.get());
- const float fScale = rLayerHolder.getScale();
- aLayerSize.width /= fScale;
- aLayerSize.height /= fScale;
-
- if( nWidth >= static_cast<int>(aLayerSize.width) - nX )
- nWidth = static_cast<int>(aLayerSize.width) - nX;
-
- if( nHeight >= static_cast<int>(aLayerSize.height) - nY )
- nHeight = static_cast<int>(aLayerSize.height) - nY;
-
- if( (nWidth < 0) || (nHeight < 0) )
- nWidth = nHeight = 0;
-
- // initialize properties
- mnWidth = nWidth;
- mnHeight = nHeight;
- mnBits = nBitmapBits ? nBitmapBits : 32;
-
- // initialize drawing context
- CreateContext();
-
- // copy layer content into the bitmap buffer
- const CGPoint aSrcPoint = { static_cast<CGFloat>(-nX * fScale), static_cast<CGFloat>(-nY * fScale) };
- if (maGraphicContext.isSet())
- {
- if( bFlipped )
- {
- CGContextTranslateCTM(maGraphicContext.get(), 0, +mnHeight);
- CGContextScaleCTM(maGraphicContext.get(), +1, -1);
- }
- maGraphicContext.saveState();
- CGContextScaleCTM(maGraphicContext.get(), 1 / fScale, 1 / fScale);
- CGContextDrawLayerAtPoint(maGraphicContext.get(), aSrcPoint, rLayerHolder.get());
- maGraphicContext.restoreState();
- }
- return true;
-}
-
bool QuartzSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette )
{
if( !isValidBitCount( nBits ) )
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 0597fe3d021d..33ffc43741a1 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -267,117 +267,6 @@ void AquaSalGraphics::ApplyXorContext()
}
}
-void AquaSalGraphics::copyBits(const SalTwoRect &rPosAry, SalGraphics *pSrcGraphics)
-{
- if (!pSrcGraphics)
- pSrcGraphics = this;
- AquaSalGraphics *pSrc = static_cast<AquaSalGraphics*>(pSrcGraphics);
- if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0)
- return;
- if (!maContextHolder.isSet())
- return;
-
- SAL_WARN_IF (!pSrc->maLayer.isSet(), "vcl.quartz", "AquaSalGraphics::copyBits() from non-layered graphics this=" << this);
-
- // Layered graphics are copied by AquaSalGraphics::copyScaledArea() which is able to consider the layer's scaling.
-
- if (pSrc->maLayer.isSet())
- copyScaledArea(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnSrcX, rPosAry.mnSrcY,
- rPosAry.mnSrcWidth, rPosAry.mnSrcHeight, pSrcGraphics);
- else
- {
- ApplyXorContext();
- pSrc->ApplyXorContext();
- std::shared_ptr<SalBitmap> pBitmap = pSrc->getBitmap(rPosAry.mnSrcX, rPosAry.mnSrcY,
- rPosAry.mnSrcWidth, rPosAry.mnSrcHeight);
- if (pBitmap)
- {
- SalTwoRect aPosAry(rPosAry);
- aPosAry.mnSrcX = 0;
- aPosAry.mnSrcY = 0;
- drawBitmap(aPosAry, *pBitmap);
- }
- }
-}
-
-void AquaSalGraphics::copyArea(tools::Long nDstX, tools::Long nDstY,tools::Long nSrcX, tools::Long nSrcY,
- tools::Long nSrcWidth, tools::Long nSrcHeight, bool)
-{
- if (!maContextHolder.isSet())
- return;
-
- // Functionality is implemented in protected member function AquaSalGraphics::copyScaledArea() which requires an additional
- // parameter of type SalGraphics to be used in AquaSalGraphics::copyBits() too.
-
- copyScaledArea(nDstX, nDstY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, this);
-}
-
-void AquaSalGraphics::copyScaledArea(tools::Long nDstX, tools::Long nDstY,tools::Long nSrcX, tools::Long nSrcY,
- tools::Long nSrcWidth, tools::Long nSrcHeight, SalGraphics *pSrcGraphics)
-{
- if (!pSrcGraphics)
- pSrcGraphics = this;
- AquaSalGraphics *pSrc = static_cast<AquaSalGraphics*>(pSrcGraphics);
-
- SAL_WARN_IF(!maLayer.isSet(), "vcl.quartz",
- "AquaSalGraphics::copyScaledArea() without graphics context or for non-layered graphics this=" << this);
-
- if (!maContextHolder.isSet() || !maLayer.isSet())
- return;
-
- // Determine scaled geometry of source and target area assuming source and target area have the same scale
-
- float fScale = maLayer.getScale();
- CGFloat nScaledSourceX = nSrcX * fScale;
- CGFloat nScaledSourceY = nSrcY * fScale;
- CGFloat nScaledTargetX = nDstX * fScale;
- CGFloat nScaledTargetY = nDstY * fScale;
- CGFloat nScaledSourceWidth = nSrcWidth * fScale;
- CGFloat nScaledSourceHeight = nSrcHeight * fScale;
-
- // Apply XOR context and get copy context from current graphics context or XOR context
-
- ApplyXorContext();
- maContextHolder.saveState();
- CGContextRef xCopyContext = maContextHolder.get();
- if (mpXorEmulation && mpXorEmulation->IsEnabled())
- xCopyContext = mpXorEmulation->GetTargetContext();
-
- // Set scale matrix of copy context to consider layer scaling
-
- CGContextScaleCTM(xCopyContext, 1 / fScale, 1 / fScale);
-
- // Creating an additional layer is required for drawing with the required scale and extent at the drawing destination
- // thereafter.
-
- CGLayerHolder aSourceLayerHolder(pSrc->maLayer);
- const CGSize aSourceSize = CGSizeMake(nScaledSourceWidth, nScaledSourceHeight);
- aSourceLayerHolder.set(CGLayerCreateWithContext(xCopyContext, aSourceSize, nullptr));
- const CGContextRef xSourceContext = CGLayerGetContext(aSourceLayerHolder.get());
- CGPoint aSrcPoint = CGPointMake(-nScaledSourceX, -nScaledSourceY);
- if (pSrc->IsFlipped())
- {
- CGContextTranslateCTM(xSourceContext, 0, nScaledSourceHeight);
- CGContextScaleCTM(xSourceContext, 1, -1);
- aSrcPoint.y = nScaledSourceY + nScaledSourceHeight - mnHeight * fScale;
- }
- CGContextSetBlendMode(xSourceContext, kCGBlendModeCopy);
- CGContextDrawLayerAtPoint(xSourceContext, aSrcPoint, pSrc->maLayer.get());
-
- // Copy source area from additional layer to traget area
-
- const CGRect aTargetRect = CGRectMake(nScaledTargetX, nScaledTargetY, nScaledSourceWidth, nScaledSourceHeight);
- CGContextSetBlendMode(xCopyContext, kCGBlendModeCopy);
- CGContextDrawLayerInRect(xCopyContext, aTargetRect, aSourceLayerHolder.get());
-
- // Housekeeping on exit
-
- maContextHolder.restoreState();
- if (aSourceLayerHolder.get() != maLayer.get())
- CGLayerRelease(aSourceLayerHolder.get());
- RefreshRect(nDstX, nDstY, nSrcWidth, nSrcHeight);
-}
-
#ifndef IOS
void AquaSalGraphics::copyResolution( AquaSalGraphics& rGraphics )
@@ -1826,74 +1715,4 @@ bool XorEmulation::UpdateTarget()
return true;
}
-void AquaSalGraphics::SetVirDevGraphics(CGLayerHolder const &rLayer, CGContextRef xContext, int nBitmapDepth)
-{
- SAL_INFO("vcl.quartz", "SetVirDevGraphics() this=" << this << " layer=" << rLayer.get() << " context=" << xContext);
-
- // Set member variables
-
- InvalidateContext();
- mbWindow = false;
- mbPrinter = false;
- mbVirDev = true;
- maLayer = rLayer;
- mnBitmapDepth = nBitmapDepth;
-
-#ifdef IOS
-
- mbForeignContext = xContext != NULL;
-
-#endif
-
- // Get size and scale from layer if set else from bitmap and AquaSalGraphics::GetWindowScaling(), which is used to determine
- // scaling for direct graphics output too
-
- CGSize aSize;
- float fScale;
- if (maLayer.isSet())
- {
- maContextHolder.set(CGLayerGetContext(maLayer.get()));
- aSize = CGLayerGetSize(maLayer.get());
- fScale = maLayer.getScale();
- }
- else
- {
- maContextHolder.set(xContext);
- if (!xContext)
- return;
- aSize.width = CGBitmapContextGetWidth(xContext);
- aSize.height = CGBitmapContextGetHeight(xContext);
- fScale = GetWindowScaling();
- }
- mnWidth = aSize.width / fScale;
- mnHeight = aSize.height / fScale;
-
- // Set color space for fill and stroke
-
- CGColorSpaceRef aColorSpace = GetSalData()->mxRGBSpace;
- CGContextSetFillColorSpace(maContextHolder.get(), aColorSpace);
- CGContextSetStrokeColorSpace(maContextHolder.get(), aColorSpace);
-
- // Apply scale matrix to virtual device graphics
-
- CGContextScaleCTM(maContextHolder.get(), fScale, fScale);
-
- // Apply XOR emulation if required
-
- if (mpXorEmulation)
- {
- mpXorEmulation->SetTarget(mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), maLayer.get());
- if (mpXorEmulation->IsEnabled())
- maContextHolder.set(mpXorEmulation->GetMaskContext());
- }
-
- // Housekeeping on exit
-
- maContextHolder.saveState();
- SetState();
-
- SAL_INFO("vcl.quartz", "SetVirDevGraphics() this=" << this <<
- " (" << mnWidth << "x" << mnHeight << ") fScale=" << fScale << " mnBitmapDepth=" << mnBitmapDepth);
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salgdiutils.cxx b/vcl/quartz/salgdiutils.cxx
deleted file mode 100644
index 01626d348999..000000000000
--- a/vcl/quartz/salgdiutils.cxx
+++ /dev/null
@@ -1,288 +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 .
- */
-
-#include <sal/config.h>
-
-#include <cstdint>
-
-#include <sal/log.hxx>
-
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/range/b2drectangle.hxx>
-#include <basegfx/range/b2irange.hxx>
-#include <basegfx/vector/b2ivector.hxx>
-#include <vcl/svapp.hxx>
-
-#include <quartz/salgdi.h>
-#include <quartz/utils.h>
-#include <osx/salframe.h>
-#include <osx/saldata.hxx>
-
-float AquaSalGraphics::GetWindowScaling()
-{
- float fScale = 1.0f;
-
-#ifdef MACOSX
-
- // Window scaling independent from main display may be forced by setting VCL_MACOS_FORCE_WINDOW_SCALING environment variable
- // whose setting is stored in mbWindowScaling. After implementation of full support of scaled displays window scaling will be
- // set to 2.0f for macOS as default. This will allow moving of windows between non retina and retina displays without blurry
- // text and graphics.
-
- // TODO: After implementation of full support of scaled displays code has to be modified to set a scaling of 2.0f as default.
-
- if (mbWindowScaling)
- {
- fScale = 2.0f;
- return fScale;
- }
-
-#endif
-
- AquaSalFrame *pSalFrame = mpFrame;
- if (!pSalFrame)
- pSalFrame = static_cast<AquaSalFrame *>(GetSalData()->mpInstance->anyFrame());
- if (pSalFrame)
- {
- NSWindow *pNSWindow = pSalFrame->getNSWindow();
- if (pNSWindow)
- fScale = [pNSWindow backingScaleFactor];
- }
- return fScale;
-}
-
-void AquaSalGraphics::SetWindowGraphics( AquaSalFrame* pFrame )
-{
- mpFrame = pFrame;
- mbWindow = true;
- mbPrinter = false;
- mbVirDev = false;
-}
-
-void AquaSalGraphics::SetPrinterGraphics( CGContextRef xContext, sal_Int32 nDPIX, sal_Int32 nDPIY )
-{
- mbWindow = false;
- mbPrinter = true;
- mbVirDev = false;
-
- maContextHolder.set(xContext);
- mnRealDPIX = nDPIX;
- mnRealDPIY = nDPIY;
-
- // a previously set clip path is now invalid
- if( mxClipPath )
- {
- CGPathRelease( mxClipPath );
- mxClipPath = nullptr;
- }
-
- if (maContextHolder.isSet())
- {
- CGContextSetFillColorSpace( maContextHolder.get(), GetSalData()->mxRGBSpace );
- CGContextSetStrokeColorSpace( maContextHolder.get(), GetSalData()->mxRGBSpace );
- CGContextSaveGState( maContextHolder.get() );
- SetState();
- }
-}
-
-void AquaSalGraphics::InvalidateContext()
-{
- UnsetState();
-
- CGContextRelease(maContextHolder.get());
- CGContextRelease(maBGContextHolder.get());
- CGContextRelease(maCSContextHolder.get());
-
- maContextHolder.set(nullptr);
- maCSContextHolder.set(nullptr);
- maBGContextHolder.set(nullptr);
-}
-
-void AquaSalGraphics::UnsetState()
-{
- if (maBGContextHolder.isSet())
- {
- CGContextRelease(maBGContextHolder.get());
- maBGContextHolder.set(nullptr);
- }
- if (maCSContextHolder.isSet())
- {
- CGContextRelease(maCSContextHolder.get());
- maBGContextHolder.set(nullptr);
- }
- if (maContextHolder.isSet())
- {
- maContextHolder.restoreState();
- maContextHolder.set(nullptr);
- }
- if( mxClipPath )
- {
- CGPathRelease( mxClipPath );
- mxClipPath = nullptr;
- }
-}
-
-/**
- * (re-)create the off-screen maLayer we render everything to if
- * necessary: eg. not initialized yet, or it has an incorrect size.
- */
-bool AquaSalGraphics::CheckContext()
-{
- if (mbWindow && mpFrame && (mpFrame->getNSWindow() || Application::IsBitmapRendering()))
- {
- const unsigned int nWidth = mpFrame->maGeometry.nWidth;
- const unsigned int nHeight = mpFrame->maGeometry.nHeight;
- const float fScale = GetWindowScaling();
- CGLayerRef rReleaseLayer = nullptr;
-
- // check if a new drawing context is needed (e.g. after a resize)
- if( (unsigned(mnWidth) != nWidth) || (unsigned(mnHeight) != nHeight) )
- {
- mnWidth = nWidth;
- mnHeight = nHeight;
- // prepare to release the corresponding resources
- if (maLayer.isSet())
- {
- rReleaseLayer = maLayer.get();
- }
- else if (maContextHolder.isSet())
- {
- CGContextRelease(maContextHolder.get());
- }
- CGContextRelease(maBGContextHolder.get());
- CGContextRelease(maCSContextHolder.get());
-
- maContextHolder.set(nullptr);
- maBGContextHolder.set(nullptr);
- maCSContextHolder.set(nullptr);
- maLayer.set(nullptr);
- }
-
- if (!maContextHolder.isSet())
- {
- const int nBitmapDepth = 32;
-
- float nScaledWidth = mnWidth * fScale;
- float nScaledHeight = mnHeight * fScale;
-
- const CGSize aLayerSize = { static_cast<CGFloat>(nScaledWidth), static_cast<CGFloat>(nScaledHeight) };
-
- const int nBytesPerRow = (nBitmapDepth * nScaledWidth) / 8;
- std::uint32_t nFlags = std::uint32_t(kCGImageAlphaNoneSkipFirst)
- | std::uint32_t(kCGBitmapByteOrder32Host);
- maBGContextHolder.set(CGBitmapContextCreate(
- nullptr, nScaledWidth, nScaledHeight, 8, nBytesPerRow, GetSalData()->mxRGBSpace, nFlags));
-
- maLayer.set(CGLayerCreateWithContext(maBGContextHolder.get(), aLayerSize, nullptr));
- maLayer.setScale(fScale);
-
- nFlags = std::uint32_t(kCGImageAlphaPremultipliedFirst)
- | std::uint32_t(kCGBitmapByteOrder32Host);
- maCSContextHolder.set(CGBitmapContextCreate(
- nullptr, nScaledWidth, nScaledHeight, 8, nBytesPerRow, GetSalData()->mxRGBSpace, nFlags));
-
- CGContextRef xDrawContext = CGLayerGetContext(maLayer.get());
- maContextHolder = xDrawContext;
-
- if (rReleaseLayer)
- {
- // copy original layer to resized layer
- if (maContextHolder.isSet())
- {
- CGContextDrawLayerAtPoint(maContextHolder.get(), CGPointZero, rReleaseLayer);
- }
- CGLayerRelease(rReleaseLayer);
- }
-
- if (maContextHolder.isSet())
- {
- CGContextTranslateCTM(maContextHolder.get(), 0, nScaledHeight);
- CGContextScaleCTM(maContextHolder.get(), 1.0, -1.0);
- CGContextSetFillColorSpace(maContextHolder.get(), GetSalData()->mxRGBSpace);
- CGContextSetStrokeColorSpace(maContextHolder.get(), GetSalData()->mxRGBSpace);
- // apply a scale matrix so everything is auto-magically scaled
- CGContextScaleCTM(maContextHolder.get(), fScale, fScale);
- maContextHolder.saveState();
- SetState();
-
- // re-enable XOR emulation for the new context
- if (mpXorEmulation)
- mpXorEmulation->SetTarget(mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), maLayer.get());
- }
- }
- }
-
- SAL_WARN_IF(!maContextHolder.isSet() && !mbPrinter, "vcl", "<<<WARNING>>> AquaSalGraphics::CheckContext() FAILED!!!!");
-
- return maContextHolder.isSet();
-}
-
-/**
- * Blit the contents of our internal maLayer state to the
- * associated window, if any; cf. drawRect event handling
- * on the frame.
- */
-void AquaSalGraphics::UpdateWindow( NSRect& )
-{
- if( !mpFrame )
- {
- return;
- }
-
- NSGraphicsContext* pContext = [NSGraphicsContext currentContext];
- if (maLayer.isSet() && pContext != nullptr)
- {
- CGContextHolder rCGContextHolder([pContext CGContext]);
-
- rCGContextHolder.saveState();
-
- CGMutablePathRef rClip = mpFrame->getClipPath();
- if (rClip)
- {
- CGContextBeginPath(rCGContextHolder.get());
- CGContextAddPath(rCGContextHolder.get(), rClip );
- CGContextClip(rCGContextHolder.get());
- }
-
- ApplyXorContext();
-
- const CGSize aSize = maLayer.getSizePoints();
- const CGRect aRect = CGRectMake(0, 0, aSize.width, aSize.height);
- const CGRect aRectPoints = { CGPointZero, maLayer.getSizePixels() };
- CGContextSetBlendMode(maCSContextHolder.get(), kCGBlendModeCopy);
- CGContextDrawLayerInRect(maCSContextHolder.get(), aRectPoints, maLayer.get());
-
- CGImageRef img = CGBitmapContextCreateImage(maCSContextHolder.get());
- CGImageRef displayColorSpaceImage = CGImageCreateCopyWithColorSpace(img, [[mpFrame->getNSWindow() colorSpace] CGColorSpace]);
- CGContextSetBlendMode(rCGContextHolder.get(), kCGBlendModeCopy);
- CGContextDrawImage(rCGContextHolder.get(), aRect, displayColorSpaceImage);
-
- CGImageRelease(img);
- CGImageRelease(displayColorSpaceImage);
-
- rCGContextHolder.restoreState();
- }
- else
- {
- SAL_WARN_IF( !mpFrame->mbInitShow, "vcl", "UpdateWindow called on uneligible graphics" );
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salvd.cxx b/vcl/quartz/salvd.cxx
index 5d7facd3ef38..9f6bfdd930aa 100644
--- a/vcl/quartz/salvd.cxx
+++ b/vcl/quartz/salvd.cxx
@@ -161,34 +161,6 @@ AquaSalVirtualDevice::~AquaSalVirtualDevice()
Destroy();
}
-void AquaSalVirtualDevice::Destroy()
-{
- SAL_INFO( "vcl.virdev", "AquaSalVirtualDevice::Destroy() this=" << this << " mbForeignContext=" << mbForeignContext );
-
- if( mbForeignContext )
- {
- // Do not delete mxContext that we have received from outside VCL
- maLayer.set(nullptr);
- return;
- }
-
- if (maLayer.isSet())
- {
- if( mpGraphics )
- {
- mpGraphics->SetVirDevGraphics(nullptr, nullptr);
- }
- CGLayerRelease(maLayer.get());
- maLayer.set(nullptr);
- }
-
- if (maBitmapContext.isSet())
- {
- CGContextRelease(maBitmapContext.get());
- maBitmapContext.set(nullptr);
- }
-}
-
SalGraphics* AquaSalVirtualDevice::AcquireGraphics()
{
if( mbGraphicsUsed || !mpGraphics )
@@ -204,80 +176,4 @@ void AquaSalVirtualDevice::ReleaseGraphics( SalGraphics* )
mbGraphicsUsed = false;
}
-bool AquaSalVirtualDevice::SetSize(tools::Long nDX, tools::Long nDY)
-{
- SAL_INFO("vcl.virdev", "AquaSalVirtualDevice::SetSize() this=" << this <<
- " (" << nDX << "x" << nDY << ") mbForeignContext=" << (mbForeignContext ? "YES" : "NO"));
-
- // Do not delete/resize graphics context if it has been received from outside VCL
-
- if (mbForeignContext)
- return true;
-
- // Do not delete/resize graphics context if no change of geometry has been requested
-
- float fScale;
- if (maLayer.isSet())
- {
- fScale = maLayer.getScale();
- const CGSize aSize = CGLayerGetSize(maLayer.get());
- if ((nDX == aSize.width / fScale) && (nDY == aSize.height / fScale))
- return true;
- }
-
- // Destroy graphics context if change of geometry has been requested
-
- Destroy();
-
- // Prepare new graphics context for initialization, use scaling independent of prior graphics context calculated by
- // AquaSalGraphics::GetWindowScaling(), which is used to determine scaling for direct graphics output too
-
- mnWidth = nDX;
- mnHeight = nDY;
- fScale = mpGraphics->GetWindowScaling();
- CGColorSpaceRef aColorSpace;
- uint32_t nFlags;
- if (mnBitmapDepth && (mnBitmapDepth < 16))
- {
- mnBitmapDepth = 8;
- aColorSpace = GetSalData()->mxGraySpace;
- nFlags = kCGImageAlphaNone;
- }
- else
- {
- mnBitmapDepth = 32;
- aColorSpace = GetSalData()->mxRGBSpace;
-
-#ifdef MACOSX
-
- nFlags = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
-
-#else
-
- nFlags = kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little;
-
-#endif
-
- }
-
- // Allocate buffer for virtual device graphics as bitmap context to store graphics with highest required (scaled) resolution
-
- size_t nScaledWidth = mnWidth * fScale;
- size_t nScaledHeight = mnHeight * fScale;
- size_t nBytesPerRow = mnBitmapDepth * nScaledWidth / 8;
- maBitmapContext.set(CGBitmapContextCreate(nullptr, nScaledWidth, nScaledHeight, 8, nBytesPerRow, aColorSpace, nFlags));
-
- SAL_INFO("vcl.virdev", "AquaSalVirtualDevice::SetSize() this=" << this <<
- " fScale=" << fScale << " mnBitmapDepth=" << mnBitmapDepth);
-
- CGSize aLayerSize = { static_cast<CGFloat>(nScaledWidth), static_cast<CGFloat>(nScaledHeight) };
- maLayer.set(CGLayerCreateWithContext(maBitmapContext.get(), aLayerSize, nullptr));
- maLayer.setScale(fScale);
- mpGraphics->SetVirDevGraphics(maLayer, CGLayerGetContext(maLayer.get()), mnBitmapDepth);
-
- SAL_WARN_IF(!maBitmapContext.isSet(), "vcl.quartz", "No context");
-
- return maLayer.isSet();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */