vcl/skia/gdiimpl.cxx | 70 +++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 32 deletions(-)
New commits: commit 97c468daae242ef8d62edb0942cb52ef4a2a1ebb Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Apr 1 11:07:30 2020 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed Apr 1 12:49:32 2020 +0200 handle weird semantics of SkRect::intersect() (tdf#131721) If the two rectangles do not intersect, it only returns false and does nothing, which is stupid and confusing. Change-Id: I24de6059807c208c39db4e942ab5624dde788723 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91471 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 390bf521336b..53ccda65c1d5 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -324,44 +324,50 @@ void SkiaSalGraphicsImpl::postDraw() { // Make slightly larger, just in case (rounding, antialiasing,...). mXorExtents.outset(2, 2); - mXorExtents.intersect(SkRect::MakeXYWH(0, 0, mSurface->width(), mSurface->height())); + if (!mXorExtents.intersect( + SkRect::MakeXYWH(0, 0, mSurface->width(), mSurface->height()))) + mXorExtents.setEmpty(); } SAL_INFO("vcl.skia.trace", "applyxor(" << this << "): " << tools::Rectangle(mXorExtents.left(), mXorExtents.top(), mXorExtents.right(), mXorExtents.bottom())); - // Copy the surface contents to another pixmap. - SkBitmap surfaceBitmap; - // Use unpremultiplied alpha format, so that we do not have to do the conversions to get - // the RGB and back (Skia will do it when converting, but it'll be presumably faster at it). - if (!surfaceBitmap.tryAllocPixels( - mSurface->imageInfo().makeAlphaType(kUnpremul_SkAlphaType))) - abort(); - SkPaint paint; - paint.setBlendMode(SkBlendMode::kSrc); // copy as is - SkCanvas canvas(surfaceBitmap); - canvas.drawImageRect(mSurface->makeImageSnapshot(), mXorExtents, mXorExtents, &paint); - // xor to surfaceBitmap - assert(surfaceBitmap.info().alphaType() == kUnpremul_SkAlphaType); - assert(mXorBitmap.info().alphaType() == kUnpremul_SkAlphaType); - assert(surfaceBitmap.bytesPerPixel() == 4); - assert(mXorBitmap.bytesPerPixel() == 4); - for (int y = mXorExtents.top(); y < mXorExtents.bottom(); ++y) + if (!mXorExtents.isEmpty()) // the intersection above may be empty { - uint8_t* data = static_cast<uint8_t*>(surfaceBitmap.getAddr(mXorExtents.x(), y)); - const uint8_t* xordata = static_cast<uint8_t*>(mXorBitmap.getAddr(mXorExtents.x(), y)); - for (int x = 0; x < mXorExtents.width(); ++x) + // Copy the surface contents to another pixmap. + SkBitmap surfaceBitmap; + // Use unpremultiplied alpha format, so that we do not have to do the conversions to get + // the RGB and back (Skia will do it when converting, but it'll be presumably faster at it). + if (!surfaceBitmap.tryAllocPixels( + mSurface->imageInfo().makeAlphaType(kUnpremul_SkAlphaType))) + abort(); + SkPaint paint; + paint.setBlendMode(SkBlendMode::kSrc); // copy as is + SkCanvas canvas(surfaceBitmap); + canvas.drawImageRect(mSurface->makeImageSnapshot(), mXorExtents, mXorExtents, &paint); + // xor to surfaceBitmap + assert(surfaceBitmap.info().alphaType() == kUnpremul_SkAlphaType); + assert(mXorBitmap.info().alphaType() == kUnpremul_SkAlphaType); + assert(surfaceBitmap.bytesPerPixel() == 4); + assert(mXorBitmap.bytesPerPixel() == 4); + for (int y = mXorExtents.top(); y < mXorExtents.bottom(); ++y) { - *data++ ^= *xordata++; - *data++ ^= *xordata++; - *data++ ^= *xordata++; - // alpha is not xor-ed - data++; - xordata++; + uint8_t* data = static_cast<uint8_t*>(surfaceBitmap.getAddr(mXorExtents.x(), y)); + const uint8_t* xordata + = static_cast<uint8_t*>(mXorBitmap.getAddr(mXorExtents.x(), y)); + for (int x = 0; x < mXorExtents.width(); ++x) + { + *data++ ^= *xordata++; + *data++ ^= *xordata++; + *data++ ^= *xordata++; + // alpha is not xor-ed + data++; + xordata++; + } } + surfaceBitmap.notifyPixelsChanged(); + mSurface->getCanvas()->drawBitmapRect(surfaceBitmap, mXorExtents, mXorExtents, &paint); } - surfaceBitmap.notifyPixelsChanged(); - mSurface->getCanvas()->drawBitmapRect(surfaceBitmap, mXorExtents, mXorExtents, &paint); mXorCanvas.reset(); mXorBitmap.reset(); mXorExtents.setEmpty(); commit a0e8c9d27a7a7d5415d8555176c830e56662a95f Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Thu Mar 26 15:04:18 2020 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed Apr 1 12:49:17 2020 +0200 fix incorrect tools::Rectangle ctor usage Change-Id: I3633a5d6f3d15b8ec32a831cc0566cb66a208892 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91470 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index dedd0839a3a9..390bf521336b 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1283,9 +1283,9 @@ void SkiaSalGraphicsImpl::drawGenericLayout(const GenericSalLayout& layout, Colo preDraw(); SAL_INFO("vcl.skia.trace", "drawtextblob(" << this << "): " - << tools::Rectangle(textBlob->bounds().x(), textBlob->bounds().y(), - textBlob->bounds().width(), - textBlob->bounds().height()) + << tools::Rectangle( + Point(textBlob->bounds().x(), textBlob->bounds().y()), + Size(textBlob->bounds().width(), textBlob->bounds().height())) << ":" << textColor); SkPaint paint; paint.setColor(toSkColor(textColor)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits