|
|
69cc7b |
From 0533dd425a46fb8344c12eead0b7ac21fe7db047 Mon Sep 17 00:00:00 2001
|
|
|
69cc7b |
From: rpmbuild <rpmbuild@fedoraproject.org>
|
|
|
69cc7b |
Date: Fri, 18 Aug 2017 12:12:40 +0100
|
|
|
69cc7b |
Subject: [PATCH] bubble the original gtk surface type through rendering
|
|
|
69cc7b |
|
|
|
69cc7b |
this makes presenting from a hidpi internal monitor to non-hidpi external
|
|
|
69cc7b |
monitor use the correct sizes
|
|
|
69cc7b |
|
|
|
69cc7b |
and this may make scrolling a tad faster in general
|
|
|
69cc7b |
---
|
|
|
69cc7b |
vcl/headless/svpframe.cxx | 4 +-
|
|
|
69cc7b |
vcl/headless/svpgdi.cxx | 135 ++++++++++++++++++++++++++----------------
|
|
|
69cc7b |
vcl/headless/svpvd.cxx | 21 +++----
|
|
|
69cc7b |
vcl/inc/headless/svpgdi.hxx | 5 +-
|
|
|
69cc7b |
vcl/inc/headless/svpvd.hxx | 1 +
|
|
|
69cc7b |
vcl/inc/unx/gtk/gtkframe.hxx | 2 +
|
|
|
69cc7b |
vcl/unx/gtk3/gtk3gtkframe.cxx | 50 +++++++---------
|
|
|
69cc7b |
7 files changed, 128 insertions(+), 90 deletions(-)
|
|
|
69cc7b |
|
|
|
69cc7b |
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
|
|
|
69cc7b |
index 0ce76cf..962cea0 100644
|
|
|
69cc7b |
--- a/vcl/headless/svpframe.cxx
|
|
|
69cc7b |
+++ b/vcl/headless/svpframe.cxx
|
|
|
69cc7b |
@@ -150,7 +150,7 @@ SalGraphics* SvpSalFrame::AcquireGraphics()
|
|
|
69cc7b |
{
|
|
|
69cc7b |
SvpSalGraphics* pGraphics = new SvpSalGraphics();
|
|
|
69cc7b |
#ifndef IOS
|
|
|
69cc7b |
- pGraphics->setSurface( m_pSurface );
|
|
|
69cc7b |
+ pGraphics->setSurface(m_pSurface, B2IVector(maGeometry.nWidth, maGeometry.nHeight));
|
|
|
69cc7b |
#endif
|
|
|
69cc7b |
m_aGraphics.push_back( pGraphics );
|
|
|
69cc7b |
return pGraphics;
|
|
|
69cc7b |
@@ -281,7 +281,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
|
|
|
69cc7b |
for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
|
|
|
69cc7b |
it != m_aGraphics.end(); ++it )
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- (*it)->setSurface(m_pSurface);
|
|
|
69cc7b |
+ (*it)->setSurface(m_pSurface, aFrameSize);
|
|
|
69cc7b |
}
|
|
|
69cc7b |
}
|
|
|
69cc7b |
if( m_bVisible )
|
|
|
69cc7b |
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
|
|
|
69cc7b |
index bcc1df9..242cc13 100644
|
|
|
69cc7b |
--- a/vcl/headless/svpgdi.cxx
|
|
|
69cc7b |
+++ b/vcl/headless/svpgdi.cxx
|
|
|
69cc7b |
@@ -133,6 +133,22 @@ namespace
|
|
|
69cc7b |
{
|
|
|
69cc7b |
return source;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
+ void mark_dirty()
|
|
|
69cc7b |
+ {
|
|
|
69cc7b |
+ cairo_surface_mark_dirty(source);
|
|
|
69cc7b |
+ }
|
|
|
69cc7b |
+ unsigned char* getBits(sal_Int32 &rStride)
|
|
|
69cc7b |
+ {
|
|
|
69cc7b |
+ cairo_surface_flush(source);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ unsigned char *mask_data = cairo_image_surface_get_data(source);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ cairo_format_t nFormat = cairo_image_surface_get_format(source);
|
|
|
69cc7b |
+ assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here");
|
|
|
69cc7b |
+ rStride = cairo_format_stride_for_width(nFormat, cairo_image_surface_get_width(source));
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ return mask_data;
|
|
|
69cc7b |
+ }
|
|
|
69cc7b |
private:
|
|
|
69cc7b |
SvpSalBitmap aTmpBmp;
|
|
|
69cc7b |
cairo_surface_t* source;
|
|
|
69cc7b |
@@ -386,9 +402,10 @@ SvpSalGraphics::~SvpSalGraphics()
|
|
|
69cc7b |
{
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
-void SvpSalGraphics::setSurface(cairo_surface_t* pSurface)
|
|
|
69cc7b |
+void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
m_pSurface = pSurface;
|
|
|
69cc7b |
+ m_aFrameSize = rSize;
|
|
|
69cc7b |
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
|
|
69cc7b |
cairo_surface_get_device_scale(pSurface, &m_fScale, nullptr);
|
|
|
69cc7b |
#endif
|
|
|
69cc7b |
@@ -402,14 +419,14 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
|
|
|
69cc7b |
|
|
|
69cc7b |
sal_uInt16 SvpSalGraphics::GetBitCount() const
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- if (CAIRO_FORMAT_A1 == cairo_image_surface_get_format(m_pSurface))
|
|
|
69cc7b |
+ if (cairo_surface_get_content(m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA)
|
|
|
69cc7b |
return 1;
|
|
|
69cc7b |
return 32;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
long SvpSalGraphics::GetGraphicsWidth() const
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- return m_pSurface ? cairo_image_surface_get_width(m_pSurface) / m_fScale : 0;
|
|
|
69cc7b |
+ return m_pSurface ? m_aFrameSize.getX() : 0;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
void SvpSalGraphics::ResetClipRegion()
|
|
|
69cc7b |
@@ -885,7 +902,7 @@ bool SvpSalGraphics::drawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPoly, d
|
|
|
69cc7b |
|
|
|
69cc7b |
void SvpSalGraphics::applyColor(cairo_t *cr, SalColor aColor)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- if (CAIRO_FORMAT_ARGB32 == cairo_image_surface_get_format(m_pSurface))
|
|
|
69cc7b |
+ if (cairo_surface_get_content(m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
cairo_set_source_rgba(cr, SALCOLOR_RED(aColor)/255.0,
|
|
|
69cc7b |
SALCOLOR_GREEN(aColor)/255.0,
|
|
|
69cc7b |
@@ -982,17 +999,10 @@ void SvpSalGraphics::copyBits( const SalTwoRect& rTR,
|
|
|
69cc7b |
if (pSrc == this)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
//self copy is a problem, so dup source in that case
|
|
|
69cc7b |
-#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 12, 0)
|
|
|
69cc7b |
pCopy = cairo_surface_create_similar(source,
|
|
|
69cc7b |
cairo_surface_get_content(m_pSurface),
|
|
|
69cc7b |
aTR.mnSrcWidth * m_fScale,
|
|
|
69cc7b |
aTR.mnSrcHeight * m_fScale);
|
|
|
69cc7b |
-#else
|
|
|
69cc7b |
- pCopy = cairo_surface_create_similar_image(source,
|
|
|
69cc7b |
- cairo_image_surface_get_format(m_pSurface),
|
|
|
69cc7b |
- aTR.mnSrcWidth * m_fScale,
|
|
|
69cc7b |
- aTR.mnSrcHeight * m_fScale);
|
|
|
69cc7b |
-#endif
|
|
|
69cc7b |
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
|
|
69cc7b |
cairo_surface_set_device_scale(pCopy, m_fScale, m_fScale);
|
|
|
69cc7b |
#endif
|
|
|
69cc7b |
@@ -1049,16 +1059,8 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR,
|
|
|
69cc7b |
/** creates an image from the given rectangle, replacing all black pixels
|
|
|
69cc7b |
* with nMaskColor and make all other full transparent */
|
|
|
69cc7b |
SourceHelper aSurface(rSalBitmap);
|
|
|
69cc7b |
- cairo_surface_t* mask = aSurface.getSurface();
|
|
|
69cc7b |
-
|
|
|
69cc7b |
- cairo_surface_flush(mask);
|
|
|
69cc7b |
-
|
|
|
69cc7b |
- unsigned char *mask_data = cairo_image_surface_get_data(mask);
|
|
|
69cc7b |
-
|
|
|
69cc7b |
- cairo_format_t nFormat = cairo_image_surface_get_format(mask);
|
|
|
69cc7b |
- assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here");
|
|
|
69cc7b |
- sal_Int32 nStride = cairo_format_stride_for_width(nFormat,
|
|
|
69cc7b |
- cairo_image_surface_get_width(mask));
|
|
|
69cc7b |
+ sal_Int32 nStride;
|
|
|
69cc7b |
+ unsigned char *mask_data = aSurface.getBits(nStride);
|
|
|
69cc7b |
for (sal_Int32 y = rTR.mnSrcY ; y < rTR.mnSrcY + rTR.mnSrcHeight; ++y)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
unsigned char *row = mask_data + (nStride*y);
|
|
|
69cc7b |
@@ -1085,7 +1087,7 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR,
|
|
|
69cc7b |
data+=4;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
}
|
|
|
69cc7b |
- cairo_surface_mark_dirty(mask);
|
|
|
69cc7b |
+ aSurface.mark_dirty();
|
|
|
69cc7b |
|
|
|
69cc7b |
cairo_t* cr = getCairoContext(false);
|
|
|
69cc7b |
clipRegion(cr);
|
|
|
69cc7b |
@@ -1098,7 +1100,7 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR,
|
|
|
69cc7b |
|
|
|
69cc7b |
cairo_translate(cr, rTR.mnDestX, rTR.mnDestY);
|
|
|
69cc7b |
cairo_scale(cr, (double)(rTR.mnDestWidth)/rTR.mnSrcWidth, ((double)rTR.mnDestHeight)/rTR.mnSrcHeight);
|
|
|
69cc7b |
- cairo_set_source_surface(cr, mask, -rTR.mnSrcX, -rTR.mnSrcY);
|
|
|
69cc7b |
+ cairo_set_source_surface(cr, aSurface.getSurface(), -rTR.mnSrcX, -rTR.mnSrcY);
|
|
|
69cc7b |
cairo_paint(cr);
|
|
|
69cc7b |
|
|
|
69cc7b |
releaseCairoContext(cr, false, extents);
|
|
|
69cc7b |
@@ -1123,18 +1125,24 @@ SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeigh
|
|
|
69cc7b |
|
|
|
69cc7b |
SalColor SvpSalGraphics::getPixel( long nX, long nY )
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- cairo_surface_flush(m_pSurface);
|
|
|
69cc7b |
- cairo_format_t nFormat = cairo_image_surface_get_format(m_pSurface);
|
|
|
69cc7b |
- assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here");
|
|
|
69cc7b |
- sal_Int32 nStride = cairo_format_stride_for_width(nFormat,
|
|
|
69cc7b |
- cairo_image_surface_get_width(m_pSurface));
|
|
|
69cc7b |
- unsigned char *surface_data = cairo_image_surface_get_data(m_pSurface);
|
|
|
69cc7b |
- unsigned char *row = surface_data + (nStride*nY);
|
|
|
69cc7b |
- unsigned char *data = row + (nX * 4);
|
|
|
69cc7b |
+ cairo_surface_t *target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
|
|
|
69cc7b |
+ cairo_t* cr = cairo_create(target);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ cairo_rectangle(cr, 0, 0, 1, 1);
|
|
|
69cc7b |
+ cairo_set_source_surface(cr, m_pSurface, -nX, -nY);
|
|
|
69cc7b |
+ cairo_paint(cr);
|
|
|
69cc7b |
+ cairo_destroy(cr);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ cairo_surface_flush(target);
|
|
|
69cc7b |
+ unsigned char *data = cairo_image_surface_get_data(target);
|
|
|
69cc7b |
sal_uInt8 b = unpremultiply(data[SVP_CAIRO_BLUE], data[SVP_CAIRO_ALPHA]);
|
|
|
69cc7b |
sal_uInt8 g = unpremultiply(data[SVP_CAIRO_GREEN], data[SVP_CAIRO_ALPHA]);
|
|
|
69cc7b |
sal_uInt8 r = unpremultiply(data[SVP_CAIRO_RED], data[SVP_CAIRO_ALPHA]);
|
|
|
69cc7b |
- return MAKE_SALCOLOR(r, g, b);
|
|
|
69cc7b |
+ SalColor nRet = MAKE_SALCOLOR(r, g, b);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ cairo_surface_destroy(target);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ return nRet;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
namespace
|
|
|
69cc7b |
@@ -1268,17 +1276,15 @@ cairo_surface_t* SvpSalGraphics::createCairoSurface(const BitmapBuffer *pBuffer)
|
|
|
69cc7b |
return target;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
-static cairo_t* createTmpCompatibleCairoContext(cairo_surface_t* pSurface, double fScale)
|
|
|
69cc7b |
+cairo_t* SvpSalGraphics::createTmpCompatibleCairoContext() const
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- cairo_surface_t *target = cairo_image_surface_create(
|
|
|
69cc7b |
- cairo_image_surface_get_format(pSurface),
|
|
|
69cc7b |
- cairo_image_surface_get_width(pSurface),
|
|
|
69cc7b |
- cairo_image_surface_get_height(pSurface));
|
|
|
69cc7b |
+ cairo_surface_t *target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
|
|
|
69cc7b |
+ m_aFrameSize.getX() * m_fScale,
|
|
|
69cc7b |
+ m_aFrameSize.getY() * m_fScale);
|
|
|
69cc7b |
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
|
|
69cc7b |
- cairo_surface_set_device_scale(target, fScale, fScale);
|
|
|
69cc7b |
-#else
|
|
|
69cc7b |
- (void)fScale;
|
|
|
69cc7b |
+ cairo_surface_set_device_scale(target, m_fScale, m_fScale);
|
|
|
69cc7b |
#endif
|
|
|
69cc7b |
+
|
|
|
69cc7b |
return cairo_create(target);
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
@@ -1286,7 +1292,7 @@ cairo_t* SvpSalGraphics::getCairoContext(bool bXorModeAllowed) const
|
|
|
69cc7b |
{
|
|
|
69cc7b |
cairo_t* cr;
|
|
|
69cc7b |
if (m_ePaintMode == XOR && bXorModeAllowed)
|
|
|
69cc7b |
- cr = createTmpCompatibleCairoContext(m_pSurface, m_fScale);
|
|
|
69cc7b |
+ cr = createTmpCompatibleCairoContext();
|
|
|
69cc7b |
else
|
|
|
69cc7b |
cr = cairo_create(m_pSurface);
|
|
|
69cc7b |
cairo_set_line_width(cr, 1);
|
|
|
69cc7b |
@@ -1316,8 +1322,8 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons
|
|
|
69cc7b |
|
|
|
69cc7b |
sal_Int32 nExtentsLeft(rExtents.getMinX()), nExtentsTop(rExtents.getMinY());
|
|
|
69cc7b |
sal_Int32 nExtentsRight(rExtents.getMaxX()), nExtentsBottom(rExtents.getMaxY());
|
|
|
69cc7b |
- sal_Int32 nWidth = cairo_image_surface_get_width(m_pSurface);
|
|
|
69cc7b |
- sal_Int32 nHeight = cairo_image_surface_get_height(m_pSurface);
|
|
|
69cc7b |
+ sal_Int32 nWidth = m_aFrameSize.getX();
|
|
|
69cc7b |
+ sal_Int32 nHeight = m_aFrameSize.getY();
|
|
|
69cc7b |
nExtentsLeft = std::max<sal_Int32>(nExtentsLeft, 0);
|
|
|
69cc7b |
nExtentsTop = std::max<sal_Int32>(nExtentsTop, 0);
|
|
|
69cc7b |
nExtentsRight = std::min<sal_Int32>(nExtentsRight, nWidth);
|
|
|
69cc7b |
@@ -1331,21 +1337,35 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons
|
|
|
69cc7b |
//emulate it (slowly) here.
|
|
|
69cc7b |
if (m_ePaintMode == XOR && bXorModeAllowed)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- cairo_surface_t* true_surface = m_pSurface;
|
|
|
69cc7b |
- cairo_surface_flush(true_surface);
|
|
|
69cc7b |
- unsigned char *true_surface_data = cairo_image_surface_get_data(true_surface);
|
|
|
69cc7b |
+ cairo_surface_t* target_surface = m_pSurface;
|
|
|
69cc7b |
+ if (cairo_surface_get_type(target_surface) != CAIRO_SURFACE_TYPE_IMAGE)
|
|
|
69cc7b |
+ {
|
|
|
69cc7b |
+ //in the unlikely case we can't use m_pSurface directly, copy contents
|
|
|
69cc7b |
+ //to another temp image surface
|
|
|
69cc7b |
+ cairo_t* copycr = createTmpCompatibleCairoContext();
|
|
|
69cc7b |
+ cairo_rectangle(copycr, nExtentsLeft, nExtentsTop,
|
|
|
69cc7b |
+ nExtentsRight - nExtentsLeft,
|
|
|
69cc7b |
+ nExtentsBottom - nExtentsTop);
|
|
|
69cc7b |
+ cairo_set_source_surface(copycr, m_pSurface, 0, 0);
|
|
|
69cc7b |
+ cairo_paint(copycr);
|
|
|
69cc7b |
+ target_surface = cairo_get_target(copycr);
|
|
|
69cc7b |
+ cairo_destroy(copycr);
|
|
|
69cc7b |
+ }
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ cairo_surface_flush(target_surface);
|
|
|
69cc7b |
+ unsigned char *target_surface_data = cairo_image_surface_get_data(target_surface);
|
|
|
69cc7b |
unsigned char *xor_surface_data = cairo_image_surface_get_data(surface);
|
|
|
69cc7b |
|
|
|
69cc7b |
- cairo_format_t nFormat = cairo_image_surface_get_format(m_pSurface);
|
|
|
69cc7b |
+ cairo_format_t nFormat = cairo_image_surface_get_format(target_surface);
|
|
|
69cc7b |
assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here");
|
|
|
69cc7b |
- sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth);
|
|
|
69cc7b |
+ sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth * m_fScale);
|
|
|
69cc7b |
sal_Int32 nUnscaledExtentsLeft = nExtentsLeft * m_fScale;
|
|
|
69cc7b |
sal_Int32 nUnscaledExtentsRight = nExtentsRight * m_fScale;
|
|
|
69cc7b |
sal_Int32 nUnscaledExtentsTop = nExtentsTop * m_fScale;
|
|
|
69cc7b |
sal_Int32 nUnscaledExtentsBottom = nExtentsBottom * m_fScale;
|
|
|
69cc7b |
for (sal_Int32 y = nUnscaledExtentsTop; y < nUnscaledExtentsBottom; ++y)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- unsigned char *true_row = true_surface_data + (nStride*y);
|
|
|
69cc7b |
+ unsigned char *true_row = target_surface_data + (nStride*y);
|
|
|
69cc7b |
unsigned char *xor_row = xor_surface_data + (nStride*y);
|
|
|
69cc7b |
unsigned char *true_data = true_row + (nUnscaledExtentsLeft * 4);
|
|
|
69cc7b |
unsigned char *xor_data = xor_row + (nUnscaledExtentsLeft * 4);
|
|
|
69cc7b |
@@ -1364,7 +1384,22 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons
|
|
|
69cc7b |
xor_data+=4;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
}
|
|
|
69cc7b |
- cairo_surface_mark_dirty(true_surface);
|
|
|
69cc7b |
+ cairo_surface_mark_dirty(target_surface);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ if (target_surface != m_pSurface)
|
|
|
69cc7b |
+ {
|
|
|
69cc7b |
+ cairo_t* copycr = cairo_create(m_pSurface);
|
|
|
69cc7b |
+ //unlikely case we couldn't use m_pSurface directly, copy contents
|
|
|
69cc7b |
+ //back from image surface
|
|
|
69cc7b |
+ cairo_rectangle(copycr, nExtentsLeft, nExtentsTop,
|
|
|
69cc7b |
+ nExtentsRight - nExtentsLeft,
|
|
|
69cc7b |
+ nExtentsBottom - nExtentsTop);
|
|
|
69cc7b |
+ cairo_set_source_surface(copycr, target_surface, 0, 0);
|
|
|
69cc7b |
+ cairo_paint(copycr);
|
|
|
69cc7b |
+ cairo_destroy(copycr);
|
|
|
69cc7b |
+ cairo_surface_destroy(target_surface);
|
|
|
69cc7b |
+ }
|
|
|
69cc7b |
+
|
|
|
69cc7b |
cairo_surface_destroy(surface);
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
|
|
|
69cc7b |
index ca28a52..b5ab755 100644
|
|
|
69cc7b |
--- a/vcl/headless/svpvd.cxx
|
|
|
69cc7b |
+++ b/vcl/headless/svpvd.cxx
|
|
|
69cc7b |
@@ -38,7 +38,7 @@ SvpSalVirtualDevice::~SvpSalVirtualDevice()
|
|
|
69cc7b |
SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
|
|
|
69cc7b |
{
|
|
|
69cc7b |
SvpSalGraphics* pGraphics = new SvpSalGraphics();
|
|
|
69cc7b |
- pGraphics->setSurface(m_pSurface);
|
|
|
69cc7b |
+ pGraphics->setSurface(m_pSurface, m_aFrameSize);
|
|
|
69cc7b |
m_aGraphics.push_back( pGraphics );
|
|
|
69cc7b |
return pGraphics;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
@@ -62,12 +62,14 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
|
|
|
69cc7b |
if (nNewDY == 0)
|
|
|
69cc7b |
nNewDY = 1;
|
|
|
69cc7b |
|
|
|
69cc7b |
- nNewDX *= m_fScale;
|
|
|
69cc7b |
- nNewDY *= m_fScale;
|
|
|
69cc7b |
-
|
|
|
69cc7b |
- if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != nNewDX ||
|
|
|
69cc7b |
- cairo_image_surface_get_height(m_pSurface) != nNewDY )
|
|
|
69cc7b |
+ if (!m_pSurface || m_aFrameSize.getX() != nNewDX ||
|
|
|
69cc7b |
+ m_aFrameSize.getY() != nNewDY )
|
|
|
69cc7b |
{
|
|
|
69cc7b |
+ m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY);
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+ nNewDX *= m_fScale;
|
|
|
69cc7b |
+ nNewDY *= m_fScale;
|
|
|
69cc7b |
+
|
|
|
69cc7b |
if (m_pSurface)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
cairo_surface_destroy(m_pSurface);
|
|
|
69cc7b |
@@ -96,20 +98,19 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
|
|
|
69cc7b |
// update device in existing graphics
|
|
|
69cc7b |
for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
|
|
|
69cc7b |
it != m_aGraphics.end(); ++it )
|
|
|
69cc7b |
- (*it)->setSurface(m_pSurface);
|
|
|
69cc7b |
-
|
|
|
69cc7b |
+ (*it)->setSurface(m_pSurface, m_aFrameSize);
|
|
|
69cc7b |
}
|
|
|
69cc7b |
return true;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
long SvpSalVirtualDevice::GetWidth() const
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- return m_pSurface ? cairo_image_surface_get_width(m_pSurface) : 0;
|
|
|
69cc7b |
+ return m_pSurface ? m_aFrameSize.getX() : 0;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
long SvpSalVirtualDevice::GetHeight() const
|
|
|
69cc7b |
{
|
|
|
69cc7b |
- return m_pSurface ? cairo_image_surface_get_height(m_pSurface) : 0;
|
|
|
69cc7b |
+ return m_pSurface ? m_aFrameSize.getY() : 0;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
#endif
|
|
|
69cc7b |
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
|
|
|
69cc7b |
index 97fd678..0f46c5f 100644
|
|
|
69cc7b |
--- a/vcl/inc/headless/svpgdi.hxx
|
|
|
69cc7b |
+++ b/vcl/inc/headless/svpgdi.hxx
|
|
|
69cc7b |
@@ -80,6 +80,7 @@ struct VCL_DLLPUBLIC DamageHandler
|
|
|
69cc7b |
class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
|
|
|
69cc7b |
{
|
|
|
69cc7b |
cairo_surface_t* m_pSurface;
|
|
|
69cc7b |
+ basegfx::B2IVector m_aFrameSize;
|
|
|
69cc7b |
double m_fScale;
|
|
|
69cc7b |
SalColor m_aLineColor;
|
|
|
69cc7b |
SalColor m_aFillColor;
|
|
|
69cc7b |
@@ -87,7 +88,7 @@ class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
|
|
|
69cc7b |
|
|
|
69cc7b |
public:
|
|
|
69cc7b |
static GlyphCache& getPlatformGlyphCache();
|
|
|
69cc7b |
- void setSurface(cairo_surface_t* pSurface);
|
|
|
69cc7b |
+ void setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize);
|
|
|
69cc7b |
static cairo_user_data_key_t* getDamageKey();
|
|
|
69cc7b |
|
|
|
69cc7b |
private:
|
|
|
69cc7b |
@@ -115,6 +116,8 @@ protected:
|
|
|
69cc7b |
const SalBitmap* pAlphaBitmap) override;
|
|
|
69cc7b |
virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) override;
|
|
|
69cc7b |
|
|
|
69cc7b |
+ cairo_t* createTmpCompatibleCairoContext() const;
|
|
|
69cc7b |
+
|
|
|
69cc7b |
public:
|
|
|
69cc7b |
SvpSalGraphics();
|
|
|
69cc7b |
virtual ~SvpSalGraphics() override;
|
|
|
69cc7b |
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
|
|
|
69cc7b |
index 882f36d..7ac1563 100644
|
|
|
69cc7b |
--- a/vcl/inc/headless/svpvd.hxx
|
|
|
69cc7b |
+++ b/vcl/inc/headless/svpvd.hxx
|
|
|
69cc7b |
@@ -31,6 +31,7 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice
|
|
|
69cc7b |
{
|
|
|
69cc7b |
DeviceFormat m_eFormat;
|
|
|
69cc7b |
cairo_surface_t* m_pSurface;
|
|
|
69cc7b |
+ basegfx::B2IVector m_aFrameSize;
|
|
|
69cc7b |
double m_fScale;
|
|
|
69cc7b |
std::list< SvpSalGraphics* > m_aGraphics;
|
|
|
69cc7b |
|
|
|
69cc7b |
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
|
|
|
69cc7b |
index f263160..8f60671 100644
|
|
|
69cc7b |
--- a/vcl/inc/unx/gtk/gtkframe.hxx
|
|
|
69cc7b |
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
|
|
|
69cc7b |
@@ -246,6 +246,7 @@ class GtkSalFrame : public SalFrame
|
|
|
69cc7b |
#endif
|
|
|
69cc7b |
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
69cc7b |
static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer );
|
|
|
69cc7b |
+ static void signalRealize(GtkWidget*, gpointer frame);
|
|
|
69cc7b |
static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame);
|
|
|
69cc7b |
static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y,
|
|
|
69cc7b |
gboolean keyboard_mode, GtkTooltip *tooltip,
|
|
|
69cc7b |
@@ -346,6 +347,7 @@ class GtkSalFrame : public SalFrame
|
|
|
69cc7b |
public:
|
|
|
69cc7b |
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
69cc7b |
cairo_surface_t* m_pSurface;
|
|
|
69cc7b |
+ basegfx::B2IVector m_aFrameSize;
|
|
|
69cc7b |
DamageHandler m_aDamageHandler;
|
|
|
69cc7b |
std::vector<GdkEvent*> m_aPendingScrollEvents;
|
|
|
69cc7b |
Idle m_aSmoothScrollIdle;
|
|
|
69cc7b |
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
|
|
|
69cc7b |
index 9be38dd..dc9d83b 100644
|
|
|
69cc7b |
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
|
|
|
69cc7b |
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
|
|
|
69cc7b |
@@ -1045,6 +1045,7 @@ void GtkSalFrame::InitCommon()
|
|
|
69cc7b |
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "scroll-event", G_CALLBACK(signalScroll), this ));
|
|
|
69cc7b |
|
|
|
69cc7b |
g_signal_connect( G_OBJECT(m_pFixedContainer), "draw", G_CALLBACK(signalDraw), this );
|
|
|
69cc7b |
+ g_signal_connect( G_OBJECT(m_pFixedContainer), "realize", G_CALLBACK(signalRealize), this );
|
|
|
69cc7b |
g_signal_connect( G_OBJECT(m_pFixedContainer), "size-allocate", G_CALLBACK(sizeAllocated), this );
|
|
|
69cc7b |
#if GTK_CHECK_VERSION(3,14,0)
|
|
|
69cc7b |
GtkGesture *pSwipe = gtk_gesture_swipe_new(pEventWidget);
|
|
|
69cc7b |
@@ -1340,7 +1341,7 @@ SalGraphics* GtkSalFrame::AcquireGraphics()
|
|
|
69cc7b |
AllocateFrame();
|
|
|
69cc7b |
TriggerPaintEvent();
|
|
|
69cc7b |
}
|
|
|
69cc7b |
- m_pGraphics->setSurface(m_pSurface);
|
|
|
69cc7b |
+ m_pGraphics->setSurface(m_pSurface, m_aFrameSize);
|
|
|
69cc7b |
}
|
|
|
69cc7b |
m_bGraphics = true;
|
|
|
69cc7b |
return m_pGraphics;
|
|
|
69cc7b |
@@ -1587,13 +1588,11 @@ void GtkSalFrame::SetMinClientSize( long nWidth, long nHeight )
|
|
|
69cc7b |
}
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
-// FIXME: we should really be an SvpSalFrame sub-class, and
|
|
|
69cc7b |
-// share their AllocateFrame !
|
|
|
69cc7b |
void GtkSalFrame::AllocateFrame()
|
|
|
69cc7b |
{
|
|
|
69cc7b |
basegfx::B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight );
|
|
|
69cc7b |
- if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != aFrameSize.getX() ||
|
|
|
69cc7b |
- cairo_image_surface_get_height(m_pSurface) != aFrameSize.getY() )
|
|
|
69cc7b |
+ if (!m_pSurface || m_aFrameSize.getX() != aFrameSize.getX() ||
|
|
|
69cc7b |
+ m_aFrameSize.getY() != aFrameSize.getY() )
|
|
|
69cc7b |
{
|
|
|
69cc7b |
if( aFrameSize.getX() == 0 )
|
|
|
69cc7b |
aFrameSize.setX( 1 );
|
|
|
69cc7b |
@@ -1603,30 +1602,17 @@ void GtkSalFrame::AllocateFrame()
|
|
|
69cc7b |
if (m_pSurface)
|
|
|
69cc7b |
cairo_surface_destroy(m_pSurface);
|
|
|
69cc7b |
|
|
|
69cc7b |
-#if GTK_CHECK_VERSION(3,10,0)
|
|
|
69cc7b |
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
|
|
69cc7b |
- int scale = gtk_widget_get_scale_factor(m_pWindow);
|
|
|
69cc7b |
-#else
|
|
|
69cc7b |
- int scale = 1;
|
|
|
69cc7b |
-#endif
|
|
|
69cc7b |
- m_pSurface = gdk_window_create_similar_image_surface(widget_get_window(m_pWindow),
|
|
|
69cc7b |
- CAIRO_FORMAT_ARGB32,
|
|
|
69cc7b |
- aFrameSize.getX() * scale,
|
|
|
69cc7b |
- aFrameSize.getY() * scale,
|
|
|
69cc7b |
- scale);
|
|
|
69cc7b |
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
|
|
69cc7b |
- cairo_surface_set_device_scale(m_pSurface, scale, scale);
|
|
|
69cc7b |
-#endif
|
|
|
69cc7b |
-#else
|
|
|
69cc7b |
- m_pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
|
|
|
69cc7b |
- aFrameSize.getX(),
|
|
|
69cc7b |
- aFrameSize.getY());
|
|
|
69cc7b |
-#endif
|
|
|
69cc7b |
+ m_pSurface = gdk_window_create_similar_surface(widget_get_window(m_pWindow),
|
|
|
69cc7b |
+ CAIRO_CONTENT_COLOR_ALPHA,
|
|
|
69cc7b |
+ aFrameSize.getX(),
|
|
|
69cc7b |
+ aFrameSize.getY());
|
|
|
69cc7b |
+ m_aFrameSize = aFrameSize;
|
|
|
69cc7b |
+
|
|
|
69cc7b |
cairo_surface_set_user_data(m_pSurface, SvpSalGraphics::getDamageKey(), &m_aDamageHandler, nullptr);
|
|
|
69cc7b |
SAL_INFO("vcl.gtk3", "allocated Frame size of " << maGeometry.nWidth << " x " << maGeometry.nHeight);
|
|
|
69cc7b |
|
|
|
69cc7b |
if (m_pGraphics)
|
|
|
69cc7b |
- m_pGraphics->setSurface(m_pSurface);
|
|
|
69cc7b |
+ m_pGraphics->setSurface(m_pSurface, m_aFrameSize);
|
|
|
69cc7b |
}
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
@@ -2967,13 +2953,23 @@ gboolean GtkSalFrame::signalDraw(GtkWidget*, cairo_t *cr, gpointer frame)
|
|
|
69cc7b |
return false;
|
|
|
69cc7b |
}
|
|
|
69cc7b |
|
|
|
69cc7b |
-void GtkSalFrame::sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame)
|
|
|
69cc7b |
+void GtkSalFrame::sizeAllocated(GtkWidget* pWidget, GdkRectangle *pAllocation, gpointer frame)
|
|
|
69cc7b |
{
|
|
|
69cc7b |
GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
|
|
|
69cc7b |
pThis->maGeometry.nWidth = pAllocation->width;
|
|
|
69cc7b |
pThis->maGeometry.nHeight = pAllocation->height;
|
|
|
69cc7b |
- pThis->AllocateFrame();
|
|
|
69cc7b |
+ bool bRealized = gtk_widget_get_realized(pWidget);
|
|
|
69cc7b |
+ if (bRealized)
|
|
|
69cc7b |
+ pThis->AllocateFrame();
|
|
|
69cc7b |
pThis->CallCallbackExc( SalEvent::Resize, nullptr );
|
|
|
69cc7b |
+ if (bRealized && !pThis->m_bSalObjectSetPosSize)
|
|
|
69cc7b |
+ pThis->TriggerPaintEvent();
|
|
|
69cc7b |
+}
|
|
|
69cc7b |
+
|
|
|
69cc7b |
+void GtkSalFrame::signalRealize(GtkWidget*, gpointer frame)
|
|
|
69cc7b |
+{
|
|
|
69cc7b |
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
|
|
|
69cc7b |
+ pThis->AllocateFrame();
|
|
|
69cc7b |
if (pThis->m_bSalObjectSetPosSize)
|
|
|
69cc7b |
return;
|
|
|
69cc7b |
pThis->TriggerPaintEvent();
|
|
|
69cc7b |
--
|
|
|
69cc7b |
2.13.0
|
|
|
69cc7b |
|