Kaydet (Commit) ada20402 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

OSX implement bitmap-only rendering mode

Eventually OSX should also depend on SVP and SVP should just
export the platform agnostic code, so we can get rid of all
the IOS and ANDROID ifdefs.

Since the SVP mode now also uses a default DPI value of 96,
we can get rid of those "broken" adjustments to the tests in
commit a4ab0c08 ("Row height tolerance level increase for
unittest") and commit 1e55a47e ("tdf#62268: allow row
height recalculation on document load").

The DPI handling on OSX seems really broken. Additionally DPI
should probably a float value, as rounding results in various
of-by-one errors in tests.

Change-Id: I47881683a9c3d3e1b4f8e7aba1d03842da4d6652
Reviewed-on: https://gerrit.libreoffice.org/64736
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst d0e30c11
......@@ -759,8 +759,7 @@ void ScBootstrapFixture::miscRowHeightsTest( TestParam const * aTestValues, unsi
bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & CRFlags::ManualSize);
CPPUNIT_ASSERT_EQUAL(aTestValues[ index ].pData[ i ].bOptimal, bOpt);
}
// Due to some minor differences on Mac this comparison is made bit fuzzy
CPPUNIT_ASSERT_LESSEQUAL( 15, abs( nHeight - nExpectedHeight ) );
CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight);
}
}
xShell->DoClose();
......
......@@ -2766,7 +2766,7 @@ void ScFiltersTest::testMiscRowHeights()
static const TestParam::RowData MultiLineOptData[] =
{
// Row 0 is 12.63 mm, but optimal flag is set
// Row 0 is 12.63 mm and optimal flag is set => 12.36 mm
{ 0, 0, 0, 1236, CHECK_OPTIMAL, true },
// Row 1 is 11.99 mm and optimal flag is NOT set
{ 1, 1, 0, 1199, CHECK_OPTIMAL, false },
......@@ -2799,9 +2799,8 @@ void ScFiltersTest::testOptimalHeightReset()
ScDocument& rDoc = xDocSh->GetDocument();
// open document in read/write mode ( otherwise optimal height stuff won't
// be triggered ) *and* you can't delete cell contents.
int nHeight = rDoc.GetRowHeight(nRow, nTab, false);
// Due to some minor differences on Mac this comparison is made bit fuzzy
CPPUNIT_ASSERT_LESSEQUAL( 8, abs( nHeight - 701 ) );
int nHeight = sc::TwipsToHMM ( rDoc.GetRowHeight(nRow, nTab, false) );
CPPUNIT_ASSERT_EQUAL(1236, nHeight);
ScDocFunc &rFunc = xDocSh->GetDocFunc();
......
......@@ -193,6 +193,9 @@ public:
// called by VCL_NSApplication to indicate screen settings have changed
void screenParametersChanged();
protected:
SalEvent PreparePosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags);
private: // methods
/** do things on initial show (like centering on parent or on screen)
*/
......
......@@ -200,6 +200,9 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH
}
SAL_WNODEPRECATED_DECLARATIONS_POP
if (Application::IsBitmapRendering())
return;
// #i91990# support GUI-less (daemon) execution
@try
{
......@@ -208,7 +211,7 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
}
@catch ( id exception )
{
return;
std::abort();
}
if( mnStyle & SalFrameStyleFlags::TOOLTIP )
......@@ -538,7 +541,7 @@ void AquaSalFrame::SetMaxClientSize( long nWidth, long nHeight )
void AquaSalFrame::GetClientSize( long& rWidth, long& rHeight )
{
if( mbShown || mbInitShow )
if (mbShown || mbInitShow || Application::IsBitmapRendering())
{
rWidth = maGeometry.nWidth;
rHeight = maGeometry.nHeight;
......@@ -550,13 +553,69 @@ void AquaSalFrame::GetClientSize( long& rWidth, long& rHeight )
}
}
SalEvent AquaSalFrame::PreparePosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)
{
SalEvent nEvent = SalEvent::NONE;
assert(mpNSWindow || Application::IsBitmapRendering());
if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y))
{
mbPositioned = true;
nEvent = SalEvent::Move;
}
if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
{
mbSized = true;
nEvent = (nEvent == SalEvent::Move) ? SalEvent::MoveResize : SalEvent::Resize;
}
if (Application::IsBitmapRendering())
{
if (nFlags & SAL_FRAME_POSSIZE_X)
maGeometry.nX = nX;
if (nFlags & SAL_FRAME_POSSIZE_Y)
maGeometry.nY = nY;
if (nFlags & SAL_FRAME_POSSIZE_WIDTH)
{
maGeometry.nWidth = nWidth;
if (mnMaxWidth > 0 && maGeometry.nWidth > static_cast<unsigned int>(mnMaxWidth))
maGeometry.nWidth = mnMaxWidth;
if (mnMinWidth > 0 && maGeometry.nWidth < static_cast<unsigned int>(mnMinWidth))
maGeometry.nWidth = mnMinWidth;
}
if (nFlags & SAL_FRAME_POSSIZE_HEIGHT)
{
maGeometry.nHeight = nHeight;
if (mnMaxHeight > 0 && maGeometry.nHeight > static_cast<unsigned int>(mnMaxHeight))
maGeometry.nHeight = mnMaxHeight;
if (mnMinHeight > 0 && maGeometry.nHeight < static_cast<unsigned int>(mnMinHeight))
maGeometry.nHeight = mnMinHeight;
}
if (nEvent != SalEvent::NONE)
CallCallback(nEvent, nullptr);
}
return nEvent;
}
void AquaSalFrame::SetWindowState( const SalFrameState* pState )
{
if (!mpNSWindow)
if (!mpNSWindow && !Application::IsBitmapRendering())
return;
OSX_SALDATA_RUNINMAIN( SetWindowState( pState ) )
sal_uInt16 nFlags = 0;
nFlags |= ((pState->mnMask & WindowStateMask::X) ? SAL_FRAME_POSSIZE_X : 0);
nFlags |= ((pState->mnMask & WindowStateMask::Y) ? SAL_FRAME_POSSIZE_Y : 0);
nFlags |= ((pState->mnMask & WindowStateMask::Width) ? SAL_FRAME_POSSIZE_WIDTH : 0);
nFlags |= ((pState->mnMask & WindowStateMask::Height) ? SAL_FRAME_POSSIZE_HEIGHT : 0);
SalEvent nEvent = PreparePosSize(pState->mnX, pState->mnY, pState->mnWidth, pState->mnHeight, nFlags);
if (Application::IsBitmapRendering())
return;
// set normal state
NSRect aStateRect = [mpNSWindow frame];
aStateRect = [NSWindow contentRectForFrameRect: aStateRect styleMask: mnStyleMask];
......@@ -596,17 +655,6 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState )
// get new geometry
UpdateFrameGeometry();
SalEvent nEvent = SalEvent::NONE;
if( pState->mnMask & (WindowStateMask::X | WindowStateMask::Y) )
{
mbPositioned = true;
nEvent = SalEvent::Move;
}
if( pState->mnMask & (WindowStateMask::Width | WindowStateMask::Height) )
{
mbSized = true;
nEvent = (nEvent == SalEvent::Move) ? SalEvent::MoveResize : SalEvent::Resize;
}
// send event that we were moved/sized
if( nEvent != SalEvent::NONE )
CallCallback( nEvent, nullptr );
......@@ -623,8 +671,22 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState )
bool AquaSalFrame::GetWindowState( SalFrameState* pState )
{
if ( !mpNSWindow )
if (!mpNSWindow)
{
if (Application::IsBitmapRendering())
{
pState->mnMask = WindowStateMask::X | WindowStateMask::Y
| WindowStateMask::Width | WindowStateMask::Height
| WindowStateMask::State;
pState->mnX = maGeometry.nX;
pState->mnY = maGeometry.nY;
pState->mnWidth = maGeometry.nWidth;
pState->mnHeight = maGeometry.nHeight;
pState->mnState = WindowStateState::Normal;
return TRUE;
}
return FALSE;
}
OSX_SALDATA_RUNINMAIN_UNION( GetWindowState( pState ), boolean )
......@@ -691,8 +753,12 @@ void AquaSalFrame::SetApplicationID( const OUString &/*rApplicationID*/ )
void AquaSalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay )
{
if ( !mpNSWindow )
if (!mpNSWindow)
{
if (Application::IsBitmapRendering() && bFullScreen)
SetPosSize(0, 0, 1024, 768, SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT);
return;
}
SAL_INFO("vcl.osx", OSL_THIS_FUNC << ": mbFullScreen=" << mbFullScreen << ", bFullScreen=" << bFullScreen);
......@@ -1152,7 +1218,8 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH
// "'lockFocus' is deprecated: first deprecated in macOS 10.14 - To draw, subclass NSView
// and implement -drawRect:; AppKit's automatic deferred display mechanism will call
// -drawRect: as necessary to display the view."
[mpNSView lockFocus];
if (![mpNSView lockFocusIfCanDraw])
return;
SAL_WNODEPRECATED_DECLARATIONS_POP
StyleSettings aStyleSettings = rSettings.GetStyleSettings();
......@@ -1254,28 +1321,18 @@ void AquaSalFrame::Beep()
void AquaSalFrame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)
{
if ( !mpNSWindow )
if (!mpNSWindow && !Application::IsBitmapRendering())
return;
OSX_SALDATA_RUNINMAIN( SetPosSize( nX, nY, nWidth, nHeight, nFlags ) )
SalEvent nEvent = SalEvent::NONE;
SalEvent nEvent = PreparePosSize(nX, nY, nWidth, nHeight, nFlags);
if (Application::IsBitmapRendering())
return;
if( [mpNSWindow isMiniaturized] )
[mpNSWindow deminiaturize: NSApp]; // expand the window
if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y))
{
mbPositioned = true;
nEvent = SalEvent::Move;
}
if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
{
mbSized = true;
nEvent = (nEvent == SalEvent::Move) ? SalEvent::MoveResize : SalEvent::Resize;
}
NSRect aFrameRect = [mpNSWindow frame];
NSRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask];
......@@ -1343,8 +1400,12 @@ void AquaSalFrame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_u
void AquaSalFrame::GetWorkArea( tools::Rectangle& rRect )
{
if ( !mpNSWindow )
if (!mpNSWindow)
{
if (Application::IsBitmapRendering())
rRect = tools::Rectangle(Point(0, 0), Size(1024, 768));
return;
}
OSX_SALDATA_RUNINMAIN( GetWorkArea( rRect ) )
......@@ -1530,7 +1591,8 @@ void AquaSalFrame::SetParent( SalFrame* pNewParent )
{
bool bShown = mbShown;
// remove from child list
Show( FALSE );
if (bShown)
Show(FALSE);
mpParent = static_cast<AquaSalFrame*>(pNewParent);
// insert to correct parent and paint
Show( bShown );
......
......@@ -173,7 +173,10 @@ static AquaSalFrame* getMouseContainerFrame()
NSRect aRect = { { static_cast<CGFloat>(pFrame->maGeometry.nX), static_cast<CGFloat>(pFrame->maGeometry.nY) },
{ static_cast<CGFloat>(pFrame->maGeometry.nWidth), static_cast<CGFloat>(pFrame->maGeometry.nHeight) } };
pFrame->VCLToCocoa( aRect );
NSWindow* pNSWindow = [super initWithContentRect: aRect styleMask: mpFrame->getStyleMask() backing: NSBackingStoreBuffered defer: NO ];
NSWindow* pNSWindow = [super initWithContentRect: aRect
styleMask: mpFrame->getStyleMask()
backing: NSBackingStoreBuffered
defer: Application::IsHeadlessModeEnabled()];
// Disallow full-screen mode on macOS >= 10.11 where it is enabled by default. We don't want it
// for now as it will just be confused with LibreOffice's home-grown full-screen concept, with
......
......@@ -40,6 +40,14 @@ unsigned int AquaSalSystem::GetDisplayScreenCount()
tools::Rectangle AquaSalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
{
if (Application::IsBitmapRendering())
{
tools::Rectangle aRect;
if (nScreen == 0)
aRect = tools::Rectangle(Point(0,0), Size(1024, 768));
return aRect;
}
NSArray* pScreens = [NSScreen screens];
tools::Rectangle aRet;
NSScreen* pScreen = nil;
......
......@@ -1432,8 +1432,15 @@ void AquaSalGraphics::ImplDrawPixel( long nX, long nY, const RGBAColor& rColor )
#ifndef IOS
void AquaSalGraphics::initResolution( NSWindow* )
void AquaSalGraphics::initResolution(NSWindow* nsWindow)
{
if (!nsWindow)
{
if (Application::IsBitmapRendering())
mnRealDPIX = mnRealDPIY = 96;
return;
}
// #i100617# read DPI only once; there is some kind of weird caching going on
// if the main screen changes
// FIXME: this is really unfortunate and needs to be investigated
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment