Skip to content

Commit

Permalink
Add enable_blend to ScheduleOverlayCHROMIUM
Browse files Browse the repository at this point in the history
Currently scheduling an overlay with ScheduleOverlayCHROMIUM
will result in alpha blending being enabled for planes
that are not the primary, and alpha blending disabled for
the primary planes.

We want to be able to explicitly control if alpha blending is
enable/disabled. In this way we can:
- Have primary planes with alpha blending enabled to support
  underlay strategies.
- Scanout RGBA buffers with alpha blending disabled (this
  happens with buffers coming from exo).

This CL adds a parameter "enable_blend" to glScheduleOverlayCHROMIUM,
and to all the layers necessary to bring this information to
KMS, in order to explicitly control alpha blending behavior.

Bug: 789288, b/74997524

Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I0b39c3b6e10a03aef983367f71b518ddb84a9ec8
Reviewed-on: https://chromium-review.googlesource.com/967415
Reviewed-by: ccameron <ccameron@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Daniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544926}
  • Loading branch information
DCastagna authored and Commit Bot committed Mar 22, 2018
1 parent 3c45641 commit 588d2f5
Show file tree
Hide file tree
Showing 83 changed files with 247 additions and 156 deletions.
1 change: 1 addition & 0 deletions components/viz/service/display/direct_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
output_surface_plane.format = output_surface_->GetOverlayBufferFormat();
output_surface_plane.use_output_surface_for_resource = true;
output_surface_plane.overlay_handled = true;
output_surface_plane.is_opaque = true;
current_frame()->overlay_list.push_back(output_surface_plane);
}

Expand Down
2 changes: 1 addition & 1 deletion components/viz/service/display/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3202,7 +3202,7 @@ void GLRenderer::ScheduleOverlays() {
context_support_->ScheduleOverlayPlane(
overlay_candidate.plane_z_order, overlay_candidate.transform,
texture_id, ToNearestRect(overlay_candidate.display_rect),
overlay_candidate.uv_rect);
overlay_candidate.uv_rect, !overlay_candidate.is_opaque);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool OverlayStrategyFullscreen::Attempt(
render_pass->output_rect.size() != candidate.resource_size_in_pixels) {
return false;
}

candidate.is_opaque = true;
candidate.plane_z_order = 0;
candidate.overlay_handled = true;
cc::OverlayCandidateList new_candidate_list;
Expand Down
3 changes: 2 additions & 1 deletion components/viz/test/test_context_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ void TestContextSupport::ScheduleOverlayPlane(
gfx::OverlayTransform plane_transform,
unsigned overlay_texture_id,
const gfx::Rect& display_bounds,
const gfx::RectF& uv_rect) {
const gfx::RectF& uv_rect,
bool enable_blend) {
if (!schedule_overlay_plane_callback_.is_null()) {
schedule_overlay_plane_callback_.Run(plane_z_order, plane_transform,
overlay_texture_id, display_bounds,
Expand Down
3 changes: 2 additions & 1 deletion components/viz/test/test_context_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class TestContextSupport : public gpu::ContextSupport {
gfx::OverlayTransform plane_transform,
unsigned overlay_texture_id,
const gfx::Rect& display_bounds,
const gfx::RectF& uv_rect) override;
const gfx::RectF& uv_rect,
bool enable_blend) override;
uint64_t ShareGroupTracingGUID() const override;
void SetErrorMessageCallback(
base::RepeatingCallback<void(const char*, int32_t)> callback) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name Strings

Version

Last Modified Date: April 2, 2014
Last Modified Date: March 18, 2018

Dependencies

Expand Down Expand Up @@ -52,7 +52,8 @@ New Procedures and Functions
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height);
GLfloat uv_height
GLboolean enable_blend);

Sets the overlay plane to be presented synchronously along with the primary
framebuffer during the call to swap buffers.
Expand All @@ -65,6 +66,8 @@ New Procedures and Functions
supposed to be on the screen.
<uv_x>, <uv_y>, <uv_width>, <uv_height> specify the region within the
buffer to be placed inside the bounds.
<enable_blend> specifies whether alpha blending should be enabled or
disabled when the buffer is presented.

Errors

Expand Down
26 changes: 14 additions & 12 deletions gpu/GLES2/gl2extchromium.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,17 +721,18 @@ typedef void (GL_APIENTRYP PFNGLWAITSYNCTOKENCHROMIUM) (

#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY
glScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLenum plane_transform,
GLuint overlay_texture_id,
GLint bounds_x,
GLint bounds_y,
GLint bounds_width,
GLint bounds_height,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height);
glScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLenum plane_transform,
GLuint overlay_texture_id,
GLint bounds_x,
GLint bounds_y,
GLint bounds_width,
GLint bounds_height,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height,
GLboolean enable_blend);
#endif
typedef void(GL_APIENTRYP PFNGLSCHEDULEOVERLAYPLANECHROMIUMPROC)(
GLint plane_z_order,
Expand All @@ -744,7 +745,8 @@ typedef void(GL_APIENTRYP PFNGLSCHEDULEOVERLAYPLANECHROMIUMPROC)(
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height);
GLfloat uv_height,
GLboolean enable_blend);
#endif /* GL_CHROMIUM_schedule_overlay_plane */

#ifndef GL_CHROMIUM_schedule_ca_layer
Expand Down
3 changes: 2 additions & 1 deletion gpu/command_buffer/client/context_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class ContextSupport {
gfx::OverlayTransform plane_transform,
unsigned overlay_texture_id,
const gfx::Rect& display_bounds,
const gfx::RectF& uv_rect) = 0;
const gfx::RectF& uv_rect,
bool enable_blend) = 0;

// Returns an ID that can be used to globally identify the share group that
// this context's resources belong to.
Expand Down
6 changes: 4 additions & 2 deletions gpu/command_buffer/client/gles2_c_lib_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1469,10 +1469,12 @@ void GL_APIENTRY GLES2ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) {
GLfloat uv_height,
GLboolean enable_blend) {
gles2::GetGLContext()->ScheduleOverlayPlaneCHROMIUM(
plane_z_order, plane_transform, overlay_texture_id, bounds_x, bounds_y,
bounds_width, bounds_height, uv_x, uv_y, uv_width, uv_height);
bounds_width, bounds_height, uv_x, uv_y, uv_width, uv_height,
enable_blend);
}
void GL_APIENTRY
GLES2ScheduleCALayerSharedStateCHROMIUM(GLfloat opacity,
Expand Down
5 changes: 3 additions & 2 deletions gpu/command_buffer/client/gles2_cmd_helper_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2742,13 +2742,14 @@ void ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) {
GLfloat uv_height,
GLboolean enable_blend) {
gles2::cmds::ScheduleOverlayPlaneCHROMIUM* c =
GetCmdSpace<gles2::cmds::ScheduleOverlayPlaneCHROMIUM>();
if (c) {
c->Init(plane_z_order, plane_transform, overlay_texture_id, bounds_x,
bounds_y, bounds_width, bounds_height, uv_x, uv_y, uv_width,
uv_height);
uv_height, enable_blend);
}
}

Expand Down
19 changes: 7 additions & 12 deletions gpu/command_buffer/client/gles2_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4726,18 +4726,13 @@ void GLES2Implementation::ScheduleOverlayPlane(
gfx::OverlayTransform plane_transform,
unsigned overlay_texture_id,
const gfx::Rect& display_bounds,
const gfx::RectF& uv_rect) {
ScheduleOverlayPlaneCHROMIUM(plane_z_order,
GetGLESOverlayTransform(plane_transform),
overlay_texture_id,
display_bounds.x(),
display_bounds.y(),
display_bounds.width(),
display_bounds.height(),
uv_rect.x(),
uv_rect.y(),
uv_rect.width(),
uv_rect.height());
const gfx::RectF& uv_rect,
bool enable_blend) {
ScheduleOverlayPlaneCHROMIUM(
plane_z_order, GetGLESOverlayTransform(plane_transform),
overlay_texture_id, display_bounds.x(), display_bounds.y(),
display_bounds.width(), display_bounds.height(), uv_rect.x(), uv_rect.y(),
uv_rect.width(), uv_rect.height(), enable_blend);
}

void GLES2Implementation::ScheduleCALayerSharedStateCHROMIUM(
Expand Down
3 changes: 2 additions & 1 deletion gpu/command_buffer/client/gles2_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface,
gfx::OverlayTransform plane_transform,
unsigned overlay_texture_id,
const gfx::Rect& display_bounds,
const gfx::RectF& uv_rect) override;
const gfx::RectF& uv_rect,
bool enable_blend) override;
uint64_t ShareGroupTracingGUID() const override;
void SetErrorMessageCallback(
base::RepeatingCallback<void(const char*, int32_t)> callback) override;
Expand Down
3 changes: 2 additions & 1 deletion gpu/command_buffer/client/gles2_implementation_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,8 @@ void ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) override;
GLfloat uv_height,
GLboolean enable_blend) override;

void ScheduleCALayerSharedStateCHROMIUM(GLfloat opacity,
GLboolean is_clipped,
Expand Down
13 changes: 8 additions & 5 deletions gpu/command_buffer/client/gles2_implementation_impl_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -3311,17 +3311,20 @@ void GLES2Implementation::ScheduleOverlayPlaneCHROMIUM(
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) {
GLfloat uv_height,
GLboolean enable_blend) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG(
"[" << GetLogPrefix() << "] glScheduleOverlayPlaneCHROMIUM("
<< plane_z_order << ", " << GLES2Util::GetStringEnum(plane_transform)
<< ", " << overlay_texture_id << ", " << bounds_x << ", " << bounds_y
<< ", " << bounds_width << ", " << bounds_height << ", " << uv_x
<< ", " << uv_y << ", " << uv_width << ", " << uv_height << ")");
helper_->ScheduleOverlayPlaneCHROMIUM(
plane_z_order, plane_transform, overlay_texture_id, bounds_x, bounds_y,
bounds_width, bounds_height, uv_x, uv_y, uv_width, uv_height);
<< ", " << uv_y << ", " << uv_width << ", " << uv_height << ", "
<< GLES2Util::GetStringBool(enable_blend) << ")");
helper_->ScheduleOverlayPlaneCHROMIUM(plane_z_order, plane_transform,
overlay_texture_id, bounds_x, bounds_y,
bounds_width, bounds_height, uv_x, uv_y,
uv_width, uv_height, enable_blend);
CheckGLError();
}

Expand Down
3 changes: 2 additions & 1 deletion gpu/command_buffer/client/gles2_interface_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,8 @@ virtual void ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) = 0;
GLfloat uv_height,
GLboolean enable_blend) = 0;
virtual void ScheduleCALayerSharedStateCHROMIUM(GLfloat opacity,
GLboolean is_clipped,
const GLfloat* clip_rect,
Expand Down
3 changes: 2 additions & 1 deletion gpu/command_buffer/client/gles2_interface_stub_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ void ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) override;
GLfloat uv_height,
GLboolean enable_blend) override;
void ScheduleCALayerSharedStateCHROMIUM(GLfloat opacity,
GLboolean is_clipped,
const GLfloat* clip_rect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,8 @@ void GLES2InterfaceStub::ScheduleOverlayPlaneCHROMIUM(
GLfloat /* uv_x */,
GLfloat /* uv_y */,
GLfloat /* uv_width */,
GLfloat /* uv_height */) {}
GLfloat /* uv_height */,
GLboolean /* enable_blend */) {}
void GLES2InterfaceStub::ScheduleCALayerSharedStateCHROMIUM(
GLfloat /* opacity */,
GLboolean /* is_clipped */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ void ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) override;
GLfloat uv_height,
GLboolean enable_blend) override;
void ScheduleCALayerSharedStateCHROMIUM(GLfloat opacity,
GLboolean is_clipped,
const GLfloat* clip_rect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2140,12 +2140,14 @@ void GLES2TraceImplementation::ScheduleOverlayPlaneCHROMIUM(
GLfloat uv_x,
GLfloat uv_y,
GLfloat uv_width,
GLfloat uv_height) {
GLfloat uv_height,
GLboolean enable_blend) {
TRACE_EVENT_BINARY_EFFICIENT0("gpu",
"GLES2Trace::ScheduleOverlayPlaneCHROMIUM");
gl_->ScheduleOverlayPlaneCHROMIUM(
plane_z_order, plane_transform, overlay_texture_id, bounds_x, bounds_y,
bounds_width, bounds_height, uv_x, uv_y, uv_width, uv_height);
gl_->ScheduleOverlayPlaneCHROMIUM(plane_z_order, plane_transform,
overlay_texture_id, bounds_x, bounds_y,
bounds_width, bounds_height, uv_x, uv_y,
uv_width, uv_height, enable_blend);
}

void GLES2TraceImplementation::ScheduleCALayerSharedStateCHROMIUM(
Expand Down
3 changes: 2 additions & 1 deletion gpu/command_buffer/client/raster_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ void RasterImplementation::ScheduleOverlayPlane(
gfx::OverlayTransform /* plane_transform */,
unsigned /* overlay_texture_id */,
const gfx::Rect& /* display_bounds */,
const gfx::RectF& /* uv_rect */) {
const gfx::RectF& /* uv_rect */,
bool /* enable_blend */) {
NOTREACHED();
}

Expand Down
3 changes: 2 additions & 1 deletion gpu/command_buffer/client/raster_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class RASTER_EXPORT RasterImplementation : public RasterInterface,
gfx::OverlayTransform plane_transform,
unsigned overlay_texture_id,
const gfx::Rect& display_bounds,
const gfx::RectF& uv_rect) override;
const gfx::RectF& uv_rect,
bool enable_blend) override;
uint64_t ShareGroupTracingGUID() const override;
void SetErrorMessageCallback(
base::RepeatingCallback<void(const char*, int32_t)> callback) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class ContextSupportStub : public ContextSupport {
gfx::OverlayTransform plane_transform,
unsigned overlay_texture_id,
const gfx::Rect& display_bounds,
const gfx::RectF& uv_rect) override {}
const gfx::RectF& uv_rect,
bool enable_blend) override {}
uint64_t ShareGroupTracingGUID() const override { return 0; }
void SetErrorMessageCallback(
base::RepeatingCallback<void(const char*, int32_t)> callback) override {}
Expand Down
23 changes: 15 additions & 8 deletions gpu/command_buffer/common/gles2_cmd_format_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -13501,7 +13501,8 @@ struct ScheduleOverlayPlaneCHROMIUM {
GLfloat _uv_x,
GLfloat _uv_y,
GLfloat _uv_width,
GLfloat _uv_height) {
GLfloat _uv_height,
GLboolean _enable_blend) {
SetHeader();
plane_z_order = _plane_z_order;
plane_transform = _plane_transform;
Expand All @@ -13514,6 +13515,7 @@ struct ScheduleOverlayPlaneCHROMIUM {
uv_y = _uv_y;
uv_width = _uv_width;
uv_height = _uv_height;
enable_blend = _enable_blend;
}

void* Set(void* cmd,
Expand All @@ -13527,11 +13529,12 @@ struct ScheduleOverlayPlaneCHROMIUM {
GLfloat _uv_x,
GLfloat _uv_y,
GLfloat _uv_width,
GLfloat _uv_height) {
static_cast<ValueType*>(cmd)->Init(_plane_z_order, _plane_transform,
_overlay_texture_id, _bounds_x,
_bounds_y, _bounds_width, _bounds_height,
_uv_x, _uv_y, _uv_width, _uv_height);
GLfloat _uv_height,
GLboolean _enable_blend) {
static_cast<ValueType*>(cmd)->Init(
_plane_z_order, _plane_transform, _overlay_texture_id, _bounds_x,
_bounds_y, _bounds_width, _bounds_height, _uv_x, _uv_y, _uv_width,
_uv_height, _enable_blend);
return NextCmdAddress<ValueType>(cmd);
}

Expand All @@ -13547,10 +13550,11 @@ struct ScheduleOverlayPlaneCHROMIUM {
float uv_y;
float uv_width;
float uv_height;
uint32_t enable_blend;
};

static_assert(sizeof(ScheduleOverlayPlaneCHROMIUM) == 48,
"size of ScheduleOverlayPlaneCHROMIUM should be 48");
static_assert(sizeof(ScheduleOverlayPlaneCHROMIUM) == 52,
"size of ScheduleOverlayPlaneCHROMIUM should be 52");
static_assert(offsetof(ScheduleOverlayPlaneCHROMIUM, header) == 0,
"offset of ScheduleOverlayPlaneCHROMIUM header should be 0");
static_assert(
Expand Down Expand Up @@ -13580,6 +13584,9 @@ static_assert(offsetof(ScheduleOverlayPlaneCHROMIUM, uv_width) == 40,
"offset of ScheduleOverlayPlaneCHROMIUM uv_width should be 40");
static_assert(offsetof(ScheduleOverlayPlaneCHROMIUM, uv_height) == 44,
"offset of ScheduleOverlayPlaneCHROMIUM uv_height should be 44");
static_assert(
offsetof(ScheduleOverlayPlaneCHROMIUM, enable_blend) == 48,
"offset of ScheduleOverlayPlaneCHROMIUM enable_blend should be 48");

struct ScheduleCALayerSharedStateCHROMIUM {
typedef ScheduleCALayerSharedStateCHROMIUM ValueType;
Expand Down
Loading

0 comments on commit 588d2f5

Please sign in to comment.