diff options
author | Michael Hoisie <hoisie@google.com> | 2024-05-03 19:55:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-03 19:55:44 +0000 |
commit | 665595fa8dce68f2f8fec127b944867b890087fb (patch) | |
tree | 3041197837e4b62c2158a6cbb0efd48e47034d47 | |
parent | 36956568bca616ad500235d4bc445a25f119c9fc (diff) | |
parent | bb2ce220a531071db63a7089b2d1ead0a8c67d73 (diff) | |
download | base-android12-hostruntime-dev.tar.gz |
Merge "Use kN32_SkColorType when creating the buffer for SkiaHostPipeline" into android12-hostruntime-devandroid12-hostruntime-dev
-rw-r--r-- | libs/hwui/pipeline/skia/SkiaHostPipeline.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaHostPipeline.cpp b/libs/hwui/pipeline/skia/SkiaHostPipeline.cpp index 5faeb9dc503e..431487a65121 100644 --- a/libs/hwui/pipeline/skia/SkiaHostPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaHostPipeline.cpp @@ -69,16 +69,14 @@ bool SkiaHostPipeline::setSurface(ANativeWindow* surface, SwapBehavior swapBehav int width, height; surface->query(surface, NATIVE_WINDOW_WIDTH, &width); surface->query(surface, NATIVE_WINDOW_HEIGHT, &height); - // The image must have color type BGRA for all platforms. - // Robolectric note: - // This forces Skia to render ARGB even though we fill an ImageReader - // Surface declared as RGBA_8888. - // Doing this allows us to directly match an Android Bitmap which also - // as the ARGB_8888 format (BGRA and ARGB are essentially the same data - // seen from a different endianness perspective). - SkImageInfo imageInfo = - SkImageInfo::Make(width, height, SkColorType::kBGRA_8888_SkColorType, - SkAlphaType::kPremul_SkAlphaType); + // The ColorType param here must match the ColorType used by + // Bitmap.Config.ARGB_8888. Android Bitmap objects use kN32_SkColorType + // by default for Bitmap.Config.ARGB_8888. The value of this is + // determined at compile time based on architecture (either BGRA or + // RGBA). If other Android Bitmap configs are used, 'kN32_SkColorType' + // may not be correct. + SkImageInfo imageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, + SkAlphaType::kPremul_SkAlphaType); size_t widthBytes = width * 4; void* pixels = buffer->reserved[0]; mSurface = SkSurface::MakeRasterDirect(imageInfo, pixels, widthBytes); |