Kaydet (Commit) b0fb5acd authored tarafından Jan Holesovsky's avatar Jan Holesovsky

lokdialog: Implement hi-dpi support for the routed dialogs.

Change-Id: I770c605a049b7ac9c26c2773414eef8b6fc093a2
Reviewed-on: https://gerrit.libreoffice.org/63032
Tested-by: Jenkins
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 498dceb4
...@@ -2431,12 +2431,13 @@ void DesktopLOKTest::testABI() ...@@ -2431,12 +2431,13 @@ void DesktopLOKTest::testABI()
CPPUNIT_ASSERT_EQUAL(documentClassOffset(39), offsetof(struct _LibreOfficeKitDocumentClass, setViewLanguage)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(39), offsetof(struct _LibreOfficeKitDocumentClass, setViewLanguage));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), offsetof(struct _LibreOfficeKitDocumentClass, postWindowExtTextInputEvent)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), offsetof(struct _LibreOfficeKitDocumentClass, postWindowExtTextInputEvent));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(41), offsetof(struct _LibreOfficeKitDocumentClass, getPartInfo)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(41), offsetof(struct _LibreOfficeKitDocumentClass, getPartInfo));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(42), offsetof(struct _LibreOfficeKitDocumentClass, insertCertificate)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(42), offsetof(struct _LibreOfficeKitDocumentClass, paintWindowDPI));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(43), offsetof(struct _LibreOfficeKitDocumentClass, addCertificate)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(43), offsetof(struct _LibreOfficeKitDocumentClass, insertCertificate));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct _LibreOfficeKitDocumentClass, getSignatureState)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct _LibreOfficeKitDocumentClass, addCertificate));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct _LibreOfficeKitDocumentClass, getSignatureState));
// Extending is fine, update this, and add new assert for the offsetof the // Extending is fine, update this, and add new assert for the offsetof the
// new method // new method
CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), sizeof(struct _LibreOfficeKitDocumentClass)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), sizeof(struct _LibreOfficeKitDocumentClass));
} }
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
......
...@@ -686,6 +686,11 @@ static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId ...@@ -686,6 +686,11 @@ static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
const int nX, const int nY, const int nX, const int nY,
const int nWidth, const int nHeight); const int nWidth, const int nHeight);
static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight,
const double fDPIScale);
static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction); static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction);
static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart); static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart);
...@@ -756,6 +761,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone ...@@ -756,6 +761,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getPartHash = doc_getPartHash; m_pDocumentClass->getPartHash = doc_getPartHash;
m_pDocumentClass->paintWindow = doc_paintWindow; m_pDocumentClass->paintWindow = doc_paintWindow;
m_pDocumentClass->paintWindowDPI = doc_paintWindowDPI;
m_pDocumentClass->postWindow = doc_postWindow; m_pDocumentClass->postWindow = doc_postWindow;
m_pDocumentClass->setViewLanguage = doc_setViewLanguage; m_pDocumentClass->setViewLanguage = doc_setViewLanguage;
...@@ -3587,10 +3593,19 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh ...@@ -3587,10 +3593,19 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
return nullptr; return nullptr;
} }
static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
unsigned char* pBuffer, unsigned char* pBuffer,
const int nX, const int nY, const int nX, const int nY,
const int nWidth, const int nHeight) const int nWidth, const int nHeight)
{
doc_paintWindowDPI(pThis, nLOKWindowId, pBuffer, nX, nY, nWidth, nHeight, 1.0);
}
static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight,
const double fDPIScale)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
if (gImpl) if (gImpl)
...@@ -3603,6 +3618,11 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind ...@@ -3603,6 +3618,11 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind
return; return;
} }
// Setup cairo to draw with the changed DPI scale (and return back to 1.0
// when the painting finishes)
comphelper::ScopeGuard dpiScaleGuard([]() { comphelper::LibreOfficeKit::setDPIScale(1.0); });
comphelper::LibreOfficeKit::setDPIScale(fDPIScale);
#if defined(IOS) #if defined(IOS)
CGContextRef cgc = CGBitmapContextCreate(pBuffer, nWidth, nHeight, 8, nWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little); CGContextRef cgc = CGBitmapContextCreate(pBuffer, nWidth, nHeight, 8, nWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little);
...@@ -3636,7 +3656,7 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind ...@@ -3636,7 +3656,7 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer); pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer);
MapMode aMapMode(pDevice->GetMapMode()); MapMode aMapMode(pDevice->GetMapMode());
aMapMode.SetOrigin(Point(-nX, -nY)); aMapMode.SetOrigin(Point(-(nX / fDPIScale), -(nY / fDPIScale)));
pDevice->SetMapMode(aMapMode); pDevice->SetMapMode(aMapMode);
comphelper::LibreOfficeKit::setDialogPainting(true); comphelper::LibreOfficeKit::setDialogPainting(true);
......
...@@ -309,6 +309,15 @@ struct _LibreOfficeKitDocumentClass ...@@ -309,6 +309,15 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::getPartInfo(). /// @see lok::Document::getPartInfo().
char* (*getPartInfo) (LibreOfficeKitDocument* pThis, int nPart); char* (*getPartInfo) (LibreOfficeKitDocument* pThis, int nPart);
/// Paints window with given id to the buffer with the give DPI scale
/// (every pixel is dpiscale-times larger).
/// @see lok::Document::paintWindow().
void (*paintWindowDPI) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
unsigned char* pBuffer,
const int x, const int y,
const int width, const int height,
const double dpiscale);
#ifdef IOS #ifdef IOS
/// @see lok::Document::paintTileToCGContext(). /// @see lok::Document::paintTileToCGContext().
void (*paintTileToCGContext) (LibreOfficeKitDocument* pThis, void (*paintTileToCGContext) (LibreOfficeKitDocument* pThis,
......
...@@ -164,16 +164,23 @@ public: ...@@ -164,16 +164,23 @@ public:
* @param y y-coordinate from where the dialog should start painting * @param y y-coordinate from where the dialog should start painting
* @param width The width of the dialog image to be painted * @param width The width of the dialog image to be painted
* @param height The height of the dialog image to be painted * @param height The height of the dialog image to be painted
* @param dpiscale The dpi scale value used by the client. Please note
* that the x, y, width, height are supposed to be the
* values with dpiscale applied (ie. dialog covering
* 100x100 "normal" pixels with dpiscale '2' will have
* 200x200 width x height), so that it is easy to compute
* the buffer sizes etc.
*/ */
void paintWindow(unsigned nWindowId, void paintWindow(unsigned nWindowId,
unsigned char* pBuffer, unsigned char* pBuffer,
const int x, const int x,
const int y, const int y,
const int width, const int width,
const int height) const int height,
const double dpiscale = 1.0)
{ {
return mpDoc->pClass->paintWindow(mpDoc, nWindowId, pBuffer, return mpDoc->pClass->paintWindowDPI(mpDoc, nWindowId, pBuffer,
x, y, width, height); x, y, width, height, dpiscale);
} }
/** /**
......
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