summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-11-05 14:04:39 +0100
committerLuboš Luňák <l.lunak@collabora.com>2019-11-26 13:24:55 +0100
commit5ffa3e7d57b36b8fcb3a3de755fa9ba0388961e2 (patch)
tree44c7827f29c1b3d6f37b4a3a85ed4a1e364b3aa0
parent256c81ac820cdfebc0c28cc8ed7c431334197815 (diff)
add SAL log group vcl.skia for tracing Skia usage
Change-Id: Ife21bbe0b86c3edd20e657da09c6e218fa4fced3
-rw-r--r--RepositoryExternal.mk1
-rw-r--r--include/sal/log-areas.dox1
-rw-r--r--vcl/inc/skia/gdiimpl.hxx10
-rw-r--r--vcl/inc/skia/salbmp.hxx11
-rw-r--r--vcl/skia/gdiimpl.cxx42
-rw-r--r--vcl/skia/salbmp.cxx13
6 files changed, 75 insertions, 3 deletions
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 37b27a0219de..91be30307dd7 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -116,6 +116,7 @@ define gb_LinkTarget__use_skia
$(call gb_LinkTarget_set_include,$(1),\
-I$(call gb_UnpackedTarball_get_dir,skia)/include/core \
-I$(call gb_UnpackedTarball_get_dir,skia)/include/effects \
+ -I$(call gb_UnpackedTarball_get_dir,skia)/include/gpu \
-I$(call gb_UnpackedTarball_get_dir,skia)/include/config \
-I$(call gb_UnpackedTarball_get_dir,skia)/include/third_party/vulkan \
-I$(call gb_UnpackedTarball_get_dir,skia) \
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 4711bd8a6a0f..ce0fa239b292 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -496,6 +496,7 @@ certain functionality.
@li @c vcl.scrollbar - Scroll Bars
@li @c vcl.se - VCL Session Manager
@li @c vcl.se.debug
+@li @c vcl.skia - drawing using the Skia library
@li @c vcl.sm - Session Manager Client
@li @c vcl.sm.debug
@li @c vcl.uitest - The UI testing framework code
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 0c70ce0705ee..f45b29abb07e 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -215,6 +215,8 @@ protected:
void setProvider(SalGeometryProvider* provider) { mProvider = provider; }
bool isOffscreen() const { return mProvider == nullptr || mProvider->IsOffScreen(); }
+ // TODO mainly for debugging purposes
+ bool isGPU() const;
void invert(basegfx::B2DPolygon const& rPoly, SalInvert eFlags);
@@ -241,6 +243,14 @@ protected:
void prefillSurface();
#endif
+ template <typename charT, typename traits>
+ friend inline std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& stream, const SkiaSalGraphicsImpl* graphics)
+ { // O - offscreen, G - GPU-based, R - raster
+ return stream << (void*)graphics << " " << Size(graphics->GetWidth(), graphics->GetHeight())
+ << (graphics->isOffscreen() ? "O" : "") << (graphics->isGPU() ? "G" : "R");
+ }
+
SalGraphics& mParent;
/// Pointer to the SalFrame or SalVirtualDevice
SalGeometryProvider* mProvider;
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index b7d0bd25a1b6..c5922685c5b7 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -78,6 +78,17 @@ private:
void verify() const {};
#endif
+ template <typename charT, typename traits>
+ friend inline std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& stream, const SkiaSalBitmap* bitmap)
+ { // TODO GPU-based, once it's done
+ // B - has SkBitmap, A - has alpha SkBitmap, D - has data buffer
+ return stream << (void*)bitmap << " " << bitmap->GetSize() << "/" << bitmap->mBitCount
+ << (!bitmap->mBitmap.drawsNothing() ? "B" : "")
+ << (!bitmap->mAlphaBitmap.drawsNothing() ? "A" : "")
+ << (bitmap->mBuffer.get() ? "D" : "");
+ }
+
// TODO use something GPU-backed, or at least cache it for when drawing it to something GPU-backed?
SkBitmap mBitmap;
SkBitmap mAlphaBitmap; // TODO for use as an alpha channel or mask
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index d85ba18ffa76..f505e7778d64 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -28,6 +28,7 @@
#include <SkPath.h>
#include <SkRegion.h>
#include <SkDashPathEffect.h>
+#include <GrBackendSurface.h>
#include <basegfx/polygon/b2dpolygontools.hxx>
@@ -255,8 +256,20 @@ void SkiaSalGraphicsImpl::postDraw()
// to create it in Init() if it gets recreated later anyway).
void SkiaSalGraphicsImpl::checkSurface()
{
- if (!mSurface || GetWidth() != mSurface->width() || GetHeight() != mSurface->height())
+ if (!mSurface)
+ {
+ recreateSurface();
+ SAL_INFO("vcl.skia",
+ "create(" << this << "): " << Size(mSurface->width(), mSurface->height()));
+ }
+ else if (GetWidth() != mSurface->width() || GetHeight() != mSurface->height())
+ {
+ Size oldSize(mSurface->width(), mSurface->height());
recreateSurface();
+ SAL_INFO("vcl.skia", "recreate(" << this << "): old " << oldSize << " new "
+ << Size(mSurface->width(), mSurface->height())
+ << " requested " << Size(GetWidth(), GetHeight()));
+ }
}
static SkIRect toSkIRect(const tools::Rectangle& rectangle)
@@ -297,6 +310,7 @@ bool SkiaSalGraphicsImpl::setClipRegion(const vcl::Region& region)
return true;
mClipRegion = region;
checkSurface();
+ SAL_INFO("vcl.skia", "setclipregion(" << this << "): " << region);
SkCanvas* canvas = mSurface->getCanvas();
// SkCanvas::clipRegion() can only further reduce the clip region,
// but we need to set the given region, which may extend it.
@@ -387,6 +401,7 @@ void SkiaSalGraphicsImpl::drawPixel(long nX, long nY, Color nColor)
if (nColor == SALCOLOR_NONE)
return;
preDraw();
+ SAL_INFO("vcl.skia", "drawpixel(" << this << "): " << Point(nX, nY) << ":" << nColor);
SkCanvas* canvas = mSurface->getCanvas();
SkPaint paint;
paint.setColor(toSkColor(nColor));
@@ -401,6 +416,8 @@ void SkiaSalGraphicsImpl::drawLine(long nX1, long nY1, long nX2, long nY2)
if (mLineColor == SALCOLOR_NONE)
return;
preDraw();
+ SAL_INFO("vcl.skia", "drawline(" << this << "): " << Point(nX1, nY1) << "->" << Point(nX2, nY2)
+ << ":" << mLineColor);
SkCanvas* canvas = mSurface->getCanvas();
SkPaint paint;
paint.setColor(toSkColor(mLineColor));
@@ -413,6 +430,9 @@ void SkiaSalGraphicsImpl::privateDrawAlphaRect(long nX, long nY, long nWidth, lo
double fTransparency, bool blockAA)
{
preDraw();
+ SAL_INFO("vcl.skia", "privatedrawrect(" << this << "): " << Point(nX, nY) << "/"
+ << Size(nWidth, nHeight) << ":" << mLineColor << ":"
+ << mFillColor << ":" << fTransparency);
SkCanvas* canvas = mSurface->getCanvas();
SkPaint paint;
paint.setAntiAlias(!blockAA && mParent.getAntiAliasB2DDraw());
@@ -497,6 +517,8 @@ bool SkiaSalGraphicsImpl::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectTo
SkPath aPath;
basegfx::B2DPolyPolygon aPolyPolygon(rPolyPolygon);
aPolyPolygon.transform(rObjectToDevice);
+ SAL_INFO("vcl.skia", "drawpolypolygon(" << this << "): " << aPolyPolygon << ":" << mLineColor
+ << ":" << mFillColor);
lclPolyPolygonToPath(aPolyPolygon, aPath);
aPath.setFillType(SkPath::kEvenOdd_FillType);
@@ -533,6 +555,7 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev
return true;
preDraw();
+ SAL_INFO("vcl.skia", "drawpolyline(" << this << "): " << rPolyLine << ":" << mLineColor);
basegfx::B2DVector aLineWidths(rLineWidths);
const bool bObjectToDeviceIsIdentity(rObjectToDevice.isIdentity());
@@ -649,6 +672,9 @@ void SkiaSalGraphicsImpl::copyArea(long nDestX, long nDestY, long nSrcX, long nS
if (nDestX == nSrcX && nDestY == nSrcY)
return;
preDraw();
+ SAL_INFO("vcl.skia", "copyarea(" << this << "): " << Point(nSrcX, nSrcY) << "->"
+ << Point(nDestX, nDestY) << "/"
+ << Size(nSrcWidth, nSrcHeight));
sk_sp<SkImage> image
= mSurface->makeImageSnapshot(SkIRect::MakeXYWH(nSrcX, nSrcY, nSrcWidth, nSrcHeight));
// TODO makeNonTextureImage() ?
@@ -668,6 +694,7 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcG
else
src = this;
src->checkSurface();
+ SAL_INFO("vcl.skia", "copybits(" << this << "): (" << src << "):" << rPosAry);
sk_sp<SkImage> image = src->mSurface->makeImageSnapshot(
SkIRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight));
// TODO makeNonTextureImage() ?
@@ -777,6 +804,8 @@ std::shared_ptr<SalBitmap> SkiaSalGraphicsImpl::getBitmap(long nX, long nY, long
long nHeight)
{
checkSurface();
+ SAL_INFO("vcl.skia",
+ "getbitmap(" << this << "): " << Point(nX, nY) << "/" << Size(nWidth, nHeight));
mSurface->getCanvas()->flush();
sk_sp<SkImage> image = mSurface->makeImageSnapshot(SkIRect::MakeXYWH(nX, nY, nWidth, nHeight));
return std::make_shared<SkiaSalBitmap>(*image);
@@ -785,6 +814,7 @@ std::shared_ptr<SalBitmap> SkiaSalGraphicsImpl::getBitmap(long nX, long nY, long
Color SkiaSalGraphicsImpl::getPixel(long nX, long nY)
{
checkSurface();
+ SAL_INFO("vcl.skia", "getpixel(" << this << "): " << Point(nX, nY));
mSurface->getCanvas()->flush();
// TODO this is presumably slow, and possibly won't work with GPU surfaces
SkBitmap bitmap;
@@ -798,6 +828,7 @@ Color SkiaSalGraphicsImpl::getPixel(long nX, long nY)
void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFlags)
{
preDraw();
+ SAL_INFO("vcl.skia", "invert(" << this << "): " << rPoly << ":" << int(eFlags));
// TrackFrame just inverts a dashed path around the polygon
if (eFlags == SalInvert::TrackFrame)
{
@@ -928,6 +959,7 @@ void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SkBitmap&
aPaint.setBlendMode(eBlendMode);
preDraw();
+ SAL_INFO("vcl.skia", "drawbitmap(" << this << "): " << rPosAry << ":" << int(eBlendMode));
mSurface->getCanvas()->drawBitmapRect(aBitmap, aSourceRect, aDestinationRect, &aPaint);
postDraw();
}
@@ -981,6 +1013,8 @@ bool SkiaSalGraphicsImpl::drawTransformedBitmap(const basegfx::B2DPoint& rNull,
aMatrix.set(SkMatrix::kMTransY, rNull.getY());
preDraw();
+ SAL_INFO("vcl.skia",
+ "drawtransformedbitmap(" << this << "): " << rNull << ":" << rX << ":" << rY);
{
SkAutoCanvasRestore autoRestore(mSurface->getCanvas(), true);
mSurface->getCanvas()->concat(aMatrix);
@@ -1018,6 +1052,12 @@ bool SkiaSalGraphicsImpl::supportsOperation(OutDevSupportType eType) const
}
}
+bool SkiaSalGraphicsImpl::isGPU() const
+{
+ return mSurface.get()
+ && mSurface->getBackendRenderTarget(SkSurface::kFlushRead_BackendHandleAccess).isValid();
+}
+
#ifdef DBG_UTIL
void SkiaSalGraphicsImpl::dump(const char* file) const
{
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 9322e7ee8e55..c1ff1f13e9e3 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -55,7 +55,8 @@ SkiaSalBitmap::SkiaSalBitmap(const SkImage& image)
bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal)
{
- Destroy();
+ mBitmap.reset();
+ mBuffer.reset();
if (!isValidBitCount(nBitCount))
return false;
// Skia only supports 8bit gray, 16bit and 32bit formats (e.g. 24bpp is actually stored as 32bpp).
@@ -96,7 +97,7 @@ bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const Bitmap
int bitScanlineWidth;
if (o3tl::checked_multiply<int>(rSize.Width(), nBitCount, bitScanlineWidth))
{
- SAL_WARN("vcl.gdi", "checked multiply failed");
+ SAL_WARN("vcl.skia", "checked multiply failed");
return false;
}
mScanlineSize = AlignedWidth4Bytes(bitScanlineWidth);
@@ -120,6 +121,7 @@ bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const Bitmap
mPalette = rPal;
mBitCount = nBitCount;
mSize = rSize;
+ SAL_INFO("vcl.skia", "create(" << this << ")");
return true;
}
@@ -154,11 +156,13 @@ bool SkiaSalBitmap::Create(const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount)
mBuffer.reset(newBuffer);
mScanlineSize = src.mScanlineSize;
}
+ SAL_INFO("vcl.skia", "create(" << this << "): (" << &src << ")");
return true;
}
if (!Create(src.mSize, src.mBitCount, src.mPalette))
return false;
// TODO copy data
+ SAL_INFO("vcl.skia", "copy(" << this << "): (" << &src << ")");
abort();
return true;
}
@@ -174,6 +178,7 @@ bool SkiaSalBitmap::Create(const css::uno::Reference<css::rendering::XBitmapCanv
void SkiaSalBitmap::Destroy()
{
+ SAL_INFO("vcl.skia", "destroy(" << this << ")");
mBitmap.reset();
mBuffer.reset();
}
@@ -309,6 +314,7 @@ const SkBitmap& SkiaSalBitmap::GetSkBitmap() const
data.release(), mSize.Width() * 4,
[](void* addr, void*) { delete[] static_cast<sal_uInt8*>(addr); }, nullptr))
abort();
+ SAL_INFO("vcl.skia", "skbitmap(" << this << ")");
}
else
{
@@ -324,6 +330,7 @@ const SkBitmap& SkiaSalBitmap::GetSkBitmap() const
data.release(), mSize.Width() * 4,
[](void* addr, void*) { delete[] static_cast<sal_uInt8*>(addr); }, nullptr))
abort();
+ SAL_INFO("vcl.skia", "skbitmap(" << this << ")");
}
}
return mBitmap;
@@ -347,6 +354,7 @@ const SkBitmap& SkiaSalBitmap::GetAlphaSkBitmap() const
[](void* addr, void*) { delete[] static_cast<sal_uInt8*>(addr); },
nullptr))
abort();
+ SAL_INFO("vcl.skia", "skalphabitmap(" << this << ")");
}
else
{
@@ -378,6 +386,7 @@ const SkBitmap& SkiaSalBitmap::GetAlphaSkBitmap() const
.setPixelRef(sk_ref_sp(bitmap8->pixelRef()), bitmap8->pixelRefOrigin().x(),
bitmap8->pixelRefOrigin().y());
delete convertedBitmap;
+ SAL_INFO("vcl.skia", "skalphabitmap(" << this << ")");
return mAlphaBitmap;
}
}