diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-02-07 13:09:31 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-02-07 13:09:31 +0000 |
commit | 19ea3db6d33e8e1de57104e42796454757facd45 (patch) | |
tree | e6baffa68f6cb5c4a8b1e234d3f98a82c827d580 /vcl/headless | |
parent | eee0206831f9682f1fa1806d08bbbeaf4783b4e9 (diff) |
revert unready stuff
Change-Id: I2b112a17a2bc70bfe4d5a6af7964a3c1d7eacf9b
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/svpframe.cxx | 4 | ||||
-rw-r--r-- | vcl/headless/svpgdi.cxx | 131 | ||||
-rw-r--r-- | vcl/headless/svpvd.cxx | 21 |
3 files changed, 59 insertions, 97 deletions
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index 962cea02a69f..0ce76cf119d1 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -150,7 +150,7 @@ SalGraphics* SvpSalFrame::AcquireGraphics() { SvpSalGraphics* pGraphics = new SvpSalGraphics(); #ifndef IOS - pGraphics->setSurface(m_pSurface, B2IVector(maGeometry.nWidth, maGeometry.nHeight)); + pGraphics->setSurface( m_pSurface ); #endif m_aGraphics.push_back( pGraphics ); return pGraphics; @@ -281,7 +281,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin(); it != m_aGraphics.end(); ++it ) { - (*it)->setSurface(m_pSurface, aFrameSize); + (*it)->setSurface(m_pSurface); } } if( m_bVisible ) diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index e05617db51f7..34bb744a76ee 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -133,22 +133,6 @@ namespace { return source; } - void mark_dirty() - { - cairo_surface_mark_dirty(source); - } - unsigned char* getBits(sal_Int32 &rStride) - { - cairo_surface_flush(source); - - unsigned char *mask_data = cairo_image_surface_get_data(source); - - cairo_format_t nFormat = cairo_image_surface_get_format(source); - assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here"); - rStride = cairo_format_stride_for_width(nFormat, cairo_image_surface_get_width(source)); - - return mask_data; - } private: SvpSalBitmap aTmpBmp; cairo_surface_t* source; @@ -402,10 +386,9 @@ SvpSalGraphics::~SvpSalGraphics() { } -void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize) +void SvpSalGraphics::setSurface(cairo_surface_t* pSurface) { m_pSurface = pSurface; - m_aFrameSize = rSize; #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) cairo_surface_get_device_scale(pSurface, &m_fScale, nullptr); #endif @@ -419,14 +402,14 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) sal_uInt16 SvpSalGraphics::GetBitCount() const { - if (cairo_surface_get_content(m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) + if (CAIRO_FORMAT_A1 == cairo_image_surface_get_format(m_pSurface)) return 1; return 32; } long SvpSalGraphics::GetGraphicsWidth() const { - return m_pSurface ? m_aFrameSize.getX() : 0; + return m_pSurface ? cairo_image_surface_get_width(m_pSurface) / m_fScale : 0; } void SvpSalGraphics::ResetClipRegion() @@ -902,7 +885,7 @@ bool SvpSalGraphics::drawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPoly, d void SvpSalGraphics::applyColor(cairo_t *cr, SalColor aColor) { - if (cairo_surface_get_content(m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA) + if (CAIRO_FORMAT_ARGB32 == cairo_image_surface_get_format(m_pSurface)) { cairo_set_source_rgba(cr, SALCOLOR_RED(aColor)/255.0, SALCOLOR_GREEN(aColor)/255.0, @@ -999,10 +982,17 @@ void SvpSalGraphics::copyBits( const SalTwoRect& rTR, if (pSrc == this) { //self copy is a problem, so dup source in that case +#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 12, 0) pCopy = cairo_surface_create_similar(source, cairo_surface_get_content(m_pSurface), aTR.mnSrcWidth * m_fScale, aTR.mnSrcHeight * m_fScale); +#else + pCopy = cairo_surface_create_similar_image(source, + cairo_image_surface_get_format(m_pSurface), + aTR.mnSrcWidth * m_fScale, + aTR.mnSrcHeight * m_fScale); +#endif #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) cairo_surface_set_device_scale(pCopy, m_fScale, m_fScale); #endif @@ -1059,8 +1049,16 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR, /** creates an image from the given rectangle, replacing all black pixels * with nMaskColor and make all other full transparent */ SourceHelper aSurface(rSalBitmap); - sal_Int32 nStride; - unsigned char *mask_data = aSurface.getBits(nStride); + cairo_surface_t* mask = aSurface.getSurface(); + + cairo_surface_flush(mask); + + unsigned char *mask_data = cairo_image_surface_get_data(mask); + + cairo_format_t nFormat = cairo_image_surface_get_format(mask); + assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here"); + sal_Int32 nStride = cairo_format_stride_for_width(nFormat, + cairo_image_surface_get_width(mask)); for (sal_Int32 y = rTR.mnSrcY ; y < rTR.mnSrcY + rTR.mnSrcHeight; ++y) { unsigned char *row = mask_data + (nStride*y); @@ -1087,7 +1085,7 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR, data+=4; } } - aSurface.mark_dirty(); + cairo_surface_mark_dirty(mask); cairo_t* cr = getCairoContext(false); clipRegion(cr); @@ -1100,7 +1098,7 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR, cairo_translate(cr, rTR.mnDestX, rTR.mnDestY); cairo_scale(cr, (double)(rTR.mnDestWidth)/rTR.mnSrcWidth, ((double)rTR.mnDestHeight)/rTR.mnSrcHeight); - cairo_set_source_surface(cr, aSurface.getSurface(), -rTR.mnSrcX, -rTR.mnSrcY); + cairo_set_source_surface(cr, mask, -rTR.mnSrcX, -rTR.mnSrcY); cairo_paint(cr); releaseCairoContext(cr, false, extents); @@ -1125,24 +1123,18 @@ SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeigh SalColor SvpSalGraphics::getPixel( long nX, long nY ) { - cairo_surface_t *target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); - cairo_t* cr = cairo_create(target); - - cairo_rectangle(cr, 0, 0, 1, 1); - cairo_set_source_surface(cr, m_pSurface, -nX, -nY); - cairo_paint(cr); - cairo_destroy(cr); - - cairo_surface_flush(target); - unsigned char *data = cairo_image_surface_get_data(target); + cairo_surface_flush(m_pSurface); + cairo_format_t nFormat = cairo_image_surface_get_format(m_pSurface); + assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here"); + sal_Int32 nStride = cairo_format_stride_for_width(nFormat, + cairo_image_surface_get_width(m_pSurface)); + unsigned char *surface_data = cairo_image_surface_get_data(m_pSurface); + unsigned char *row = surface_data + (nStride*nY); + unsigned char *data = row + (nX * 4); sal_uInt8 b = unpremultiply(data[SVP_CAIRO_BLUE], data[SVP_CAIRO_ALPHA]); sal_uInt8 g = unpremultiply(data[SVP_CAIRO_GREEN], data[SVP_CAIRO_ALPHA]); sal_uInt8 r = unpremultiply(data[SVP_CAIRO_RED], data[SVP_CAIRO_ALPHA]); - SalColor nRet = MAKE_SALCOLOR(r, g, b); - - cairo_surface_destroy(target); - - return nRet; + return MAKE_SALCOLOR(r, g, b); } namespace @@ -1276,17 +1268,17 @@ cairo_surface_t* SvpSalGraphics::createCairoSurface(const BitmapBuffer *pBuffer) return target; } -cairo_t* SvpSalGraphics::createTmpCompatibleCairoContext() const +static cairo_t* createTmpCompatibleCairoContext(cairo_surface_t* pSurface, double fScale) { - cairo_surface_t *target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - m_aFrameSize.getX() * m_fScale, - m_aFrameSize.getY() * m_fScale); + cairo_surface_t *target = cairo_image_surface_create( + cairo_image_surface_get_format(pSurface), + cairo_image_surface_get_width(pSurface), + cairo_image_surface_get_height(pSurface)); #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) - cairo_surface_set_device_scale(target, m_fScale, m_fScale); + cairo_surface_set_device_scale(target, fScale, fScale); #else (void)fScale; #endif - return cairo_create(target); } @@ -1294,7 +1286,7 @@ cairo_t* SvpSalGraphics::getCairoContext(bool bXorModeAllowed) const { cairo_t* cr; if (m_ePaintMode == XOR && bXorModeAllowed) - cr = createTmpCompatibleCairoContext(); + cr = createTmpCompatibleCairoContext(m_pSurface, m_fScale); else cr = cairo_create(m_pSurface); cairo_set_line_width(cr, 1); @@ -1324,8 +1316,8 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons sal_Int32 nExtentsLeft(rExtents.getMinX()), nExtentsTop(rExtents.getMinY()); sal_Int32 nExtentsRight(rExtents.getMaxX()), nExtentsBottom(rExtents.getMaxY()); - sal_Int32 nWidth = m_aFrameSize.getX(); - sal_Int32 nHeight = m_aFrameSize.getY(); + sal_Int32 nWidth = cairo_image_surface_get_width(m_pSurface); + sal_Int32 nHeight = cairo_image_surface_get_height(m_pSurface); nExtentsLeft = std::max<sal_Int32>(nExtentsLeft, 0); nExtentsTop = std::max<sal_Int32>(nExtentsTop, 0); nExtentsRight = std::min<sal_Int32>(nExtentsRight, nWidth); @@ -1339,35 +1331,21 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons //emulate it (slowly) here. if (m_ePaintMode == XOR && bXorModeAllowed) { - cairo_surface_t* target_surface = m_pSurface; - if (cairo_surface_get_type(target_surface) != CAIRO_SURFACE_TYPE_IMAGE) - { - //in the unlikely case we can't use m_pSurface directly, copy contents - //to another temp image surface - cairo_t* copycr = createTmpCompatibleCairoContext(); - cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, - nExtentsRight - nExtentsLeft, - nExtentsBottom - nExtentsTop); - cairo_set_source_surface(copycr, m_pSurface, 0, 0); - cairo_paint(copycr); - target_surface = cairo_get_target(copycr); - cairo_destroy(copycr); - } - - cairo_surface_flush(target_surface); - unsigned char *target_surface_data = cairo_image_surface_get_data(target_surface); + cairo_surface_t* true_surface = m_pSurface; + cairo_surface_flush(true_surface); + unsigned char *true_surface_data = cairo_image_surface_get_data(true_surface); unsigned char *xor_surface_data = cairo_image_surface_get_data(surface); cairo_format_t nFormat = cairo_image_surface_get_format(m_pSurface); assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here"); - sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth * m_fScale); + sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth); sal_Int32 nUnscaledExtentsLeft = nExtentsLeft * m_fScale; sal_Int32 nUnscaledExtentsRight = nExtentsRight * m_fScale; sal_Int32 nUnscaledExtentsTop = nExtentsTop * m_fScale; sal_Int32 nUnscaledExtentsBottom = nExtentsBottom * m_fScale; for (sal_Int32 y = nUnscaledExtentsTop; y < nUnscaledExtentsBottom; ++y) { - unsigned char *true_row = target_surface_data + (nStride*y); + unsigned char *true_row = true_surface_data + (nStride*y); unsigned char *xor_row = xor_surface_data + (nStride*y); unsigned char *true_data = true_row + (nUnscaledExtentsLeft * 4); unsigned char *xor_data = xor_row + (nUnscaledExtentsLeft * 4); @@ -1386,22 +1364,7 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons xor_data+=4; } } - cairo_surface_mark_dirty(target_surface); - - if (target_surface != m_pSurface) - { - cairo_t* copycr = cairo_create(m_pSurface); - //unlikely case we couldn't use m_pSurface directly, copy contents - //back from image surface - cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, - nExtentsRight - nExtentsLeft, - nExtentsBottom - nExtentsTop); - cairo_set_source_surface(copycr, target_surface, 0, 0); - cairo_paint(copycr); - cairo_destroy(copycr); - cairo_surface_destroy(target_surface); - } - + cairo_surface_mark_dirty(true_surface); cairo_surface_destroy(surface); } diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index b5ab755a0d1b..ca28a5246b46 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -38,7 +38,7 @@ SvpSalVirtualDevice::~SvpSalVirtualDevice() SalGraphics* SvpSalVirtualDevice::AcquireGraphics() { SvpSalGraphics* pGraphics = new SvpSalGraphics(); - pGraphics->setSurface(m_pSurface, m_aFrameSize); + pGraphics->setSurface(m_pSurface); m_aGraphics.push_back( pGraphics ); return pGraphics; } @@ -62,14 +62,12 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, if (nNewDY == 0) nNewDY = 1; - if (!m_pSurface || m_aFrameSize.getX() != nNewDX || - m_aFrameSize.getY() != nNewDY ) - { - m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY); - - nNewDX *= m_fScale; - nNewDY *= m_fScale; + nNewDX *= m_fScale; + nNewDY *= m_fScale; + if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != nNewDX || + cairo_image_surface_get_height(m_pSurface) != nNewDY ) + { if (m_pSurface) { cairo_surface_destroy(m_pSurface); @@ -98,19 +96,20 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, // update device in existing graphics for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin(); it != m_aGraphics.end(); ++it ) - (*it)->setSurface(m_pSurface, m_aFrameSize); + (*it)->setSurface(m_pSurface); + } return true; } long SvpSalVirtualDevice::GetWidth() const { - return m_pSurface ? m_aFrameSize.getX() : 0; + return m_pSurface ? cairo_image_surface_get_width(m_pSurface) : 0; } long SvpSalVirtualDevice::GetHeight() const { - return m_pSurface ? m_aFrameSize.getY() : 0; + return m_pSurface ? cairo_image_surface_get_height(m_pSurface) : 0; } #endif |