disable DAA and AAA in flutter
If we're looking to cut out unnecessary code in Flutter, SkScan_AAA always jumps out to me as a bunch of code that is not logically required for GPU rendering. Looking at a treemap[1], SkScan_AAA is the biggest chunk of code under src/core. I don't see DAA... maybe it's small, or somehow already trimmed? Anyway, I cut it out too. [1] https://storage.googleapis.com/flutter_infra/flutter/c8755d74c17e949ee7c19cd114f084b465dac632/android-arm-release/sizes/index.html Change-Id: I4acf4aec365504c90e6b66393fd265a399f0f525 Reviewed-on: https://skia-review.googlesource.com/c/159760 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
d18a95a7d1
commit
1421120316
@ -7,4 +7,8 @@ flutter_defines = [
|
||||
"SK_DISABLE_RENDER_TARGET_SORTING",
|
||||
"SK_SUPPORT_LEGACY_VULKAN_INTERFACE",
|
||||
"SK_LEGACY_SKCODEC_NONE_ENUM",
|
||||
|
||||
# Remove software rasterizers to save some code size.
|
||||
"SK_DISABLE_AAA",
|
||||
"SK_DISABLE_DAA",
|
||||
]
|
||||
|
@ -600,14 +600,11 @@ static SkIRect safeRoundOut(const SkRect& src) {
|
||||
}
|
||||
|
||||
constexpr int kSampleSize = 8;
|
||||
constexpr SkScalar kComplexityThreshold = 0.25;
|
||||
constexpr SkScalar kSmallCubicThreshold = 16;
|
||||
#if !defined(SK_DISABLE_DAA) || !defined(SK_DISABLE_AAA)
|
||||
constexpr SkScalar kComplexityThreshold = 0.25;
|
||||
#endif
|
||||
|
||||
static inline SkScalar sqr(SkScalar x) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
static void ComputeComplexity(const SkPath& path, SkScalar& avgLength, SkScalar& complexity) {
|
||||
static void compute_complexity(const SkPath& path, SkScalar& avgLength, SkScalar& complexity) {
|
||||
int n = path.countPoints();
|
||||
if (n < kSampleSize || path.getBounds().isEmpty()) {
|
||||
// set to invalid value to indicate that we failed to compute
|
||||
@ -624,6 +621,8 @@ static void ComputeComplexity(const SkPath& path, SkScalar& avgLength, SkScalar&
|
||||
}
|
||||
avgLength = sumLength / (kSampleSize - 1);
|
||||
|
||||
auto sqr = [](SkScalar x) { return x*x; };
|
||||
|
||||
SkScalar diagonalSqr = sqr(path.getBounds().width()) + sqr(path.getBounds().height());
|
||||
|
||||
// If the path consists of random line segments, the number of intersections should be
|
||||
@ -639,6 +638,11 @@ static void ComputeComplexity(const SkPath& path, SkScalar& avgLength, SkScalar&
|
||||
}
|
||||
|
||||
static bool ShouldUseDAA(const SkPath& path, SkScalar avgLength, SkScalar complexity) {
|
||||
#if defined(SK_DISABLE_DAA)
|
||||
return false;
|
||||
#else
|
||||
constexpr SkScalar kSmallCubicThreshold = 16;
|
||||
|
||||
if (gSkForceDeltaAA) {
|
||||
return true;
|
||||
}
|
||||
@ -646,10 +650,10 @@ static bool ShouldUseDAA(const SkPath& path, SkScalar avgLength, SkScalar comple
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_AA_CHOICE
|
||||
#ifdef SK_SUPPORT_LEGACY_AA_CHOICE
|
||||
const SkRect& bounds = path.getBounds();
|
||||
return !path.isConvex() && path.countPoints() >= SkTMax(bounds.width(), bounds.height()) / 8;
|
||||
#else
|
||||
#else
|
||||
if (avgLength < 0 || complexity < 0 || path.getBounds().isEmpty() || path.isConvex()) {
|
||||
return false;
|
||||
}
|
||||
@ -674,10 +678,14 @@ static bool ShouldUseDAA(const SkPath& path, SkScalar avgLength, SkScalar comple
|
||||
}
|
||||
|
||||
return complexity >= kComplexityThreshold;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool ShouldUseAAA(const SkPath& path, SkScalar avgLength, SkScalar complexity) {
|
||||
#if defined(SK_DISABLE_AAA)
|
||||
return false;
|
||||
#else
|
||||
if (gSkForceAnalyticAA) {
|
||||
return true;
|
||||
}
|
||||
@ -688,7 +696,7 @@ static bool ShouldUseAAA(const SkPath& path, SkScalar avgLength, SkScalar comple
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_AAA_CHOICE
|
||||
#ifdef SK_SUPPORT_LEGACY_AAA_CHOICE
|
||||
const SkRect& bounds = path.getBounds();
|
||||
// When the path have so many points compared to the size of its bounds/resolution,
|
||||
// it indicates that the path is not quite smooth in the current resolution:
|
||||
@ -696,7 +704,7 @@ static bool ShouldUseAAA(const SkPath& path, SkScalar avgLength, SkScalar comple
|
||||
// zero. Hence Aanlytic AA is not likely to produce visible quality improvements, and Analytic
|
||||
// AA might be slower than supersampling.
|
||||
return path.countPoints() < SkTMax(bounds.width(), bounds.height()) / 2 - 10;
|
||||
#else
|
||||
#else
|
||||
if (path.countPoints() >= path.getBounds().height()) {
|
||||
// SAA is faster than AAA in this case even if there are no intersections because AAA will
|
||||
// have too many scan lines. See skbug.com/8272
|
||||
@ -705,6 +713,7 @@ static bool ShouldUseAAA(const SkPath& path, SkScalar avgLength, SkScalar comple
|
||||
|
||||
// We will use AAA if the number of verbs < kSampleSize and therefore complexity < 0
|
||||
return complexity < kComplexityThreshold;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -824,7 +833,7 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip,
|
||||
}
|
||||
|
||||
SkScalar avgLength, complexity;
|
||||
ComputeComplexity(path, avgLength, complexity);
|
||||
compute_complexity(path, avgLength, complexity);
|
||||
|
||||
if (daaRecord || ShouldUseDAA(path, avgLength, complexity)) {
|
||||
SkScan::DAAFillPath(path, blitter, ir, clipRgn->getBounds(), forceRLE, daaRecord);
|
||||
|
Loading…
Reference in New Issue
Block a user