[Libreoffice-commits] core.git: vcl/skia

2023-11-03 Thread Patrick Luby (via logerrit)
 vcl/skia/salbmp.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit e4821ce3e0eb814f8942b9451183b4589e901ec3
Author: Patrick Luby 
AuthorDate: Fri Nov 3 09:13:22 2023 -0400
Commit: Patrick Luby 
CommitDate: Fri Nov 3 18:33:23 2023 +0100

tdf#158014 make image immutable after using Skia to invert

I can't explain why inverting using Skia causes this bug on
macOS but not other platforms. My guess is that Skia on macOS
is sharing some data when different SkiaSalBitmap instances
are created from the same OutputDevice. So, mark this
SkiaSalBitmap instance's image as immutable so that successive
inversions are done with buffered bitmap data instead of Skia.

Change-Id: I8acf90561c48edba14a5f43d16f375f15f25820c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158880
Reviewed-by: Patrick Luby 
Reviewed-by: Noel Grandin 
Tested-by: Jenkins

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index ea5430abdf53..f82833881470 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -688,6 +688,18 @@ bool SkiaSalBitmap::Invert()
paint);
 ResetToSkImage(makeCheckedImageSnapshot(surface));
 DataChanged();
+
+#ifdef MACOSX
+// tdf#158014 make image immutable after using Skia to invert
+// I can't explain why inverting using Skia causes this bug on
+// macOS but not other platforms. My guess is that Skia on macOS
+// is sharing some data when different SkiaSalBitmap instances
+// are created from the same OutputDevice. So, mark this
+// SkiaSalBitmap instance's image as immutable so that successive
+// inversions are done with buffered bitmap data instead of Skia.
+mImageImmutable = true;
+#endif
+
 SAL_INFO("vcl.skia.trace", "invert(" << this << ")");
 return true;
 }


[Libreoffice-commits] core.git: vcl/skia

2023-10-28 Thread Patrick Luby (via logerrit)
 vcl/skia/salbmp.cxx |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 7a1250b17cb671d3f57f13842ee3df8c49f8af19
Author: Patrick Luby 
AuthorDate: Sat Oct 28 15:03:12 2023 -0400
Commit: Patrick Luby 
CommitDate: Sat Oct 28 22:45:34 2023 +0200

Fix testDelayedScaleAlphaImage unit test

Do not return the alpha mask if it is awaiting pending scaling.
Pending scaling has not yet been done at this point since the
scaling is done in the code following this block.

Change-Id: I995d7f7eca4190f0a8b2094928bd92f718f1d5bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158599
Tested-by: Jenkins
Reviewed-by: Patrick Luby 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index fe92a7a44110..13cf8aa5a4b9 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -963,7 +963,12 @@ const sk_sp& 
SkiaSalBitmap::GetAlphaSkImage(DirectImage direct) const
 // be temporary.
 SkiaSalBitmap* thisPtr = const_cast(this);
 thisPtr->mAlphaImage = alphaImage;
-return mAlphaImage;
+// Fix testDelayedScaleAlphaImage unit test
+// Do not return the alpha mask if it is awaiting pending scaling.
+// Pending scaling has not yet been done at this point since the
+// scaling is done in the code following this block.
+if (!scaling)
+return mAlphaImage;
 }
 // Move the R channel value to the alpha channel. This seems to be the 
only
 // way to reinterpret data in SkImage as an alpha SkImage without 
accessing the pixels.


[Libreoffice-commits] core.git: vcl/skia

2023-10-28 Thread Mike Kaganski (via logerrit)
 vcl/skia/salbmp.cxx |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

New commits:
commit d33f5a5783e025fe7a66bc09e1a55b4fa71d629d
Author: Mike Kaganski 
AuthorDate: Sat Oct 28 10:08:01 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sat Oct 28 10:59:51 2023 +0200

Simplify calculation

... after commit 9b5a00d2281bebaac5fccfde17de6ca5134fc229.

It passes a sanity check:

for (sal_uInt16 nGrey1 = 0; nGrey1 < 256; ++nGrey1)
{
for (sal_uInt16 nGrey2 = 0; nGrey2 < 256; ++nGrey2)
{
const sal_uInt8 n1 = static_cast(
255 - ((255 - nGrey1) + (255 - nGrey2) - (255 - nGrey1) * 
(255 - nGrey2) / 255));
const sal_uInt8 n2 = static_cast(nGrey1 * nGrey2 / 
255);
CPPUNIT_ASSERT_EQUAL(n1, n2);
}
}


Change-Id: Ib4b4e700a50027fb502767d72843b271f993f9c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158582
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 44997798db8b..fe92a7a44110 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -628,11 +628,7 @@ bool SkiaSalBitmap::AlphaBlendWith(const SalBitmap& 
rSalBmp)
 {
 const sal_uInt16 nGrey1 = mEraseColor.GetRed();
 const sal_uInt16 nGrey2 = otherBitmap->mEraseColor.GetRed();
-// Awkward calculation because the original used transparency, and to 
replicate
-// the logic we need to translate into transparency, perform the 
original logic,
-// then translate back to alpha.
-const sal_uInt8 nGrey = static_cast(
-255 - ((255 - nGrey1) + (255 - nGrey2) - (255 - nGrey1) * (255 - 
nGrey2) / 255));
+const sal_uInt8 nGrey = static_cast(nGrey1 * nGrey2 / 255);
 mEraseColor = Color(nGrey, nGrey, nGrey);
 DataChanged();
 SAL_INFO("vcl.skia.trace",


[Libreoffice-commits] core.git: vcl/skia

2023-10-27 Thread Noel Grandin (via logerrit)
 vcl/skia/salbmp.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 9b5a00d2281bebaac5fccfde17de6ca5134fc229
Author: Noel Grandin 
AuthorDate: Fri Oct 27 10:29:20 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Oct 27 21:16:30 2023 +0200

fix erase logic in SkiaSalBmp::BlendWith

regression from
commit 81994cb2b8b32453a92bcb011830fcb884f22ff3
Author: Noel Grandin 
Date:   Fri Apr 16 20:33:10 2021 +0200
Convert internal vcl bitmap formats transparency->alpha (II)

Change-Id: I5cefa51c96d412f43f73277b590fd861397eb1a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158526
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 0876efed92ed..44997798db8b 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -628,7 +628,11 @@ bool SkiaSalBitmap::AlphaBlendWith(const SalBitmap& 
rSalBmp)
 {
 const sal_uInt16 nGrey1 = mEraseColor.GetRed();
 const sal_uInt16 nGrey2 = otherBitmap->mEraseColor.GetRed();
-const sal_uInt8 nGrey = static_cast(nGrey1 + nGrey2 - 
nGrey1 * nGrey2 / 255);
+// Awkward calculation because the original used transparency, and to 
replicate
+// the logic we need to translate into transparency, perform the 
original logic,
+// then translate back to alpha.
+const sal_uInt8 nGrey = static_cast(
+255 - ((255 - nGrey1) + (255 - nGrey2) - (255 - nGrey1) * (255 - 
nGrey2) / 255));
 mEraseColor = Color(nGrey, nGrey, nGrey);
 DataChanged();
 SAL_INFO("vcl.skia.trace",


[Libreoffice-commits] core.git: vcl/skia

2023-10-11 Thread Patrick Luby (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 82ed49b81eb0a45c25f3808a7d12efd5161a
Author: Patrick Luby 
AuthorDate: Wed Oct 11 14:36:12 2023 -0400
Commit: Patrick Luby 
CommitDate: Wed Oct 11 22:46:58 2023 +0200

tdf#157613 make sure surface is not a null pointer

Change-Id: I8e3c1be3f05f7ccc1f3ba00093cd71a564e5ae9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157848
Reviewed-by: Patrick Luby 
Tested-by: Patrick Luby 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 752208c0bc41..c4bd75184242 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -224,6 +224,11 @@ bool 
AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
 const tools::Rectangle& 
rControlRegion,
 ControlState nState, const 
ImplControlValue& aValue)
 {
+// tdf#157613 make sure surface is not a nullptr
+checkSurface();
+if (!mSurface)
+return false;
+
 // rControlRegion is not the whole area that the control should be painted 
to (e.g. highlight
 // around focused lineedit is outside of it). Since we draw to a temporary 
bitmap, we need tofind out
 // the real size. Using getNativeControlRegion() might seem like the 
function to call, but we need


[Libreoffice-commits] core.git: vcl/skia

2023-09-27 Thread Patrick Luby (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |   21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

New commits:
commit d43e2a9214c0d06465a3027231948760e65ad4ee
Author: Patrick Luby 
AuthorDate: Wed Sep 27 10:29:05 2023 -0400
Commit: Patrick Luby 
CommitDate: Wed Sep 27 19:25:59 2023 +0200

Let SkBitmap determine when it is safe to delete the pixel buffer

Also, make bitmap immutable to avoid making a copy in bitmap.asImage()
and, just to be safe, flush the canvas after drawing the pixel buffer.

Change-Id: I3ac99cf4acf0bf4c8b274dc73295ca7b9f386c70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157333
Tested-by: Jenkins
Reviewed-by: Patrick Luby 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index abe9befb2fce..e64f84b111bc 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -37,6 +37,13 @@
 
 using namespace SkiaHelper;
 
+static void releaseInstalledPixels(void* pAddr, void* pContext)
+{
+(void)pContext;
+if (pAddr)
+delete[] static_cast(pAddr);
+}
+
 AquaSkiaSalGraphicsImpl::AquaSkiaSalGraphicsImpl(AquaSalGraphics& rParent,
  AquaSharedAttributes& rShared)
 : SkiaSalGraphicsImpl(rParent, rShared.mpFrame)
@@ -232,10 +239,10 @@ bool 
AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
 const tools::Long width = boundingRegion.GetWidth() * mScaling;
 const tools::Long height = boundingRegion.GetHeight() * mScaling;
 const size_t bytes = width * height * 4;
-std::unique_ptr data(new sal_uInt8[bytes]);
-memset(data.get(), 0, bytes);
+sal_uInt8* data = new sal_uInt8[bytes];
+memset(data, 0, bytes);
 CGContextRef context = CGBitmapContextCreate(
-data.get(), width, height, 8, width * 4, GetSalData()->mxRGBSpace,
+data, width, height, 8, width * 4, GetSalData()->mxRGBSpace,
 SkiaToCGBitmapType(mSurface->imageInfo().colorType(), 
kPremul_SkAlphaType));
 if (!context)
 {
@@ -271,13 +278,17 @@ bool 
AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
 CGContextRelease(context);
 if (bOK)
 {
+// Let SkBitmap determine when it is safe to delete the pixel buffer
 SkBitmap bitmap;
 if (!bitmap.installPixels(SkImageInfo::Make(width, height,
 
mSurface->imageInfo().colorType(),
 kPremul_SkAlphaType),
-  data.get(), width * 4))
+  data, width * 4, releaseInstalledPixels, 
nullptr))
 abort();
 
+// Make bitmap immutable to avoid making a copy in bitmap.asImage()
+bitmap.setImmutable();
+
 preDraw();
 SAL_INFO("vcl.skia.trace", "drawnativecontrol(" << this << "): " << 
rControlRegion << ":"
 << int(nType) << "/" 
<< int(nPart));
@@ -292,6 +303,8 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType 
nType, ControlPart n
boundingRegion.GetWidth(), 
boundingRegion.GetHeight());
 assert(drawRect.width() * mScaling == bitmap.width()); // no scaling 
should be needed
 getDrawCanvas()->drawImageRect(bitmap.asImage(), drawRect, 
SkSamplingOptions());
+// Related: tdf#156881 flush the canvas after drawing the pixel buffer
+getDrawCanvas()->flush();
 ++pendingOperationsToFlush; // tdf#136369
 postDraw();
 }


[Libreoffice-commits] core.git: vcl/skia

2023-09-22 Thread Patrick Luby (via logerrit)
 vcl/skia/gdiimpl.cxx |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit f4c2c7c79cfe4464ac596afda37b8904d06969db
Author: Patrick Luby 
AuthorDate: Thu Sep 21 20:20:33 2023 -0400
Commit: Patrick Luby 
CommitDate: Fri Sep 22 15:03:43 2023 +0200

tdf#157312 Don't change priority

Instances of this class are constructed with
TaskPriority::POST_PAINT, but then it was set to
TaskPriority::HIGHEST when reused. Flushing
seems to be expensive (at least with Skia/Metal) so keep the
existing priority when reused.

Change-Id: Ieb40cd6122f543f76e66456cc92a8643e2320d73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157162
Tested-by: Jenkins
Reviewed-by: Patrick Luby 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 3f42546b930d..e4e71798da48 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -268,7 +268,13 @@ public:
 {
 mpGraphics->performFlush();
 Stop();
-SetPriority(TaskPriority::HIGHEST);
+// tdf#157312 Don't change priority
+// Instances of this class are constructed with
+// TaskPriority::POST_PAINT, but then it was set to
+// TaskPriority::HIGHEST when reused. Flushing
+// seems to be expensive (at least with Skia/Metal) so keep the
+// existing priority when reused.
+SetPriority(TaskPriority::POST_PAINT);
 }
 };
 


[Libreoffice-commits] core.git: vcl/skia

2023-08-31 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 8109a05543e16a5a499bf3ddc9d45b7c979480bc
Author: Julien Nabet 
AuthorDate: Thu Aug 31 12:33:45 2023 +0200
Commit: Julien Nabet 
CommitDate: Thu Aug 31 17:25:14 2023 +0200

Related tdf#156986: blacklist Nvidia RTX 4070 for Skia hardware rendering

Change-Id: I3f59be1f5501684238a5ccd2736509afe7ac8d57
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156334
Reviewed-by: Julien Nabet 
Tested-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 2bb3b73bb747..8da86069fc46 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -48,6 +48,9 @@
  
 
 
+ 
+
+
  
 
 


[Libreoffice-commits] core.git: vcl/skia vcl/source

2023-08-24 Thread Patrick Luby (via logerrit)
 vcl/skia/salbmp.cxx|   12 
 vcl/source/bitmap/alpha.cxx|   14 ++
 vcl/source/gdi/pdfwriter_impl2.cxx |6 ++
 3 files changed, 28 insertions(+), 4 deletions(-)

New commits:
commit 462f1c43cc97eb5c13343f285516702aa0c47a8d
Author: Patrick Luby 
AuthorDate: Wed Aug 23 17:22:55 2023 -0400
Commit: Patrick Luby 
CommitDate: Thu Aug 24 15:14:43 2023 +0200

tdf#156866 use mSize instead of mPixelSize for inverted surface

Commit 5baac4e53128d3c0fc73b9918dc9a9c2777ace08 switched to setting
the surface size to mPixelsSize in an attempt to avoid downscaling
mImage but since it causes tdf#156866, revert back to setting the
surface size to mSize.

Also, in release builds, tdf#156629 and tdf#156630 reappear in many
cases because a BitmapInfoAccess is in a debug block. So, instead
of relying on other code to a create a BitmapInfoAccess instance,
create one here to force the alpha mask to handle any pending
scaling and make the alpha mask immutable.

Change-Id: If9f0dfb7b9a82cf7a3e402965ceffd42eace4c82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156022
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
Reviewed-by: Patrick Luby 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 2aa9a0a69cee..0876efed92ed 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -672,15 +672,19 @@ bool SkiaSalBitmap::Invert()
 if (!mBuffer && mImage && !mImageImmutable && !mEraseColorSet)
 {
 // This is 8-bit bitmap serving as alpha/transparency/mask, so the 
image itself needs no alpha.
-// Use pixels size so that we don't downscale the image
-sk_sp surface = createSkSurface(mPixelsSize, 
kOpaque_SkAlphaType);
+// tdf#156866 use mSize instead of mPixelSize for inverted surface
+// Commit 5baac4e53128d3c0fc73b9918dc9a9c2777ace08 switched to setting
+// the surface size to mPixelsSize in an attempt to avoid downscaling
+// mImage but since it causes tdf#156866, revert back to setting the
+// surface size to mSize.
+sk_sp surface = createSkSurface(mSize, kOpaque_SkAlphaType);
 surface->getCanvas()->clear(SK_ColorWHITE);
 SkPaint paint;
 paint.setBlendMode(SkBlendMode::kDifference);
 // Drawing the image does not work so create a shader from the image
 paint.setShader(GetSkShader(SkSamplingOptions()));
-surface->getCanvas()->drawRect(
-SkRect::MakeXYWH(0, 0, mPixelsSize.Width(), mPixelsSize.Height()), 
paint);
+surface->getCanvas()->drawRect(SkRect::MakeXYWH(0, 0, mSize.Width(), 
mSize.Height()),
+   paint);
 ResetToSkImage(makeCheckedImageSnapshot(surface));
 DataChanged();
 SAL_INFO("vcl.skia.trace", "invert(" << this << ")");
diff --git a/vcl/source/bitmap/alpha.cxx b/vcl/source/bitmap/alpha.cxx
index ff0d035d52d1..cb8be28664d4 100644
--- a/vcl/source/bitmap/alpha.cxx
+++ b/vcl/source/bitmap/alpha.cxx
@@ -25,6 +25,10 @@
 #include 
 #include 
 #include 
+#if HAVE_FEATURE_SKIA
+#include 
+#endif
+
 
 AlphaMask::AlphaMask() = default;
 
@@ -34,6 +38,16 @@ AlphaMask::AlphaMask( const Bitmap& rBitmap ) :
 // no need to do any conversion if it is already an AlphaMask
 if ( typeid(rBitmap) != typeid(AlphaMask) && !rBitmap.IsEmpty() )
 Convert( BmpConversion::N8BitNoConversion );
+#if HAVE_FEATURE_SKIA
+// Related tdf#156866 force snapshot of alpha mask when using Skia
+// In release builds, tdf#156629 and tdf#156630 reappear in many
+// cases because a BitmapInfoAccess is in a debug block. So, instead
+// of relying on other code to a create a BitmapInfoAccess instance,
+// create one here to force the alpha mask to handle any pending
+// scaling and make the alpha mask immutable.
+else if ( SkiaHelper::isVCLSkiaEnabled() )
+BitmapInfoAccess aInfoAccess( *this );
+#endif
 assert( (IsEmpty() || getPixelFormat() == vcl::PixelFormat::N8_BPP) && 
"alpha bitmap should be 8bpp" );
 assert( (IsEmpty() || HasGreyPalette8Bit()) && "alpha bitmap should have 
greyscale palette" );
 }
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx 
b/vcl/source/gdi/pdfwriter_impl2.cxx
index cd46a6a2e9fe..37583d0b01d1 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -509,7 +509,13 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& 
i_rMtf, vcl::PDFExtOutDevDa
 aAlpha.Invert(); // convert to alpha
 aAlpha.BlendWith(aPaintAlpha);
 #if HAVE_FEATURE_SKIA
+#if OSL_DEBUG_LEVEL > 0
+// In release builds, we always invert
+// regardless of whether Skia is enabled or 
not.
+// But in debug builds, we can't invert when
+// Skia is 

[Libreoffice-commits] core.git: vcl/skia

2023-08-23 Thread Patrick Luby (via logerrit)
 vcl/skia/osx/bitmap.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 2f5bc5989bab384fee066d0346eb7312f4a58d2a
Author: Patrick Luby 
AuthorDate: Wed Aug 23 08:32:48 2023 -0400
Commit: Patrick Luby 
CommitDate: Wed Aug 23 16:48:44 2023 +0200

tdf#156854 invert alpha mask for macOS native menu item images

At the time of this change, only the AquaSalMenu class calls this
function so it should be safe to invert the alpha mask here.

Change-Id: Id67ad0f453bbf88b43d37087eef36a27ced3ad37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155977
Tested-by: Jenkins
Reviewed-by: Patrick Luby 

diff --git a/vcl/skia/osx/bitmap.cxx b/vcl/skia/osx/bitmap.cxx
index 1052efc32de7..edb339ce5292 100644
--- a/vcl/skia/osx/bitmap.cxx
+++ b/vcl/skia/osx/bitmap.cxx
@@ -63,6 +63,10 @@ CGImageRef createCGImage(const Image& rImage)
 else
 {
 AlphaMask alpha(bitmapEx.GetAlphaMask());
+// tdf#156854 invert alpha mask for macOS native menu item images
+// At the time of this change, only the AquaSalMenu class calls this
+// function so it should be safe to invert the alpha mask here.
+alpha.Invert();
 Bitmap alphaBitmap(alpha.GetBitmap());
 
assert(dynamic_cast(alphaBitmap.ImplGetSalBitmap().get()) != 
nullptr);
 SkiaSalBitmap* skiaAlpha


[Libreoffice-commits] core.git: vcl/skia

2023-08-17 Thread Mike Kaganski (via logerrit)
 vcl/skia/salbmp.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 5ca28013a5ceb1b633fd4df8f9451778be5f1734
Author: Mike Kaganski 
AuthorDate: Thu Aug 17 17:33:22 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Aug 17 22:27:44 2023 +0200

Skia: Avoid assertion failure inside ProcessAndBlurAlphaMask

As seen opening https://bugs.documentfoundation.org/attachment.cgi?id=182024
from tdf#150610.

The upscale is pending, and SkiaSalBitmap::mImage is empty here;
EnsureBitmapData call works correctly in this case.

Change-Id: I71575b09b3b4513b06b55271f6440688785cfb84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155792
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index b5da2e4bd432..eac913671384 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -235,7 +235,8 @@ BitmapBuffer* SkiaSalBitmap::AcquireBuffer(BitmapAccessMode 
nMode)
 // set otherwise exporting the following animated .png image will
 // fail:
 //   https://bugs.documentfoundation.org/attachment.cgi?id=188792
-if ((mPixelsSize != mSize || getenv("SAL_FORCE_HIDPI_SCALING")) && 
mImage)
+static const bool bForceHiDPIScaling = 
getenv("SAL_FORCE_HIDPI_SCALING") != nullptr;
+if (mPixelsSize != mSize || (bForceHiDPIScaling && mImage))
 EnsureBitmapData();
 assert(mPixelsSize == mSize);
 break;


[Libreoffice-commits] core.git: vcl/skia

2023-07-25 Thread Noel Grandin (via logerrit)
 vcl/skia/salbmp.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c49b377798f5abd0e30acc32d562f63481daa287
Author: Noel Grandin 
AuthorDate: Tue Jul 25 10:03:14 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 25 11:10:58 2023 +0200

loplugin:redundantcast

after
commit 81994cb2b8b32453a92bcb011830fcb884f22ff3
Author: Noel Grandin 
Date:   Fri Apr 16 20:33:10 2021 +0200
Convert internal vcl bitmap formats transparency->alpha (II)

Change-Id: Ia0b29e87696b99459c62275898e1ec47283072b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154883
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 5a514aebb05d..8e07a00ec2d2 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -646,7 +646,7 @@ bool SkiaSalBitmap::Invert()
 SkPaint paint;
 paint.setBlendMode(SkBlendMode::kDifference);
 // Drawing the image does not work so create a shader from the image
-paint.setShader(GetSkShader(SkSamplingOptions(SkSamplingOptions(;
+paint.setShader(GetSkShader(SkSamplingOptions()));
 surface->getCanvas()->drawRect(SkRect::MakeXYWH(0, 0, mSize.Width(), 
mSize.Height()),
paint);
 ResetToSkImage(makeCheckedImageSnapshot(surface));


[Libreoffice-commits] core.git: vcl/skia

2023-07-17 Thread Aron Budea (via logerrit)
 vcl/skia/gdiimpl.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 4202dfcae19ee47e9a3fda02fac34c18cb0d16ff
Author: Aron Budea 
AuthorDate: Sun Jul 16 17:25:55 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jul 18 06:50:30 2023 +0200

tdf#155661 Apply border from center point not from whole size

Regression from 6965bb07bb33429a7663a3f3ebe58ed89c4327d9
and 8b8a988f38b704e466211bb91a3269756c34222b.

Change-Id: I2e8c21fbdbbc7efb4b473c63b098044384a70d6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154501
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 3c0957be4806..45f3fc1c1b97 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -2049,8 +2049,8 @@ bool SkiaSalGraphicsImpl::drawGradient(const 
tools::PolyPolygon& rPolyPolygon,
   SkPoint::Make(toSkX(aPoly[1].X()), 
toSkY(aPoly[1].Y())) };
 SkColor colors[3] = { endColor, startColor, endColor };
 SkScalar border = SkDoubleToScalar(aGradient.GetBorder() / 100.0);
-SkScalar pos[3]
-= { std::min(border, 0.5), 0.5, std::max(1 - 
border, 0.5) };
+SkScalar pos[3] = { std::min(border * 0.5f, 0.5f), 0.5f,
+std::max(1 - border * 0.5f, 0.5f) };
 shader = SkGradientShader::MakeLinear(points, colors, pos, 3, 
SkTileMode::kClamp);
 }
 else


[Libreoffice-commits] core.git: vcl/skia

2023-07-10 Thread Justin Luth (via logerrit)
 vcl/skia/SkiaHelper.cxx |2 +-
 vcl/skia/x11/textrender.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 6ed4c4a1b008e7bd4917d9cca255c862fbcd08aa
Author: Justin Luth 
AuthorDate: Mon Jul 10 07:53:23 2023 -0400
Commit: Noel Grandin 
CommitDate: Mon Jul 10 15:55:11 2023 +0200

fix build: SkiaHelper.cxx missed W on -Wunused-parameter

The error message was
vcl/skia/SkiaHelper.cxx:75:32: error: ‘-unused-parameter’
is not an option that controls warnings [-Werror=pragmas]
   75 | #pragma GCC diagnostic ignored "-unused-parameter"

This fixes commit f8c15850dbfaa46605e1e353ae1f49e69184e8a1
for gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

Change-Id: Iae927e6c794e09cdab2d0fbd30a84a631800c9a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154247
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index ec668315ef62..a8332cfe7e1d 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -72,7 +72,7 @@ bool isVCLSkiaEnabled() { return false; }
 #endif
 #if defined __GNUC__ && !defined __clang__
 #pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-unused-parameter"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
 #endif
 #include 
 #if defined __GNUC__ && !defined __clang__
diff --git a/vcl/skia/x11/textrender.cxx b/vcl/skia/x11/textrender.cxx
index 81d6efa670c9..c0bbb102f5d8 100644
--- a/vcl/skia/x11/textrender.cxx
+++ b/vcl/skia/x11/textrender.cxx
@@ -25,7 +25,7 @@
 #endif
 #if defined __GNUC__ && !defined __clang__
 #pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-unused-value"
+#pragma GCC diagnostic ignored "-Wunused-value"
 #endif
 
 #include 


[Libreoffice-commits] core.git: vcl/skia

2023-07-04 Thread Noel Grandin (via logerrit)
 vcl/skia/salbmp.cxx |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

New commits:
commit d697e25846433c3a589228262cf8d0f7b6f5fd7e
Author: Noel Grandin 
AuthorDate: Tue Jul 4 10:41:14 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 4 12:14:31 2023 +0200

remove skia workaround

No longer necessary since

commit 9c9a711ac5d8f32ac318d0e4ecab7b3a26bc2150
Author: Noel Grandin 
Date:   Fri Jan 27 10:48:45 2023 +0200
Update skia to m111

Change-Id: Icfef07ed3683e84bdd8b94350f40ea83e95bf324
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153948
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 1ce85dd0e837..97609c11d125 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -888,10 +888,7 @@ const sk_sp& 
SkiaSalBitmap::GetAlphaSkImage(DirectImage direct) const
 SkiaZone zone;
 const bool scaling = imageSize(mImage) != mSize;
 SkPixmap pixmap;
-// Note: We cannot do this when 'scaling' because 
SkCanvas::drawImageRect()
-// with kAlpha_8_SkColorType as source and destination would act as 
SkBlendMode::kSrcOver
-// despite SkBlendMode::kSrc set 
(https://bugs.chromium.org/p/skia/issues/detail?id=9692).
-if (mImage->peekPixels() && !scaling)
+if (mImage->peekPixels())
 {
 assert(pixmap.colorType() == kN32_SkColorType);
 // In non-GPU mode, convert 32bit data to 8bit alpha, this is 
faster than


[Libreoffice-commits] core.git: vcl/skia

2023-06-21 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 10cf2e7da6048eca7526149f4a2c824e7c3cfdfe
Author: Julien Nabet 
AuthorDate: Wed Jun 21 11:03:21 2023 +0200
Commit: Julien Nabet 
CommitDate: Wed Jun 21 15:59:30 2023 +0200

Related tdf#155143: blacklist Nvidia GTX 960M for Skia hardware rendering

Change-Id: I1404ef059de9781f1fe8123a880a70495b159a87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153383
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 5c63283d9720..2bb3b73bb747 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -54,6 +54,9 @@
  
 
 
+ 
+
+
  
 
 


[Libreoffice-commits] core.git: vcl/skia

2023-05-07 Thread Caolán McNamara (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 863d7317a16bdc5a491a1284386abe3dd1f09469
Author: Caolán McNamara 
AuthorDate: Sun May 7 15:13:05 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 7 17:23:46 2023 +0200

crash seen with empty moLineColor on macOS with skia

Change-Id: I260f6bd060b9f1ec3a782ff765b676f78d126d40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151461
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index e9c2e67fd1a4..fd0bdca04333 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -241,12 +241,18 @@ bool 
AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
 // Setup context state for drawing (performDrawNativeControl() e.g. fills 
background in some cases).
 CGContextSetFillColorSpace(context, GetSalData()->mxRGBSpace);
 CGContextSetStrokeColorSpace(context, GetSalData()->mxRGBSpace);
-RGBAColor lineColor(*moLineColor);
-CGContextSetRGBStrokeColor(context, lineColor.GetRed(), 
lineColor.GetGreen(),
-   lineColor.GetBlue(), lineColor.GetAlpha());
-RGBAColor fillColor(*moFillColor);
-CGContextSetRGBFillColor(context, fillColor.GetRed(), 
fillColor.GetGreen(), fillColor.GetBlue(),
- fillColor.GetAlpha());
+if (moLineColor)
+{
+RGBAColor lineColor(*moLineColor);
+CGContextSetRGBStrokeColor(context, lineColor.GetRed(), 
lineColor.GetGreen(),
+   lineColor.GetBlue(), lineColor.GetAlpha());
+}
+if (moFillColor)
+{
+RGBAColor fillColor(*moFillColor);
+CGContextSetRGBFillColor(context, fillColor.GetRed(), 
fillColor.GetGreen(),
+ fillColor.GetBlue(), fillColor.GetAlpha());
+}
 // Adjust for our drawn-to coordinates in the bitmap.
 tools::Rectangle movedRegion(Point(rControlRegion.getX() - 
boundingRegion.getX(),
rControlRegion.getY() - 
boundingRegion.getY()),


[Libreoffice-commits] core.git: vcl/skia

2023-03-26 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 4938bbcd64e95c9b494bcc32e8a5be3706f00cfa
Author: Julien Nabet 
AuthorDate: Sun Mar 26 11:23:48 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Mar 26 10:28:34 2023 +

tdf#154378: blacklist GeForce RTX 3080 for Skia hardware rendering

Change-Id: I0dc4e0fd34737613a45eb358449a7cfb12467bbe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149617
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 3c77f3c5ad59..ee79abe6a61f 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -48,6 +48,9 @@
  
 
 
+ 
+
+
 
 
 


[Libreoffice-commits] core.git: vcl/skia

2023-03-07 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit c0ed486d96fca70704a7f7e24199de9c663003cc
Author: Julien Nabet 
AuthorDate: Tue Mar 7 22:34:50 2023 +0100
Commit: Julien Nabet 
CommitDate: Wed Mar 8 05:38:28 2023 +

tdf#153538: blacklist GeForce GTX 1070 Ti for Skia hardware rendering

Change-Id: I4ec53d9bcde229f3df3f19e952536ba64e1dc3d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148447
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 5ac2c426594c..3c77f3c5ad59 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -45,6 +45,9 @@
  
 
 
+ 
+
+
 
 
 


[Libreoffice-commits] core.git: vcl/skia

2023-03-03 Thread Mike Kaganski (via logerrit)
 vcl/skia/gdiimpl.cxx |   20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

New commits:
commit ebee2930a3558c5eb8921e1b5f3e275702f8a64f
Author: Mike Kaganski 
AuthorDate: Fri Mar 3 14:00:06 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 3 12:07:29 2023 +

Fix SAL_INFO dereferencing optionals

Change-Id: I6d8ec4cd481284a42db33bf85ec7770fbb89cf83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148168
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 0ffafb040a46..f26b2d26711b 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -41,6 +41,8 @@
 #include 
 
 #include 
+#include 
+
 #include 
 #include 
 #include 
@@ -216,6 +218,17 @@ bool checkInvalidSourceOrDestination(SalTwoRect const& 
rPosAry)
|| rPosAry.mnDestHeight <= 0;
 }
 
+std::string dumpOptionalColor(const std::optional& c)
+{
+std::ostringstream oss;
+if (c)
+oss << *c;
+else
+oss << "no color";
+
+return std::move(oss).str(); // optimized in C++20
+}
+
 } // end anonymous namespace
 
 // Class that triggers flushing the backing buffer when idle.
@@ -738,8 +751,8 @@ void SkiaSalGraphicsImpl::privateDrawAlphaRect(tools::Long 
nX, tools::Long nY, t
 preDraw();
 SAL_INFO("vcl.skia.trace", "privatedrawrect("
<< this << "): " << SkIRect::MakeXYWH(nX, 
nY, nWidth, nHeight)
-   << ":" << *moLineColor << ":" << 
*moFillColor << ":"
-   << fTransparency);
+   << ":" << dumpOptionalColor(moLineColor) << 
":"
+   << dumpOptionalColor(moFillColor) << ":" << 
fTransparency);
 addUpdateRegion(SkRect::MakeXYWH(nX, nY, nWidth, nHeight));
 SkCanvas* canvas = getDrawCanvas();
 if (moFillColor)
@@ -840,7 +853,8 @@ bool SkiaSalGraphicsImpl::drawPolyPolygon(const 
basegfx::B2DHomMatrix& rObjectTo
 aPolyPolygon.transform(rObjectToDevice);
 
 SAL_INFO("vcl.skia.trace", "drawpolypolygon(" << this << "): " << 
aPolyPolygon << ":"
-  << *moLineColor << ":" << 
*moFillColor);
+  << 
dumpOptionalColor(moLineColor) << ":"
+  << 
dumpOptionalColor(moFillColor));
 
 if (delayDrawPolyPolygon(aPolyPolygon, fTransparency))
 {


[Libreoffice-commits] core.git: vcl/skia

2022-12-17 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit f7b94d7ffd785470962e73408f6fd7f7728f8ec5
Author: Julien Nabet 
AuthorDate: Sat Dec 17 13:18:59 2022 +0100
Commit: Julien Nabet 
CommitDate: Sat Dec 17 13:13:46 2022 +

tdf#151627 + tdf#152559: blacklist Nvidia device id="0x1402"

Change-Id: I37430b38cd8d5daaca39b783c59bc10cd571c552
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144377
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 8170f60febcc..5ac2c426594c 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -42,6 +42,9 @@
  
 
 
+ 
+
+
 
 
 


[Libreoffice-commits] core.git: vcl/skia

2022-12-14 Thread Patrick Luby (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |   49 +--
 1 file changed, 39 insertions(+), 10 deletions(-)

New commits:
commit 9ec57a3dc7925d6f86a19d0e179e065df53e542f
Author: Patrick Luby 
AuthorDate: Wed Dec 14 13:11:57 2022 -0500
Commit: Noel Grandin 
CommitDate: Thu Dec 15 05:33:36 2022 +

tdf#145843 Do not use CGBitmapContextCreate() to create a bitmap context

As described in the comment in the above code, CGBitmapContextCreate()
and CGBitmapContextCreateWithData() will try to access pixels up to
mDirtyRect.x() + pixmap.bounds.width() for each row. When reading the
last line in the SkPixmap, the buffer allocated for the SkPixmap ends at
mDirtyRect.x() + mDirtyRect.width() and mDirtyRect.width() is clamped to
pixmap.bounds.width() - mDirtyRect.x().

This behavior looks like an optimization within CGBitmapContextCreate()
to draw with a single memcpy() so fix this bug by chaining the
CGDataProvider(), CGImageCreate(), and CGImageCreateWithImageInRect()
functions to create the screen image.

Change-Id: Ic83f6162f8eb63de22693c0c40015da3b88aee65
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144194
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 38927e92c9ca..9d3765c3cc03 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -142,7 +142,7 @@ void AquaSkiaSalGraphicsImpl::flushSurfaceToScreenCG()
 if (pixmap.bounds() != mDirtyRect && pixmap.bounds().bottom() == 
mDirtyRect.bottom())
 {
 // HACK for tdf#145843: If mDirtyRect includes the last line but not 
the first pixel of it,
-// then the rowBytes() trick would lead to the GC* functions thinking 
that even pixels after
+// then the rowBytes() trick would lead to the CG* functions thinking 
that even pixels after
 // the pixmap data belong to the area (since the shifted 
x()+rowBytes() points there) and
 // at least on Intel Mac they would actually read those data, even 
though I see no good reason
 // to do that, as that's beyond the x()+width() for the last line. 
That could be handled
@@ -151,22 +151,49 @@ void AquaSkiaSalGraphicsImpl::flushSurfaceToScreenCG()
 mDirtyRect.fLeft = 0;
 assert(mDirtyRect.width() == pixmap.bounds().width());
 }
-CGContextRef context = CGBitmapContextCreate(
-pixmap.writable_addr32(mDirtyRect.x() * mScaling, mDirtyRect.y() * 
mScaling),
-mDirtyRect.width() * mScaling, mDirtyRect.height() * mScaling, 8, 
pixmap.rowBytes(),
-GetSalData()->mxRGBSpace, toCGBitmapType(image->colorType(), 
image->alphaType()));
-if (!context)
+
+// tdf#145843 Do not use CGBitmapContextCreate() to create a bitmap context
+// As described in the comment in the above code, CGBitmapContextCreate()
+// and CGBitmapContextCreateWithData() will try to access pixels up to
+// mDirtyRect.x() + pixmap.bounds.width() for each row. When reading the
+// last line in the SkPixmap, the buffer allocated for the SkPixmap ends at
+// mDirtyRect.x() + mDirtyRect.width() and mDirtyRect.width() is clamped to
+// pixmap.bounds.width() - mDirtyRect.x().
+// This behavior looks like an optimization within CGBitmapContextCreate()
+// to draw with a single memcpy() so fix this bug by chaining the
+// CGDataProvider(), CGImageCreate(), and CGImageCreateWithImageInRect()
+// functions to create the screen image.
+CGDataProviderRef dataProvider = CGDataProviderCreateWithData(
+nullptr, pixmap.writable_addr32(0, 0), pixmap.computeByteSize(), 
nullptr);
+if (!dataProvider)
 {
-SAL_WARN("vcl.skia", "flushSurfaceToScreenGC(): Failed to allocate 
bitmap context");
+SAL_WARN("vcl.skia", "flushSurfaceToScreenGC(): Failed to allocate 
data provider");
 return;
 }
-CGImageRef screenImage = CGBitmapContextCreateImage(context);
+
+CGImageRef fullImage = CGImageCreate(pixmap.bounds().width(), 
pixmap.bounds().height(), 8,
+ 8 * 
image->imageInfo().bytesPerPixel(), pixmap.rowBytes(),
+ GetSalData()->mxRGBSpace,
+ toCGBitmapType(image->colorType(), 
image->alphaType()),
+ dataProvider, nullptr, false, 
kCGRenderingIntentDefault);
+if (!fullImage)
+{
+CGDataProviderRelease(dataProvider);
+SAL_WARN("vcl.skia", "flushSurfaceToScreenGC(): Failed to allocate 
full image");
+return;
+}
+
+CGImageRef screenImage = CGImageCreateWithImageInRect(
+fullImage, CGRectMake(mDirtyRect.x() * mScaling, mDirtyRect.y() * 
mScaling,
+  mDirtyRect.width() * mScaling, 
mDirtyRect.height() * mScaling));
 if (!screenImage)
 {
-CGContextRelease(context);
+   

[Libreoffice-commits] core.git: vcl/skia

2022-11-09 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit a0dec4bc9a48b263be182ad7bbe4ba3f8cbb27e1
Author: Julien Nabet 
AuthorDate: Wed Nov 9 13:57:08 2022 +0100
Commit: Julien Nabet 
CommitDate: Wed Nov 9 17:55:12 2022 +0100

tdf#151929: crash if video card changed (Win nVidia GTX 670)

Change-Id: I9566487ed8353674d623cd270c85edcdbfa263b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142486
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 39163fc9a71e..8170f60febcc 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -36,6 +36,9 @@
 
 
 
+ 
+
+
  
 
 


[Libreoffice-commits] core.git: vcl/skia

2022-09-07 Thread Xisco Fauli (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |6 --
 1 file changed, 6 deletions(-)

New commits:
commit ce79edd7e79c28516ba43814e4f900b2c05ab23a
Author: Xisco Fauli 
AuthorDate: Wed Sep 7 08:24:21 2022 +0200
Commit: Julien Nabet 
CommitDate: Wed Sep 7 18:04:04 2022 +0200

Revert "tdf#150555: Skia seems to fail with Windows 8/8.1"

This reverts commit e2a16489ff4a65e747e93b28d39096cb259bddd7.

Reason for revert: See discussion in 
https://gerrit.libreoffice.org/c/core/+/138549

Change-Id: I9ad22c594478d11e1eb062f69d83ce6b55b09eaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139554
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index ee7ca9e01e02..39163fc9a71e 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -42,11 +42,5 @@
 
 
 
-
-
-
-
-
-
 
 


[Libreoffice-commits] core.git: vcl/skia vcl/unx

2022-09-05 Thread Caolán McNamara (via logerrit)
 vcl/skia/osx/gdiimpl.cxx|4 
 vcl/skia/win/gdiimpl.cxx|4 
 vcl/skia/x11/textrender.cxx |2 ++
 vcl/unx/generic/gdi/cairotextrender.cxx |   21 +++--
 4 files changed, 25 insertions(+), 6 deletions(-)

New commits:
commit 4059cb5dbec67d17a636b03e6f6344ca313516fa
Author: Caolán McNamara 
AuthorDate: Sun Sep 4 21:26:22 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Sep 5 16:02:29 2022 +0200

tdf#150507 like skia, even when subpixel rendering snap to a pixel Baseline

Change-Id: Iaf064b483d65d25251f733cc6a67d9f1863bb64c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139380
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index f8bcdd68352e..ffc84ae89006 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -313,7 +313,11 @@ void AquaSkiaSalGraphicsImpl::drawTextLayout(const 
GenericSalLayout& rLayout,
 SkFont::Edging ePreferredAliasing
 = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
SkFont::Edging::kAntiAlias;
 if (bSubpixelPositioning)
+{
+// note that SkFont defaults to a BaselineSnap of true, so I think 
really only
+// subpixel in text direction
 font.setSubpixel(true);
+}
 font.setEdging(mrShared.mbNonAntialiasedText ? SkFont::Edging::kAlias : 
ePreferredAliasing);
 
 // Vertical font, use width as "height".
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 27a915db1f93..692ad36b9eb2 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -271,7 +271,11 @@ bool WinSkiaSalGraphicsImpl::DrawTextLayout(const 
GenericSalLayout& rLayout)
 SkFont::Edging ePreferredAliasing
 = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
fontEdging;
 if (bSubpixelPositioning)
+{
+// note that SkFont defaults to a BaselineSnap of true, so I think 
really only
+// subpixel in text direction
 font.setSubpixel(true);
+}
 font.setEdging(logFont.lfQuality == NONANTIALIASED_QUALITY ? 
SkFont::Edging::kAlias
: 
ePreferredAliasing);
 
diff --git a/vcl/skia/x11/textrender.cxx b/vcl/skia/x11/textrender.cxx
index 7be518e96c92..153551e12ddd 100644
--- a/vcl/skia/x11/textrender.cxx
+++ b/vcl/skia/x11/textrender.cxx
@@ -60,6 +60,8 @@ void SkiaTextRender::DrawTextLayout(const GenericSalLayout& 
rLayout, const SalGr
 = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
SkFont::Edging::kAntiAlias;
 if (bSubpixelPositioning)
 {
+// note that SkFont defaults to a BaselineSnap of true, so I think 
really only
+// subpixel in text direction
 font.setSubpixel(true);
 
 SkFontHinting eHinting = font.getHinting();
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 3f43591b97a3..1e971bf37efe 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -165,6 +165,8 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
 const FreetypeFontInstance& rInstance = 
static_cast(rLayout.GetFont());
 const FreetypeFont& rFont = rInstance.GetFreetypeFont();
 
+const bool bResolutionIndependentLayoutEnabled = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
+
 std::vector cairo_glyphs;
 std::vector glyph_extrarotation;
 cairo_glyphs.reserve( 256 );
@@ -178,12 +180,20 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
 aGlyph.index = pGlyph->glyphId();
 aGlyph.x = aPos.getX();
 aGlyph.y = aPos.getY();
-cairo_glyphs.push_back(aGlyph);
 
-if (pGlyph->IsVertical())
-glyph_extrarotation.push_back(1);
-else
-glyph_extrarotation.push_back(0);
+const bool bVertical = pGlyph->IsVertical();
+glyph_extrarotation.push_back(bVertical ? 1 : 0);
+
+// tdf#150507 like skia even when subpixel rendering snap to a pixel 
Baseline
+if (bResolutionIndependentLayoutEnabled)
+{
+if (!bVertical)
+aGlyph.y = std::floor(aGlyph.y + 0.5);
+else
+aGlyph.x = std::floor(aGlyph.x + 0.5);
+}
+
+cairo_glyphs.push_back(aGlyph);
 }
 
 if (cairo_glyphs.empty())
@@ -226,7 +236,6 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
 
 const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
 const bool bDisableAA = !rStyleSettings.GetUseFontAAFromSystem() && 
!rGraphics.getAntiAlias();
-const bool bResolutionIndependentLayoutEnabled = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
 
 const cairo_font_options_t* pFontOptions = 

[Libreoffice-commits] core.git: vcl/skia

2022-08-23 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit e2a16489ff4a65e747e93b28d39096cb259bddd7
Author: Julien Nabet 
AuthorDate: Tue Aug 23 20:47:46 2022 +0200
Commit: Julien Nabet 
CommitDate: Tue Aug 23 21:30:41 2022 +0200

tdf#150555: Skia seems to fail with Windows 8/8.1

See https://bugs.documentfoundation.org/show_bug.cgi?id=150555#c7

Change-Id: I7c2f0a30b3d8cc3c5c528690087a42423fba68a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138743
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 39163fc9a71e..ee7ca9e01e02 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -42,5 +42,11 @@
 
 
 
+
+
+
+
+
+
 
 


[Libreoffice-commits] core.git: vcl/skia

2022-08-06 Thread Julien Nabet (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 407a61943539063c6d56eab8ab0c1b728dd642af
Author: Julien Nabet 
AuthorDate: Wed Aug 3 21:19:21 2022 +0200
Commit: Julien Nabet 
CommitDate: Sat Aug 6 16:30:27 2022 +0200

tdf#150232: put Intel Iris driver Skia/Vulkan in denylist for all versions

+ Nvidia on Windows just for device id "0x1401" in order to not being too 
restrictive.

Change-Id: Ie2cb2c6c6bb50ac6080721230ca3e451e886bb07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137768
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 63df3938b8a2..39163fc9a71e 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -27,7 +27,7 @@
  

 
 
- 
+ 
 
 
  
@@ -36,6 +36,9 @@
 
 
 
+ 
+
+
 
 
 


[Libreoffice-commits] core.git: vcl/skia

2022-07-13 Thread Luboš Luňák (via logerrit)
 vcl/skia/SkiaHelper.cxx |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 6c58b01c791ec4939523147d5d075611bbbfe314
Author: Luboš Luňák 
AuthorDate: Wed Jul 13 12:54:20 2022 +0200
Commit: Luboš Luňák 
CommitDate: Wed Jul 13 16:23:26 2022 +0200

move Skia setup code to a shared function

Change-Id: Ifcd434512854b5fedb0baf4ce1251a05f659b006
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137017
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 84c40baffae4..f4346b74f73a 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -273,6 +273,8 @@ static bool supportsVCLSkia()
 return getenv("SAL_DISABLESKIA") == nullptr;
 }
 
+static void initInternal();
+
 bool isVCLSkiaEnabled()
 {
 /**
@@ -308,8 +310,7 @@ bool isVCLSkiaEnabled()
 if (bForceSkia && bSupportsVCLSkia)
 {
 bRet = true;
-SkGraphics::Init();
-SkLoOpts::Init();
+initInternal();
 // don't actually block if denylisted, but log it if enabled, and also 
get the vendor id
 checkDeviceDenylisted(true);
 }
@@ -334,8 +335,7 @@ bool isVCLSkiaEnabled()
 
 if (bEnable)
 {
-SkGraphics::Init();
-SkLoOpts::Init();
+initInternal();
 checkDeviceDenylisted(); // switch to raster if driver is 
denylisted
 }
 
@@ -754,6 +754,13 @@ void setBlenderXor(SkPaint* paint)
 paint->setBlender(xorBlender);
 }
 
+static void initInternal()
+{
+// Set up all things needed for using Skia.
+SkGraphics::Init();
+SkLoOpts::Init();
+}
+
 void cleanup()
 {
 sharedWindowContext.reset();


[Libreoffice-commits] core.git: vcl/skia

2022-06-16 Thread Luboš Luňák (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit 8a5beccc19b4fdffb7b82ba5fd26f4cf316d9811
Author: Luboš Luňák 
AuthorDate: Thu Jun 16 18:21:10 2022 +0200
Commit: Luboš Luňák 
CommitDate: Fri Jun 17 06:16:28 2022 +0200

handle GC* pixmap functions on Mac reading past pixmap (tdf#145843)

The code passes adjusted position for pixel data in order to create
a sub-rect of the pixmap without copying, but at least on Intel Mac
the GC* functions then try to read the entire pixel row even though
it shouldn't be necessary. Since that may cause reading past the
pixmap data if the last line is involved, use entire pixmap width
to avoid that.

Change-Id: Ia08059b363d39dd465b2cadde5138ee045628f59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136003
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 0c9ac5e9c14b..f8bcdd68352e 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -139,6 +139,18 @@ void AquaSkiaSalGraphicsImpl::flushSurfaceToScreenCG()
 // This creates the bitmap context from the cropped part, 
writable_addr32() will get
 // the first pixel of mDirtyRect.topLeft(), and using pixmap.rowBytes() 
ensures the following
 // pixel lines will be read from correct positions.
+if (pixmap.bounds() != mDirtyRect && pixmap.bounds().bottom() == 
mDirtyRect.bottom())
+{
+// HACK for tdf#145843: If mDirtyRect includes the last line but not 
the first pixel of it,
+// then the rowBytes() trick would lead to the GC* functions thinking 
that even pixels after
+// the pixmap data belong to the area (since the shifted 
x()+rowBytes() points there) and
+// at least on Intel Mac they would actually read those data, even 
though I see no good reason
+// to do that, as that's beyond the x()+width() for the last line. 
That could be handled
+// by creating a subset SkImage (which as is said above copies data), 
or set the x coordinate
+// to 0, which will then make rowBytes() match the actual data.
+mDirtyRect.fLeft = 0;
+assert(mDirtyRect.width() == pixmap.bounds().width());
+}
 CGContextRef context = CGBitmapContextCreate(
 pixmap.writable_addr32(mDirtyRect.x() * mScaling, mDirtyRect.y() * 
mScaling),
 mDirtyRect.width() * mScaling, mDirtyRect.height() * mScaling, 8, 
pixmap.rowBytes(),


[Libreoffice-commits] core.git: vcl/skia

2022-05-03 Thread Arnaud VERSINI (via logerrit)
 vcl/skia/gdiimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1e8db42c878b0e0608717cec8e012269856e5934
Author: Arnaud VERSINI 
AuthorDate: Sat Apr 30 19:25:15 2022 +0200
Commit: Luboš Luňák 
CommitDate: Wed May 4 06:04:52 2022 +0200

vcl : avoid recursive call if skia context creation failed.

To avoid this bactrace : 
https://crashreport.libreoffice.org/stats/crash_details/4d1984f3-3352-49fa-8569-ebf6994ed216

Change-Id: I45ae8b56191c546c551ccaf48d5ab27a20b8e0e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133662
Tested-by: Jenkins
Reviewed-by: Arnaud Versini 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index c253ceb3a2df..82f25ad17c2d 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -301,7 +301,7 @@ void SkiaSalGraphicsImpl::createWindowSurface(bool 
forceRaster)
 createWindowSurfaceInternal(forceRaster);
 if (!mSurface)
 {
-switch (renderMethodToUse())
+switch (forceRaster ? RenderRaster : renderMethodToUse())
 {
 case RenderVulkan:
 SAL_WARN("vcl.skia",


[Libreoffice-commits] core.git: vcl/skia

2022-03-16 Thread Stephan Bergmann (via logerrit)
 vcl/skia/x11/gdiimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a20e0ae4e346dae93bacf25deff2e7fbcbf1dbe1
Author: Stephan Bergmann 
AuthorDate: Wed Mar 16 16:21:52 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Mar 16 21:09:54 2022 +0100

-Werror=unused-but-set-variable

(with --disable-assert-always-abort --enable-dbgutil,
)

Change-Id: I46c4ed35e1882a98bde4022681624ae6c94031b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131664
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index fa0f81176a5d..6a7cce14dd3f 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -84,7 +84,7 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, 
Drawable drawable,
 assert(winInfo.fVisualInfo->visual != nullptr); // make sure it's not an 
uninitialized SalVisual
 winInfo.fWidth = width;
 winInfo.fHeight = height;
-#ifdef DBG_UTIL
+#if defined DBG_UTIL && !defined NDEBUG
 // Our patched Skia has VulkanWindowContext that shares grDirectContext, 
which requires
 // that the X11 visual is always the same. Ensure it is so.
 static VisualID checkVisualID = -1U;


[Libreoffice-commits] core.git: vcl/skia

2022-01-25 Thread Mike Kaganski (via logerrit)
 vcl/skia/win/gdiimpl.cxx |   99 ++-
 1 file changed, 39 insertions(+), 60 deletions(-)

New commits:
commit bc1b2b03718b596506db2acedd6dad10f489d9fe
Author: Mike Kaganski 
AuthorDate: Sat Jan 15 11:30:42 2022 +0300
Commit: Mike Kaganski 
CommitDate: Wed Jan 26 07:30:59 2022 +0100

Simplify error COM handling using exceptions

Change-Id: I2514e39bba8debcbdbb60929d2ca2f1ba3aaa2e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128456
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index e9074340e66e..f2f0d82a9047 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -16,7 +16,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 #include 
 #include 
@@ -119,39 +121,16 @@ bool 
WinSkiaSalGraphicsImpl::RenderAndCacheNativeControl(CompatibleDC& rWhite, C
 return true;
 }
 
-#ifdef SAL_LOG_INFO
-static HRESULT checkResult(HRESULT hr, const char* file, size_t line)
-{
-if (FAILED(hr))
-{
-OUString sLocationString
-= OUString::createFromAscii(file) + ":" + OUString::number(line) + 
" ";
-SAL_DETAIL_LOG_STREAM(SAL_DETAIL_ENABLE_LOG_INFO, 
::SAL_DETAIL_LOG_LEVEL_INFO, "vcl.skia",
-  sLocationString.toUtf8().getStr(),
-  "HRESULT failed with: 0x" << 
OUString::number(hr, 16) << ": "
-<< 
WindowsErrorStringFromHRESULT(hr));
-}
-return hr;
-}
-
-#define CHECKHR(funct) checkResult(funct, __FILE__, __LINE__)
-#else
-#define CHECKHR(funct) (funct)
-#endif
-
-sk_sp WinSkiaSalGraphicsImpl::createDirectWriteTypeface(HDC hdc, 
HFONT hfont)
+sk_sp WinSkiaSalGraphicsImpl::createDirectWriteTypeface(HDC hdc, 
HFONT hfont) try
 {
+using sal::systools::ThrowIfFailed;
 if (!dwriteDone)
 {
-if (SUCCEEDED(
-CHECKHR(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, 
__uuidof(IDWriteFactory),
-
reinterpret_cast()
-{
-if 
(SUCCEEDED(CHECKHR(dwriteFactory->GetGdiInterop(
-dwriteFontMgr = SkFontMgr_New_DirectWrite(dwriteFactory.get());
-else
-dwriteFactory.clear();
-}
+ThrowIfFailed(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, 
__uuidof(IDWriteFactory),
+  
reinterpret_cast()),
+  SAL_WHERE);
+ThrowIfFailed(dwriteFactory->GetGdiInterop(), 
SAL_WHERE);
+dwriteFontMgr = SkFontMgr_New_DirectWrite(dwriteFactory.get());
 dwriteDone = true;
 }
 if (!dwriteFontMgr)
@@ -164,20 +143,17 @@ sk_sp 
WinSkiaSalGraphicsImpl::createDirectWriteTypeface(HDC hdc, HFO
 // For that CreateFromFaceFromHdc() is necessary. The simpler
 // CreateFontFromLOGFONT() seems to search for the best matching font,
 // which may not be the exact font.
-HFONT oldFont = SelectFont(hdc, hfont);
 sal::systools::COMReference fontFace;
-if (FAILED(CHECKHR(dwriteGdiInterop->CreateFontFaceFromHdc(hdc, 

 {
-SelectFont(hdc, oldFont);
-return nullptr;
+comphelper::ScopeGuard g(
+[ hdc, oldFont(SelectFont(hdc, hfont)) ] { SelectFont(hdc, 
oldFont); });
+ThrowIfFailed(dwriteGdiInterop->CreateFontFaceFromHdc(hdc, ), 
SAL_WHERE);
 }
 
-SelectFont(hdc, oldFont);
 sal::systools::COMReference collection;
-if (FAILED(CHECKHR(dwriteFactory->GetSystemFontCollection(
-return nullptr;
+ThrowIfFailed(dwriteFactory->GetSystemFontCollection(), 
SAL_WHERE);
 sal::systools::COMReference font;
-// Do not use CHECKHR() here, as said above, this fails for our fonts.
+// As said above, this fails for our fonts.
 if (FAILED(collection->GetFontFromFontFace(fontFace.get(), )))
 {
 // If not found in system collection, try our private font collection.
@@ -191,26 +167,26 @@ sk_sp 
WinSkiaSalGraphicsImpl::createDirectWriteTypeface(HDC hdc, HFO
 // private fonts with this newly used font.
 
 sal::systools::COMReference dwriteFactory3;
-if 
(FAILED(dwriteFactory->QueryInterface()))
-return nullptr;
+ThrowIfFailed(dwriteFactory->QueryInterface(), 
SAL_WHERE);
 
-if (!dwriteFontSetBuilder
-&& 
FAILED(dwriteFactory3->CreateFontSetBuilder()))
-return nullptr;
+if (!dwriteFontSetBuilder)
+
ThrowIfFailed(dwriteFactory3->CreateFontSetBuilder(),
+  SAL_WHERE);
 
 UINT32 numberOfFiles;
-if (FAILED(fontFace->GetFiles(, nullptr)) || 
numberOfFiles != 1)
+ThrowIfFailed(fontFace->GetFiles(, nullptr), 
SAL_WHERE);
+if (numberOfFiles != 1)
 return nullptr;
 
 

[Libreoffice-commits] core.git: vcl/skia

2022-01-12 Thread Luboš Luňák (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6fd4209a7e5884e44f4214342c7565229aa9b7d5
Author: Luboš Luňák 
AuthorDate: Wed Jan 12 15:20:41 2022 +0100
Commit: Luboš Luňák 
CommitDate: Wed Jan 12 15:23:41 2022 +0100

block amd drivers that crash with Skia's kDifference (tdf#146402)

This is a follow-up to 4a11c85baeb4998e12bc2ab45b0c23, after all
it was a driver problem. But the time 7.4 is out the newer one
working will be hopefully in sufficient use.

Change-Id: I682a56ec6e5b6dfe4c85930346177fc5c13569c9

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index e2cd9e3aa6ab..63df3938b8a2 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -30,7 +30,7 @@
  
 
 
-
+ 
 
 
 


[Libreoffice-commits] core.git: vcl/skia

2022-01-07 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 2692dc5f662c74e3df63224ae829fc492503aa1e
Author: Luboš Luňák 
AuthorDate: Tue Dec 7 18:52:29 2021 +0100
Commit: Luboš Luňák 
CommitDate: Fri Jan 7 10:01:12 2022 +0100

save alpha channel processing when not needed

Change-Id: Icbf19e86b833c0cec08a9ac5c41c01fd2dd1a4e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128060
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index b81e55221f34..df3536b4de91 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -602,7 +602,8 @@ bool SkiaSalBitmap::AlphaBlendWith(const SalBitmap& rSalBmp)
 return false;
 otherBitmap = otherBitmapAllocated.get();
 }
-sk_sp surface = createSkSurface(mSize);
+// This is 8-bit bitmap serving as mask, so the image itself needs no 
alpha.
+sk_sp surface = createSkSurface(mSize, kOpaque_SkAlphaType);
 SkPaint paint;
 paint.setBlendMode(SkBlendMode::kSrc); // set as is
 surface->getCanvas()->drawImage(GetSkImage(), 0, 0, SkSamplingOptions(), 
);


[Libreoffice-commits] core.git: vcl/skia

2021-12-10 Thread Julien Nabet (via logerrit)
 vcl/skia/SkiaHelper.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e369efa01183b4c304b49603628a7393aeb9ced0
Author: Julien Nabet 
AuthorDate: Fri Dec 10 12:46:56 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Dec 10 14:24:53 2021 +0100

[loplugin:external] in vcl/skia/SkiaHelper.cxx

Following 2c86b79e87bc8579f5213708954d5c85fe231407
cache Skia drawing based on checksum of bitmap content (tdf#146095)

Change-Id: I184a7d96988b7a52100de026c13f422590755ded
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126635
Reviewed-by: Luboš Luňák 
Tested-by: Jenkins

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 2a4a7f1a6d7f..8dc3827b097a 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -648,7 +648,7 @@ tools::Long maxImageCacheSize()
 
 static o3tl::lru_map checksumCache(256);
 
-uint32_t computeSkPixmapChecksum(const SkPixmap& pixmap)
+static uint32_t computeSkPixmapChecksum(const SkPixmap& pixmap)
 {
 // Use uint32_t because that's what SkOpts::hash_fn() returns.
 static_assert(std::is_same_v);


[Libreoffice-commits] core.git: vcl/skia

2021-12-06 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   55 ++-
 1 file changed, 29 insertions(+), 26 deletions(-)

New commits:
commit c5785d3bd0ff575df08a1192f4e7f736750e
Author: Luboš Luňák 
AuthorDate: Sat Dec 4 11:52:26 2021 +0100
Commit: Luboš Luňák 
CommitDate: Mon Dec 6 17:08:34 2021 +0100

a large but clipped image may still be cached from a previous call

Canvas apparently likes to redraw only small parts of the background,
which means that there may be repeated scaling of clipped parts
of a large background image that are considered too clipped to be
cached, but even the drawing of the clipped part may add up to be
costly in the end if done often. Refusing the caching only after
checking whether the image is possibly cached may avoid some
of the drawing in case there was an initial drawing that wasn't
clipped and thus generated the cached image. Helps a bit with
e.g. tdf#136223.

Change-Id: I4de6164940ec7a06fb6ae2f504907b4fa076f1d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126412
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index f6620dfaafc0..593e2ffb57e4 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1586,9 +1586,37 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 if (reduceRatio < 10)
 return {};
 }
+// Do not cache the result if it would take most of the cache and thus get 
evicted soon.
+if (targetSize.Width() * targetSize.Height() * 4 > maxImageCacheSize() * 
0.7)
+return {};
+
+// Use ready direct image if they are both available, now even the size 
doesn't matter
+// (we'll scale as necessary and it's better to scale from the original). 
Require only
+// that they are the same size, or that one prefers a shader or doesn't 
exist
+// (i.e. avoid two images of different size).
+bitmapReady = bitmap.GetSkImage(DirectImage::Yes) != nullptr;
+alphaBitmapReady = alphaBitmap && 
alphaBitmap->GetAlphaSkImage(DirectImage::Yes) != nullptr;
+if (bitmapReady && alphaBitmap && !alphaBitmapReady && 
!alphaBitmap->PreferSkShader())
+bitmapReady = false;
+if (alphaBitmapReady && !bitmapReady && bitmap.PreferSkShader())
+alphaBitmapReady = false;
+
+DirectImage bitmapType = bitmapReady ? DirectImage::Yes : DirectImage::No;
+DirectImage alphaBitmapType = alphaBitmapReady ? DirectImage::Yes : 
DirectImage::No;
+
+// Try to find a cached result, this time after possible delayed scaling.
+OString key = makeCachedImageKey(bitmap, alphaBitmap, targetSize, 
bitmapType, alphaBitmapType);
+if (sk_sp image = findCachedImage(key))
+{
+assert(imageSize(image) == targetSize);
+return image;
+}
+
 // In some cases (tdf#134237) the target size may be very large. In that 
case it's
 // better to rely on Skia to clip and draw only the necessary, rather than 
prepare
-// a very large image only to not use most of it.
+// a very large image only to not use most of it. Do this only after 
checking whether
+// the image is already cached, since it might have been already cached in 
a previous
+// call that had the draw area large enough to be seen as worth caching.
 const Size drawAreaSize = mClipRegion.GetBoundRect().GetSize() * mScaling;
 if (targetSize.Width() > drawAreaSize.Width() || targetSize.Height() > 
drawAreaSize.Height())
 {
@@ -1613,31 +1641,6 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 return {};
 }
 }
-// Do not cache the result if it would take most of the cache and thus get 
evicted soon.
-if (targetSize.Width() * targetSize.Height() * 4 > maxImageCacheSize() * 
0.7)
-return {};
-
-// Use ready direct image if they are both available, now even the size 
doesn't matter
-// (we'll scale as necessary and it's better to scale from the original). 
Require only
-// that they are the same size, or that one prefers a shader or doesn't 
exist
-// (i.e. avoid two images of different size).
-bitmapReady = bitmap.GetSkImage(DirectImage::Yes) != nullptr;
-alphaBitmapReady = alphaBitmap && 
alphaBitmap->GetAlphaSkImage(DirectImage::Yes) != nullptr;
-if (bitmapReady && alphaBitmap && !alphaBitmapReady && 
!alphaBitmap->PreferSkShader())
-bitmapReady = false;
-if (alphaBitmapReady && !bitmapReady && bitmap.PreferSkShader())
-alphaBitmapReady = false;
-
-DirectImage bitmapType = bitmapReady ? DirectImage::Yes : DirectImage::No;
-DirectImage alphaBitmapType = alphaBitmapReady ? DirectImage::Yes : 
DirectImage::No;
-
-// Try to find a cached result, this time after possible delayed scaling.
-OString key = makeCachedImageKey(bitmap, alphaBitmap, targetSize, 
bitmapType, alphaBitmapType);
-if (sk_sp image = 

[Libreoffice-commits] core.git: vcl/skia

2021-11-30 Thread Luboš Luňák (via logerrit)
 vcl/skia/osx/bitmap.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit afdfc9bb5d56fde866882e7d87869ecafed1e3d0
Author: Luboš Luňák 
AuthorDate: Tue Nov 30 14:13:53 2021 +0100
Commit: Luboš Luňák 
CommitDate: Tue Nov 30 15:44:11 2021 +0100

handle Skia not drawing GPU-backend shader to a bitmap (tdf#145797)

https: //bugs.chromium.org/p/skia/issues/detail?id=12685
Change-Id: I4de51b154e270df470102c357c25bdfa430a4488
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126118
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/osx/bitmap.cxx b/vcl/skia/osx/bitmap.cxx
index 77e34697aa50..16d32191a627 100644
--- a/vcl/skia/osx/bitmap.cxx
+++ b/vcl/skia/osx/bitmap.cxx
@@ -66,9 +66,18 @@ CGImageRef createCGImage(const Image& rImage)
 
assert(dynamic_cast(alphaBitmap.ImplGetSalBitmap().get()) != 
nullptr);
 SkiaSalBitmap* skiaAlpha
 = 
static_cast(alphaBitmap.ImplGetSalBitmap().get());
+#if 0
+// Drawing to a bitmap using a shader from a GPU-backed image fails 
silently.
+// https://bugs.chromium.org/p/skia/issues/detail?id=12685
 paint.setShader(SkShaders::Blend(SkBlendMode::kDstOut,
  
skiaBitmap->GetSkShader(SkSamplingOptions()),
  
skiaAlpha->GetAlphaSkShader(SkSamplingOptions(;
+#else
+sk_sp imB = skiaBitmap->GetSkImage()->makeNonTextureImage();
+sk_sp imA = 
skiaAlpha->GetAlphaSkImage()->makeNonTextureImage();
+paint.setShader(SkShaders::Blend(SkBlendMode::kDstOut, 
imB->makeShader(SkSamplingOptions()),
+ 
imA->makeShader(SkSamplingOptions(;
+#endif
 SkCanvas canvas(targetBitmap);
 canvas.concat(matrix);
 canvas.drawPaint(paint);


[Libreoffice-commits] core.git: vcl/skia

2021-11-30 Thread Stephan Bergmann (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 81b3619fb59b617cda7335b5d6de32c5abf4e554
Author: Stephan Bergmann 
AuthorDate: Tue Nov 30 12:13:38 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Nov 30 13:24:10 2021 +0100

loplugin:simplifyconstruct

Change-Id: I280b668e40d800ecd6eb03ddcda3c2ebd2dd0254
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126114
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 126f43bb6ac3..643b38b52557 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -214,10 +214,10 @@ bool 
AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
 // Setup context state for drawing (performDrawNativeControl() e.g. fills 
background in some cases).
 CGContextSetFillColorSpace(context, GetSalData()->mxRGBSpace);
 CGContextSetStrokeColorSpace(context, GetSalData()->mxRGBSpace);
-RGBAColor lineColor = RGBAColor(mLineColor);
+RGBAColor lineColor(mLineColor);
 CGContextSetRGBStrokeColor(context, lineColor.GetRed(), 
lineColor.GetGreen(),
lineColor.GetBlue(), lineColor.GetAlpha());
-RGBAColor fillColor = RGBAColor(mFillColor);
+RGBAColor fillColor(mFillColor);
 CGContextSetRGBFillColor(context, fillColor.GetRed(), 
fillColor.GetGreen(), fillColor.GetBlue(),
  fillColor.GetAlpha());
 // Adjust for our drawn-to coordinates in the bitmap.


[Libreoffice-commits] core.git: vcl/skia

2021-11-18 Thread Luboš Luňák (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |   25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

New commits:
commit 07a9d2f60dabac5b8f9d10acb73a8eade1593aae
Author: Luboš Luňák 
AuthorDate: Thu Nov 18 10:17:54 2021 +0100
Commit: Luboš Luňák 
CommitDate: Thu Nov 18 16:43:46 2021 +0100

draw Mac widget controls at proper size when HiDPI

This code was drawing them at non-HiDPI size and then scaling up.

Change-Id: I90abfd36adaff4e7c4929cd28d0aa50d919449a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125467
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 73e5e09d20d0..0f451f8916df 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -187,21 +187,27 @@ bool 
AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
 const tools::Rectangle& 
rControlRegion,
 ControlState nState, const 
ImplControlValue& aValue)
 {
-const tools::Long width = rControlRegion.GetWidth();
-const tools::Long height = rControlRegion.GetHeight();
+// Do a scaled bitmap in HiDPI in order not to lose precision.
+const tools::Long width = rControlRegion.GetWidth() * mScaling;
+const tools::Long height = rControlRegion.GetHeight() * mScaling;
 const size_t bytes = width * height * 4;
 std::unique_ptr data(new sal_uInt8[bytes]);
 memset(data.get(), 0, bytes);
 CGContextRef context = CGBitmapContextCreate(
 data.get(), width, height, 8, width * 4, GetSalData()->mxRGBSpace,
 toCGBitmapType(mSurface->imageInfo().colorType(), 
kPremul_SkAlphaType));
-assert(context); // TODO
-// Flip upside down.
+if (!context)
+{
+SAL_WARN("vcl.skia", "drawNativeControl(): Failed to allocate bitmap 
context");
+return false;
+}
+// Adjust for our drawn-to coordinates in the bitmap.
+tools::Rectangle movedRegion(Point(0, 0), rControlRegion.GetSize());
+// Flip drawing upside down.
 CGContextTranslateCTM(context, 0, height);
 CGContextScaleCTM(context, 1, -1);
-// Adjust for our drawn-to coordinates in the bitmap.
-tools::Rectangle movedRegion = rControlRegion;
-movedRegion.SetPos(Point(0, 0));
+// And possibly scale the native drawing.
+CGContextScaleCTM(context, mScaling, mScaling);
 bool bOK = performDrawNativeControl(nType, nPart, movedRegion, nState, 
aValue, context,
 mrShared.mpFrame);
 CGContextRelease(context);
@@ -224,7 +230,10 @@ bool 
AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
 updateRect.Intersection(mClipRegion.GetBoundRect());
 addUpdateRegion(SkRect::MakeXYWH(updateRect.getX(), updateRect.getY(),
  updateRect.GetWidth(), 
updateRect.GetHeight()));
-getDrawCanvas()->drawImage(bitmap.asImage(), rControlRegion.getX(), 
rControlRegion.getY());
+SkRect drawRect = SkRect::MakeXYWH(rControlRegion.getX(), 
rControlRegion.getY(),
+   rControlRegion.GetWidth(), 
rControlRegion.GetHeight());
+assert(drawRect.width() * mScaling == bitmap.width()); // no scaling 
should be needed
+getDrawCanvas()->drawImageRect(bitmap.asImage(), drawRect, 
SkSamplingOptions());
 ++mPendingOperationsToFlush; // tdf#136369
 postDraw();
 }


[Libreoffice-commits] core.git: vcl/skia wizards/source

2021-11-18 Thread Andrea Gelmini (via logerrit)
 vcl/skia/gdiimpl.cxx   |2 +-
 wizards/source/sfdocuments/SF_DocumentListener.xba |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 187b28063fa9b908f5324ed345ba223d8f6168a2
Author: Andrea Gelmini 
AuthorDate: Tue Nov 16 22:46:06 2021 +0100
Commit: Michael Stahl 
CommitDate: Thu Nov 18 15:02:31 2021 +0100

Fix typos

Change-Id: Idd21ee0026d8a36653f0fb25b350dae37315f603
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125336
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index f15954f95117..81f581d6ff78 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -884,7 +884,7 @@ void SkiaSalGraphicsImpl::privateDrawAlphaRect(tools::Long 
nX, tools::Long nY, t
 paint.setStyle(SkPaint::kStroke_Style);
 if (mScaling != 1 && isUnitTestRunning())
 {
-// On HiDPI displays, do not draw just a harline but instead a 
full-width "pixel" when running unittests,
+// On HiDPI displays, do not draw just a hairline but instead a 
full-width "pixel" when running unittests,
 // since tests often require precise pixel drawing.
 paint.setStrokeWidth(1); // this will be scaled by mScaling
 paint.setStrokeCap(SkPaint::kSquare_Cap);
diff --git a/wizards/source/sfdocuments/SF_DocumentListener.xba 
b/wizards/source/sfdocuments/SF_DocumentListener.xba
index 9ccc04f62d19..fbb0271bbc38 100644
--- a/wizards/source/sfdocuments/SF_DocumentListener.xba
+++ b/wizards/source/sfdocuments/SF_DocumentListener.xba
@@ -64,7 +64,7 @@ Try:
_RangeSelectionFinished = False
oController.startRangeSelection(pvPropertyValues)
 
- Dummy thread synchonization
+ Dummy thread synchronization
lCountLoops = 0
Do While Not _RangeSelectionFinished And lCountLoops  cstMaxSleep
Wait(cstSleep)


[Libreoffice-commits] core.git: vcl/skia

2021-11-17 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   47 ++-
 1 file changed, 22 insertions(+), 25 deletions(-)

New commits:
commit 5e6e45eb4247bf8bd57d157b44f49577dde38716
Author: Luboš Luňák 
AuthorDate: Wed Nov 17 16:35:31 2021 +0100
Commit: Luboš Luňák 
CommitDate: Thu Nov 18 08:01:12 2021 +0100

handle also curved lines for nojoin skia polylines (tdf#143837)

Change-Id: I2f5aa12eb656f6b337843d81a2a30de277dff7b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125410
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 6a01601662a4..f15954f95117 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -55,33 +55,28 @@ namespace
 // bottom-most line of pixels of the bounding rectangle (see
 // 
https://lists.freedesktop.org/archives/libreoffice/2019-November/083709.html).
 // So be careful with rectangle->polygon conversions (generally avoid them).
-void addPolygonToPath(const basegfx::B2DPolygon& rPolygon, SkPath& rPath,
-  bool* hasOnlyOrthogonal = nullptr)
+void addPolygonToPath(const basegfx::B2DPolygon& rPolygon, SkPath& rPath, 
sal_uInt32 nFirstIndex,
+  sal_uInt32 nLastIndex, const sal_uInt32 nPointCount, 
const bool bClosePath,
+  const bool bHasCurves, bool* hasOnlyOrthogonal = nullptr)
 {
-const sal_uInt32 nPointCount(rPolygon.count());
+assert(nFirstIndex < nPointCount);
+assert(nLastIndex <= nPointCount);
 
 if (nPointCount <= 1)
 return;
 
-const bool bClosePath(rPolygon.isClosed());
-const bool bHasCurves(rPolygon.areControlPointsUsed());
-
 bool bFirst = true;
+sal_uInt32 nPreviousIndex = nFirstIndex == 0 ? nPointCount - 1 : 
nFirstIndex - 1;
+basegfx::B2DPoint aPreviousPoint = rPolygon.getB2DPoint(nPreviousIndex);
 
-sal_uInt32 nCurrentIndex = 0;
-sal_uInt32 nPreviousIndex = nPointCount - 1;
-
-basegfx::B2DPoint aCurrentPoint;
-basegfx::B2DPoint aPreviousPoint;
-
-for (sal_uInt32 nIndex = 0; nIndex <= nPointCount; nIndex++)
+for (sal_uInt32 nIndex = nFirstIndex; nIndex <= nLastIndex; nIndex++)
 {
 if (nIndex == nPointCount && !bClosePath)
 continue;
 
 // Make sure we loop the last point to first point
-nCurrentIndex = nIndex % nPointCount;
-aCurrentPoint = rPolygon.getB2DPoint(nCurrentIndex);
+sal_uInt32 nCurrentIndex = nIndex % nPointCount;
+basegfx::B2DPoint aCurrentPoint = rPolygon.getB2DPoint(nCurrentIndex);
 
 if (bFirst)
 {
@@ -132,12 +127,19 @@ void addPolygonToPath(const basegfx::B2DPolygon& 
rPolygon, SkPath& rPath,
 aPreviousPoint = aCurrentPoint;
 nPreviousIndex = nCurrentIndex;
 }
-if (bClosePath)
+if (bClosePath && nFirstIndex == 0 && nLastIndex == nPointCount)
 {
 rPath.close();
 }
 }
 
+void addPolygonToPath(const basegfx::B2DPolygon& rPolygon, SkPath& rPath,
+  bool* hasOnlyOrthogonal = nullptr)
+{
+addPolygonToPath(rPolygon, rPath, 0, rPolygon.count(), rPolygon.count(), 
rPolygon.isClosed(),
+ rPolygon.areControlPointsUsed(), hasOnlyOrthogonal);
+}
+
 void addPolyPolygonToPath(const basegfx::B2DPolyPolygon& rPolyPolygon, SkPath& 
rPath,
   bool* hasOnlyOrthogonal = nullptr)
 {
@@ -1246,7 +1248,6 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const 
basegfx::B2DHomMatrix& rObjectToDev
 {
 SkPath aPath;
 aPath.incReserve(aPolyLine.count() * 3); // because cubicTo is 3 
elements
-aPath.setFillType(SkPathFillType::kEvenOdd);
 addPolygonToPath(aPolyLine, aPath);
 aPath.offset(toSkX(0) + posFix, toSkY(0) + posFix, nullptr);
 addUpdateRegion(aPath.getBounds());
@@ -1256,16 +1257,12 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const 
basegfx::B2DHomMatrix& rObjectToDev
 {
 sal_uInt32 nPoints = aPolyLine.count();
 bool bClosed = aPolyLine.isClosed();
-for (sal_uInt32 j = 0; j < (bClosed ? nPoints : nPoints - 1); ++j)
+bool bHasCurves = aPolyLine.areControlPointsUsed();
+for (sal_uInt32 j = 0; j < nPoints; ++j)
 {
-sal_uInt32 index1 = (j + 0) % nPoints;
-sal_uInt32 index2 = (j + 1) % nPoints;
 SkPath aPath;
-aPath.moveTo(aPolyLine.getB2DPoint(index1).getX(),
- aPolyLine.getB2DPoint(index1).getY());
-aPath.lineTo(aPolyLine.getB2DPoint(index2).getX(),
- aPolyLine.getB2DPoint(index2).getY());
-
+aPath.incReserve(2 * 3); // because cubicTo is 3 elements
+addPolygonToPath(aPolyLine, aPath, j, j + 1, nPoints, bClosed, 
bHasCurves);
 aPath.offset(toSkX(0) + posFix, toSkY(0) + posFix, nullptr);
 addUpdateRegion(aPath.getBounds());
 getDrawCanvas()->drawPath(aPath, aPaint);


[Libreoffice-commits] core.git: vcl/skia

2021-11-17 Thread Luboš Luňák (via logerrit)
 vcl/skia/SkiaHelper.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 23b17e409976f3c106028cc6617ca3a841eb839d
Author: Luboš Luňák 
AuthorDate: Wed Nov 17 10:20:33 2021 +0100
Commit: Luboš Luňák 
CommitDate: Wed Nov 17 14:12:29 2021 +0100

Skia dumping is no longer dbgutil-only

This is a mistake from f33b76b4e675818deae244427cef84c576a1a1f8.

Change-Id: Iae69ae0099a62451d156c80255f55b1f6aad4725
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125370
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index cc9303af39f5..631e5b64fe52 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -47,9 +47,7 @@ bool isVCLSkiaEnabled() { return false; }
 #include 
 #include 
 #include 
-#ifdef DBG_UTIL
 #include 
-#endif
 
 namespace SkiaHelper
 {


[Libreoffice-commits] core.git: vcl/skia

2021-11-16 Thread Stephan Bergmann (via logerrit)
 vcl/skia/gdiimpl.cxx |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 8ab30014e4e098e202b3bee571aa9d6bcdfa1c70
Author: Stephan Bergmann 
AuthorDate: Wed Nov 17 07:32:47 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 17 08:38:34 2021 +0100

loplugin:simplifybool

Change-Id: Ifb7c6d8a4506808b5f56492e692ef7172a367e26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125344
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index ac6f33ea7398..6a01601662a4 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1728,8 +1728,7 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 // that they are the same size, or that one prefers a shader or doesn't 
exist
 // (i.e. avoid two images of different size).
 bitmapReady = bitmap.GetSkImage(DirectImage::Yes) != nullptr;
-alphaBitmapReady
-= alphaBitmap ? alphaBitmap->GetAlphaSkImage(DirectImage::Yes) != 
nullptr : false;
+alphaBitmapReady = alphaBitmap && 
alphaBitmap->GetAlphaSkImage(DirectImage::Yes) != nullptr;
 if (bitmapReady && alphaBitmap && !alphaBitmapReady && 
!alphaBitmap->PreferSkShader())
 bitmapReady = false;
 if (alphaBitmapReady && !bitmapReady && bitmap.PreferSkShader())


[Libreoffice-commits] core.git: vcl/skia

2021-11-16 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   27 +--
 1 file changed, 21 insertions(+), 6 deletions(-)

New commits:
commit 621430208d29e40ab95509a4e94da6e8313ed389
Author: Luboš Luňák 
AuthorDate: Tue Nov 16 08:03:06 2021 +0100
Commit: Luboš Luňák 
CommitDate: Tue Nov 16 10:41:36 2021 +0100

optimize Skia's copyArea() to copy less data

Change-Id: Ia1cd0522643b58ea1be3ad974c1fc5f7fed657d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125268
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index b97d2f28c428..4019c436d51d 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1347,17 +1347,32 @@ void SkiaSalGraphicsImpl::privateCopyBits(const 
SalTwoRect& rPosAry, SkiaSalGrap
  rPosAry.mnDestHeight));
 SkPaint paint;
 paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
-SkRect srcRect
-= SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, 
rPosAry.mnSrcHeight);
+SkIRect srcRect = SkIRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, 
rPosAry.mnSrcWidth,
+rPosAry.mnSrcHeight);
 SkRect destRect = SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, 
rPosAry.mnDestWidth,
rPosAry.mnDestHeight);
 // Scaling for source coordinates must be done manually.
 if (src->mScaling != 1)
 srcRect = scaleRect(srcRect, src->mScaling);
-// Do not use makeImageSnapshot(rect), as that one may make a needless 
data copy.
-getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(src->mSurface), 
srcRect, destRect,
-   makeSamplingOptions(rPosAry, mScaling, 
src->mScaling), ,
-   SkCanvas::kFast_SrcRectConstraint);
+if (src == this)
+{
+// Copy-to-self means that we'd take a snapshot, which would refcount 
the data,
+// and then drawing would result in copy in write, copying the entire 
surface.
+// Try to copy less by making a snapshot of only what is needed.
+sk_sp image = makeCheckedImageSnapshot(src->mSurface, 
srcRect);
+srcRect.offset(-srcRect.x(), -srcRect.y());
+getDrawCanvas()->drawImageRect(image, SkRect::Make(srcRect), destRect,
+   makeSamplingOptions(rPosAry, mScaling, 
src->mScaling),
+   , 
SkCanvas::kFast_SrcRectConstraint);
+}
+else
+{
+// Do not use makeImageSnapshot(rect), as that one may make a needless 
data copy.
+getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(src->mSurface),
+   SkRect::Make(srcRect), destRect,
+   makeSamplingOptions(rPosAry, mScaling, 
src->mScaling),
+   , 
SkCanvas::kFast_SrcRectConstraint);
+}
 }
 
 bool SkiaSalGraphicsImpl::blendBitmap(const SalTwoRect& rPosAry, const 
SalBitmap& rBitmap)


[Libreoffice-commits] core.git: vcl/skia

2021-11-16 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 07e5e9f4c4318c19dd553459132efa71d456eaef
Author: Luboš Luňák 
AuthorDate: Mon Nov 15 20:07:51 2021 +0100
Commit: Luboš Luňák 
CommitDate: Tue Nov 16 10:40:00 2021 +0100

don't bother caching bitmaps that prefer shaders

Change-Id: Ibc78371f9e2ba92470714847bb6a5b8b96d1037f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125264
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index de1e8c47cb12..b97d2f28c428 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1611,6 +1611,9 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 return image;
 if (alphaBitmap && alphaBitmap->IsFullyOpaqueAsAlpha())
 alphaBitmap = nullptr; // the alpha can be ignored
+if (bitmap.PreferSkShader() && (!alphaBitmap || 
alphaBitmap->PreferSkShader()))
+return image;
+
 // Probably not much point in caching of just doing a copy.
 if (alphaBitmap == nullptr && targetSize == bitmap.GetSize())
 return image;
@@ -1730,7 +1733,8 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const 
SalTwoRect& rPosAry, const SalBi
 = mergeCacheBitmaps(rSkiaSourceBitmap, , imageSize * 
mScaling);
 if (image)
 drawImage(imagePosAry, image, mScaling);
-else if (rSkiaAlphaBitmap.IsFullyOpaqueAsAlpha()) // alpha can be ignored
+else if (rSkiaAlphaBitmap.IsFullyOpaqueAsAlpha()
+ && !rSkiaSourceBitmap.PreferSkShader()) // alpha can be ignored
 drawBitmap(rPosAry, rSkiaSourceBitmap);
 else
 drawShader(rPosAry,
@@ -1744,11 +1748,6 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const 
SalTwoRect& rPosAry, const SalBi
 void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const 
SkiaSalBitmap& bitmap,
  SkBlendMode blendMode)
 {
-if (bitmap.PreferSkShader())
-{
-drawShader(rPosAry, bitmap.GetSkShader(makeSamplingOptions(rPosAry, 
mScaling)), blendMode);
-return;
-}
 // Use mergeCacheBitmaps(), which may decide to cache the result, avoiding 
repeated
 // scaling.
 SalTwoRect imagePosAry(rPosAry);
@@ -1766,6 +1765,8 @@ void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& 
rPosAry, const SkiaSalBit
 sk_sp image = mergeCacheBitmaps(bitmap, nullptr, imageSize * 
mScaling);
 if (image)
 drawImage(imagePosAry, image, mScaling, blendMode);
+else if (bitmap.PreferSkShader())
+drawShader(rPosAry, bitmap.GetSkShader(makeSamplingOptions(rPosAry, 
mScaling)), blendMode);
 else
 drawImage(rPosAry, bitmap.GetSkImage(), 1, blendMode);
 }


[Libreoffice-commits] core.git: vcl/skia

2021-11-16 Thread Luboš Luňák (via logerrit)
 vcl/skia/x11/gdiimpl.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 29a2120fcf56ef7fcdb5c95e896e4366454b63bf
Author: Luboš Luňák 
AuthorDate: Mon Nov 15 18:17:57 2021 +0100
Commit: Luboš Luňák 
CommitDate: Tue Nov 16 10:39:27 2021 +0100

apply SAL_FORCE_HIDPI_SCALING on X11 even while drawing

It'll draw double-sized 1/4 of the content in the topleft corner
of windows, but it's still useful for some tests.

Change-Id: I20c6d2382d704ddcd67b8cb81eb7abf37b57a92f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125262
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 03211d8050dd..fa0f81176a5d 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -46,9 +46,10 @@ void 
X11SkiaSalGraphicsImpl::createWindowSurfaceInternal(bool forceRaster)
 assert(!mSurface);
 assert(mX11Parent.GetDrawable() != None);
 RenderMethod renderMethod = forceRaster ? RenderRaster : 
renderMethodToUse();
+mScaling = getWindowScaling();
 mWindowContext = createWindowContext(mX11Parent.GetXDisplay(), 
mX11Parent.GetDrawable(),
- (), GetWidth(), 
GetHeight(),
- renderMethod, false);
+ (), GetWidth() * 
mScaling,
+ GetHeight() * mScaling, renderMethod, 
false);
 if (mWindowContext)
 {
 // See flushSurfaceToWindowContext().


[Libreoffice-commits] core.git: vcl/skia

2021-11-13 Thread Julien Nabet (via logerrit)
 vcl/skia/SkiaHelper.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7dc558c29841b9934d1fcadc19fa155b38374feb
Author: Julien Nabet 
AuthorDate: Sat Nov 13 12:28:16 2021 +0100
Commit: Julien Nabet 
CommitDate: Sat Nov 13 13:40:09 2021 +0100

loplugin:conststringvar

[CXX] vcl/source/window/keycod.cxx
/home/julien/lo/libreoffice/vcl/skia/SkiaHelper.cxx:664:21: error: variable 
is only used as rvalue, should be const [loplugin:conststringvar]
const char* diff = R"(
^~
1 error generated.

From 
https://cgit.freedesktop.org/libreoffice/core/commit/?id=110fa313628c55fef1d35830358aea7e27c1e3ee
get rid of Skia's 'rasterhack' for Invert()
It seems that manually writing a shader that does the same
as SkBlendMode::kDifference works fine even though the blend mode
crashes e.g. on Windows/AMD. So get rid of the memory<->GPU
conversions and use the shader as a workaround.

Change-Id: I721d88664f9cb03529ec6e9244424d8e3ed4d156
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125126
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index ed04e5f20ec0..57bde5abf919 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -661,7 +661,7 @@ void setBlendModeDifference(SkPaint* paint)
 // so do that.
 if (!differenceBlender)
 {
-const char* diff = R"(
+const char* const diff = R"(
 vec4 main( vec4 src, vec4 dst )
 {
 return vec4(abs( src.r - dst.r ), abs( src.g - dst.g ), abs( 
src.b - dst.b ), dst.a );


[Libreoffice-commits] core.git: vcl/skia

2021-11-12 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   62 ---
 1 file changed, 30 insertions(+), 32 deletions(-)

New commits:
commit 754697f0dcd63e1f0ce2edd70ab8b42b1b4d4484
Author: Luboš Luňák 
AuthorDate: Thu Nov 11 16:23:53 2021 +0100
Commit: Luboš Luňák 
CommitDate: Fri Nov 12 18:49:19 2021 +0100

revert part of 'loplugin:flatten' in Skia code

The automated code flattening may make sense in old spaghetti code,
but this is new code, and it's structured the way it makes sense.
Both those if's are logically just a part of a larger function
and bailing out sooner is at least conceptually wrong (and the moment
I add more code there, I'd need to revert anyway).

Change-Id: Iddbd22166159429636196eb1545b008ef576036b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125054
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 1fb1518386d0..9e2da70323de 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -455,23 +455,22 @@ void SkiaSalGraphicsImpl::postDraw()
 }
 SkiaZone::leave(); // matched in preDraw()
 // If there's a problem with the GPU context, abort.
-GrDirectContext* context = 
GrAsDirectContext(mSurface->getCanvas()->recordingContext());
-if (!context)
-return;
-
-// Running out of memory on the GPU technically could be possibly 
recoverable,
-// but we don't know the exact status of the surface (and what has or has 
not been drawn to it),
-// so in practice this is unrecoverable without possible data loss.
-if (context->oomed())
-{
-SAL_WARN("vcl.skia", "GPU context has run out of memory, aborting.");
-abort();
-}
-// Unrecoverable problem.
-if (context->abandoned())
+if (GrDirectContext* context = 
GrAsDirectContext(mSurface->getCanvas()->recordingContext()))
 {
-SAL_WARN("vcl.skia", "GPU context has been abandoned, aborting.");
-abort();
+// Running out of memory on the GPU technically could be possibly 
recoverable,
+// but we don't know the exact status of the surface (and what has or 
has not been drawn to it),
+// so in practice this is unrecoverable without possible data loss.
+if (context->oomed())
+{
+SAL_WARN("vcl.skia", "GPU context has run out of memory, 
aborting.");
+abort();
+}
+// Unrecoverable problem.
+if (context->abandoned())
+{
+SAL_WARN("vcl.skia", "GPU context has been abandoned, aborting.");
+abort();
+}
 }
 }
 
@@ -1061,22 +1060,21 @@ static void roundPolygonPoints(basegfx::B2DPolyPolygon& 
polyPolygon)
 
 void SkiaSalGraphicsImpl::checkPendingDrawing()
 {
-if (mLastPolyPolygonInfo.polygons.size() == 0)
-return;
-
-// Flush any pending polygon drawing.
-basegfx::B2DPolyPolygonVector polygons;
-std::swap(polygons, mLastPolyPolygonInfo.polygons);
-double transparency = mLastPolyPolygonInfo.transparency;
-mLastPolyPolygonInfo.bounds.reset();
-if (polygons.size() == 1)
-performDrawPolyPolygon(polygons.front(), transparency, true);
-else
-{
-for (basegfx::B2DPolyPolygon& p : polygons)
-roundPolygonPoints(p);
-
performDrawPolyPolygon(basegfx::utils::mergeToSinglePolyPolygon(polygons), 
transparency,
-   true);
+if (mLastPolyPolygonInfo.polygons.size() != 0)
+{ // Flush any pending polygon drawing.
+basegfx::B2DPolyPolygonVector polygons;
+std::swap(polygons, mLastPolyPolygonInfo.polygons);
+double transparency = mLastPolyPolygonInfo.transparency;
+mLastPolyPolygonInfo.bounds.reset();
+if (polygons.size() == 1)
+performDrawPolyPolygon(polygons.front(), transparency, true);
+else
+{
+for (basegfx::B2DPolyPolygon& p : polygons)
+roundPolygonPoints(p);
+
performDrawPolyPolygon(basegfx::utils::mergeToSinglePolyPolygon(polygons), 
transparency,
+   true);
+}
 }
 }
 


[Libreoffice-commits] core.git: vcl/skia

2021-11-12 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 1008f2a06e43c19b7d8b95427198bd691eed5992
Author: Luboš Luňák 
AuthorDate: Wed Nov 10 16:29:36 2021 +0100
Commit: Luboš Luňák 
CommitDate: Fri Nov 12 11:08:40 2021 +0100

clean up SkCanvas before using the bitmap it's painted to

I think this is not strictly needed with raster bitmaps, but still,
this is the proper way.

Change-Id: If6ccf82cf633afefa5c043096ec01b5f3891dc0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125057
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 642752a3bbdd..cc5e309a4d40 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -680,10 +680,12 @@ void SkiaSalGraphicsImpl::applyXor()
 abort();
 SkPaint paint;
 paint.setBlendMode(SkBlendMode::kSrc); // copy as is
-SkCanvas canvas(surfaceBitmap);
 SkRect area = SkRect::Make(mXorRegion.getBounds());
-canvas.drawImageRect(makeCheckedImageSnapshot(mSurface), area, area, 
SkSamplingOptions(),
- , SkCanvas::kFast_SrcRectConstraint);
+{
+SkCanvas canvas(surfaceBitmap);
+canvas.drawImageRect(makeCheckedImageSnapshot(mSurface), area, area, 
SkSamplingOptions(),
+ , SkCanvas::kFast_SrcRectConstraint);
+}
 // xor to surfaceBitmap
 assert(surfaceBitmap.info().alphaType() == kUnpremul_SkAlphaType);
 assert(mXorBitmap.info().alphaType() == kUnpremul_SkAlphaType);


[Libreoffice-commits] core.git: vcl/skia

2021-11-12 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   93 ++-
 1 file changed, 27 insertions(+), 66 deletions(-)

New commits:
commit b11a510541f3758e1769f75b34cf27e70b846923
Author: Luboš Luňák 
AuthorDate: Mon Sep 13 14:08:33 2021 +0200
Commit: Luboš Luňák 
CommitDate: Fri Nov 12 11:08:22 2021 +0100

drop usage of SkSurface::draw()

It causes so many problems that it almost doesn't get used in practice
anyway.

Change-Id: Ie11042749d0cca998af45be1daee6f14bf9531f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125056
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 434209ae1dcf..642752a3bbdd 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1213,37 +1213,6 @@ bool 
SkiaSalGraphicsImpl::drawPolyPolygonBezier(sal_uInt32, const sal_uInt32*, c
 return false;
 }
 
-static void copyArea(SkCanvas* canvas, sk_sp surface, tools::Long 
nDestX,
- tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY,
- tools::Long nSrcWidth, tools::Long nSrcHeight, bool 
srcIsRaster,
- bool destIsRaster)
-{
-// Using SkSurface::draw() should be more efficient than 
SkSurface::makeImageSnapshot(),
-// because it may detect copying to itself and avoid some needless copies.
-// But it has problems with drawing to itself
-// (https://groups.google.com/forum/#!topic/skia-discuss/6yiuw24jv0I) and 
also
-// raster surfaces do not avoid a copy of the source
-// (https://groups.google.com/forum/#!topic/skia-discuss/S3FMpCi82k0).
-// Finally, there's not much point if one of them is raster and the other 
is not (chrome/m86 even crashes).
-if (canvas == surface->getCanvas() || srcIsRaster || (srcIsRaster != 
destIsRaster))
-{
-SkPaint paint;
-paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
-canvas->drawImageRect(makeCheckedImageSnapshot(surface),
-  SkRect::MakeXYWH(nSrcX, nSrcY, nSrcWidth, 
nSrcHeight),
-  SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, 
nSrcHeight),
-  SkSamplingOptions(), , 
SkCanvas::kFast_SrcRectConstraint);
-return;
-}
-// SkCanvas::draw() cannot do a subrectangle, so clip.
-canvas->save();
-canvas->clipRect(SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight));
-SkPaint paint;
-paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
-surface->draw(canvas, nDestX - nSrcX, nDestY - nSrcY, );
-canvas->restore();
-}
-
 void SkiaSalGraphicsImpl::copyArea(tools::Long nDestX, tools::Long nDestY, 
tools::Long nSrcX,
tools::Long nSrcY, tools::Long nSrcWidth, 
tools::Long nSrcHeight,
bool /*bWindowInvalidate*/)
@@ -1256,8 +1225,13 @@ void SkiaSalGraphicsImpl::copyArea(tools::Long nDestX, 
tools::Long nDestY, tools
<< SkIRect::MakeXYWH(nDestX, nDestY, 
nSrcWidth, nSrcHeight));
 assert(!mXorMode);
 addUpdateRegion(SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight));
-::copyArea(getDrawCanvas(), mSurface, nDestX, nDestY, nSrcX, nSrcY, 
nSrcWidth, nSrcHeight,
-   !isGPU(), !isGPU());
+// Using SkSurface::draw() should be more efficient, but it's too buggy.
+SkPaint paint;
+paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
+getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(mSurface),
+   SkRect::MakeXYWH(nSrcX, nSrcY, nSrcWidth, 
nSrcHeight),
+   SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, 
nSrcHeight),
+   SkSamplingOptions(), , 
SkCanvas::kFast_SrcRectConstraint);
 postDraw();
 }
 
@@ -1280,39 +1254,26 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& 
rPosAry, SalGraphics* pSrcG
 assert(!mXorMode);
 addUpdateRegion(SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, 
rPosAry.mnDestWidth,
  rPosAry.mnDestHeight));
-if (rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == 
rPosAry.mnDestHeight)
-{
-auto srcDebug = [&]() -> std::string {
-if (src == this)
-return "(self)";
-else
-{
-std::ostringstream stream;
-stream << "(" << src << ")";
-return stream.str();
-}
-};
-SAL_INFO("vcl.skia.trace",
- "copybits(" << this << "): " << srcDebug() << " copy area: " 
<< rPosAry);
-::copyArea(getDrawCanvas(), src->mSurface, rPosAry.mnDestX, 
rPosAry.mnDestY, rPosAry.mnSrcX,
-   rPosAry.mnSrcY, rPosAry.mnDestWidth, rPosAry.mnDestHeight, 
!src->isGPU(),
-   !isGPU());
-}
-else
-{

[Libreoffice-commits] core.git: vcl/skia

2021-11-12 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   70 +--
 1 file changed, 24 insertions(+), 46 deletions(-)

New commits:
commit 0bd7dcf09d1801b03367ecbfd388c5940081d483
Author: Luboš Luňák 
AuthorDate: Fri Sep 10 16:06:03 2021 +0200
Commit: Luboš Luňák 
CommitDate: Fri Nov 12 09:12:47 2021 +0100

reduce copy

Change-Id: Ie37f96755f348316bb8d5129df925134943e7ace
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125055
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 73f6cc3dd479..434209ae1dcf 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1466,46 +1466,24 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon 
const& rPoly, SalInvert eFl
 addPolygonToPath(rPoly, aPath);
 aPath.setFillType(SkPathFillType::kEvenOdd);
 addUpdateRegion(aPath.getBounds());
+SkAutoCanvasRestore autoRestore(getDrawCanvas(), true);
+SkPaint aPaint;
 // TrackFrame just inverts a dashed path around the polygon
 if (eFlags == SalInvert::TrackFrame)
 {
 // TrackFrame is not supposed to paint outside of the polygon (usually 
rectangle),
 // but wider stroke width usually results in that, so ensure the 
requirement
 // by clipping.
-SkAutoCanvasRestore autoRestore(getDrawCanvas(), true);
 getDrawCanvas()->clipRect(aPath.getBounds(), SkClipOp::kIntersect, 
false);
-SkPaint aPaint;
 aPaint.setStrokeWidth(2);
-float intervals[] = { 4.0f, 4.0f };
+constexpr float intervals[] = { 4.0f, 4.0f };
 aPaint.setStyle(SkPaint::kStroke_Style);
 aPaint.setPathEffect(SkDashPathEffect::Make(intervals, 
SK_ARRAY_COUNT(intervals), 0));
 aPaint.setColor(SkColorSetARGB(255, 255, 255, 255));
 aPaint.setBlendMode(SkBlendMode::kDifference);
-if (!rasterHack)
-getDrawCanvas()->drawPath(aPath, aPaint);
-else
-{
-SkRect area;
-aPath.getBounds().roundOut();
-SkRect size = SkRect::MakeWH(area.width(), area.height());
-sk_sp surface
-= SkSurface::MakeRasterN32Premul(area.width(), area.height(), 
surfaceProps());
-SkPaint copy;
-copy.setBlendMode(SkBlendMode::kSrc);
-flushDrawing();
-
surface->getCanvas()->drawImageRect(makeCheckedImageSnapshot(mSurface), area, 
size,
-SkSamplingOptions(), ,
-
SkCanvas::kFast_SrcRectConstraint);
-aPath.offset(-area.x(), -area.y());
-surface->getCanvas()->drawPath(aPath, aPaint);
-getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(surface), 
size, area,
-   SkSamplingOptions(), ,
-   SkCanvas::kFast_SrcRectConstraint);
-}
 }
 else
 {
-SkPaint aPaint;
 aPaint.setColor(SkColorSetARGB(255, 255, 255, 255));
 aPaint.setStyle(SkPaint::kFill_Style);
 aPaint.setBlendMode(SkBlendMode::kDifference);
@@ -1532,27 +1510,27 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon 
const& rPoly, SalInvert eFl
 aPaint.setShader(
 aBitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, 
SkSamplingOptions()));
 }
-if (!rasterHack)
-getDrawCanvas()->drawPath(aPath, aPaint);
-else
-{
-SkRect area;
-aPath.getBounds().roundOut();
-SkRect size = SkRect::MakeWH(area.width(), area.height());
-sk_sp surface
-= SkSurface::MakeRasterN32Premul(area.width(), area.height(), 
surfaceProps());
-SkPaint copy;
-copy.setBlendMode(SkBlendMode::kSrc);
-flushDrawing();
-
surface->getCanvas()->drawImageRect(makeCheckedImageSnapshot(mSurface), area, 
size,
-SkSamplingOptions(), ,
-
SkCanvas::kFast_SrcRectConstraint);
-aPath.offset(-area.x(), -area.y());
-surface->getCanvas()->drawPath(aPath, aPaint);
-getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(surface), 
size, area,
-   SkSamplingOptions(), ,
-   SkCanvas::kFast_SrcRectConstraint);
-}
+}
+if (!rasterHack)
+getDrawCanvas()->drawPath(aPath, aPaint);
+else
+{
+SkRect area;
+aPath.getBounds().roundOut();
+SkRect size = SkRect::MakeWH(area.width(), area.height());
+sk_sp surface
+= SkSurface::MakeRasterN32Premul(area.width(), area.height(), 
surfaceProps());
+SkPaint copy;
+copy.setBlendMode(SkBlendMode::kSrc);
+flushDrawing();
+

[Libreoffice-commits] core.git: vcl/skia

2021-11-08 Thread Ilmari Lauhakangas (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 7db51fdbd8c06192941666ad8f444079c334fdef
Author: Ilmari Lauhakangas 
AuthorDate: Mon Nov 8 14:48:23 2021 +0200
Commit: Ilmari Lauhakangas 
CommitDate: Mon Nov 8 20:42:13 2021 +0100

Add an Intel Iris driver to Skia/Vulkan denylist

From off-topic comments in tdf#144923

Change-Id: I1f91622c29d2f8e1b0acd88b6e6fe1c2d5429466
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124845
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 9ae2fce70c6f..e2cd9e3aa6ab 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -27,6 +27,9 @@
  

 
 
+ 
+
+
 
 
 


[Libreoffice-commits] core.git: vcl/skia

2021-09-22 Thread Julien Nabet (via logerrit)
 vcl/skia/README |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 876b58e7030b2a24eca5464bb172bdd0b45c8546
Author: Julien Nabet 
AuthorDate: Tue Sep 21 21:17:33 2021 +0200
Commit: Julien Nabet 
CommitDate: Wed Sep 22 13:04:19 2021 +0200

Fix Skia/Raster description

See https://bugs.documentfoundation.org/show_bug.cgi?id=144598#c16

Change-Id: I5a39fbc324af0944560e91d4249ab572e5579af1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122404
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/README b/vcl/skia/README
index 8381dd8dca89..f2903d97fdd7 100644
--- a/vcl/skia/README
+++ b/vcl/skia/README
@@ -13,7 +13,7 @@ Skia drawing methods:
 =
 
 Skia supports several methods to draw:
-- Raster - CPU-based drawing (here primarily used for debugging)
+- Raster - CPU-based drawing (here primarily used for fallback when Vulkan 
isn't available or for debugging)
 - Vulkan - Vulkan-based GPU drawing, this is the default
 - Metal - MACOSX GPU drawing, this is the Mac default
 


[Libreoffice-commits] core.git: vcl/skia

2021-09-10 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ef6def16e8d83bd425f3613c19989a409db7eb66
Author: Luboš Luňák 
AuthorDate: Wed Sep 1 15:58:43 2021 +0200
Commit: Luboš Luňák 
CommitDate: Fri Sep 10 15:32:56 2021 +0200

fix Skia/Raster screen flushing on Mac

There's no window context in that case, so check the surface, as
other places do. A mistake from 234ed4bcd5c4b5b41467890b82c6ef.

Change-Id: I7f9d97340ed30444cb151c1141f8cc3045bd6dea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121892
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 433663eadd55..c580471a9608 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -395,7 +395,7 @@ void SkiaSalGraphicsImpl::performFlush()
 {
 SkiaZone zone;
 flushDrawing();
-if (mWindowContext)
+if (mSurface)
 {
 if (mDirtyRect.intersect(SkIRect::MakeWH(GetWidth(), GetHeight(
 flushSurfaceToWindowContext();


[Libreoffice-commits] core.git: vcl/skia

2021-08-31 Thread Luboš Luňák (via logerrit)
 vcl/skia/SkiaHelper.cxx |   54 +++-
 1 file changed, 40 insertions(+), 14 deletions(-)

New commits:
commit bbf7dc39abf64c314e9c43c4d0554d1d7bdef3e7
Author: Luboš Luňák 
AuthorDate: Mon Aug 30 11:51:25 2021 +0200
Commit: Luboš Luňák 
CommitDate: Tue Aug 31 10:04:23 2021 +0200

test at least creating Metal context when initializing Skia

Change-Id: Ic00236e7876039c3f5c0c1e719e829b844d1d2e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121271
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 6881ad1cbf83..458f415befa4 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -158,7 +158,7 @@ static void writeSkiaRasterInfo()
 writeToLog(logFile, "Compiler", skia_compiler_name());
 }
 
-#ifdef SK_VULKAN
+#if defined(SK_VULKAN) || defined(SK_METAL)
 static std::unique_ptr getTemporaryWindowContext();
 #endif
 
@@ -170,6 +170,7 @@ static void checkDeviceDenylisted(bool blockDisable = false)
 
 SkiaZone zone;
 
+bool useRaster = false;
 switch (renderMethodToUse())
 {
 case RenderVulkan:
@@ -204,32 +205,57 @@ static void checkDeviceDenylisted(bool blockDisable = 
false)
 if (denylisted && !blockDisable)
 {
 disableRenderMethod(RenderVulkan);
-writeSkiaRasterInfo();
+useRaster = true;
 }
-break;
 #else
 SAL_WARN("vcl.skia", "Vulkan support not built in");
 (void)blockDisable;
-[[fallthrough]];
+useRaster = true;
 #endif
+break;
 }
 case RenderMetal:
+{
 #ifdef SK_METAL
-// Try to assume Metal always works, given that Mac doesn't have 
such as wide range of HW vendors as PC.
-// If there turns out to be problems, handle it similarly to 
Vulkan.
-SAL_INFO("vcl.skia", "Using Skia Metal mode");
-writeSkiaMetalInfo();
-break;
+// First try if a GrDirectContext already exists.
+std::unique_ptr temporaryWindowContext;
+GrDirectContext* grDirectContext = 
sk_app::getMetalSharedGrDirectContext();
+if (!grDirectContext)
+{
+// Create a temporary window context just to get the 
GrDirectContext,
+// as an initial test of Metal functionality.
+temporaryWindowContext = getTemporaryWindowContext();
+grDirectContext = sk_app::getMetalSharedGrDirectContext();
+}
+if (grDirectContext) // Metal was initialized properly
+{
+// Try to assume Metal always works, given that Mac doesn't 
have such as wide range of HW vendors as PC.
+// If there turns out to be problems, handle it similarly to 
Vulkan.
+SAL_INFO("vcl.skia", "Using Skia Metal mode");
+writeSkiaMetalInfo();
+}
+else
+{
+SAL_INFO("vcl.skia", "Metal could not be initialized");
+disableRenderMethod(RenderMetal);
+useRaster = true;
+}
 #else
 SAL_WARN("vcl.skia", "Metal support not built in");
-[[fallthrough]];
+useRaster = true;
 #endif
+break;
+}
 case RenderRaster:
-SAL_INFO("vcl.skia", "Using Skia raster mode");
-// software, never denylisted
-writeSkiaRasterInfo();
+useRaster = true;
 break;
 }
+if (useRaster)
+{
+SAL_INFO("vcl.skia", "Using Skia raster mode");
+// software, never denylisted
+writeSkiaRasterInfo();
+}
 done = true;
 }
 
@@ -431,7 +457,7 @@ GrDirectContext* getSharedGrDirectContext()
 return nullptr;
 }
 
-#ifdef SK_VULKAN
+#if defined(SK_VULKAN) || defined(SK_METAL)
 static std::unique_ptr getTemporaryWindowContext()
 {
 if (createGpuWindowContextFunction == nullptr)


[Libreoffice-commits] core.git: vcl/skia

2021-08-30 Thread Luboš Luňák (via logerrit)
 vcl/skia/x11/gdiimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 774bc3d64b6e1149ab9607e3fd11c96eee0da59f
Author: Luboš Luňák 
AuthorDate: Mon Aug 30 12:10:44 2021 +0200
Commit: Luboš Luňák 
CommitDate: Mon Aug 30 15:25:50 2021 +0200

fix missing variable assignment

Change-Id: Ic353aabe130dd82d4ee14208ab2c8d66fd839681
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121293
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index b53e0bd5cea7..b667dbe4c2b7 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -53,7 +53,7 @@ void X11SkiaSalGraphicsImpl::createWindowSurfaceInternal(bool 
forceRaster)
 {
 // See flushSurfaceToWindowContext().
 if (renderMethod == RenderRaster)
-mWindowContext->getBackbufferSurface();
+mSurface = mWindowContext->getBackbufferSurface();
 else
 mSurface = createSkSurface(GetWidth(), GetHeight());
 }


[Libreoffice-commits] core.git: vcl/skia

2021-08-27 Thread Stephan Bergmann (via logerrit)
 vcl/skia/osx/gdiimpl.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit c7c2b90ad4ed88856699dae2839a3437ec3a9c77
Author: Stephan Bergmann 
AuthorDate: Fri Aug 27 13:49:55 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Aug 27 16:20:05 2021 +0200

-Werror,-Wdeprecated-anon-enum-enum-conversion

...similar to 5b8f505cd11517362b2c4a29c87d802a286a677d "Avoid
-Werror,-Wdeprecated-anon-enum-enum-conversion"

Change-Id: Ia9e8994cdb74ecdb078f347c864a89ad40321609
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121143
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 13a5dd32aa82..c262a93c14fe 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -106,15 +106,16 @@ constexpr static uint32_t toCGBitmapType(SkColorType 
color, SkAlphaType alpha)
 if (alpha == kPremul_SkAlphaType)
 {
 return color == kBGRA__SkColorType
-   ? (kCGImageAlphaPremultipliedFirst | 
kCGBitmapByteOrder32Little)
-   : (kCGImageAlphaPremultipliedLast | 
kCGBitmapByteOrder32Big);
+   ? (uint32_t(kCGImageAlphaPremultipliedFirst)
+  | uint32_t(kCGBitmapByteOrder32Little))
+   : (uint32_t(kCGImageAlphaPremultipliedLast) | 
uint32_t(kCGBitmapByteOrder32Big));
 }
 else
 {
 assert(alpha == kOpaque_SkAlphaType);
 return color == kBGRA__SkColorType
-   ? (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little)
-   : (kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big);
+   ? (uint32_t(kCGImageAlphaNoneSkipFirst) | 
uint32_t(kCGBitmapByteOrder32Little))
+   : (uint32_t(kCGImageAlphaNoneSkipLast) | 
uint32_t(kCGBitmapByteOrder32Big));
 }
 }
 


[Libreoffice-commits] core.git: vcl/skia

2021-08-24 Thread Noel Grandin (via logerrit)
 vcl/skia/gdiimpl.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 6b2046b41719a391e758ea57055adb2e111f94c1
Author: Noel Grandin 
AuthorDate: Mon Aug 23 20:27:01 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Aug 24 11:28:07 2021 +0200

reduce skia realloc when drawing polygons

Change-Id: Ide65945b2baa01b78c954112cdbf35edc41e2f8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120916
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index ef4809bc0288..f3122dc208e5 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -148,8 +148,8 @@ void addPolyPolygonToPath(const basegfx::B2DPolyPolygon& 
rPolyPolygon, SkPath& r
 
 sal_uInt32 nPointCount = 0;
 for (const auto& rPolygon : rPolyPolygon)
-nPointCount += rPolygon.count();
-rPath.incReserve(nPointCount * 2);
+nPointCount += rPolygon.count() * 3; // because cubicTo is 3 elements
+rPath.incReserve(nPointCount);
 
 for (const auto& rPolygon : rPolyPolygon)
 {
@@ -1142,7 +1142,7 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const 
basegfx::B2DHomMatrix& rObjectToDev
 if (eLineJoin != basegfx::B2DLineJoin::NONE || fLineWidth <= 1.0)
 {
 SkPath aPath;
-aPath.incReserve(aPolyLine.count() + 2);
+aPath.incReserve(aPolyLine.count() * 3); // because cubicTo is 3 
elements
 aPath.setFillType(SkPathFillType::kEvenOdd);
 addPolygonToPath(aPolyLine, aPath);
 aPath.offset(toSkX(0) + posFix, toSkY(0) + posFix, nullptr);


[Libreoffice-commits] core.git: vcl/skia

2021-07-01 Thread Attila Szűcs (via logerrit)
 vcl/skia/salbmp.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit aa7b1f2ec7da5b94459f808e151085f4d301afd1
Author: Attila Szűcs 
AuthorDate: Thu Jul 1 02:58:09 2021 +0200
Commit: László Németh 
CommitDate: Thu Jul 1 17:05:29 2021 +0200

tdf#143059 sw export: fix assert crash

Incomplete reset in SkiaSalBitmap::ResetAllData() was
followed by a broken scaling of a dummy image without
buffer/image data.

SvxLineStyleToolBoxControl::statusChanged() creates
a dummy image via GetBitmapForUISolidLine... deleted its
image/buffer data immediately ("no line style" dummy
image preview for the line style popup list).

But the dummy image wasn't ready, it still needed
postponed scaling processed by the GPU. This information
wasn't reset by Erase, and without pixel data it couldn't
be scaled, so this dummy image became a forever "not ready"/
"waiting to be scaled" image. There are parts in the code
that require that the image is already scaled... These parts
check if scalings are ended with the assert(mPixelsSize == mSize).

Note: Use the following method to start LO with Skia in Linux

SAL_USE_VCLPLUGIN=gen SAL_ENABLESKIA=1 ./soffice

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: I5099eb8671a1c5d16668743f26feb47fe99cd70e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118204
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index fa2cf67ed5d9..3c0c9d32ed99 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -1289,6 +1289,8 @@ void SkiaSalBitmap::ResetAllData()
 mImage.reset();
 mAlphaImage.reset();
 mEraseColorSet = false;
+mPixelsSize = mSize;
+ComputeScanlineSize();
 }
 
 void SkiaSalBitmap::ResetPendingScaling()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-05-24 Thread Luboš Luňák (via logerrit)
 vcl/skia/win/gdiimpl.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 1b97f8010bc3e7af1aadc19a29a621aa5a3bb986
Author: Luboš Luňák 
AuthorDate: Fri May 7 21:53:13 2021 +0200
Commit: Luboš Luňák 
CommitDate: Mon May 24 11:01:11 2021 +0200

disable AA in Skia/Windows text rendering if asked to

Change-Id: I8bff295277c623125d81de7804b43f91f680df4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115619
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 24daf1fc8b7c..e245f488433a 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -235,7 +235,8 @@ bool WinSkiaSalGraphicsImpl::DrawTextLayout(const 
GenericSalLayout& rLayout)
 if (fontHeight < 0)
 fontHeight = -fontHeight;
 SkFont font(typeface, fontHeight, pWinFont->getHScale(), 0);
-font.setEdging(fontEdging);
+font.setEdging(logFont.lfQuality == NONANTIALIASED_QUALITY ? 
SkFont::Edging::kAlias
+   : fontEdging);
 assert(dynamic_cast(mWinParent.GetImpl()));
 SkiaSalGraphicsImpl* impl = 
static_cast(mWinParent.GetImpl());
 COLORREF color = ::GetTextColor(mWinParent.getHDC());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-04-28 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit 56c450a9e9e12ba55ce8f62de546000df146052d
Author: Luboš Luňák 
AuthorDate: Wed Apr 28 17:22:29 2021 +0200
Commit: Luboš Luňák 
CommitDate: Wed Apr 28 23:24:57 2021 +0200

Skia understands that linewidth == 0 means hairline

Change-Id: Ic5aea464d6414fc2218179143d16121ef293bdfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114816
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index f0b9fb2e0d5c..b0a992fa942f 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1065,11 +1065,8 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const 
basegfx::B2DHomMatrix& rObjectToDev
 preDraw();
 SAL_INFO("vcl.skia.trace", "drawpolyline(" << this << "): " << rPolyLine 
<< ":" << mLineColor);
 
-// tdf#124848 get correct LineWidth in discrete coordinates,
-if (fLineWidth == 0) // hairline
-fLineWidth = 1.0;
-else // Adjust line width for object-to-device scale.
-fLineWidth = (rObjectToDevice * basegfx::B2DVector(fLineWidth, 
0)).getLength();
+// Adjust line width for object-to-device scale.
+fLineWidth = (rObjectToDevice * basegfx::B2DVector(fLineWidth, 
0)).getLength();
 
 // Transform to DeviceCoordinates, get DeviceLineWidth, execute 
PixelSnapHairline
 basegfx::B2DPolyPolygon aPolyPolygonLine;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-04-21 Thread Luboš Luňák (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit eb10c4dd78703f1af501db14a0c72ef5d1b74be4
Author: Luboš Luňák 
AuthorDate: Wed Apr 21 18:50:16 2021 +0200
Commit: Luboš Luňák 
CommitDate: Wed Apr 21 18:51:02 2021 +0200

blacklist intel 0.402.743 vulkan driver (tdf#138729)

Change-Id: Id827dc4daba8abeb5829528283a26a661fe7e6a1

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 507bc04d2d94..9ae2fce70c6f 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -24,6 +24,9 @@
 
 
 
+ 

+
+
 
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-04-20 Thread Luboš Luňák (via logerrit)
 vcl/skia/win/gdiimpl.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 764360df78535befcc4806736fcbaedbe0e34ea1
Author: Luboš Luňák 
AuthorDate: Tue Apr 20 09:48:25 2021 +
Commit: Luboš Luňák 
CommitDate: Tue Apr 20 14:13:47 2021 +0200

fix too wide glyphs with Skia/GDI if horizontal scale is used (tdf#141715)

Change-Id: I7b06b64e04313493f48b7224fbc4883356feda95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114327
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 94162bb55fbe..5f7e1fe3538a 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -216,6 +216,12 @@ bool WinSkiaSalGraphicsImpl::DrawTextLayout(const 
GenericSalLayout& rLayout)
 bool dwrite = true;
 if (!typeface) // fall back to GDI text rendering
 {
+// If lfWidth is kept, then with fHScale != 1 characters get too 
wide, presumably
+// because the horizontal scaling gets applied twice if GDI is 
used for drawing (tdf#141715).
+// Using lfWidth /= fHScale gives slightly incorrect sizes, for a 
reason I don't understand.
+// LOGFONT docs say that 0 means GDI will find out the right value 
on its own somehow,
+// and it apparently works.
+logFont.lfWidth = 0;
 typeface.reset(SkCreateTypefaceFromLOGFONT(logFont));
 dwrite = false;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-04-14 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit aa03f1a564abf967a60a284f5656fb2f2efb977f
Author: Luboš Luňák 
AuthorDate: Wed Apr 14 14:58:32 2021 +0200
Commit: Luboš Luňák 
CommitDate: Wed Apr 14 18:54:54 2021 +0200

SkBlendMode::kDifference causes AMD/Linux driver instability

Change-Id: I70de779c20185ac6efe8da7ad197c5e4c68a8d23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114091
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index e2d4ff9a3800..145bbf19cc4c 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1434,7 +1434,14 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon 
const& rPoly, SalInvert eFl
 // with SkBlendMode::kDifference(?) and surfaces wider than 1024 pixels, 
resulting
 // in drawing errors. Work that around by fetching the relevant part of 
the surface
 // and drawing using CPU.
-bool intelHack = (isGPU() && getVendor() == DriverBlocklist::VendorIntel 
&& !mXorMode);
+bool rasterHack = (isGPU() && getVendor() == DriverBlocklist::VendorIntel 
&& !mXorMode);
+#if defined LINUX
+// BackendTest::testDrawInvertTrackFrameWithRectangle() also has a problem
+// with SkBlendMode::kDifference on AMD/Linux, leading to crashes or even
+// driver instability. Also work around by drawing using CPU.
+if (isGPU() && getVendor() == DriverBlocklist::VendorAMD && !mXorMode)
+rasterHack = true;
+#endif
 SkPath aPath;
 addPolygonToPath(rPoly, aPath);
 aPath.setFillType(SkPathFillType::kEvenOdd);
@@ -1454,7 +1461,7 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon 
const& rPoly, SalInvert eFl
 aPaint.setPathEffect(SkDashPathEffect::Make(intervals, 
SK_ARRAY_COUNT(intervals), 0));
 aPaint.setColor(SkColorSetARGB(255, 255, 255, 255));
 aPaint.setBlendMode(SkBlendMode::kDifference);
-if (!intelHack)
+if (!rasterHack)
 getDrawCanvas()->drawPath(aPath, aPaint);
 else
 {
@@ -1505,7 +1512,7 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon 
const& rPoly, SalInvert eFl
 aPaint.setShader(
 aBitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, 
SkSamplingOptions()));
 }
-if (!intelHack)
+if (!rasterHack)
 getDrawCanvas()->drawPath(aPath, aPaint);
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-03-16 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |   11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

New commits:
commit 2c84920182ee18d0cff97637bc7f20facc5f29cd
Author: Luboš Luňák 
AuthorDate: Mon Mar 15 16:56:44 2021 +0100
Commit: Luboš Luňák 
CommitDate: Tue Mar 16 12:55:53 2021 +0100

with mEraseColorSet, there should be no pixel buffer

Change-Id: Icc39ce0516f6cb058cb11e20420a387a913a81e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112544
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 83dd16950eaa..c8abfb64252b 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -1024,15 +1024,10 @@ void SkiaSalBitmap::EnsureBitmapData()
 if (mEraseColorSet)
 {
 SkiaZone zone;
-if (mPixelsSize != mSize)
-{
-mPixelsSize = mSize;
-ComputeScanlineSize();
-mBuffer.reset();
-}
+assert(mPixelsSize == mSize);
+assert(!mBuffer);
 mScaleQuality = BmpScaleFlag::BestQuality;
-if (!mBuffer)
-CreateBitmapData();
+CreateBitmapData();
 // Unset now, so that repeated call will return mBuffer.
 mEraseColorSet = false;
 PerformErase();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-03-12 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 43390c8642d575b2ebe02f9aae78d7350246119e
Author: Luboš Luňák 
AuthorDate: Fri Mar 12 15:53:54 2021 +0100
Commit: Luboš Luňák 
CommitDate: Fri Mar 12 22:28:27 2021 +0100

convert to/from premultiplied alpha if needed

A mistake from bf2ba0f39be62978b512d6ed101219b9dd0dc6e4.

Change-Id: I8c732e8d79b376c9a5bb7b39c2562663e097db99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112396
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index e8266f86990e..0fa95deb39db 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -1118,8 +1118,11 @@ void SkiaSalBitmap::EnsureBitmapData()
 #endif
 SkBitmap bitmap;
 SkPixmap pixmap;
-if (mSize == mPixelsSize && mImage->peekPixels())
+if (mSize == mPixelsSize && mImage->imageInfo().alphaType() == alphaType
+&& mImage->peekPixels())
+{
 bitmap.installPixels(pixmap);
+}
 else
 {
 if (!bitmap.tryAllocPixels(SkImageInfo::MakeS32(mSize.Width(), 
mSize.Height(), alphaType)))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-03-10 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   31 ---
 1 file changed, 20 insertions(+), 11 deletions(-)

New commits:
commit 88b7ac11be5548f46c3664117173699046895610
Author: Luboš Luňák 
AuthorDate: Tue Mar 9 21:35:42 2021 +0100
Commit: Luboš Luňák 
CommitDate: Wed Mar 10 19:46:03 2021 +0100

cache extensive downscaling in GPU mode too (tdf#140925)

Change-Id: I0d77cf157bc1f669da906ed55feedee6bc78ba7b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112252
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 1a707f7d9476..aa934f1e4942 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1543,14 +1543,12 @@ bool SkiaSalGraphicsImpl::drawEPS(tools::Long, 
tools::Long, tools::Long, tools::
 
 // Create SkImage from a bitmap and possibly an alpha mask (the usual VCL 
one-minus-alpha),
 // with the given target size. Result will be possibly cached, unless disabled.
+// Especially in raster mode scaling and alpha blending may be expensive if 
done repeatedly.
 sk_sp SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& 
bitmap,
   const SkiaSalBitmap* 
alphaBitmap,
   const Size targetSize)
 {
 sk_sp image;
-// GPU-accelerated drawing with SkShader should be fast enough to not need 
caching.
-if (isGPU())
-return image;
 if (targetSize.IsEmpty())
 return image;
 if (alphaBitmap && alphaBitmap->IsFullyOpaqueAsAlpha())
@@ -1561,6 +1559,16 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 // Image too small to be worth caching if not scaling.
 if (targetSize == bitmap.GetSize() && targetSize.Width() < 100 && 
targetSize.Height() < 100)
 return image;
+// GPU-accelerated drawing with SkShader should be fast enough to not need 
caching.
+if (isGPU())
+{
+// tdf#140925: But if this is such an extensive downscaling that 
caching the result
+// would noticeably reduce amount of data processed by the GPU on 
repeated usage, do it.
+int reduceRatio = bitmap.GetSize().Width() * bitmap.GetSize().Height() 
/ targetSize.Width()
+  / targetSize.Height();
+if (reduceRatio < 10)
+return image;
+}
 // In some cases (tdf#134237) the target size may be very large. In that 
case it's
 // better to rely on Skia to clip and draw only the necessary, rather than 
prepare
 // a very large image only to not use most of it.
@@ -1637,6 +1645,9 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 }
 else
 canvas->drawImage(bitmap.GetSkImage(), 0, 0, samplingOptions, );
+if (isGPU())
+SAL_INFO("vcl.skia.trace", "mergecachebitmaps(" << this << "): caching 
GPU downscaling:"
+<< bitmap.GetSize() << 
"->" << targetSize);
 image = makeCheckedImageSnapshot(tmpSurface);
 addCachedImage(key, image);
 return image;
@@ -1649,8 +1660,8 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const 
SalTwoRect& rPosAry, const SalBi
 assert(dynamic_cast());
 const SkiaSalBitmap& rSkiaSourceBitmap = static_cast(rSourceBitmap);
 const SkiaSalBitmap& rSkiaAlphaBitmap = static_cast(rAlphaBitmap);
-// In raster mode use mergeCacheBitmaps(), which will cache the result, 
avoiding repeated
-// alpha blending or scaling. In GPU mode it is simpler to just use 
SkShader.
+// Use mergeCacheBitmaps(), which may decide to cache the result, avoiding 
repeated
+// alpha blending or scaling.
 SalTwoRect imagePosAry(rPosAry);
 Size imageSize = rSourceBitmap.GetSize();
 // If the bitmap will be scaled, prefer to do it in mergeCacheBitmaps(), 
if possible.
@@ -1685,8 +1696,8 @@ void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& 
rPosAry, const SkiaSalBit
 drawShader(rPosAry, bitmap.GetSkShader(makeSamplingOptions(rPosAry)), 
blendMode);
 return;
 }
-// In raster mode use mergeCacheBitmaps(), which will cache the result, 
avoiding repeated
-// scaling. In GPU mode it is simpler to just use SkShader.
+// Use mergeCacheBitmaps(), which may decide to cache the result, avoiding 
repeated
+// scaling.
 SalTwoRect imagePosAry(rPosAry);
 Size imageSize = bitmap.GetSize();
 // If the bitmap will be scaled, prefer to do it in mergeCacheBitmaps(), 
if possible.
@@ -1826,10 +1837,8 @@ bool SkiaSalGraphicsImpl::drawTransformedBitmap(const 
basegfx::B2DPoint& rNull,
 << " " << rNull << ":" 
<< rX << ":" << rY);
 
 addUpdateRegion(SkRect::MakeWH(GetWidth(), GetHeight())); // can't tell, 
use whole area
-// In raster mode scaling and alpha blending is still somewhat expensive 
if done repeatedly,
-// so use mergeCacheBitmaps(), which 

[Libreoffice-commits] core.git: vcl/skia

2021-03-10 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |   70 ++--
 1 file changed, 41 insertions(+), 29 deletions(-)

New commits:
commit bf2ba0f39be62978b512d6ed101219b9dd0dc6e4
Author: Luboš Luňák 
AuthorDate: Tue Mar 9 22:08:04 2021 +0100
Commit: Luboš Luňák 
CommitDate: Wed Mar 10 19:45:43 2021 +0100

access pixels directly if SkImage is a raster one (tdf#140925)

This avoids copying the data to a temporary storage that's not needed.
Moreover Skia does not memcpy() the data if the format is
kAlpha_8_SkColorType.

Change-Id: I66974acd7656df8b82d1babacf7a0cb60711fc76
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112253
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index b94debcb7d3a..e8266f86990e 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -1054,13 +1054,19 @@ void SkiaSalBitmap::EnsureBitmapData()
 assert(mAlphaImage->colorType() == kAlpha_8_SkColorType);
 SkiaZone zone;
 SkBitmap bitmap;
-if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(mSize.Width(), 
mSize.Height(
-abort();
-SkCanvas canvas(bitmap);
-SkPaint paint;
-paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
-canvas.drawImage(mAlphaImage, 0, 0, SkSamplingOptions(), );
-canvas.flush();
+SkPixmap pixmap;
+if (mAlphaImage->peekPixels())
+bitmap.installPixels(pixmap);
+else
+{
+if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(mSize.Width(), 
mSize.Height(
+abort();
+SkCanvas canvas(bitmap);
+SkPaint paint;
+paint.setBlendMode(SkBlendMode::kSrc); // set as is, including 
alpha
+canvas.drawImage(mAlphaImage, 0, 0, SkSamplingOptions(), );
+canvas.flush();
+}
 bitmap.setImmutable();
 CreateBitmapData();
 assert(mBuffer != nullptr);
@@ -,30 +1117,36 @@ void SkiaSalBitmap::EnsureBitmapData()
 alphaType = kPremul_SkAlphaType;
 #endif
 SkBitmap bitmap;
-if (!bitmap.tryAllocPixels(SkImageInfo::MakeS32(mSize.Width(), 
mSize.Height(), alphaType)))
-abort();
-SkCanvas canvas(bitmap);
-SkPaint paint;
-paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
-if (mSize != mPixelsSize) // pending scaling?
+SkPixmap pixmap;
+if (mSize == mPixelsSize && mImage->peekPixels())
+bitmap.installPixels(pixmap);
+else
 {
-assert(mImage->width() == mPixelsSize.getWidth()
-   && mImage->height() == mPixelsSize.getHeight());
-canvas.drawImageRect(mImage, SkRect::MakeWH(mSize.getWidth(), 
mSize.getHeight()),
- makeSamplingOptions(mScaleQuality), );
-SAL_INFO("vcl.skia.trace", "ensurebitmapdata(" << this << "): image 
scaled " << mPixelsSize
-   << "->" << mSize << ":"
-   << 
static_cast(mScaleQuality));
-mPixelsSize = mSize;
-ComputeScanlineSize();
-mScaleQuality = BmpScaleFlag::BestQuality;
-// Information about the pending scaling has been discarded, so make 
sure we do not
-// keep around any cached images that would still need scaling.
-ResetCachedDataBySize();
+if (!bitmap.tryAllocPixels(SkImageInfo::MakeS32(mSize.Width(), 
mSize.Height(), alphaType)))
+abort();
+SkCanvas canvas(bitmap);
+SkPaint paint;
+paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
+if (mSize != mPixelsSize) // pending scaling?
+{
+assert(mImage->width() == mPixelsSize.getWidth()
+   && mImage->height() == mPixelsSize.getHeight());
+canvas.drawImageRect(mImage, SkRect::MakeWH(mSize.getWidth(), 
mSize.getHeight()),
+ makeSamplingOptions(mScaleQuality), );
+SAL_INFO("vcl.skia.trace", "ensurebitmapdata(" << this << "): 
image scaled "
+   << mPixelsSize << 
"->" << mSize << ":"
+   << 
static_cast(mScaleQuality));
+mPixelsSize = mSize;
+ComputeScanlineSize();
+mScaleQuality = BmpScaleFlag::BestQuality;
+// Information about the pending scaling has been discarded, so 
make sure we do not
+// keep around any cached images that would still need scaling.
+ResetCachedDataBySize();
+}
+else
+canvas.drawImage(mImage, 0, 0, SkSamplingOptions(), );
+canvas.flush();
 }
-else
-canvas.drawImage(mImage, 0, 0, SkSamplingOptions(), );
-canvas.flush();
 bitmap.setImmutable();
 CreateBitmapData();
 assert(mBuffer 

[Libreoffice-commits] core.git: vcl/skia

2021-03-10 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 7ba7a1170a46ad340d06822a03f7196ccef29d84
Author: Luboš Luňák 
AuthorDate: Wed Mar 10 13:03:54 2021 +0100
Commit: Luboš Luňák 
CommitDate: Wed Mar 10 15:32:02 2021 +0100

forgotten ComputeScanlineSize() (tdf#140917)

Change-Id: Id139cea52832b7973dfac47d309d5bba8299b4e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112263
Reviewed-by: Mark Hung 
Reviewed-by: Luboš Luňák 
Tested-by: Jenkins

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 68d2f9a76964..b94debcb7d3a 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -388,6 +388,7 @@ bool SkiaSalBitmap::Scale(const double& rScaleX, const 
double& rScaleY, BmpScale
 if (mEraseColorSet)
 { // Simple.
 mSize = mPixelsSize = newSize;
+ComputeScanlineSize();
 EraseInternal(mEraseColor);
 return true;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-03-04 Thread Luboš Luňák (via logerrit)
 vcl/skia/win/gdiimpl.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 0087dc55121808a7fbf09cd94549b44dc17707dd
Author: Luboš Luňák 
AuthorDate: Thu Mar 4 16:40:19 2021 +
Commit: Luboš Luňák 
CommitDate: Thu Mar 4 20:23:45 2021 +0100

actually restore the original HFONT

A mistake I made when fixing tdf#137122.

Change-Id: Ie3a258de69e17d8cedb3bf722841af1054bd0fe1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111972
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 9381693213b1..6b09375c4138 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -176,10 +176,13 @@ sk_sp 
WinSkiaSalGraphicsImpl::createDirectWriteTypeface(HDC hdc, HFO
 // included the DWrite system font collection). For such cases, we'll
 // need to fall back to Skia's GDI-based font rendering.
 HFONT oldFont = SelectFont(hdc, hfont);
-auto restoreFont = [hdc, oldFont]() { SelectFont(hdc, oldFont); };
 sal::systools::COMReference fontFace;
 if (FAILED(CHECKHR(dwriteGdiInterop->CreateFontFaceFromHdc(hdc, 

+{
+SelectFont(hdc, oldFont);
 return nullptr;
+}
+SelectFont(hdc, oldFont);
 sal::systools::COMReference collection;
 if (FAILED(CHECKHR(dwriteFactory->GetSystemFontCollection(
 return nullptr;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2021-03-03 Thread Luboš Luňák (via logerrit)
 vcl/skia/SkiaHelper.cxx  |8 ++---
 vcl/skia/gdiimpl.cxx |   75 +++
 vcl/skia/salbmp.cxx  |   44 ---
 vcl/skia/win/gdiimpl.cxx |   16 +-
 vcl/skia/x11/gdiimpl.cxx |   19 ++-
 vcl/skia/zone.cxx|6 +--
 6 files changed, 83 insertions(+), 85 deletions(-)

New commits:
commit 715fe00a5052b35310b2d1289ab6137d77767ddd
Author: Luboš Luňák 
AuthorDate: Mon Mar 1 20:18:12 2021 +0100
Commit: Luboš Luňák 
CommitDate: Wed Mar 3 11:08:02 2021 +0100

'using namespace SkiaHelper' in skia vcl sources

Change-Id: I9a9f687242c788ca5e4594d7cb20d66403e0421a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111793
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 0616c5060af0..b9b5b4fb2f20 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -389,9 +389,9 @@ sk_sp createSkSurface(int width, int height, 
SkColorType type, SkAlph
 SkiaZone zone;
 assert(type == kN32_SkColorType || type == kAlpha_8_SkColorType);
 sk_sp surface;
-switch (SkiaHelper::renderMethodToUse())
+switch (renderMethodToUse())
 {
-case SkiaHelper::RenderVulkan:
+case RenderVulkan:
 {
 if (GrDirectContext* grDirectContext = getSharedGrDirectContext())
 {
@@ -432,9 +432,9 @@ sk_sp createSkImage(const SkBitmap& bitmap)
 {
 SkiaZone zone;
 assert(bitmap.colorType() == kN32_SkColorType || bitmap.colorType() == 
kAlpha_8_SkColorType);
-switch (SkiaHelper::renderMethodToUse())
+switch (renderMethodToUse())
 {
-case SkiaHelper::RenderVulkan:
+case RenderVulkan:
 {
 if (GrDirectContext* grDirectContext = getSharedGrDirectContext())
 {
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 36e10068afb6..1a707f7d9476 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -319,20 +319,20 @@ void SkiaSalGraphicsImpl::createWindowSurface(bool 
forceRaster)
 mSurface = mWindowContext->getBackbufferSurface();
 if (!mSurface)
 {
-switch (SkiaHelper::renderMethodToUse())
+switch (renderMethodToUse())
 {
-case SkiaHelper::RenderVulkan:
+case RenderVulkan:
 SAL_WARN("vcl.skia",
  "cannot create Vulkan GPU window surface, falling 
back to Raster");
 destroySurface(); // destroys also WindowContext
 return createWindowSurface(true); // try again
-case SkiaHelper::RenderRaster:
+case RenderRaster:
 abort(); // This should not really happen, do not even try to 
cope with it.
 }
 }
 mIsGPU = mSurface->getCanvas()->recordingContext() != nullptr;
 #ifdef DBG_UTIL
-SkiaHelper::prefillSurface(mSurface);
+prefillSurface(mSurface);
 #endif
 }
 
@@ -356,13 +356,13 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
 // HACK: See isOffscreen().
 int width = std::max(1, GetWidth());
 int height = std::max(1, GetHeight());
-switch (SkiaHelper::renderMethodToUse())
+switch (renderMethodToUse())
 {
-case SkiaHelper::RenderVulkan:
+case RenderVulkan:
 {
-if (SkiaHelper::getSharedGrDirectContext())
+if (getSharedGrDirectContext())
 {
-mSurface = SkiaHelper::createSkSurface(width, height);
+mSurface = createSkSurface(width, height);
 if (mSurface)
 {
 mIsGPU = mSurface->getCanvas()->recordingContext() != 
nullptr;
@@ -375,7 +375,7 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
 break;
 }
 // Create raster surface as a fallback.
-mSurface = SkiaHelper::createSkSurface(width, height);
+mSurface = createSkSurface(width, height);
 assert(mSurface);
 assert(!mSurface->getCanvas()->recordingContext()); // is not GPU-backed
 mIsGPU = false;
@@ -485,7 +485,7 @@ void SkiaSalGraphicsImpl::checkSurface()
 if (!isOffscreen())
 {
 flushDrawing();
-snapshot = SkiaHelper::makeCheckedImageSnapshot(mSurface);
+snapshot = makeCheckedImageSnapshot(mSurface);
 }
 
 destroySurface();
@@ -654,8 +654,8 @@ void SkiaSalGraphicsImpl::applyXor()
 paint.setBlendMode(SkBlendMode::kSrc); // copy as is
 SkCanvas canvas(surfaceBitmap);
 SkRect area = SkRect::Make(mXorRegion.getBounds());
-canvas.drawImageRect(SkiaHelper::makeCheckedImageSnapshot(mSurface), area, 
area,
- SkSamplingOptions(), , 
SkCanvas::kFast_SrcRectConstraint);
+canvas.drawImageRect(makeCheckedImageSnapshot(mSurface), area, area, 
SkSamplingOptions(),
+ , SkCanvas::kFast_SrcRectConstraint);
 // xor to 

[Libreoffice-commits] core.git: vcl/skia

2021-02-19 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit bba3afbd5e5ad65375e832a0e3174fe70d42a6e5
Author: Luboš Luňák 
AuthorDate: Fri Feb 5 20:05:17 2021 +0100
Commit: Luboš Luňák 
CommitDate: Fri Feb 19 10:38:03 2021 +0100

write color components properly in debug output

They are sal_uInt8, which is technically unsigned char, and those
are normally written as chars, not as numbers.

Change-Id: I63d81ce270f95d06f1641eea3b2231a12a8aea2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/24
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 70405e2b5111..e89a824f0d84 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -1229,8 +1229,9 @@ OString SkiaSalBitmap::GetImageKey() const
 if (mEraseColorSet)
 {
 std::stringstream ss;
-ss << std::hex << std::setfill('0') << std::setw(2) << 
mEraseColor.GetAlpha()
-   << std::setw(6) << sal_uInt32(mEraseColor.GetRGBColor());
+ss << std::hex << std::setfill('0') << std::setw(6)
+   << static_cast(mEraseColor.GetRGBColor()) << 
std::setw(2)
+   << static_cast(mEraseColor.GetAlpha());
 return OStringLiteral("E") + ss.str().c_str();
 }
 return OStringLiteral("I") + OString::number(GetSkImage()->uniqueID());
@@ -1242,7 +1243,7 @@ OString SkiaSalBitmap::GetAlphaImageKey() const
 {
 std::stringstream ss;
 ss << std::hex << std::setfill('0') << std::setw(2)
-   << (255 - 
SkColorGetA(fromEraseColorToAlphaImageColor(mEraseColor)));
+   << static_cast(255 - 
SkColorGetA(fromEraseColorToAlphaImageColor(mEraseColor)));
 return OStringLiteral("E") + ss.str().c_str();
 }
 return OStringLiteral("I") + 
OString::number(GetAlphaSkImage()->uniqueID());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-12-25 Thread Andrea Gelmini (via logerrit)
 vcl/skia/SkiaHelper.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 358d21fdf940d813e5a05b16e737f88f29f939c7
Author: Andrea Gelmini 
AuthorDate: Sat Dec 12 06:44:39 2020 +0100
Commit: Julien Nabet 
CommitDate: Fri Dec 25 09:56:38 2020 +0100

Removed duplicated include

Change-Id: I46d1777dcc533973fca516d34647e28bc118f7aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107612
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index fdbf3eef21b9..6d76d1dfce65 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -36,7 +36,6 @@ bool isVCLSkiaEnabled() { return false; }
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-12-09 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |   49 -
 1 file changed, 44 insertions(+), 5 deletions(-)

New commits:
commit b99aada53eb259a3045ced558ebc9c44d3eb722f
Author: Luboš Luňák 
AuthorDate: Tue Dec 8 12:48:08 2020 +0100
Commit: Luboš Luňák 
CommitDate: Wed Dec 9 11:50:56 2020 +0100

faster Skia conversion to alpha for the alpha-vdev hack

SkColorFilter::Matrix() uses a matrix and some range checks, so
it's faster to just directly convert RGBA -> R in order to get
the one channel we want.

Change-Id: If7e42c13ec2a4aba5f98ada4facccac1eaf4f7a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107409
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 0ce99d5778e4..096a667e9382 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -754,10 +754,46 @@ const sk_sp& SkiaSalBitmap::GetAlphaSkImage() 
const
 if (mImage)
 {
 SkiaZone zone;
-sk_sp surface = SkiaHelper::createSkSurface(mSize, 
kAlpha_8_SkColorType);
-assert(surface);
-SkPaint paint;
-paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
+bool scaling = mImage->width() != mSize.Width() || mImage->height() != 
mSize.Height();
+SkPixmap pixmap;
+// Note: We cannot do this when 'scaling' because 
SkCanvas::drawImageRect()
+// with kAlpha_8_SkColorType as source and destination would act as 
SkBlendMode::kSrcOver
+// despite SkBlendMode::kSrc set 
(https://bugs.chromium.org/p/skia/issues/detail?id=9692).
+if (mImage->peekPixels() && !scaling)
+{
+assert(pixmap.colorType() == kN32_SkColorType);
+// In non-GPU mode, convert 32bit data to 8bit alpha, this is 
faster than
+// the SkColorFilter below. Since this is the VCL alpha-vdev 
alpha, where
+// all R,G,B are the same and in fact mean alpha, this means we 
simply take one
+// 8bit channel from the input, and that's the output.
+SkBitmap bitmap;
+if (!bitmap.installPixels(pixmap))
+abort();
+SkBitmap alphaBitmap;
+if 
(!alphaBitmap.tryAllocPixels(SkImageInfo::MakeA8(bitmap.width(), 
bitmap.height(
+abort();
+if (int(bitmap.rowBytes()) == bitmap.width() * 4)
+{
+SkConvertRGBAToR(alphaBitmap.getAddr8(0, 0), 
bitmap.getAddr32(0, 0),
+ bitmap.width() * bitmap.height());
+}
+else
+{
+for (tools::Long y = 0; y < bitmap.height(); ++y)
+SkConvertRGBAToR(alphaBitmap.getAddr8(0, y), 
bitmap.getAddr32(0, y),
+ bitmap.width());
+}
+alphaBitmap.setImmutable();
+sk_sp alphaImage = SkiaHelper::createSkImage(alphaBitmap);
+assert(alphaImage);
+SAL_INFO("vcl.skia.trace", "getalphaskimage(" << this << ") from 
raster image");
+// Don't bother here with ConserveMemory(), mImage -> mAlphaImage 
conversions should
+// generally only happen with the separate-alpha-outdev hack, and 
those bitmaps should
+// be temporary.
+SkiaSalBitmap* thisPtr = const_cast(this);
+thisPtr->mAlphaImage = alphaImage;
+return mAlphaImage;
+}
 // Move the R channel value to the alpha channel. This seems to be the 
only
 // way to reinterpret data in SkImage as an alpha SkImage without 
accessing the pixels.
 // NOTE: The matrix is 4x5 organized as columns (i.e. each line is a 
column, not a row).
@@ -765,13 +801,16 @@ const sk_sp& SkiaSalBitmap::GetAlphaSkImage() 
const
0, 0, 0, 0, 0, // G column
0, 0, 0, 0, 0, // B column
1, 0, 0, 0, 0); // A column
+SkPaint paint;
 paint.setColorFilter(SkColorFilters::Matrix(redToAlpha));
-bool scaling = mImage->width() != mSize.Width() || mImage->height() != 
mSize.Height();
 if (scaling)
 {
 assert(!mBuffer); // This code should be only called if only 
mImage holds data.
 paint.setFilterQuality(mScaleQuality);
 }
+sk_sp surface = SkiaHelper::createSkSurface(mSize, 
kAlpha_8_SkColorType);
+assert(surface);
+paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
 surface->getCanvas()->drawImageRect(mImage,
 SkRect::MakeWH(mImage->width(), 
mImage->height()),
 SkRect::MakeWH(mSize.Width(), 
mSize.Height()), );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

[Libreoffice-commits] core.git: vcl/skia

2020-11-28 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   20 
 1 file changed, 20 insertions(+)

New commits:
commit a66a3c3c55f6e338bc9cc0a3b71136786a71f1e6
Author: Luboš Luňák 
AuthorDate: Fri Nov 20 11:40:13 2020 +0100
Commit: Luboš Luňák 
CommitDate: Sat Nov 28 09:20:24 2020 +0100

cache one more place when drawing Skia images

Change-Id: I845dc8524c95676a25153be62b15553cdf57c8ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106786
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index c7035e7d3de7..ee2e72889152 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1664,7 +1664,27 @@ void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& 
rPosAry, const SkiaSalBit
  SkBlendMode blendMode)
 {
 if (bitmap.PreferSkShader())
+{
 drawShader(rPosAry, bitmap.GetSkShader(), blendMode);
+return;
+}
+// In raster mode use mergeCacheBitmaps(), which will cache the result, 
avoiding repeated
+// scaling. In GPU mode it is simpler to just use SkShader.
+SalTwoRect imagePosAry(rPosAry);
+Size imageSize = bitmap.GetSize();
+// If the bitmap will be scaled, prefer to do it in mergeCacheBitmaps(), 
if possible.
+if ((rPosAry.mnSrcWidth != rPosAry.mnDestWidth || rPosAry.mnSrcHeight != 
rPosAry.mnDestHeight)
+&& rPosAry.mnSrcX == 0 && rPosAry.mnSrcY == 0
+&& rPosAry.mnSrcWidth == bitmap.GetSize().Width()
+&& rPosAry.mnSrcHeight == bitmap.GetSize().Height())
+{
+imagePosAry.mnSrcWidth = imagePosAry.mnDestWidth;
+imagePosAry.mnSrcHeight = imagePosAry.mnDestHeight;
+imageSize = Size(imagePosAry.mnSrcWidth, imagePosAry.mnSrcHeight);
+}
+sk_sp image = mergeCacheBitmaps(bitmap, nullptr, imageSize);
+if (image)
+drawImage(imagePosAry, image, blendMode);
 else
 drawImage(rPosAry, bitmap.GetSkImage(), blendMode);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-11-16 Thread Luboš Luňák (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit a72b0ae16684feb438558686253d9b4701313017
Author: Luboš Luňák 
AuthorDate: Mon Nov 16 12:39:03 2020 +0100
Commit: Luboš Luňák 
CommitDate: Mon Nov 16 12:41:05 2020 +0100

disable Vulkan for Windows 7 (tdf#138219)

The bugreport says the latest Intel drivers for Windows 7 are
problematic, and since Windows 7 is EOL anyway, simply don't bother.

Change-Id: Iee429d99ebf9b0e0a99a50c38ef77d06ab5b797b

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 8c01a0956664..507bc04d2d94 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -30,5 +30,8 @@
 
 
 
+
+
+
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-11-14 Thread Luboš Luňák (via logerrit)
 vcl/skia/win/gdiimpl.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 96f5152486a28d77050dc114e293431afddf5142
Author: Luboš Luňák 
AuthorDate: Thu Nov 12 15:56:32 2020 +0100
Commit: Luboš Luňák 
CommitDate: Sat Nov 14 12:20:27 2020 +0100

fix updates of Skia draw region for Windows widgets (tdf#137559)

Change-Id: I787c427dd17334095d5b2d90c6a9670d58ee9a4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105762
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index c3cb3a48b066..6b68571d6ab1 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -92,6 +92,8 @@ bool 
WinSkiaSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey const&
<< this << "): "
<< SkIRect::MakeXYWH(nX, nY, 
iterator->second->width(),
 
iterator->second->height()));
+addUpdateRegion(
+SkRect::MakeXYWH(nX, nY, iterator->second->width(), 
iterator->second->height()));
 mSurface->getCanvas()->drawImage(iterator->second, nX, nY);
 postDraw();
 return true;
@@ -110,6 +112,7 @@ bool 
WinSkiaSalGraphicsImpl::RenderAndCacheNativeControl(CompatibleDC& rWhite, C
 SAL_INFO("vcl.skia.trace",
  "renderandcachednativecontrol("
  << this << "): " << SkIRect::MakeXYWH(nX, nY, image->width(), 
image->height()));
+addUpdateRegion(SkRect::MakeXYWH(nX, nY, image->width(), image->height()));
 mSurface->getCanvas()->drawImage(image, nX, nY);
 postDraw();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-11-13 Thread Luboš Luňák (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f413852e657dc524b3d2773862e788dfc6595d8d
Author: Luboš Luňák 
AuthorDate: Thu Nov 12 12:37:17 2020 +0100
Commit: Luboš Luňák 
CommitDate: Fri Nov 13 16:05:31 2020 +0100

block nvidia drivers for vulkan only for version<457.36.0 (tdf#138145)

Reportedly that one works fine, although the situation is somewhat
unclear to me (tdf#135370 appears to have been worked around as
a side effect of d18731f71c60cbb6c02cabb042004b1aa9454de8,
and both tdf#136036 and tdf#136407 do not have confirmation from
anybody else than the reporters). If things do not go well,
the blocklist can get more fine-grained.

Change-Id: I8cd5257d6391fe0604e7a95e1ed7edfc0143ec3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105642
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 5bcab2940ace..8c01a0956664 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -27,7 +27,7 @@
 
 
 
-
+
 
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-10-09 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit f62846d54ef9d4eb447cf405b74b6f47599d6d69
Author: Luboš Luňák 
AuthorDate: Thu Oct 8 15:58:21 2020 +0200
Commit: Luboš Luňák 
CommitDate: Fri Oct 9 11:08:14 2020 +0200

32bpp SKIA_USE_BITMAP32 bitmaps always need kPremul_SkAlphaType

I'm not sure if kOpaque_SkAlphaType would guarantee 255 in the alpha,
so better be safe. This should be a rare case anyway.

Change-Id: Iadec97a83621403a56f62ac07e238d8e98a3a905
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104090
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 531c9661be64..d1cd76b61d5f 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -995,18 +995,18 @@ void SkiaSalBitmap::EnsureBitmapData()
 // Try to fill mBuffer from mImage.
 assert(mImage->colorType() == kN32_SkColorType);
 SkiaZone zone;
-// Use kUnpremul_SkAlphaType to make Skia convert from premultiplied alpha 
when reading
-// from the SkImage, in case there is any alpha involved. If converting to 
bpp<32 formats,
-// we will ignore the alpha when converting to mBuffer. Unless bpp==32 and 
SKIA_USE_BITMAP32,
-// in which case keep the format, since SKIA_USE_BITMAP32 implies 
premultiplied alpha.
+// If the source image has no alpha, then use no alpha (faster to 
convert), otherwise
+// use kUnpremul_SkAlphaType to make Skia convert from premultiplied alpha 
when reading
+// from the SkImage (the alpha will be ignored if converting to bpp<32 
formats, but
+// the color channels must be unpremultiplied. Unless bpp==32 and 
SKIA_USE_BITMAP32,
+// in which case use kPremul_SkAlphaType, since SKIA_USE_BITMAP32 implies 
premultiplied alpha.
 SkAlphaType alphaType = kUnpremul_SkAlphaType;
+if (mImage->imageInfo().alphaType() == kOpaque_SkAlphaType)
+alphaType = kOpaque_SkAlphaType;
 #if SKIA_USE_BITMAP32
 if (mBitCount == 32)
 alphaType = kPremul_SkAlphaType;
 #endif
-// But if the source image has no alpha, then use no alpha (faster to 
convert).
-if (mImage->imageInfo().alphaType() == kOpaque_SkAlphaType)
-alphaType = kOpaque_SkAlphaType;
 SkBitmap bitmap;
 if (!bitmap.tryAllocPixels(SkImageInfo::MakeS32(mSize.Width(), 
mSize.Height(), alphaType)))
 abort();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-10-07 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 6456ffec9d2082cc61d4ae60cad99e3c4ebfe82d
Author: Luboš Luňák 
AuthorDate: Tue Oct 6 21:31:02 2020 +0200
Commit: Luboš Luňák 
CommitDate: Wed Oct 7 16:17:58 2020 +0200

faster Skia from-image conversions if no alpha is involved

Skia's drawImage() is faster if alpha types match. So if the source
is opaque, use that and not unpremultiplied alpha (which is
technically the same if no alpha is involved, but it leads to
a slower path).

Change-Id: Ie55eaa55099a9a4c9e6db1e66e212da0acef71f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104043
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 24f955891e05..bbf1e6f0670e 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -995,6 +995,9 @@ void SkiaSalBitmap::EnsureBitmapData()
 if (mBitCount == 32)
 alphaType = kPremul_SkAlphaType;
 #endif
+// But if the source image has no alpha, then use no alpha (faster to 
convert).
+if (mImage->imageInfo().alphaType() == kOpaque_SkAlphaType)
+alphaType = kOpaque_SkAlphaType;
 SkBitmap bitmap;
 if (!bitmap.tryAllocPixels(SkImageInfo::MakeS32(mSize.Width(), 
mSize.Height(), alphaType)))
 abort();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-10-06 Thread Luboš Luňák (via logerrit)
 vcl/skia/x11/gdiimpl.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit e1482daecff877e3b0e22f1fc864e614376cb6b1
Author: Luboš Luňák 
AuthorDate: Tue Oct 6 14:51:21 2020 +0200
Commit: Luboš Luňák 
CommitDate: Tue Oct 6 14:51:56 2020 +0200

add missing null pointer check

It's possible to trigger this case, and the windows variant already
has the check.

Change-Id: I465fbccb8910bd1b529a2639f34249c18289baa8

diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 9b93a603dc38..d993cf61d8d7 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -140,7 +140,8 @@ void X11SkiaSalGraphicsImpl::performFlush()
 SkiaZone zone;
 flushDrawing();
 // TODO XPutImage() is somewhat inefficient, XShmPutImage() should be 
preferred.
-mWindowContext->swapBuffers();
+if (mWindowContext)
+mWindowContext->swapBuffers();
 }
 
 std::unique_ptr createVulkanWindowContext(bool 
temporary)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-10-04 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit bb66f3b772115506b8b39e6cc24c1f82e7a6dc1e
Author: Luboš Luňák 
AuthorDate: Fri Oct 2 19:07:09 2020 +0200
Commit: Luboš Luňák 
CommitDate: Sun Oct 4 14:56:03 2020 +0200

do not set high filter quality if not changing image

It seems setting kHigh_SkFilterQuality may have a performance impact
even when there is no resizing/transforming involved (besides moving,
which doesn't affect the image itself).

Change-Id: I08a6a1a6cd3c002643caabac91532fdc6659c1c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103889
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index e194ba964c58..f0076d9a90f9 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1720,7 +1720,8 @@ bool SkiaSalGraphicsImpl::drawTransformedBitmap(const 
basegfx::B2DPoint& rNull,
 SkAutoCanvasRestore autoRestore(canvas, true);
 canvas->concat(matrix);
 SkPaint paint;
-paint.setFilterQuality(kHigh_SkFilterQuality);
+if (!matrix.isTranslate())
+paint.setFilterQuality(kHigh_SkFilterQuality);
 canvas->drawImage(imageToDraw, 0, 0, );
 }
 else
@@ -1737,7 +1738,8 @@ bool SkiaSalGraphicsImpl::drawTransformedBitmap(const 
basegfx::B2DPoint& rNull,
 SkAutoCanvasRestore autoRestore(canvas, true);
 canvas->concat(matrix);
 SkPaint paint;
-paint.setFilterQuality(kHigh_SkFilterQuality);
+if (!matrix.isTranslate())
+paint.setFilterQuality(kHigh_SkFilterQuality);
 if (pSkiaAlphaBitmap)
 {
 paint.setShader(SkShaders::Blend(SkBlendMode::kDstOut, // VCL 
alpha is one-minus-alpha.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-10-02 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 5acdb23a413ce82a279eb4fee0ddf867e989fec8
Author: Luboš Luňák 
AuthorDate: Tue Sep 29 19:33:08 2020 +0200
Commit: Luboš Luňák 
CommitDate: Fri Oct 2 15:42:48 2020 +0200

cache Skia bitmaps if they are small but to be scaled

In raster mode this still may cost a bit, especially with code
that paints the same bitmap repeatedly to create tiling.

Change-Id: I0b65414b418f96a8b1620c8487562b61bd87c221
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103783
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index b6ffda221424..e194ba964c58 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1491,9 +1491,8 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 // Probably not much point in caching of just doing a copy.
 if (alphaBitmap == nullptr && targetSize == bitmap.GetSize())
 return image;
-// Image too small to be worth caching.
-if (bitmap.GetSize().Width() < 100 && bitmap.GetSize().Height() < 100
-&& targetSize.Width() < 100 && targetSize.Height() < 100)
+// Image too small to be worth caching if not scaling.
+if (targetSize == bitmap.GetSize() && targetSize.Width() < 100 && 
targetSize.Height() < 100)
 return image;
 // In some cases (tdf#134237) the target size may be very large. In that 
case it's
 // better to rely on Skia to clip and draw only the necessary, rather than 
prepare
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-29 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 1cd7e2a4042b92123d8c94ef10b2e8baf7cfaafa
Author: Luboš Luňák 
AuthorDate: Tue Sep 29 09:52:05 2020 +0200
Commit: Luboš Luňák 
CommitDate: Tue Sep 29 10:33:42 2020 +0200

avoid crash if DrawTransformedBitmap() would mean empty Skia bitmap

I can reproduce this sometimes with the document from tdf#136223.

Change-Id: Ie6e57f18936a5de7f99ab01932be229625b737c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103596
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 0fff8776fe8f..ade34a6e8b01 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1484,6 +1484,8 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 // GPU-accelerated drawing with SkShader should be fast enough to not need 
caching.
 if (isGPU())
 return image;
+if (targetSize.IsEmpty())
+return image;
 if (alphaBitmap && alphaBitmap->IsFullyOpaqueAsAlpha())
 alphaBitmap = nullptr; // the alpha can be ignored
 // Probably not much point in caching of just doing a copy.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-29 Thread Luboš Luňák (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit f8d6eb6f171dbcf7e3aa4afa0da32bd504f473dc
Author: Luboš Luňák 
AuthorDate: Mon Sep 28 10:01:46 2020 +0200
Commit: Luboš Luňák 
CommitDate: Tue Sep 29 09:57:42 2020 +0200

blacklist Windows/nVidia for Skia/Vulkan (tdf#135370, tdf#136036, 
tdf#136407)

The bugreports all appear to be specific to Vulkan on Windows
with nVidia drivers, and I do not have that OS/HW combination to
debug this. So disable Vulkan use there until somebody can do
something about it.

Change-Id: I0dea7b87b0f72e393ea90985bd2cc64c89671181
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103533
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index f7d82bc8bfeb..5bcab2940ace 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -27,5 +27,8 @@
 
 
 
+
+
+
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-25 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit f3ca55e78799934c19ae66a822397d98b7997fa9
Author: Luboš Luňák 
AuthorDate: Fri Sep 25 10:40:36 2020 +0200
Commit: Luboš Luňák 
CommitDate: Fri Sep 25 19:29:52 2020 +0200

Skia drawGradient() tweaks

Change-Id: Id16a714c19c42b7071162107cbaa96c4ea95674d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103373
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 0adaf301a321..fc384d58f78e 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1798,8 +1798,6 @@ bool SkiaSalGraphicsImpl::drawGradient(const 
tools::PolyPolygon& rPolyPolygon,
 Point aCenter;
 aGradient.SetAngle(aGradient.GetAngle() + 2700);
 aGradient.GetBoundRect(boundRect, aBoundRect, aCenter);
-tools::Polygon aPoly(aBoundRect);
-aPoly.Rotate(aCenter, aGradient.GetAngle() % 3600);
 
 SkColor startColor
 = toSkColorWithIntensity(rGradient.GetStartColor(), 
rGradient.GetStartIntensity());
@@ -1808,6 +1806,8 @@ bool SkiaSalGraphicsImpl::drawGradient(const 
tools::PolyPolygon& rPolyPolygon,
 sk_sp shader;
 if (rGradient.GetStyle() == GradientStyle::Linear)
 {
+tools::Polygon aPoly(aBoundRect);
+aPoly.Rotate(aCenter, aGradient.GetAngle() % 3600);
 SkPoint points[2] = { SkPoint::Make(toSkX(aPoly[0].X()), 
toSkY(aPoly[0].Y())),
   SkPoint::Make(toSkX(aPoly[1].X()), 
toSkY(aPoly[1].Y())) };
 SkColor colors[2] = { startColor, endColor };
@@ -1816,15 +1816,17 @@ bool SkiaSalGraphicsImpl::drawGradient(const 
tools::PolyPolygon& rPolyPolygon,
 }
 else
 {
-// Move the center by (-1,-1) (the default VCL algorithm is a bit 
off-center that way).
+// Move the center by (-1,-1) (the default VCL algorithm is a bit 
off-center that way,
+// Skia is the opposite way).
 SkPoint center = SkPoint::Make(toSkX(aCenter.X()) - 1, 
toSkY(aCenter.Y()) - 1);
-SkScalar radius = std::max(aBoundRect.GetWidth() / 2, 
aBoundRect.GetHeight() / 2);
+SkScalar radius = std::max(aBoundRect.GetWidth() / 2.0, 
aBoundRect.GetHeight() / 2.0);
 SkColor colors[2] = { endColor, startColor };
 SkScalar pos[2] = { SkDoubleToScalar(aGradient.GetBorder() / 100.0), 
1.0 };
 shader = SkGradientShader::MakeRadial(center, radius, colors, pos, 2, 
SkTileMode::kClamp);
 }
 
 SkPaint paint;
+paint.setAntiAlias(mParent.getAntiAliasB2DDraw());
 paint.setShader(shader);
 getDrawCanvas()->drawPath(path, paint);
 postDraw();
@@ -1856,6 +1858,7 @@ bool SkiaSalGraphicsImpl::implDrawGradient(const 
basegfx::B2DPolyPolygon& rPolyP
 sk_sp shader = SkGradientShader::MakeLinear(points, 
colors.data(), pos.data(),
   colors.size(), 
SkTileMode::kDecal);
 SkPaint paint;
+paint.setAntiAlias(mParent.getAntiAliasB2DDraw());
 paint.setShader(shader);
 getDrawCanvas()->drawPath(path, paint);
 addXorRegion(path.getBounds());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-25 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 9a0d564dd949e09a15b16e9926f1631ac076e548
Author: Luboš Luňák 
AuthorDate: Fri Sep 25 11:31:00 2020 +0200
Commit: Luboš Luňák 
CommitDate: Fri Sep 25 11:31:18 2020 +0200

remove useless line

This should have been removed in b5e023a7ef21c2ce546035b.

Change-Id: I89d4617d83b802c6d59d8ef2932aadb8af6f1fef

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 2128511247bc..b6b85f60d9f3 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -77,7 +77,6 @@ SkiaSalBitmap::SkiaSalBitmap(const sk_sp& image)
 bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const 
BitmapPalette& rPal)
 {
 ResetAllData();
-mBuffer.reset();
 if (!isValidBitCount(nBitCount))
 return false;
 mPalette = rPal;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-23 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |   34 --
 1 file changed, 12 insertions(+), 22 deletions(-)

New commits:
commit 8df27fb120fec098db0f5a4cab1bd37ac40e751b
Author: Luboš Luňák 
AuthorDate: Wed Sep 23 10:36:00 2020 +0200
Commit: Luboš Luňák 
CommitDate: Wed Sep 23 12:21:25 2020 +0200

nicer code

Change-Id: I391fee76b86bb3fed2f8e840f8b469b6aff3ac2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103234
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 3c5b21ef1461..d7399855a3ec 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -47,6 +47,9 @@
 #define CANARY "skia-canary"
 #endif
 
+// As constexpr here, evaluating it directly in code makes Clang warn about 
unreachable code.
+constexpr bool kN32_SkColorTypeIsBGRA = (kN32_SkColorType == 
kBGRA__SkColorType);
+
 SkiaSalBitmap::SkiaSalBitmap() {}
 
 SkiaSalBitmap::~SkiaSalBitmap() {}
@@ -253,23 +256,14 @@ BitmapBuffer* 
SkiaSalBitmap::AcquireBuffer(BitmapAccessMode nMode)
 buffer->mnFormat = ScanlineFormat::N8BitPal;
 break;
 case 24:
-{
-// Make the RGB/BGR format match the default Skia 32bpp format, to allow
-// easy conversion later.
-// Use a macro to hide an unreachable code warning.
-#define GET_FORMAT 
\
-(kN32_SkColorType == kBGRA__SkColorType ? ScanlineFormat::N24BitTcBgr  
\
-: ScanlineFormat::N24BitTcRgb)
-buffer->mnFormat = GET_FORMAT;
-#undef GET_FORMAT
+// Make the RGB/BGR format match the default Skia 32bpp format, to 
allow
+// easy conversion later.
+buffer->mnFormat = kN32_SkColorTypeIsBGRA ? 
ScanlineFormat::N24BitTcBgr
+  : 
ScanlineFormat::N24BitTcRgb;
 break;
-}
 case 32:
-#define GET_FORMAT 
\
-(kN32_SkColorType == kBGRA__SkColorType ? ScanlineFormat::N32BitTcBgra 
\
-: ScanlineFormat::N32BitTcRgba)
-buffer->mnFormat = GET_FORMAT;
-#undef GET_FORMAT
+buffer->mnFormat = kN32_SkColorTypeIsBGRA ? 
ScanlineFormat::N32BitTcBgra
+  : 
ScanlineFormat::N32BitTcRgba;
 break;
 default:
 abort();
@@ -542,13 +536,9 @@ SkBitmap SkiaSalBitmap::GetAsSkBitmap() const
 }
 else
 {
-// Use a macro to hide an unreachable code warning.
-#define GET_FORMAT 
\
-(kN32_SkColorType == kBGRA__SkColorType ? BitConvert::BGRA : 
BitConvert::RGBA)
-std::unique_ptr data
-= convertDataBitCount(mBuffer.get(), mPixelsSize.Width(), 
mPixelsSize.Height(),
-  mBitCount, mScanlineSize, mPalette, 
GET_FORMAT);
-#undef GET_FORMAT
+std::unique_ptr data = convertDataBitCount(
+mBuffer.get(), mPixelsSize.Width(), mPixelsSize.Height(), 
mBitCount, mScanlineSize,
+mPalette, kN32_SkColorTypeIsBGRA ? BitConvert::BGRA : 
BitConvert::RGBA);
 if (!bitmap.installPixels(
 SkImageInfo::MakeS32(mPixelsSize.Width(), 
mPixelsSize.Height(),
  kOpaque_SkAlphaType),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-23 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   18 ++
 1 file changed, 18 insertions(+)

New commits:
commit 795b30b69a3b623837645f2b14d318e09c6bd210
Author: Luboš Luňák 
AuthorDate: Tue Sep 22 17:31:10 2020 +0200
Commit: Luboš Luňák 
CommitDate: Wed Sep 23 08:58:27 2020 +0200

abort if Skia code detects problems with Vulkan

The document from tdf#136244 in low memory conditions (32bit Windows)
may be sometimes rendered without the alpha channel, i.e. Skia/Vulkan
apparently render just the data bitmap but not the alpha bitmap.
So check the status of the GPU context and abort if there's a problem.
I've considered trying to recover by switching to Raster, but
e.g. in this specific case something has already been drawn and it
can't be done. Another problem in this specific case is that the whole
app is running low on memory and copying the data from the GPU would
fail anyway. So just fail hard to avoid silent data loss.

Change-Id: If05f9c65b160ad5e7b9407b9f809606a1392d740
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103206
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 698d20730751..7722a8018619 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -399,6 +399,24 @@ void SkiaSalGraphicsImpl::postDraw()
 mPendingOperationsToFlush = 0;
 }
 SkiaZone::leave(); // matched in preDraw()
+// If there's a problem with the GPU context, abort.
+if (GrContext* context = mSurface->getCanvas()->getGrContext())
+{
+// Running out of memory on the GPU technically could be possibly 
recoverable,
+// but we don't know the exact status of the surface (and what has or 
has not been drawn to it),
+// so in practice this is unrecoverable without possible data loss.
+if (context->oomed())
+{
+SAL_WARN("vcl.skia", "GPU context has run out of memory, 
aborting.");
+abort();
+}
+// Unrecoverable problem.
+if (context->abandoned())
+{
+SAL_WARN("vcl.skia", "GPU context has been abandoned, aborting.");
+abort();
+}
+}
 }
 
 void SkiaSalGraphicsImpl::scheduleFlush()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-23 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 1f5141522ffa79f2a94d0f11fa7e6008755ae6d6
Author: Luboš Luňák 
AuthorDate: Tue Sep 22 17:13:06 2020 +0200
Commit: Luboš Luňák 
CommitDate: Wed Sep 23 08:45:11 2020 +0200

assert that SkiaSalBitmap mImage is not deleted if it's the only data

Change-Id: Idec2e0f3e852c37b37e220ac5059ef0b6accc77a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103205
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index c77b80e39bc1..d933b33e6ac2 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -1059,6 +1059,8 @@ void SkiaSalBitmap::EnsureBitmapUniqueData()
 void SkiaSalBitmap::ResetCachedData()
 {
 SkiaZone zone;
+// This should never be called to drop mImage if that's the only data we 
have.
+assert(mBuffer || !mImage);
 mImage.reset();
 mAlphaImage.reset();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-23 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6a3a17c8dcd860506781b28b14c3df7036eaaaba
Author: Luboš Luňák 
AuthorDate: Tue Sep 22 17:12:01 2020 +0200
Commit: Luboš Luňák 
CommitDate: Wed Sep 23 08:44:54 2020 +0200

createSurface() should be enough if the surface doesn't exist yet

Change-Id: Ic390b94e6140169d878b428c782e03c29cce0ea2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103184
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index bf9fab349d1c..8f73db8411fa 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -421,7 +421,7 @@ void SkiaSalGraphicsImpl::checkSurface()
 {
 if (!mSurface)
 {
-recreateSurface();
+createSurface();
 SAL_INFO("vcl.skia.trace",
  "create(" << this << "): " << Size(mSurface->width(), 
mSurface->height()));
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-22 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 9fb6355b47ef35d77450b756b90100ecdf10ae07
Author: Luboš Luňák 
AuthorDate: Tue Sep 22 11:34:17 2020 +0200
Commit: Luboš Luňák 
CommitDate: Tue Sep 22 15:02:45 2020 +0200

do not use SkShader if not needed

Change-Id: I9913673c889e605d608e25dad9a36b05912447be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103153
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index a5a8b00b9b0c..bf9fab349d1c 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1566,7 +1566,7 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const 
SalTwoRect& rPosAry, const SalBi
 if (image)
 drawImage(imagePosAry, image);
 else if (rSkiaAlphaBitmap.IsFullyOpaqueAsAlpha()) // alpha can be ignored
-drawShader(rPosAry, rSkiaSourceBitmap.GetSkShader());
+drawBitmap(rPosAry, rSkiaSourceBitmap);
 else
 drawShader(rPosAry,
SkShaders::Blend(SkBlendMode::kDstOut, // VCL alpha is 
one-minus-alpha.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-21 Thread Luboš Luňák (via logerrit)
 vcl/skia/x11/textrender.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 94129b3ed8c158bf61fa0e17ee12a21fb9bf07e6
Author: Luboš Luňák 
AuthorDate: Mon Sep 21 13:28:53 2020 +0200
Commit: Luboš Luňák 
CommitDate: Mon Sep 21 15:34:27 2020 +0200

set properly font X-scale for Skia+X11 (tdf#136891)

Change-Id: I715453f6729363e6bf803f8493d91bb260fb808a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103097
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/x11/textrender.cxx b/vcl/skia/x11/textrender.cxx
index 13eff3012721..e8596641c052 100644
--- a/vcl/skia/x11/textrender.cxx
+++ b/vcl/skia/x11/textrender.cxx
@@ -49,6 +49,7 @@ void SkiaTextRender::DrawTextLayout(const GenericSalLayout& 
rLayout, const SalGr
 sk_sp typeface
 = SkFontMgr_createTypefaceFromFcPattern(fontManager, 
rFont.GetFontOptions()->GetPattern());
 SkFont font(typeface, nHeight);
+font.setScaleX(1.0 * nWidth / nHeight);
 // TODO are these correct?
 if (rFont.NeedsArtificialItalic())
 font.setSkewX(-0x6000L / 0x1L);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-21 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   41 +
 1 file changed, 41 insertions(+)

New commits:
commit 859596233146590f7ebac1f05bbb83ce5ea8aac4
Author: Luboš Luňák 
AuthorDate: Fri Sep 18 10:19:33 2020 +0200
Commit: Luboš Luňák 
CommitDate: Mon Sep 21 14:33:11 2020 +0200

do not try to merge polygons if they do not share a point (tdf#136222)

If two polygons do not share a point, then they do not share an edge,
so they cannot be adjacent polygons. As a side-effect this avoids
the problem with tdf#136222, as it turns out
basegfx::utils::mergeToSinglePolyPolygon() is broken with polygons
that are almost but not quite adjacent.

Change-Id: Ibf290cc886d7c337fd04c925b551b2e7773a6b70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102985
Reviewed-by: Noel Grandin 
Reviewed-by: Luboš Luňák 
Tested-by: Jenkins

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index f6abc2ffb6fb..a5a8b00b9b0c 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace
 {
@@ -849,6 +850,19 @@ void SkiaSalGraphicsImpl::performDrawPolyPolygon(const 
basegfx::B2DPolyPolygon&
 #endif
 }
 
+namespace
+{
+struct LessThan
+{
+bool operator()(const basegfx::B2DPoint& point1, const basegfx::B2DPoint& 
point2) const
+{
+if (basegfx::fTools::equal(point1.getX(), point2.getX()))
+return basegfx::fTools::less(point1.getY(), point2.getY());
+return basegfx::fTools::less(point1.getX(), point2.getX());
+}
+};
+} // namespace
+
 bool SkiaSalGraphicsImpl::delayDrawPolyPolygon(const basegfx::B2DPolyPolygon& 
aPolyPolygon,
double fTransparency)
 {
@@ -877,6 +891,9 @@ bool SkiaSalGraphicsImpl::delayDrawPolyPolygon(const 
basegfx::B2DPolyPolygon& aP
 // so they do not need joining.
 if (aPolyPolygon.count() != 1)
 return false;
+// If the polygon is not closed, it doesn't mark an area to be filled.
+if (!aPolyPolygon.isClosed())
+return false;
 // If a polygon does not contain a straight line, i.e. it's all curves, 
then do not merge.
 // First of all that's even more expensive, and second it's very unlikely 
that it's a polygon
 // split into more polygons.
@@ -889,6 +906,28 @@ bool SkiaSalGraphicsImpl::delayDrawPolyPolygon(const 
basegfx::B2DPolyPolygon& aP
 {
 checkPendingDrawing(); // Cannot be parts of the same larger polygon, 
draw the last and reset.
 }
+if (!mLastPolyPolygonInfo.polygons.empty())
+{
+assert(aPolyPolygon.count() == 1);
+assert(mLastPolyPolygonInfo.polygons.back().count() == 1);
+// Check if the new and the previous polygon share at least one point. 
If not, then they
+// cannot be adjacent polygons, so there's no point in trying to merge 
them.
+bool sharePoint = false;
+const basegfx::B2DPolygon& poly1 = aPolyPolygon.getB2DPolygon(0);
+const basegfx::B2DPolygon& poly2 = 
mLastPolyPolygonInfo.polygons.back().getB2DPolygon(0);
+o3tl::sorted_vector poly1Points; // for 
O(n log n)
+poly1Points.reserve(poly1.count());
+for (sal_uInt32 i = 0; i < poly1.count(); ++i)
+poly1Points.insert(poly1.getB2DPoint(i));
+for (sal_uInt32 i = 0; i < poly2.count(); ++i)
+if (poly1Points.find(poly2.getB2DPoint(i)) != poly1Points.end())
+{
+sharePoint = true;
+break;
+}
+if (!sharePoint)
+checkPendingDrawing(); // Draw the previous one and reset.
+}
 // Collect the polygons that can be possibly merged. Do the merging only 
once at the end,
 // because it's not a cheap operation.
 mLastPolyPolygonInfo.polygons.push_back(aPolyPolygon);
@@ -908,6 +947,8 @@ void SkiaSalGraphicsImpl::checkPendingDrawing()
 if (polygons.size() == 1)
 performDrawPolyPolygon(polygons.front(), transparency, true);
 else
+// TODO: tdf#136222 shows that 
basegfx::utils::mergeToSinglePolyPolygon() is unreliable
+// in corner cases, possibly either a bug or rounding errors 
somewhere.
 
performDrawPolyPolygon(basegfx::utils::mergeToSinglePolyPolygon(polygons), 
transparency,
true);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-10 Thread Luboš Luňák (via logerrit)
 vcl/skia/skia_denylist_vulkan.xml |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 3f620e74aa00e34f773d97e9480a6532d9e8863e
Author: Luboš Luňák 
AuthorDate: Wed Sep 9 11:25:59 2020 +0200
Commit: Luboš Luňák 
CommitDate: Thu Sep 10 11:10:01 2020 +0200

blacklist amd driver with vulkan version <= 2.0.49 (tdf#136553)

It's from 2018 and there are newer versions available (although maybe
not for older Windows versions).

Change-Id: Ib3e8973c90b6ef9eee160cd2436978741150a2f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102290
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/skia_denylist_vulkan.xml 
b/vcl/skia/skia_denylist_vulkan.xml
index 43143548cd5a..2e7dd22a0fe0 100644
--- a/vcl/skia/skia_denylist_vulkan.xml
+++ b/vcl/skia/skia_denylist_vulkan.xml
@@ -24,5 +24,8 @@
 
 
 
+
+
+
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-09 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8821bd663ed75fb2c9706b102e1d6f8ccfcf00f5
Author: Luboš Luňák 
AuthorDate: Tue Sep 8 17:48:26 2020 +0200
Commit: Luboš Luňák 
CommitDate: Wed Sep 9 11:02:41 2020 +0200

allow xor mode with Skia drawTransformedBitmap() (tdf#136575)

I thought this wouldn't make sense, but the document uses invert and
then VclProcessor2D::RenderBitmapPrimitive2D(), which simply uses
DrawTransformedBitmap() with its transformation data (which is
a no-op I'd guess). Still, don't bother with the possibly complicated
finding out the bounds, just invalidate the whole area.

Change-Id: I309953338f11d1c1c90c684bf0314e60bc44a249
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102267
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 17fcbf092335..f6abc2ffb6fb 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1681,7 +1681,7 @@ bool SkiaSalGraphicsImpl::drawTransformedBitmap(const 
basegfx::B2DPoint& rNull,
 canvas->drawImage(rSkiaBitmap.GetSkImage(), 0, 0, );
 }
 }
-assert(!mXorMode);
+addXorRegion(SkRect::MakeWH(GetWidth(), GetHeight())); // can't tell, use 
whole area
 postDraw();
 return true;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-08 Thread Luboš Luňák (via logerrit)
 vcl/skia/salbmp.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 9b1e31f154d6824fccebe9d1a691f19248f09466
Author: Luboš Luňák 
AuthorDate: Mon Sep 7 21:05:25 2020 +0200
Commit: Luboš Luňák 
CommitDate: Tue Sep 8 09:57:35 2020 +0200

conserve memory used by SkiaSalBitmap buffers also for 32bit builds

Since 32bit builds have limited address space, so with large images
they can come more easily under memory pressure.

Change-Id: Ie63baceaa4a0f8bed137e85fa8951bd714c6b31c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102208
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 83b807e87b15..0c855ef79ebf 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -649,8 +649,11 @@ const sk_sp& SkiaSalBitmap::GetSkImage() const
 // Ideally SalBitmap should be able to say which bitmap formats it supports
 // and VCL code should oblige, which would allow reusing the same data.
 static bool keepBitmapBuffer = getenv("SAL_SKIA_KEEP_BITMAP_BUFFER") != 
nullptr;
+// 32bit builds have limited address space, so try to conserve memory as 
well.
+constexpr bool is32Bit = sizeof(void*) == 4;
 constexpr long maxBufferSize = 2000 * 2000 * 4;
-if (!keepBitmapBuffer && SkiaHelper::renderMethodToUse() == 
SkiaHelper::RenderRaster
+if (!keepBitmapBuffer
+&& (SkiaHelper::renderMethodToUse() == SkiaHelper::RenderRaster || 
is32Bit)
 && mPixelsSize.Height() * mScanlineSize > maxBufferSize
 && (mBitCount > 8 || (mBitCount == 8 && mPalette.IsGreyPalette8Bit(
 thisPtr->ResetToSkImage(mImage);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-07 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   92 +--
 1 file changed, 24 insertions(+), 68 deletions(-)

New commits:
commit 717ce6838b7ef0add1f9a9655e2b8c0bf60203f0
Author: Luboš Luňák 
AuthorDate: Sat Sep 5 07:05:16 2020 +0200
Commit: Luboš Luňák 
CommitDate: Mon Sep 7 15:19:32 2020 +0200

avoid temporary SkImage when merging bitmaps in Skia (tdf#136244)

The original idea was to create a temporary SkImage in order to first
merge the bitmap and its alpha bitmap, otherwise scaling already
while merging them could introduce artefacts because of smoothscaling
the alpha. But SkShader use blends the bitmap and alpha values
before the scaling, so this is actually not necessary.

Change-Id: I4e351611e3c33530dd5326c542b0a191955b5109
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102068
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 61f843dee609..652fea88f38e 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1391,31 +1391,6 @@ void SkiaSalGraphicsImpl::invert(sal_uInt32 nPoints, 
const SalPoint* pPointArray
 
 bool SkiaSalGraphicsImpl::drawEPS(long, long, long, long, void*, sal_uInt32) { 
return false; }
 
-static void drawBitmapToCanvas(const SkiaSalBitmap& bitmap, SkCanvas* canvas, 
const SkPaint& paint)
-{
-if (bitmap.PreferSkShader())
-{
-SkPaint paint2(paint);
-paint2.setShader(bitmap.GetSkShader());
-canvas->drawPaint(paint2);
-}
-else
-canvas->drawImage(bitmap.GetSkImage(), 0, 0, );
-}
-
-static void drawAlphaBitmapToCanvas(const SkiaSalBitmap& bitmap, SkCanvas* 
canvas,
-const SkPaint& paint)
-{
-if (bitmap.PreferSkShader())
-{
-SkPaint paint2(paint);
-paint2.setShader(bitmap.GetAlphaSkShader());
-canvas->drawPaint(paint2);
-}
-else
-canvas->drawImage(bitmap.GetAlphaSkImage(), 0, 0, );
-}
-
 // Create SkImage from a bitmap and possibly an alpha mask (the usual VCL 
one-minus-alpha),
 // with the given target size. Result will be possibly cached, unless disabled.
 sk_sp SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& 
bitmap,
@@ -1477,54 +1452,35 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 assert(image->width() == targetSize.Width() && image->height() == 
targetSize.Height());
 return image;
 }
-// Combine bitmap + alpha bitmap into one temporary bitmap with alpha.
-// If scaling is needed, first apply the alpha, then scale, otherwise the 
scaling might affect the alpha values.
-if (alphaBitmap && targetSize != bitmap.GetSize())
+sk_sp tmpSurface = SkiaHelper::createSkSurface(targetSize);
+if (!tmpSurface)
+return nullptr;
+SkCanvas* canvas = tmpSurface->getCanvas();
+SkAutoCanvasRestore autoRestore(canvas, true);
+SkPaint paint;
+if (targetSize != bitmap.GetSize())
 {
-sk_sp mergedSurface = 
SkiaHelper::createSkSurface(bitmap.GetSize());
-if (!mergedSurface)
-return nullptr;
-SkPaint paint;
-paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
-drawBitmapToCanvas(bitmap, mergedSurface->getCanvas(), paint);
-paint.setBlendMode(SkBlendMode::kDstOut); // VCL alpha is 
one-minus-alpha
-drawAlphaBitmapToCanvas(*alphaBitmap, mergedSurface->getCanvas(), 
paint);
-sk_sp scaledSurface = 
SkiaHelper::createSkSurface(targetSize);
-if (!scaledSurface)
-return nullptr;
-paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
+SkMatrix matrix;
+matrix.set(SkMatrix::kMScaleX, 1.0 * targetSize.Width() / 
bitmap.GetSize().Width());
+matrix.set(SkMatrix::kMScaleY, 1.0 * targetSize.Height() / 
bitmap.GetSize().Height());
+canvas->concat(matrix);
 paint.setFilterQuality(kHigh_SkFilterQuality);
-scaledSurface->getCanvas()->drawImageRect(
-mergedSurface->makeImageSnapshot(),
-SkRect::MakeXYWH(0, 0, bitmap.GetSize().Width(), 
bitmap.GetSize().Height()),
-SkRect::MakeXYWH(0, 0, targetSize.Width(), targetSize.Height()), 
);
-image = scaledSurface->makeImageSnapshot();
 }
-else // No alpha or no scaling, scale directly.
+if (alphaBitmap != nullptr)
 {
-sk_sp tmpSurface = SkiaHelper::createSkSurface(targetSize);
-if (!tmpSurface)
-return nullptr;
-SkCanvas* canvas = tmpSurface->getCanvas();
-SkAutoCanvasRestore autoRestore(canvas, true);
-SkPaint paint;
-if (targetSize != bitmap.GetSize())
-{
-SkMatrix matrix;
-matrix.set(SkMatrix::kMScaleX, 1.0 * targetSize.Width() / 
bitmap.GetSize().Width());
-matrix.set(SkMatrix::kMScaleY, 1.0 * targetSize.Height() / 
bitmap.GetSize().Height());
-   

[Libreoffice-commits] core.git: vcl/skia

2020-09-07 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 93a7f074d3bdcb293fe2e6410c0401056f6c860f
Author: Luboš Luňák 
AuthorDate: Sat Sep 5 09:13:31 2020 +0200
Commit: Luboš Luňák 
CommitDate: Mon Sep 7 15:20:15 2020 +0200

tweak not caching overly large Skia images (tdf#136244)

If the image is way too oversized, it doesn't matter it's being
scaled down.

Change-Id: I148cd6b95953abb9fcbb5ea8dd19cadaa513e573
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102070
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index f5374b773028..cb0f9b47ecf8 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1422,17 +1422,18 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 // Since the problem is mainly the cost of upscaling and then the size 
of the resulting bitmap,
 // compute a ratio of how much this is going to be scaled up, how much 
this is larger than
 // the drawing area, and then refuse to cache if it's too much.
-const double upscaleRatio = 1.0 * targetSize.Width() / 
bitmap.GetSize().Width()
-* targetSize.Height() / 
bitmap.GetSize().Height();
+const double upscaleRatio
+= std::max(1.0, 1.0 * targetSize.Width() / bitmap.GetSize().Width()
+* targetSize.Height() / 
bitmap.GetSize().Height());
 const double oversizeRatio = 1.0 * targetSize.Width() / 
drawAreaSize.Width()
  * targetSize.Height() / 
drawAreaSize.Height();
 const double ratio = upscaleRatio * oversizeRatio;
-if (ratio > 10)
+if (ratio > 4)
 {
 SAL_INFO("vcl.skia.trace", "mergecachebitmaps("
-   << this << "): not caching 
upscaling, ratio:" << ratio
-   << ", " << bitmap.GetSize() << "->" 
<< targetSize
-   << " in " << drawAreaSize);
+   << this << "): not caching, ratio:" 
<< ratio << ", "
+   << bitmap.GetSize() << "->" << 
targetSize << " in "
+   << drawAreaSize);
 return image;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/skia

2020-09-07 Thread Luboš Luňák (via logerrit)
 vcl/skia/gdiimpl.cxx |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 23762a704133051184850fc711e44bc9a112f59a
Author: Luboš Luňák 
AuthorDate: Sat Sep 5 07:03:52 2020 +0200
Commit: Luboš Luňák 
CommitDate: Mon Sep 7 15:19:17 2020 +0200

limit draw size by clip region size, not whole size

If the graphics area is clipped to a smaller size, use that
as the maximum size that would be drawn, not the whole graphics
area.

Change-Id: I8892e62ca83fb4de4d58edffb1783eccfbd39dc2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102067
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 8c8eee3e3f88..61f843dee609 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1435,10 +1435,11 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 if (bitmap.GetSize().Width() < 100 && bitmap.GetSize().Height() < 100
 && targetSize.Width() < 100 && targetSize.Height() < 100)
 return image;
-// In some cases (tdf#134237) the draw size may be very large. In that 
case it's
+// In some cases (tdf#134237) the target size may be very large. In that 
case it's
 // better to rely on Skia to clip and draw only the necessary, rather than 
prepare
 // a very large image only to not use most of it.
-if (targetSize.Width() > GetWidth() || targetSize.Height() > GetHeight())
+const Size drawAreaSize = mClipRegion.GetBoundRect().GetSize();
+if (targetSize.Width() > drawAreaSize.Width() || targetSize.Height() > 
drawAreaSize.Height())
 {
 // This is a bit tricky. The condition above just checks that at least 
a part of the resulting
 // image will not be used (it's larger then our drawing area). But 
this may often happen
@@ -1448,15 +1449,15 @@ sk_sp 
SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
 // the drawing area, and then refuse to cache if it's too much.
 const double upscaleRatio = 1.0 * targetSize.Width() / 
bitmap.GetSize().Width()
 * targetSize.Height() / 
bitmap.GetSize().Height();
-const double oversizeRatio
-= 1.0 * targetSize.Width() / GetWidth() * targetSize.Height() / 
GetHeight();
+const double oversizeRatio = 1.0 * targetSize.Width() / 
drawAreaSize.Width()
+ * targetSize.Height() / 
drawAreaSize.Height();
 const double ratio = upscaleRatio * oversizeRatio;
 if (ratio > 10)
 {
 SAL_INFO("vcl.skia.trace", "mergecachebitmaps("
<< this << "): not caching 
upscaling, ratio:" << ratio
<< ", " << bitmap.GetSize() << "->" 
<< targetSize
-   << " in " << Size(GetWidth(), 
GetHeight()));
+   << " in " << drawAreaSize);
 return image;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


  1   2   >