vcl/inc/skia/gdiimpl.hxx | 3 +-- vcl/inc/skia/salbmp.hxx | 3 +-- vcl/inc/skia/utils.hxx | 3 ++- vcl/skia/README | 3 ++- vcl/skia/SkiaHelper.cxx | 31 +++++++++++++++---------------- vcl/skia/gdiimpl.cxx | 2 -- vcl/skia/salbmp.cxx | 3 +-- 7 files changed, 22 insertions(+), 26 deletions(-)
New commits: commit f33b76b4e675818deae244427cef84c576a1a1f8 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Sat Nov 13 08:30:36 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Tue Nov 16 18:37:06 2021 +0100 make SkiaHelper::dump() available also in non-dbgutil builds They are just a set of small functions, and I sometimes need to debug optimized builds too. Change-Id: I6350476e8c7fef85460a88b9e3d56d02213764ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125310 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 942567fec0f6..abfa89ca8bfa 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -198,9 +198,8 @@ public: virtual bool supportsOperation(OutDevSupportType eType) const override; -#ifdef DBG_UTIL + // Dump contents to a file for debugging. void dump(const char* file) const; -#endif // Default blend mode for SkPaint is SkBlendMode::kSrcOver void drawBitmap(const SalTwoRect& rPosAry, const SkiaSalBitmap& bitmap, diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index b2f452c82979..aa8d245ce741 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -88,9 +88,8 @@ public: // Alpha type best suitable for the content. SkAlphaType alphaType() const; -#ifdef DBG_UTIL + // Dump contents to a file for debugging. void dump(const char* file) const; -#endif // These are to be used only by unittests. bool unittestHasBuffer() const { return mBuffer.get(); } diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx index ed404f7cc3eb..0a17ee81bc4d 100644 --- a/vcl/inc/skia/utils.hxx +++ b/vcl/inc/skia/utils.hxx @@ -194,10 +194,11 @@ inline SkIRect scaleRect(const SkIRect& rect, int scaling) #ifdef DBG_UTIL void prefillSurface(const sk_sp<SkSurface>& surface); +#endif + VCL_DLLPUBLIC void dump(const SkBitmap& bitmap, const char* file); VCL_DLLPUBLIC void dump(const sk_sp<SkImage>& image, const char* file); VCL_DLLPUBLIC void dump(const sk_sp<SkSurface>& surface, const char* file); -#endif VCL_DLLPUBLIC extern uint32_t vendorId; diff --git a/vcl/skia/README b/vcl/skia/README index f2903d97fdd7..63f6073bac87 100644 --- a/vcl/skia/README +++ b/vcl/skia/README @@ -31,7 +31,8 @@ Debugging: Both SkiaSalBitmap and SkiaSalGraphicsImpl have a dump() method that writes a PNG with the current contents. There is also SkiaHelper::dump() for dumping contents -of SkBitmap, SkImage and SkSurface. +of SkBitmap, SkImage and SkSurface. You can use these in a debugger too, for example +'p SkiaHelper::dump(image, "/tmp/a.png")'. If there is a drawing problem, you can use something like the following piece of code to dump an image after each relevant operation (or do it in postDraw() if you don't diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx index 57bde5abf919..cc9303af39f5 100644 --- a/vcl/skia/SkiaHelper.cxx +++ b/vcl/skia/SkiaHelper.cxx @@ -704,6 +704,21 @@ void prepareSkia(std::unique_ptr<sk_app::WindowContext> (*createGpuWindowContext skiaSupportedByBackend = true; } +void dump(const SkBitmap& bitmap, const char* file) { dump(SkImage::MakeFromBitmap(bitmap), file); } + +void dump(const sk_sp<SkSurface>& surface, const char* file) +{ + surface->getCanvas()->flush(); + dump(makeCheckedImageSnapshot(surface), file); +} + +void dump(const sk_sp<SkImage>& image, const char* file) +{ + sk_sp<SkData> data = image->encodeToData(SkEncodedImageFormat::kPNG, 1); + std::ofstream ostream(file, std::ios::binary); + ostream.write(static_cast<const char*>(data->data()), data->size()); +} + #ifdef DBG_UTIL void prefillSurface(const sk_sp<SkSurface>& surface) { @@ -724,22 +739,6 @@ void prefillSurface(const sk_sp<SkSurface>& surface) bitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, SkSamplingOptions())); surface->getCanvas()->drawPaint(paint); } - -void dump(const SkBitmap& bitmap, const char* file) { dump(SkImage::MakeFromBitmap(bitmap), file); } - -void dump(const sk_sp<SkSurface>& surface, const char* file) -{ - surface->getCanvas()->flush(); - dump(makeCheckedImageSnapshot(surface), file); -} - -void dump(const sk_sp<SkImage>& image, const char* file) -{ - sk_sp<SkData> data = image->encodeToData(SkEncodedImageFormat::kPNG, 1); - std::ofstream ostream(file, std::ios::binary); - ostream.write(static_cast<const char*>(data->data()), data->size()); -} - #endif } // namespace diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 4019c436d51d..f532e48528a9 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -2213,12 +2213,10 @@ int SkiaSalGraphicsImpl::getWindowScaling() const return scaling; } -#ifdef DBG_UTIL void SkiaSalGraphicsImpl::dump(const char* file) const { assert(mSurface.get()); SkiaHelper::dump(mSurface, file); } -#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index c064f00ad565..dd96e3ecd094 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -1339,7 +1339,6 @@ OString SkiaSalBitmap::GetAlphaImageKey() const return OString::Concat("I") + OString::number(GetAlphaSkImage()->uniqueID()); } -#ifdef DBG_UTIL void SkiaSalBitmap::dump(const char* file) const { // Use a copy, so that debugging doesn't affect this instance. @@ -1348,6 +1347,7 @@ void SkiaSalBitmap::dump(const char* file) const SkiaHelper::dump(copy.GetSkImage(), file); } +#ifdef DBG_UTIL void SkiaSalBitmap::verify() const { if (!mBuffer) @@ -1356,7 +1356,6 @@ void SkiaSalBitmap::verify() const assert(memcmp(mBuffer.get() + mScanlineSize * mPixelsSize.Height(), CANARY, sizeof(CANARY)) == 0); } - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */