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

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 6 13:29:34 UTC 2019


 vcl/skia/SkiaHelper.cxx          |    1 +
 vcl/skia/gdiimpl.cxx             |    1 +
 vcl/skia/win/gdiimpl.cxx         |    4 ++++
 vcl/skia/x11/cairotextrender.cxx |    1 +
 4 files changed, 7 insertions(+)

New commits:
commit 1f6cb09706e413f591986845840cb0a5907b8001
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Dec 5 15:34:20 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Dec 6 14:27:10 2019 +0100

    use SkBitmap::setImmutable() where suitable
    
    This is a little correctness check, and it may also possibly slightly
    improve performance.
    
    Change-Id: I6e4a013aedcafd9a7d1e0e86a5c036d511078f79
    Reviewed-on: https://gerrit.libreoffice.org/84568
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 6949c2d9fe40..eff77ae5340f 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -208,6 +208,7 @@ void prefillSurface(sk_sp<SkSurface>& surface)
     scanline = bitmap.getAddr32(0, 1);
     *scanline++ = SkPreMultiplyARGB(0xFF, 0xE3, 0x5C, 0x13);
     *scanline++ = SkPreMultiplyARGB(0xFF, 0x13, 0x5C, 0xE3);
+    bitmap.setImmutable();
     SkPaint paint;
     paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
     paint.setShader(bitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat));
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index ddcd9b75d30f..c081be975657 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -934,6 +934,7 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl
             *scanline++ = black;
             *scanline++ = white;
             *scanline++ = white;
+            aBitmap.setImmutable();
             // The bitmap is repeated in both directions the checker pattern is as big
             // as the polygon (usually rectangle)
             aPaint.setShader(aBitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat));
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index c680d21dde70..09ebb0139660 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -175,6 +175,7 @@ sk_sp<SkImage> SkiaCompatibleDC::getAsMaskImage()
                                                    kBGRA_8888_SkColorType, kOpaque_SkAlphaType),
                                  mpData, maRects.mnSrcWidth * 4))
         abort();
+    tmpBitmap.setImmutable();
     SkBitmap bitmap8;
     if (!bitmap8.tryAllocPixels(SkImageInfo::Make(maRects.mnSrcWidth, maRects.mnSrcHeight,
                                                   kGray_8_SkColorType, kOpaque_SkAlphaType)))
@@ -188,11 +189,13 @@ sk_sp<SkImage> SkiaCompatibleDC::getAsMaskImage()
     matrix.setConcat(matrix, SkMatrix::MakeScale(1, -1));
     canvas8.concat(matrix);
     canvas8.drawBitmap(tmpBitmap, 0, 0, &paint8);
+    bitmap8.setImmutable();
     // use the 8bit data as an alpha channel
     SkBitmap alpha;
     alpha.setInfo(bitmap8.info().makeColorType(kAlpha_8_SkColorType), bitmap8.rowBytes());
     alpha.setPixelRef(sk_ref_sp(bitmap8.pixelRef()), bitmap8.pixelRefOrigin().x(),
                       bitmap8.pixelRefOrigin().y());
+    alpha.setImmutable();
     sk_sp<SkSurface> surface
         = SkiaHelper::createSkSurface(alpha.width(), alpha.height(), kAlpha_8_SkColorType);
     // https://bugs.chromium.org/p/skia/issues/detail?id=9692
@@ -212,6 +215,7 @@ sk_sp<SkImage> SkiaCompatibleDC::getAsImage()
                                                    kBGRA_8888_SkColorType, kUnpremul_SkAlphaType),
                                  mpData, maRects.mnSrcWidth * 4))
         abort();
+    tmpBitmap.setImmutable();
     sk_sp<SkSurface> surface = SkiaHelper::createSkSurface(tmpBitmap.width(), tmpBitmap.height());
     SkPaint paint;
     paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
diff --git a/vcl/skia/x11/cairotextrender.cxx b/vcl/skia/x11/cairotextrender.cxx
index 73b7fc1052db..57f663f29e6d 100644
--- a/vcl/skia/x11/cairotextrender.cxx
+++ b/vcl/skia/x11/cairotextrender.cxx
@@ -81,6 +81,7 @@ void SkiaX11CairoTextRender::releaseCairoContext(cairo_t* cr)
     SkBitmap bitmap;
     if (!bitmap.installPixels(info, pSrc, nWidth * 4))
         abort();
+    bitmap.setImmutable();
 
     pImpl->drawBitmap(aRect, bitmap);
 


More information about the Libreoffice-commits mailing list