Initialize unfilled textures based on GrCaps
This is especially relevant on WebGL, where there
can be a large performance hit to dealing with
uninitialized textures.
Change-Id: Ic8469ec833464a88fe846c72fc02a9af5d43d0d5
Bug: skia:8378
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206396
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index 94afadc..0d9cd80 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -515,7 +515,13 @@
SkASSERT(SkIsPow2(fTextureWidth) && SkIsPow2(fTextureHeight));
GrSurfaceDesc desc;
- desc.fFlags = kNone_GrSurfaceFlags;
+ if (proxyProvider->caps()->shouldInitializeTextures()) {
+ // The atlas isn't guaranteed to touch all its pixels so, for platforms that benefit
+ // from complete initialization, clear everything.
+ desc.fFlags = kPerformInitialClear_GrSurfaceFlag;
+ } else {
+ desc.fFlags = kNone_GrSurfaceFlags;
+ }
desc.fWidth = fTextureWidth;
desc.fHeight = fTextureHeight;
desc.fConfig = fPixelConfig;