[graphite] Fix SkBitmap creation for ClipAtlas ProxyCache use.
Using detachPixels() also clears the pixmap's info so we need to make
a copy beforehand.
Bug: b/404880920
Change-Id: I010242ef4529ec7c8108259e78172632b1ab9e25
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/971416
Reviewed-by: Thomas Smith <thomsmit@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/graphite/ClipAtlasManager.cpp b/src/gpu/graphite/ClipAtlasManager.cpp
index 1b0b694..9c20144 100644
--- a/src/gpu/graphite/ClipAtlasManager.cpp
+++ b/src/gpu/graphite/ClipAtlasManager.cpp
@@ -145,9 +145,12 @@
draw_clip_mask_to_pixmap(cdc->fElementList, cdc->fBounds, cdc->fRenderSize,
cdc->fDrawBounds, &dst);
SkBitmap bm;
+ // SkPixmap::detachPixels() clears these so we need to make a copy.
+ SkImageInfo ii = dst.info();
+ size_t rowBytes = dst.rowBytes();
// The bitmap needs to take ownership of the pixels, so we detach them from the
// SkAutoPixmapStorage and pass them to SkBitmap::installPixels().
- SkAssertResult(bm.installPixels(dst.info(), dst.detachPixels(), dst.rowBytes(),
+ SkAssertResult(bm.installPixels(ii, dst.detachPixels(), rowBytes,
[](void* addr, void* context) { sk_free(addr); },
nullptr));
bm.setImmutable();