Adds histogram metrics to log the filter quality and scale factor of
each image draw. To make the data easier to consume, this is broken
down into a number of individual histograms:
- Filter quality across all draw calls
- Scale amount across all draw calls
- Scale amount per filter quality (4 histograms total)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=
1686203002
Committed: https://skia.googlesource.com/skia/+/
f57b3a6e4a002caf01378832cbd756c6c163a783
Review URL: https://codereview.chromium.org/
1686203002
virtual void drawSpriteWithFilter(const SkDraw&, const SkBitmap&,
int x, int y, const SkPaint&);
+ // A helper function used by derived classes to log the scale factor of a bitmap or image draw.
+ static void LogDrawScaleFactor(const SkMatrix&, SkFilterQuality);
+
private:
friend class SkCanvas;
friend struct DeviceCM; //for setMatrixClip
kNone_SkFilterQuality, //!< fastest but lowest quality, typically nearest-neighbor
kLow_SkFilterQuality, //!< typically bilerp
kMedium_SkFilterQuality, //!< typically bilerp + mipmaps for down-scaling
- kHigh_SkFilterQuality //!< slowest but highest quality, typically bicubic or better
+ kHigh_SkFilterQuality, //!< slowest but highest quality, typically bicubic or better
+
+ kLast_SkFilterQuality = kHigh_SkFilterQuality
};
#endif
//////////////////////////////////////////////////////////////////////
+#if defined(SK_HISTOGRAM_ENUMERATION) && defined(SK_HISTOGRAM_BOOLEAN)
+# define SK_HISTOGRAMS_ENABLED 1
+#else
+# define SK_HISTOGRAMS_ENABLED 0
+#endif
+
#ifndef SK_HISTOGRAM_BOOLEAN
# define SK_HISTOGRAM_BOOLEAN(name, value)
#endif
void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint& paint) {
+ LogDrawScaleFactor(SkMatrix::Concat(*draw.fMatrix, matrix), paint.getFilterQuality());
draw.drawBitmap(bitmap, matrix, nullptr, paint);
}
}
matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
+ LogDrawScaleFactor(SkMatrix::Concat(*draw.fMatrix, matrix), paint.getFilterQuality());
+
const SkRect* dstPtr = &dst;
const SkBitmap* bitmapPtr = &bitmap;
sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps const&) {
return nullptr;
}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+void SkBaseDevice::LogDrawScaleFactor(const SkMatrix& matrix, SkFilterQuality filterQuality) {
+#if SK_HISTOGRAMS_ENABLED
+ enum ScaleFactor {
+ kUpscale_ScaleFactor,
+ kNoScale_ScaleFactor,
+ kDownscale_ScaleFactor,
+ kLargeDownscale_ScaleFactor,
+
+ kLast_ScaleFactor = kLargeDownscale_ScaleFactor
+ };
+
+ float rawScaleFactor = matrix.getMinScale();
+
+ ScaleFactor scaleFactor;
+ if (rawScaleFactor < 0.5f) {
+ scaleFactor = kLargeDownscale_ScaleFactor;
+ } else if (rawScaleFactor < 1.0f) {
+ scaleFactor = kDownscale_ScaleFactor;
+ } else if (rawScaleFactor > 1.0f) {
+ scaleFactor = kUpscale_ScaleFactor;
+ } else {
+ scaleFactor = kNoScale_ScaleFactor;
+ }
+
+ switch (filterQuality) {
+ case kNone_SkFilterQuality:
+ SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.NoneFilterQuality", scaleFactor,
+ kLast_ScaleFactor + 1);
+ break;
+ case kLow_SkFilterQuality:
+ SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.LowFilterQuality", scaleFactor,
+ kLast_ScaleFactor + 1);
+ break;
+ case kMedium_SkFilterQuality:
+ SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.MediumFilterQuality", scaleFactor,
+ kLast_ScaleFactor + 1);
+ break;
+ case kHigh_SkFilterQuality:
+ SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.HighFilterQuality", scaleFactor,
+ kLast_ScaleFactor + 1);
+ break;
+ }
+
+ // Also log filter quality independent scale factor.
+ SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor,
+ kLast_ScaleFactor + 1);
+
+ // Also log an overall histogram of filter quality.
+ SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuality + 1);
+#endif
+}
+
bool bicubic) {
ASSERT_SINGLE_OWNER
- // This is the funnel for all paths that draw tiled bitmaps/images. Log histogram entry.
+ // This is the funnel for all paths that draw tiled bitmaps/images. Log histogram entries.
SK_HISTOGRAM_BOOLEAN("DrawTiled", true);
+ LogDrawScaleFactor(viewMatrix, origPaint.getFilterQuality());
// The following pixel lock is technically redundant, but it is desirable
// to lock outside of the tile loop to prevent redecoding the whole image
}
}
+ // Now that we have both the view and srcToDst matrices, log our scale factor.
+ LogDrawScaleFactor(SkMatrix::Concat(viewMatrix, srcToDstMatrix), paint.getFilterQuality());
+
this->drawTextureProducerImpl(producer, clippedSrcRect, clippedDstRect, constraint, viewMatrix,
srcToDstMatrix, clip, paint);
}