summaryrefslogtreecommitdiff
path: root/vcl/headless
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2023-01-05 12:02:35 +0000
committerCaolán McNamara <caolanm@redhat.com>2023-01-06 08:46:43 +0000
commite8effd1c4c0a4dd389054d311f432c42f26a3a6b (patch)
tree7fc50bbcdc7b1dc4eb7775cbf024d05f649ef586 /vcl/headless
parentc010b5d2b2cdb22f48ef9d2b9d1fdc6125e1fec2 (diff)
Revert "move getPixel into CairoCommon and reuse from X11CairoSalGraphicsImpl"
This reverts commit 00b62877fa2f900d1c2dcf7b721f7a956408f8a0. XIOError seen with vcldemo Change-Id: Id75497f8148964372beaed9432ee6097ec8afc47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145076 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/headless')
-rw-r--r--vcl/headless/CairoCommon.cxx33
-rw-r--r--vcl/headless/SvpGraphicsBackend.cxx30
2 files changed, 29 insertions, 34 deletions
diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index 39538a9f9f40..5781eff048e8 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -623,39 +623,6 @@ void CairoCommon::drawPixel(cairo_t* cr, basegfx::B2DRange* pExtents, const Colo
*pExtents = getClippedFillDamage(cr);
}
-Color CairoCommon::getPixel(cairo_surface_t* pSurface, tools::Long nX, tools::Long nY)
-{
- cairo_surface_t* target
- = cairo_surface_create_similar_image(pSurface, CAIRO_FORMAT_ARGB32, 1, 1);
-
- cairo_t* cr = cairo_create(target);
-
- cairo_rectangle(cr, 0, 0, 1, 1);
- cairo_set_source_surface(cr, pSurface, -nX, -nY);
- cairo_paint(cr);
- cairo_destroy(cr);
-
- cairo_surface_flush(target);
-#if !ENABLE_WASM_STRIP_PREMULTIPLY
- vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table();
-#endif
- unsigned char* data = cairo_image_surface_get_data(target);
- sal_uInt8 a = data[SVP_CAIRO_ALPHA];
-#if ENABLE_WASM_STRIP_PREMULTIPLY
- sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]);
- sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]);
- sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]);
-#else
- sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]];
- sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]];
- sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]];
-#endif
- Color aColor(ColorAlpha, a, r, g, b);
- cairo_surface_destroy(target);
-
- return aColor;
-}
-
void CairoCommon::drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor,
bool bAntiAlias, tools::Long nX1, tools::Long nY1, tools::Long nX2,
tools::Long nY2)
diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx
index efff52387575..84d6aa1dcd09 100644
--- a/vcl/headless/SvpGraphicsBackend.cxx
+++ b/vcl/headless/SvpGraphicsBackend.cxx
@@ -566,7 +566,35 @@ void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect& rTR, const BitmapBuf
Color SvpGraphicsBackend::getPixel(tools::Long nX, tools::Long nY)
{
- return CairoCommon::getPixel(m_rCairoCommon.m_pSurface, nX, nY);
+ cairo_surface_t* target
+ = cairo_surface_create_similar_image(m_rCairoCommon.m_pSurface, CAIRO_FORMAT_ARGB32, 1, 1);
+
+ cairo_t* cr = cairo_create(target);
+
+ cairo_rectangle(cr, 0, 0, 1, 1);
+ cairo_set_source_surface(cr, m_rCairoCommon.m_pSurface, -nX, -nY);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+
+ cairo_surface_flush(target);
+#if !ENABLE_WASM_STRIP_PREMULTIPLY
+ vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table();
+#endif
+ unsigned char* data = cairo_image_surface_get_data(target);
+ sal_uInt8 a = data[SVP_CAIRO_ALPHA];
+#if ENABLE_WASM_STRIP_PREMULTIPLY
+ sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]);
+ sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]);
+ sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]);
+#else
+ sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]];
+ sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]];
+ sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]];
+#endif
+ Color aColor(ColorAlpha, a, r, g, b);
+ cairo_surface_destroy(target);
+
+ return aColor;
}
void SvpGraphicsBackend::invert(tools::Long nX, tools::Long nY, tools::Long nWidth,