Commit a3fdaed2 authored by Vasiliy Telezhnikov's avatar Vasiliy Telezhnikov Committed by Commit Bot

SkiaRenderer: Fix RGB and RGB565 formats

This CL fixes color type that we pass to the skia for the
FBO0. It changes two things:
* Use RGB565 if the surface uses 16 bit format .
* Fallback to RGBA is skia doesn't support rgb color type.

Bug: 1126490

Change-Id: I6f5342ac7bb128134afc2c5182a6c6b99600c7a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441311
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813787}
parent 3e0f2e63
...@@ -111,14 +111,6 @@ bool IsUsingSkiaRenderer() { ...@@ -111,14 +111,6 @@ bool IsUsingSkiaRenderer() {
if (IsUsingVizForWebView()) if (IsUsingVizForWebView())
return true; return true;
#if defined(OS_ANDROID)
// https://crbug.com/1126490 Mali-400 with <= 512 MB is currently broken.
// Must be checked after IsUsingVizForWebView because it requires
// SkiaRenderer.
if (base::SysInfo::AmountOfPhysicalMemoryMB() <= 512)
return false;
#endif
return base::FeatureList::IsEnabled(kUseSkiaRenderer) || return base::FeatureList::IsEnabled(kUseSkiaRenderer) ||
base::FeatureList::IsEnabled(kVulkan); base::FeatureList::IsEnabled(kVulkan);
} }
......
...@@ -125,8 +125,22 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL( ...@@ -125,8 +125,22 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL(
} }
CHECK_GL_ERROR(); CHECK_GL_ERROR();
auto color_type = auto color_type = kRGBA_8888_SkColorType;
(alpha_bits > 0) ? kRGBA_8888_SkColorType : kRGB_888x_SkColorType;
if (!alpha_bits) {
color_type = gl_surface_->GetFormat().GetBufferSize() == 16
? kRGB_565_SkColorType
: kRGB_888x_SkColorType;
// Skia disables RGBx on some GPUs, fallback to RGBA if it's the
// case. This doesn't change framebuffer itself, as we already allocated it,
// but will change any temporary buffer Skia needs to allocate.
if (!context_state_->gr_context()
->defaultBackendFormat(color_type, GrRenderable::kYes)
.isValid()) {
color_type = kRGBA_8888_SkColorType;
}
}
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] = capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] =
color_type; color_type;
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBX_8888)] = capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBX_8888)] =
...@@ -175,6 +189,9 @@ bool SkiaOutputDeviceGL::Reshape(const gfx::Size& size, ...@@ -175,6 +189,9 @@ bool SkiaOutputDeviceGL::Reshape(const gfx::Size& size,
case kRGB_888x_SkColorType: case kRGB_888x_SkColorType:
framebuffer_info.fFormat = GL_RGB8; framebuffer_info.fFormat = GL_RGB8;
break; break;
case kRGB_565_SkColorType:
framebuffer_info.fFormat = GL_RGB565;
break;
case kRGBA_F16_SkColorType: case kRGBA_F16_SkColorType:
framebuffer_info.fFormat = GL_RGBA16F; framebuffer_info.fFormat = GL_RGBA16F;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment