From 14d308a548848f2a860818db9d4897c6cdff219f Mon Sep 17 00:00:00 2001 From: Myriad Date: Sun, 15 Dec 2024 13:04:12 -0500 Subject: [PATCH 1/3] docs: Fix RGB565 format documentation and bit masks\n\nThe RGB565 format documentation incorrectly stated that red component uses the least significant bits. This commit fixes the documentation to correctly reflect that:\n\n- Red uses 5 MSBs [15:11]\n- Green uses 6 middle bits [10:5]\n- Blue uses 5 LSBs [4:0]\n\nAlso fixes the example bit extraction code to use correct masks. --- shell/platform/embedder/embedder.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shell/platform/embedder/embedder.h b/shell/platform/embedder/embedder.h index 8ca474222d39e..108e1e6883a19 100644 --- a/shell/platform/embedder/embedder.h +++ b/shell/platform/embedder/embedder.h @@ -327,9 +327,10 @@ typedef enum { /// occupying the lowest memory address. /// /// - all other formats are called packed formats, and the component order -/// as specified in the format name refers to the order in the native type. -/// for example, for kFlutterSoftwarePixelFormatRGB565, the R component -/// uses the 5 least significant bits of the uint16_t pixel value. +/// as specified in the format name refers to the order from most significant +/// to least significant bits in the native type. +/// for example, for kFlutterSoftwarePixelFormatRGB565, R occupies the 5 most +/// significant bits, G the middle 6 bits, and B the 5 least significant bits. /// /// Each pixel format in this list is documented with an example on how to get /// the color components from the pixel. @@ -348,11 +349,11 @@ typedef enum { kFlutterSoftwarePixelFormatGray8, /// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word. - /// r = p & 0x3F; g = (p>>5) & 0x3F; b = p>>11; + /// r = (p >> 11) & 0x1F; g = (p >> 5) & 0x3F; b = p & 0x1F; kFlutterSoftwarePixelFormatRGB565, /// pixel with 4 bits for alpha, red, green, blue; in 16-bit word. - /// r = p & 0xF; g = (p>>4) & 0xF; b = (p>>8) & 0xF; a = p>>12; + /// r = (p >> 8) & 0xF; g = (p >> 4) & 0xF; b = p & 0xF; a = (p >> 12) & 0xF; kFlutterSoftwarePixelFormatRGBA4444, /// pixel with 8 bits for red, green, blue, alpha. From 75048c21b404752d328bc405aa7d7e24708a157e Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 16 Dec 2024 09:59:37 -0800 Subject: [PATCH 2/3] Formatting --- shell/platform/embedder/embedder.h | 39 ++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/shell/platform/embedder/embedder.h b/shell/platform/embedder/embedder.h index 108e1e6883a19..f2f55b10debc4 100644 --- a/shell/platform/embedder/embedder.h +++ b/shell/platform/embedder/embedder.h @@ -327,10 +327,10 @@ typedef enum { /// occupying the lowest memory address. /// /// - all other formats are called packed formats, and the component order -/// as specified in the format name refers to the order from most significant -/// to least significant bits in the native type. -/// for example, for kFlutterSoftwarePixelFormatRGB565, R occupies the 5 most -/// significant bits, G the middle 6 bits, and B the 5 least significant bits. +/// as specified in the format name refers to the order from most +/// significant to least significant bits in the native type. for example, +/// for kFlutterSoftwarePixelFormatRGB565, R occupies the 5 most significant +/// bits, G the middle 6 bits, and B the 5 least significant bits. /// /// Each pixel format in this list is documented with an example on how to get /// the color components from the pixel. @@ -349,23 +349,36 @@ typedef enum { kFlutterSoftwarePixelFormatGray8, /// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word. - /// r = (p >> 11) & 0x1F; g = (p >> 5) & 0x3F; b = p & 0x1F; + /// r = (p >> 11) & 0x1F; + /// g = (p >> 5) & 0x3F; + /// b = p & 0x1F; kFlutterSoftwarePixelFormatRGB565, - /// pixel with 4 bits for alpha, red, green, blue; in 16-bit word. - /// r = (p >> 8) & 0xF; g = (p >> 4) & 0xF; b = p & 0xF; a = (p >> 12) & 0xF; + /// pixel with 4 bits each for alpha, red, green, blue; in 16-bit word. + /// r = (p >> 8) & 0xF; + /// g = (p >> 4) & 0xF; + /// b = p & 0xF; + /// a = (p >> 12) & 0xF; kFlutterSoftwarePixelFormatRGBA4444, - /// pixel with 8 bits for red, green, blue, alpha. - /// r = p[0]; g = p[1]; b = p[2]; a = p[3]; + /// pixel with 8 bits each for red, green, blue, alpha. + /// r = p[0]; + /// g = p[1]; + /// b = p[2]; + /// a = p[3]; kFlutterSoftwarePixelFormatRGBA8888, - /// pixel with 8 bits for red, green and blue and 8 unused bits. - /// r = p[0]; g = p[1]; b = p[2]; + /// pixel with 8 bits each for red, green and blue and 8 unused bits. + /// r = p[0]; + /// g = p[1]; + /// b = p[2]; kFlutterSoftwarePixelFormatRGBX8888, - /// pixel with 8 bits for blue, green, red and alpha. - /// r = p[2]; g = p[1]; b = p[0]; a = p[3]; + /// pixel with 8 bits each for blue, green, red and alpha. + /// r = p[2]; + /// g = p[1]; + /// b = p[0]; + /// a = p[3]; kFlutterSoftwarePixelFormatBGRA8888, /// either kFlutterSoftwarePixelFormatBGRA8888 or From fcb98c2aa39e519a08bdbe16b61590b7f6adfeea Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 16 Dec 2024 10:04:17 -0800 Subject: [PATCH 3/3] Minor punctuation + capitalisation fixes --- shell/platform/embedder/embedder.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shell/platform/embedder/embedder.h b/shell/platform/embedder/embedder.h index f2f55b10debc4..4b880a6855d93 100644 --- a/shell/platform/embedder/embedder.h +++ b/shell/platform/embedder/embedder.h @@ -343,46 +343,46 @@ typedef enum { /// can get the p for a RGBA8888 formatted buffer like this: /// const uint8_t *p = ((const uint8_t*) allocation) + row_bytes*y + x*4; typedef enum { - /// pixel with 8 bit grayscale value. + /// Pixel with 8 bit grayscale value. /// The grayscale value is the luma value calculated from r, g, b /// according to BT.709. (gray = r*0.2126 + g*0.7152 + b*0.0722) kFlutterSoftwarePixelFormatGray8, - /// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word. + /// Pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word. /// r = (p >> 11) & 0x1F; /// g = (p >> 5) & 0x3F; /// b = p & 0x1F; kFlutterSoftwarePixelFormatRGB565, - /// pixel with 4 bits each for alpha, red, green, blue; in 16-bit word. + /// Pixel with 4 bits each for alpha, red, green, blue; in 16-bit word. /// r = (p >> 8) & 0xF; /// g = (p >> 4) & 0xF; /// b = p & 0xF; /// a = (p >> 12) & 0xF; kFlutterSoftwarePixelFormatRGBA4444, - /// pixel with 8 bits each for red, green, blue, alpha. + /// Pixel with 8 bits each for red, green, blue, alpha. /// r = p[0]; /// g = p[1]; /// b = p[2]; /// a = p[3]; kFlutterSoftwarePixelFormatRGBA8888, - /// pixel with 8 bits each for red, green and blue and 8 unused bits. + /// Pixel with 8 bits each for red, green and blue and 8 unused bits. /// r = p[0]; /// g = p[1]; /// b = p[2]; kFlutterSoftwarePixelFormatRGBX8888, - /// pixel with 8 bits each for blue, green, red and alpha. + /// Pixel with 8 bits each for blue, green, red and alpha. /// r = p[2]; /// g = p[1]; /// b = p[0]; /// a = p[3]; kFlutterSoftwarePixelFormatBGRA8888, - /// either kFlutterSoftwarePixelFormatBGRA8888 or - /// kFlutterSoftwarePixelFormatRGBA8888 depending on CPU endianess and OS + /// Either kFlutterSoftwarePixelFormatBGRA8888 or + /// kFlutterSoftwarePixelFormatRGBA8888 depending on CPU endianess and OS. kFlutterSoftwarePixelFormatNative32, } FlutterSoftwarePixelFormat;