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

Commit 2c534dc

Browse files
committed
properly namespace flutter software pixel formats
- rename `kGray8 --> kFlutterSoftwarePixelFormatGray8` - rename `kRGB565 --> kFlutterSoftwarePixelFormatRGB565` - etc.
1 parent a512ceb commit 2c534dc

7 files changed

+80
-55
lines changed

shell/platform/embedder/embedder.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ typedef enum {
299299
///
300300
/// - all other formats are called packed formats, and the component order
301301
/// as specified in the format name refers to the order in the native type.
302-
/// for example, for kRGB565, the R component uses the 5 least significant
303-
/// bits of the uint16_t pixel value.
302+
/// for example, for kFlutterSoftwarePixelFormatRGB565, the R component
303+
/// uses the 5 least significant bits of the uint16_t pixel value.
304304
///
305305
/// Each pixel format in this list is documented with an example on how to get
306306
/// the color components from the pixel.
@@ -316,30 +316,31 @@ typedef enum {
316316
/// pixel with 8 bit grayscale value.
317317
/// The grayscale value is the luma value calculated from r, g, b
318318
/// according to BT.709. (gray = r*0.2126 + g*0.7152 + b*0.0722)
319-
kGray8,
319+
kFlutterSoftwarePixelFormatGray8,
320320

321321
/// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word.
322322
/// r = p & 0x3F; g = (p>>5) & 0x3F; b = p>>11;
323-
kRGB565,
323+
kFlutterSoftwarePixelFormatRGB565,
324324

325325
/// pixel with 4 bits for alpha, red, green, blue; in 16-bit word.
326326
/// r = p & 0xF; g = (p>>4) & 0xF; b = (p>>8) & 0xF; a = p>>12;
327-
kRGBA4444,
327+
kFlutterSoftwarePixelFormatRGBA4444,
328328

329329
/// pixel with 8 bits for red, green, blue, alpha.
330330
/// r = p[0]; g = p[1]; b = p[2]; a = p[3];
331-
kRGBA8888,
331+
kFlutterSoftwarePixelFormatRGBA8888,
332332

333333
/// pixel with 8 bits for red, green and blue and 8 unused bits.
334334
/// r = p[0]; g = p[1]; b = p[2];
335-
kRGBX8888,
335+
kFlutterSoftwarePixelFormatRGBX8888,
336336

337337
/// pixel with 8 bits for blue, green, red and alpha.
338338
/// r = p[2]; g = p[1]; b = p[0]; a = p[3];
339-
kBGRA8888,
339+
kFlutterSoftwarePixelFormatBGRA8888,
340340

341-
/// either kBGRA8888 or kRGBA8888 depending on CPU endianess and OS
342-
kNative32,
341+
/// either kFlutterSoftwarePixelFormatBGRA8888 or
342+
/// kFlutterSoftwarePixelFormatRGBA8888 depending on CPU endianess and OS
343+
kFlutterSoftwarePixelFormatNative32,
343344
} FlutterSoftwarePixelFormat;
344345

345346
typedef struct {

shell/platform/embedder/pixel_formats.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77

88
std::optional<SkColorType> getSkColorType(FlutterSoftwarePixelFormat pixfmt) {
99
switch (pixfmt) {
10-
case kGray8:
10+
case kFlutterSoftwarePixelFormatGray8:
1111
return kGray_8_SkColorType;
12-
case kRGB565:
12+
case kFlutterSoftwarePixelFormatRGB565:
1313
return kRGB_565_SkColorType;
14-
case kRGBA4444:
14+
case kFlutterSoftwarePixelFormatRGBA4444:
1515
return kARGB_4444_SkColorType;
16-
case kRGBA8888:
16+
case kFlutterSoftwarePixelFormatRGBA8888:
1717
return kRGBA_8888_SkColorType;
18-
case kRGBX8888:
18+
case kFlutterSoftwarePixelFormatRGBX8888:
1919
return kRGB_888x_SkColorType;
20-
case kBGRA8888:
20+
case kFlutterSoftwarePixelFormatBGRA8888:
2121
return kBGRA_8888_SkColorType;
22-
case kNative32:
22+
case kFlutterSoftwarePixelFormatNative32:
2323
return kN32_SkColorType;
2424
default:
2525
FML_LOG(ERROR) << "Invalid software rendering pixel format";

shell/platform/embedder/tests/embedder_assertions.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,20 +355,20 @@ inline std::string FlutterOpenGLTargetTypeToString(
355355
inline std::string FlutterSoftwarePixelFormatToString(
356356
FlutterSoftwarePixelFormat pixfmt) {
357357
switch (pixfmt) {
358-
case kGray8:
359-
return "kGray8";
360-
case kRGB565:
361-
return "kRGB565";
362-
case kRGBA4444:
363-
return "kRGBA4444";
364-
case kRGBA8888:
365-
return "kRGBA8888";
366-
case kRGBX8888:
367-
return "kRGBX8888";
368-
case kBGRA8888:
369-
return "kBGRA8888";
370-
case kNative32:
371-
return "kNative32";
358+
case kFlutterSoftwarePixelFormatGray8:
359+
return "kFlutterSoftwarePixelFormatGray8";
360+
case kFlutterSoftwarePixelFormatRGB565:
361+
return "kFlutterSoftwarePixelFormatRGB565";
362+
case kFlutterSoftwarePixelFormatRGBA4444:
363+
return "kFlutterSoftwarePixelFormatRGBA4444";
364+
case kFlutterSoftwarePixelFormatRGBA8888:
365+
return "kFlutterSoftwarePixelFormatRGBA8888";
366+
case kFlutterSoftwarePixelFormatRGBX8888:
367+
return "kFlutterSoftwarePixelFormatRGBX8888";
368+
case kFlutterSoftwarePixelFormatBGRA8888:
369+
return "kFlutterSoftwarePixelFormatBGRA8888";
370+
case kFlutterSoftwarePixelFormatNative32:
371+
return "kFlutterSoftwarePixelFormatNative32";
372372
default:
373373
FML_LOG(ERROR) << "Invalid software rendering pixel format";
374374
}

shell/platform/embedder/tests/embedder_config_builder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class EmbedderConfigBuilder {
108108

109109
void SetRenderTargetType(
110110
EmbedderTestBackingStoreProducer::RenderTargetType type,
111-
FlutterSoftwarePixelFormat software_pixfmt = kNative32);
111+
FlutterSoftwarePixelFormat software_pixfmt =
112+
kFlutterSoftwarePixelFormatNative32);
112113

113114
UniqueEngine LaunchEngine() const;
114115

shell/platform/embedder/tests/embedder_test_backingstore_producer.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ EmbedderTestBackingStoreProducer::EmbedderTestBackingStoreProducer(
3636
#endif
3737
{
3838
if (type == RenderTargetType::kSoftwareBuffer &&
39-
software_pixfmt_ != kNative32) {
40-
FML_LOG(ERROR) << "Expected pixel format to be the default (kNative32) when"
39+
software_pixfmt_ != kFlutterSoftwarePixelFormatNative32) {
40+
FML_LOG(ERROR) << "Expected pixel format to be the default "
41+
"(kFlutterSoftwarePixelFormatNative32) when"
4142
"backing store producer should produce deprecated v1 "
4243
"software backing "
4344
"stores.";

shell/platform/embedder/tests/embedder_test_backingstore_producer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class EmbedderTestBackingStoreProducer {
3838
kVulkanImage,
3939
};
4040

41-
EmbedderTestBackingStoreProducer(
42-
sk_sp<GrDirectContext> context,
43-
RenderTargetType type,
44-
FlutterSoftwarePixelFormat software_pixfmt = kNative32);
41+
EmbedderTestBackingStoreProducer(sk_sp<GrDirectContext> context,
42+
RenderTargetType type,
43+
FlutterSoftwarePixelFormat software_pixfmt =
44+
kFlutterSoftwarePixelFormatNative32);
4545
~EmbedderTestBackingStoreProducer();
4646

4747
bool Create(const FlutterBackingStoreConfig* config,

shell/platform/embedder/tests/embedder_unittests.cc

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,49 +1635,71 @@ static void expectSoftwareRenderingOutputMatches(
16351635
matcher); \
16361636
}
16371637

1638-
// Don't test the pixel formats that contain padding (so an X) and the kNative32
1639-
// pixel format here, so we don't add any flakiness.
1640-
SW_PIXFMT_TEST_F(RedRGBA565xF800, draw_solid_red, kRGB565, (uint16_t)0xF800);
1641-
SW_PIXFMT_TEST_F(RedRGBA4444xF00F, draw_solid_red, kRGBA4444, (uint16_t)0xF00F);
1638+
// Don't test the pixel formats that contain padding (so an X) and the
1639+
// kFlutterSoftwarePixelFormatNative32 pixel format here, so we don't add any
1640+
// flakiness.
1641+
SW_PIXFMT_TEST_F(RedRGBA565xF800,
1642+
draw_solid_red,
1643+
kFlutterSoftwarePixelFormatRGB565,
1644+
(uint16_t)0xF800);
1645+
SW_PIXFMT_TEST_F(RedRGBA4444xF00F,
1646+
draw_solid_red,
1647+
kFlutterSoftwarePixelFormatRGBA4444,
1648+
(uint16_t)0xF00F);
16421649
SW_PIXFMT_TEST_F(RedRGBA8888xFFx00x00xFF,
16431650
draw_solid_red,
1644-
kRGBA8888,
1651+
kFlutterSoftwarePixelFormatRGBA8888,
16451652
(std::vector<uint8_t>{0xFF, 0x00, 0x00, 0xFF}));
16461653
SW_PIXFMT_TEST_F(RedBGRA8888x00x00xFFxFF,
16471654
draw_solid_red,
1648-
kBGRA8888,
1655+
kFlutterSoftwarePixelFormatBGRA8888,
16491656
(std::vector<uint8_t>{0x00, 0x00, 0xFF, 0xFF}));
1650-
SW_PIXFMT_TEST_F(RedGray8x36, draw_solid_red, kGray8, (uint8_t)0x36);
1657+
SW_PIXFMT_TEST_F(RedGray8x36,
1658+
draw_solid_red,
1659+
kFlutterSoftwarePixelFormatGray8,
1660+
(uint8_t)0x36);
16511661

1652-
SW_PIXFMT_TEST_F(GreenRGB565x07E0, draw_solid_green, kRGB565, (uint16_t)0x07E0);
1662+
SW_PIXFMT_TEST_F(GreenRGB565x07E0,
1663+
draw_solid_green,
1664+
kFlutterSoftwarePixelFormatRGB565,
1665+
(uint16_t)0x07E0);
16531666
SW_PIXFMT_TEST_F(GreenRGBA4444x0F0F,
16541667
draw_solid_green,
1655-
kRGBA4444,
1668+
kFlutterSoftwarePixelFormatRGBA4444,
16561669
(uint16_t)0x0F0F);
16571670
SW_PIXFMT_TEST_F(GreenRGBA8888x00xFFx00xFF,
16581671
draw_solid_green,
1659-
kRGBA8888,
1672+
kFlutterSoftwarePixelFormatRGBA8888,
16601673
(std::vector<uint8_t>{0x00, 0xFF, 0x00, 0xFF}));
16611674
SW_PIXFMT_TEST_F(GreenBGRA8888x00xFFx00xFF,
16621675
draw_solid_green,
1663-
kBGRA8888,
1676+
kFlutterSoftwarePixelFormatBGRA8888,
16641677
(std::vector<uint8_t>{0x00, 0xFF, 0x00, 0xFF}));
1665-
SW_PIXFMT_TEST_F(GreenGray8xB6, draw_solid_green, kGray8, (uint8_t)0xB6);
1678+
SW_PIXFMT_TEST_F(GreenGray8xB6,
1679+
draw_solid_green,
1680+
kFlutterSoftwarePixelFormatGray8,
1681+
(uint8_t)0xB6);
16661682

1667-
SW_PIXFMT_TEST_F(BlueRGB565x001F, draw_solid_blue, kRGB565, (uint16_t)0x001F);
1683+
SW_PIXFMT_TEST_F(BlueRGB565x001F,
1684+
draw_solid_blue,
1685+
kFlutterSoftwarePixelFormatRGB565,
1686+
(uint16_t)0x001F);
16681687
SW_PIXFMT_TEST_F(BlueRGBA4444x00FF,
16691688
draw_solid_blue,
1670-
kRGBA4444,
1689+
kFlutterSoftwarePixelFormatRGBA4444,
16711690
(uint16_t)0x00FF);
16721691
SW_PIXFMT_TEST_F(BlueRGBA8888x00x00xFFxFF,
16731692
draw_solid_blue,
1674-
kRGBA8888,
1693+
kFlutterSoftwarePixelFormatRGBA8888,
16751694
(std::vector<uint8_t>{0x00, 0x00, 0xFF, 0xFF}));
16761695
SW_PIXFMT_TEST_F(BlueBGRA8888xFFx00x00xFF,
16771696
draw_solid_blue,
1678-
kBGRA8888,
1697+
kFlutterSoftwarePixelFormatBGRA8888,
16791698
(std::vector<uint8_t>{0xFF, 0x00, 0x00, 0xFF}));
1680-
SW_PIXFMT_TEST_F(BlueGray8x12, draw_solid_blue, kGray8, (uint8_t)0x12);
1699+
SW_PIXFMT_TEST_F(BlueGray8x12,
1700+
draw_solid_blue,
1701+
kFlutterSoftwarePixelFormatGray8,
1702+
(uint8_t)0x12);
16811703

16821704
//------------------------------------------------------------------------------
16831705
// Key Data

0 commit comments

Comments
 (0)