Commit 48d1ecaf authored by Kristian H. Kristensen's avatar Kristian H. Kristensen Committed by Commit Bot

ozone/drm: Render primary framebuffers as RGBA

In preparation for hardware plane underlay support in ChromeOS, we
need to allow for RGBA primary framebuffers. When using an underlay,
we cut out a transparent rectangle in the primary framebuffer to allow
the underlay to show through, while still allowing for RGBA content on
top of the underlay (for example, video controls or annotations).
When not using an underlay, the primary framebuffer will be displayed
as RGBX (opaque) to avoid unnecessary blending in the display
controller.

Bug: 789288
Change-Id: I2fc94e524e250ec9b7e11cd6801e1c8308046a10
Reviewed-on: https://chromium-review.googlesource.com/801974Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Reviewed-by: default avatarStéphane Marchesin <marcheu@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542877}
parent b7c8d1ce
...@@ -94,6 +94,9 @@ const gpu::SurfaceHandle kFakeSurfaceHandle = ...@@ -94,6 +94,9 @@ const gpu::SurfaceHandle kFakeSurfaceHandle =
const gpu::SurfaceHandle kFakeSurfaceHandle = 1; const gpu::SurfaceHandle kFakeSurfaceHandle = 1;
#endif #endif
const unsigned int kBufferQueueInternalformat = GL_RGBA;
const gfx::BufferFormat kBufferQueueFormat = gfx::BufferFormat::RGBA_8888;
class MockBufferQueue : public BufferQueue { class MockBufferQueue : public BufferQueue {
public: public:
MockBufferQueue(gpu::gles2::GLES2Interface* gl, MockBufferQueue(gpu::gles2::GLES2Interface* gl,
...@@ -102,8 +105,8 @@ class MockBufferQueue : public BufferQueue { ...@@ -102,8 +105,8 @@ class MockBufferQueue : public BufferQueue {
unsigned int internalformat) unsigned int internalformat)
: BufferQueue(gl, : BufferQueue(gl,
target, target,
internalformat, kBufferQueueInternalformat,
display::DisplaySnapshot::PrimaryFormat(), kBufferQueueFormat,
nullptr, nullptr,
gpu_memory_buffer_manager, gpu_memory_buffer_manager,
kFakeSurfaceHandle) {} kFakeSurfaceHandle) {}
...@@ -123,7 +126,8 @@ class BufferQueueTest : public ::testing::Test { ...@@ -123,7 +126,8 @@ class BufferQueueTest : public ::testing::Test {
gpu_memory_buffer_manager_.reset(new StubGpuMemoryBufferManager); gpu_memory_buffer_manager_.reset(new StubGpuMemoryBufferManager);
mock_output_surface_ = new MockBufferQueue(context_provider_->ContextGL(), mock_output_surface_ = new MockBufferQueue(context_provider_->ContextGL(),
gpu_memory_buffer_manager_.get(), gpu_memory_buffer_manager_.get(),
GL_TEXTURE_2D, GL_RGB); GL_TEXTURE_2D,
kBufferQueueInternalformat);
output_surface_.reset(mock_output_surface_); output_surface_.reset(mock_output_surface_);
output_surface_->Initialize(); output_surface_->Initialize();
} }
...@@ -263,7 +267,7 @@ std::unique_ptr<BufferQueue> CreateBufferQueue( ...@@ -263,7 +267,7 @@ std::unique_ptr<BufferQueue> CreateBufferQueue(
gpu::gles2::GLES2Interface* gl, gpu::gles2::GLES2Interface* gl,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
std::unique_ptr<BufferQueue> buffer_queue(new BufferQueue( std::unique_ptr<BufferQueue> buffer_queue(new BufferQueue(
gl, target, GL_RGB, display::DisplaySnapshot::PrimaryFormat(), nullptr, gl, target, kBufferQueueInternalformat, kBufferQueueFormat, nullptr,
gpu_memory_buffer_manager, kFakeSurfaceHandle)); gpu_memory_buffer_manager, kFakeSurfaceHandle));
buffer_queue->Initialize(); buffer_queue->Initialize();
return buffer_queue; return buffer_queue;
...@@ -302,7 +306,8 @@ TEST(BufferQueueStandaloneTest, FboBinding) { ...@@ -302,7 +306,8 @@ TEST(BufferQueueStandaloneTest, FboBinding) {
EXPECT_CALL(*context, bindTexture(target, Ne(0U))); EXPECT_CALL(*context, bindTexture(target, Ne(0U)));
EXPECT_CALL(*context, destroyImageCHROMIUM(1)); EXPECT_CALL(*context, destroyImageCHROMIUM(1));
Expectation image = Expectation image =
EXPECT_CALL(*context, createImageCHROMIUM(_, 0, 0, GL_RGB)) EXPECT_CALL(*context,
createImageCHROMIUM(_, 0, 0, kBufferQueueInternalformat))
.WillOnce(Return(1)); .WillOnce(Return(1));
Expectation fb = Expectation fb =
EXPECT_CALL(*context, bindFramebuffer(GL_FRAMEBUFFER, Ne(0U))); EXPECT_CALL(*context, bindFramebuffer(GL_FRAMEBUFFER, Ne(0U)));
...@@ -332,8 +337,9 @@ TEST(BufferQueueStandaloneTest, CheckBoundFramebuffer) { ...@@ -332,8 +337,9 @@ TEST(BufferQueueStandaloneTest, CheckBoundFramebuffer) {
context_provider->ContextSupport())); context_provider->ContextSupport()));
output_surface.reset(new BufferQueue( output_surface.reset(new BufferQueue(
context_provider->ContextGL(), GL_TEXTURE_2D, GL_RGB, context_provider->ContextGL(), GL_TEXTURE_2D,
display::DisplaySnapshot::PrimaryFormat(), gl_helper.get(), kBufferQueueInternalformat, kBufferQueueFormat,
gl_helper.get(),
gpu_memory_buffer_manager.get(), kFakeSurfaceHandle)); gpu_memory_buffer_manager.get(), kFakeSurfaceHandle));
output_surface->Initialize(); output_surface->Initialize();
output_surface->Reshape(screen_size, 1.0f, gfx::ColorSpace(), false); output_surface->Reshape(screen_size, 1.0f, gfx::ColorSpace(), false);
...@@ -622,7 +628,8 @@ TEST_F(BufferQueueMockedContextTest, RecreateBuffers) { ...@@ -622,7 +628,8 @@ TEST_F(BufferQueueMockedContextTest, RecreateBuffers) {
// Expect all 4 images to be destroyed, 3 of the existing textures to be // Expect all 4 images to be destroyed, 3 of the existing textures to be
// copied from and 3 new images to be created. // copied from and 3 new images to be created.
EXPECT_CALL(*context_, createImageCHROMIUM(_, screen_size.width(), EXPECT_CALL(*context_, createImageCHROMIUM(_, screen_size.width(),
screen_size.height(), GL_RGB)) screen_size.height(),
kBufferQueueInternalformat))
.Times(3); .Times(3);
Expectation copy1 = EXPECT_CALL(*mock_output_surface_, Expectation copy1 = EXPECT_CALL(*mock_output_surface_,
CopyBufferDamage(_, displayed->texture, _, _)) CopyBufferDamage(_, displayed->texture, _, _))
......
...@@ -516,11 +516,12 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( ...@@ -516,11 +516,12 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
disable_overlay_ca_layers), disable_overlay_ca_layers),
GetGpuMemoryBufferManager()); GetGpuMemoryBufferManager());
#else #else
DCHECK(capabilities.texture_format_bgra8888);
auto gpu_output_surface = auto gpu_output_surface =
std::make_unique<GpuSurfacelessBrowserCompositorOutputSurface>( std::make_unique<GpuSurfacelessBrowserCompositorOutputSurface>(
context_provider, data->surface_handle, vsync_callback, context_provider, data->surface_handle, vsync_callback,
CreateOverlayCandidateValidator(compositor->widget()), CreateOverlayCandidateValidator(compositor->widget()),
GL_TEXTURE_2D, GL_RGB, GL_TEXTURE_2D, GL_BGRA_EXT,
display::DisplaySnapshot::PrimaryFormat(), display::DisplaySnapshot::PrimaryFormat(),
GetGpuMemoryBufferManager()); GetGpuMemoryBufferManager());
gpu_vsync_control = gpu_output_surface.get(); gpu_vsync_control = gpu_output_surface.get();
......
...@@ -140,7 +140,7 @@ std::string DisplaySnapshot::ToString() const { ...@@ -140,7 +140,7 @@ std::string DisplaySnapshot::ToString() const {
// static // static
gfx::BufferFormat DisplaySnapshot::PrimaryFormat() { gfx::BufferFormat DisplaySnapshot::PrimaryFormat() {
return gfx::BufferFormat::BGRX_8888; return gfx::BufferFormat::BGRA_8888;
} }
} // namespace display } // namespace display
...@@ -63,7 +63,9 @@ class ClientNativePixmapFactoryDmabuf : public ClientNativePixmapFactory { ...@@ -63,7 +63,9 @@ class ClientNativePixmapFactoryDmabuf : public ClientNativePixmapFactory {
format == gfx::BufferFormat::YVU_420; format == gfx::BufferFormat::YVU_420;
case gfx::BufferUsage::SCANOUT: case gfx::BufferUsage::SCANOUT:
return format == gfx::BufferFormat::BGRX_8888 || return format == gfx::BufferFormat::BGRX_8888 ||
format == gfx::BufferFormat::RGBX_8888; format == gfx::BufferFormat::RGBX_8888 ||
format == gfx::BufferFormat::RGBA_8888 ||
format == gfx::BufferFormat::BGRA_8888;
case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE:
return return
#if defined(ARCH_CPU_X86_FAMILY) #if defined(ARCH_CPU_X86_FAMILY)
......
...@@ -114,7 +114,7 @@ bool SurfacelessSkiaRenderer::BufferWrapper::Initialize( ...@@ -114,7 +114,7 @@ bool SurfacelessSkiaRenderer::BufferWrapper::Initialize(
->GetSurfaceFactoryOzone() ->GetSurfaceFactoryOzone()
->CreateNativePixmap(widget, size, format, gfx::BufferUsage::SCANOUT); ->CreateNativePixmap(widget, size, format, gfx::BufferUsage::SCANOUT);
scoped_refptr<gl::GLImageNativePixmap> image( scoped_refptr<gl::GLImageNativePixmap> image(
new gl::GLImageNativePixmap(size, GL_RGB)); new gl::GLImageNativePixmap(size, GL_BGRA_EXT));
if (!image->Initialize(pixmap.get(), format)) { if (!image->Initialize(pixmap.get(), format)) {
LOG(ERROR) << "Failed to create GLImage"; LOG(ERROR) << "Failed to create GLImage";
return false; return false;
......
...@@ -136,7 +136,7 @@ bool GbmSurface::CreatePixmaps() { ...@@ -136,7 +136,7 @@ bool GbmSurface::CreatePixmaps() {
if (!pixmap) if (!pixmap)
return false; return false;
scoped_refptr<gl::GLImageNativePixmap> image = scoped_refptr<gl::GLImageNativePixmap> image =
new gl::GLImageNativePixmap(GetSize(), GL_RGB); new gl::GLImageNativePixmap(GetSize(), GL_BGRA_EXT);
if (!image->Initialize(pixmap.get(), if (!image->Initialize(pixmap.get(),
display::DisplaySnapshot::PrimaryFormat())) display::DisplaySnapshot::PrimaryFormat()))
return false; return false;
......
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