From 8abebfdd564ba378cb0516d56d7fd5298beda2df Mon Sep 17 00:00:00 2001 From: "radu.velea" Date: Mon, 7 Mar 2016 02:32:35 -0800 Subject: cc: Fix interchange of red and blue content when using ETC1_RGB8_OES textures Content is swizzled when texture format has different component order than expected format by platform. ETC1 implies the use RGBX layout and should not trigger a swizzle. Updated unittest. TEST=visual inspection with --enable-tile-compression and PlatformColorTest.SameComponentOrder in cc_unittests BUG=570715 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1746763002 Cr-Commit-Position: refs/heads/master@{#379533} --- cc/resources/platform_color.h | 24 +++++++++++++++++------- cc/resources/platform_color_unittest.cc | 8 ++------ 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'cc/resources') diff --git a/cc/resources/platform_color.h b/cc/resources/platform_color.h index 26d6b02..67ede54 100644 --- a/cc/resources/platform_color.h +++ b/cc/resources/platform_color.h @@ -47,15 +47,25 @@ class PlatformColor { return RGBA_8888; } - // Return true if the given texture format has the same component order - // as the color on this platform. + // Return true if the given 32bpp resource format has the same component order + // as the platform color data format. static bool SameComponentOrder(ResourceFormat format) { - switch (Format()) { - case SOURCE_FORMAT_RGBA8: - return format == RGBA_8888 || format == RGBA_4444; - case SOURCE_FORMAT_BGRA8: - return format == BGRA_8888 || format == RGBA_4444; + switch (format) { + case RGBA_8888: + return Format() == SOURCE_FORMAT_RGBA8; + case BGRA_8888: + return Format() == SOURCE_FORMAT_BGRA8; + case ALPHA_8: + case LUMINANCE_8: + case RGB_565: + case RGBA_4444: + case ETC1: + case RED_8: + case LUMINANCE_F16: + NOTREACHED(); + return false; } + NOTREACHED(); return false; } diff --git a/cc/resources/platform_color_unittest.cc b/cc/resources/platform_color_unittest.cc index 49c8353..83f65b6 100644 --- a/cc/resources/platform_color_unittest.cc +++ b/cc/resources/platform_color_unittest.cc @@ -21,21 +21,17 @@ TEST(PlatformColorTest, SameComponentOrder) { case RGBA_8888: EXPECT_EQ(rgba, PlatformColor::SameComponentOrder(format)); break; - case RGBA_4444: - // RGBA_4444 indicates the number of bytes per pixel but the format - // doesn't actually imply RGBA ordering. It uses the native ordering. - EXPECT_EQ(true, PlatformColor::SameComponentOrder(format)); - break; case BGRA_8888: EXPECT_NE(rgba, PlatformColor::SameComponentOrder(format)); break; + // The following formats are not platform colors. case ALPHA_8: case LUMINANCE_8: case RGB_565: + case RGBA_4444: case ETC1: case RED_8: case LUMINANCE_F16: - EXPECT_FALSE(PlatformColor::SameComponentOrder(format)); break; } } -- cgit v1.1