Limit the max atlas path width to 1024
The way GrDynamicAtlas works, a single 2048x1 path is given an entire
2048x2048 atlas with draw bounds of 2048x1025. Limit the max width to
1024 to avoid this landmine until it's resolved.
Bug: skia:12291
Change-Id: I4719ea789615a22238fa30b66f857dbfc113f33d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433966
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ops/GrAtlasPathRenderer.cpp b/src/gpu/ops/GrAtlasPathRenderer.cpp
index 26bbe99..b9ac4a6 100644
--- a/src/gpu/ops/GrAtlasPathRenderer.cpp
+++ b/src/gpu/ops/GrAtlasPathRenderer.cpp
@@ -38,6 +38,11 @@
// atlasing when they are very small.
constexpr static int kAtlasMaxPathHeightWithMSAAFallback = 128;
+// http://skbug.com/12291 -- The way GrDynamicAtlas works, a single 2048x1 path is given an entire
+// 2048x2048 atlas with draw bounds of 2048x1025. Limit the max width to 1024 to avoid this landmine
+// until it's resolved.
+constexpr static int kAtlasMaxPathWidth = 1024;
+
bool GrAtlasPathRenderer::IsSupported(GrRecordingContext* rContext) {
const GrCaps& caps = *rContext->priv().caps();
auto atlasFormat = caps.getDefaultBackendFormat(kAtlasAlpha8Type, GrRenderable::kYes);
@@ -63,6 +68,7 @@
fAtlasMaxSize = 2048;
#endif
fAtlasMaxSize = SkPrevPow2(std::min(fAtlasMaxSize, (float)caps.maxPreferredRenderTargetSize()));
+ fAtlasMaxPathWidth = std::min((float)kAtlasMaxPathWidth, fAtlasMaxSize);
fAtlasInitialSize = SkNextPow2(std::min(kAtlasInitialSize, (int)fAtlasMaxSize));
}
@@ -81,7 +87,7 @@
auto [topLeftFloor, botRightCeil] = round_out(pathDevBounds);
float2 size = botRightCeil - topLeftFloor;
return // Ensure the path's largest dimension fits in the atlas.
- skvx::all(size <= fAtlasMaxSize) &&
+ skvx::all(size <= fAtlasMaxPathWidth) &&
// Since we will transpose tall skinny paths, limiting to atlasMaxPathHeight^2 pixels
// guarantees heightInAtlas <= atlasMaxPathHeight, while also allowing paths that are
// very wide and short.
@@ -140,7 +146,7 @@
std::swap(heightInAtlas, widthInAtlas);
}
// pathFitsInAtlas() should have guaranteed these constraints on the path size.
- SkASSERT(widthInAtlas <= (int)fAtlasMaxSize);
+ SkASSERT(widthInAtlas <= (int)fAtlasMaxPathWidth);
SkASSERT(heightInAtlas <= kAtlasMaxPathHeight);
// Check if this path is already in the atlas. This is mainly for clip paths.