Index: src/core/SkDevice.cpp |
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp |
index 1b228565283cc1cc8cf36ed4a79d4b361591ee9f..da120f0e68cbe863ea8b51ce43e5f9eb30fe7f6c 100644 |
--- a/src/core/SkDevice.cpp |
+++ b/src/core/SkDevice.cpp |
@@ -459,3 +459,58 @@ uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { |
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 |
+} |
+ |