Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit dcfbbd7

Browse files
authored
embedder: fix bit-order in software pixel format description (#57156)
The order of the components for packed software pixel formats is incorrectly documented as being the order in the native type, least-significant-bit first. In reality it's the other way around. For example, for `RGB565`, the `R` is the 5 most significant bits in the 2-byte pixel value, rather than the least significant bits. The test even verify it is that way: https://github.com/flutter/engine/blob/main/shell/platform/embedder/tests/embedder_unittests.cc#L2782-L2785 I assume noone used the software pixel formats until @sodiboo did, that's why it's gone unnoticed for so long. Also contains some other minor documentation improvements. - Issue: flutter/flutter#160149 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 0d5a750 commit dcfbbd7

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

shell/platform/embedder/embedder.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,33 +352,48 @@ typedef enum {
352352
/// r = (p >> 11) & 0x1F;
353353
/// g = (p >> 5) & 0x3F;
354354
/// b = p & 0x1F;
355+
///
356+
/// On most (== little-endian) systems, this is equivalent to wayland format
357+
/// RGB565 (WL_DRM_FORMAT_RGB565, WL_SHM_FORMAT_RGB565).
355358
kFlutterSoftwarePixelFormatRGB565,
356359

357360
/// Pixel with 4 bits each for alpha, red, green, blue; in 16-bit word.
358361
/// r = (p >> 8) & 0xF;
359362
/// g = (p >> 4) & 0xF;
360363
/// b = p & 0xF;
361364
/// a = (p >> 12) & 0xF;
365+
///
366+
/// On most (== little-endian) systems, this is equivalent to wayland format
367+
/// RGBA4444 (WL_DRM_FORMAT_RGBA4444, WL_SHM_FORMAT_RGBA4444).
362368
kFlutterSoftwarePixelFormatRGBA4444,
363369

364370
/// Pixel with 8 bits each for red, green, blue, alpha.
365371
/// r = p[0];
366372
/// g = p[1];
367373
/// b = p[2];
368374
/// a = p[3];
375+
///
376+
/// This is equivalent to wayland format ABGR8888 (WL_DRM_FORMAT_ABGR8888,
377+
/// WL_SHM_FORMAT_ABGR8888).
369378
kFlutterSoftwarePixelFormatRGBA8888,
370379

371380
/// Pixel with 8 bits each for red, green and blue and 8 unused bits.
372381
/// r = p[0];
373382
/// g = p[1];
374383
/// b = p[2];
384+
///
385+
/// This is equivalent to wayland format XBGR8888 (WL_DRM_FORMAT_XBGR8888,
386+
/// WL_SHM_FORMAT_XBGR8888).
375387
kFlutterSoftwarePixelFormatRGBX8888,
376388

377389
/// Pixel with 8 bits each for blue, green, red and alpha.
378390
/// r = p[2];
379391
/// g = p[1];
380392
/// b = p[0];
381393
/// a = p[3];
394+
///
395+
/// This is equivalent to wayland format ARGB8888 (WL_DRM_FORMAT_ARGB8888,
396+
/// WL_SHM_FORMAT_ARGB8888).
382397
kFlutterSoftwarePixelFormatBGRA8888,
383398

384399
/// Either kFlutterSoftwarePixelFormatBGRA8888 or
@@ -1741,7 +1756,8 @@ typedef struct {
17411756
/// store.
17421757
VoidCallback destruction_callback;
17431758
/// The pixel format that the engine should use to render into the allocation.
1744-
/// In most cases, kR
1759+
///
1760+
/// On Linux, kFlutterSoftwarePixelFormatBGRA8888 is most commonly used.
17451761
FlutterSoftwarePixelFormat pixel_format;
17461762
} FlutterSoftwareBackingStore2;
17471763

@@ -2011,6 +2027,14 @@ typedef struct {
20112027
/// The callback should return true if the operation was successful.
20122028
FlutterLayersPresentCallback present_layers_callback;
20132029
/// Avoid caching backing stores provided by this compositor.
2030+
///
2031+
/// The engine has an internal backing store cache. Instead of
2032+
/// creating & destroying backing stores for every frame, created
2033+
/// backing stores are automatically reused for subsequent frames.
2034+
///
2035+
/// If you wish to change this behavior and destroy backing stores after
2036+
/// they've been used once, and create new backing stores for every frame,
2037+
/// you can set this bool to true.
20142038
bool avoid_backing_store_cache;
20152039
/// Callback invoked by the engine to composite the contents of each layer
20162040
/// onto the specified view.

0 commit comments

Comments
 (0)