diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-06-30 10:19:34 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-07-01 07:36:39 +0200 |
commit | d1fcc9053f98cc4afb52498b40a836884bb5ec6f (patch) | |
tree | 1bc3fed7ffc3972ad051f1a46f759825eeb82690 /vcl/inc | |
parent | 8663d81828541072999b26451f7d6e6bfcb5f951 (diff) |
optimize Bitmap::Erase() for Skia by delaying the erase (tdf#134363)
Tdf#134363 causes OutputDevice::DrawTransformBitmapExDirect()
to create a huge 1bpp bitmap as mask, and Skia code then tries
to convert all the bits to a format Skia would understand. Which
is wasteful, as SkShader with the color given will do the same
task much more efficiently.
Change-Id: If0bba16f56fed9c3720be801b25a1e703054ed8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97488
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/salbmp.hxx | 5 | ||||
-rw-r--r-- | vcl/inc/skia/gdiimpl.hxx | 6 | ||||
-rw-r--r-- | vcl/inc/skia/salbmp.hxx | 15 |
3 files changed, 25 insertions, 1 deletions
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx index 4244ae1a376f..ab16b317d7eb 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -86,6 +86,11 @@ public: return false; } + virtual bool Erase( const Color& /*color*/ ) + { + return false; + } + void GetChecksum(BitmapChecksum& rChecksum) const { updateChecksum(); diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 73fbee394072..c98038807287 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -200,10 +200,14 @@ public: #endif // Default blend mode for SkPaint is SkBlendMode::kSrcOver + void drawBitmap(const SalTwoRect& rPosAry, const SkiaSalBitmap& bitmap, + SkBlendMode blendMode = SkBlendMode::kSrcOver); + void drawImage(const SalTwoRect& rPosAry, const sk_sp<SkImage>& aImage, SkBlendMode eBlendMode = SkBlendMode::kSrcOver); - void drawShader(const SalTwoRect& rPosAry, const sk_sp<SkShader>& shader); + void drawShader(const SalTwoRect& rPosAry, const sk_sp<SkShader>& shader, + SkBlendMode blendMode = SkBlendMode::kSrcOver); enum class GlyphOrientation { diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index d5491e367700..4ee6e4908ee7 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -59,13 +59,24 @@ public: sal_uInt8 nTol) override; virtual bool InterpretAs8Bit() override; virtual bool ConvertToGreyscale() override; + virtual bool Erase(const Color& color) override; const BitmapPalette& Palette() const { return mPalette; } + + // True if GetSkShader() should be preferred to GetSkImage() (or the Alpha variants). + bool PreferSkShader() const; + // Returns the contents as SkImage (possibly GPU-backed). const sk_sp<SkImage>& GetSkImage() const; + sk_sp<SkShader> GetSkShader() const; // Returns the contents as alpha SkImage (possibly GPU-backed) const sk_sp<SkImage>& GetAlphaSkImage() const; + sk_sp<SkShader> GetAlphaSkShader() const; + + // Key for caching/hashing. + OString GetImageKey() const; + OString GetAlphaImageKey() const; #ifdef DBG_UTIL void dump(const char* file) const; @@ -86,6 +97,7 @@ private: void EnsureBitmapUniqueData(); // Allocate mBuffer (with uninitialized contents). bool CreateBitmapData(); + void EraseInternal(); SkBitmap GetAsSkBitmap() const; #ifdef DBG_UTIL void verify() const; @@ -126,6 +138,9 @@ private: // data in mBuffer, if it differs from mSize, then there is a scaling operation pending. Size mPixelsSize; SkFilterQuality mScaleQuality = kHigh_SkFilterQuality; // quality for on-demand scaling + // Erase() is delayed, just sets these two instead of filling the buffer. + bool mEraseColorSet = false; + Color mEraseColor; #ifdef DBG_UTIL int mWriteAccessCount = 0; // number of write AcquireAccess() that have not been released #endif |