Commit 5ea3025c authored by Mark Yacoub's avatar Mark Yacoub Committed by Commit Bot

Handle 4CC format for opaque fb when TestPageFlip

When TestPageFlip, choose the FourCC format that takes opacity into
consideration.

BUG=983937
TEST=GPU doesn't crash anymore on Kefka

Change-Id: I72af7f1755c9cd9c4464246fc73d38adbec57b25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1724558Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Commit-Queue: Mark Yacoub <markyacoub@google.com>
Auto-Submit: Mark Yacoub <markyacoub@google.com>
Cr-Commit-Position: refs/heads/master@{#682848}
parent 2a759d5e
...@@ -85,6 +85,7 @@ void OverlayCandidateValidatorOzone::CheckOverlaySupport( ...@@ -85,6 +85,7 @@ void OverlayCandidateValidatorOzone::CheckOverlaySupport(
ozone_surface_list.at(i).crop_rect = surfaces->at(i).uv_rect; ozone_surface_list.at(i).crop_rect = surfaces->at(i).uv_rect;
ozone_surface_list.at(i).clip_rect = surfaces->at(i).clip_rect; ozone_surface_list.at(i).clip_rect = surfaces->at(i).clip_rect;
ozone_surface_list.at(i).is_clipped = surfaces->at(i).is_clipped; ozone_surface_list.at(i).is_clipped = surfaces->at(i).is_clipped;
ozone_surface_list.at(i).is_opaque = surfaces->at(i).is_opaque;
ozone_surface_list.at(i).plane_z_order = surfaces->at(i).plane_z_order; ozone_surface_list.at(i).plane_z_order = surfaces->at(i).plane_z_order;
ozone_surface_list.at(i).buffer_size = ozone_surface_list.at(i).buffer_size =
surfaces->at(i).resource_size_in_pixels; surfaces->at(i).resource_size_in_pixels;
......
...@@ -31,6 +31,7 @@ OverlayCheck_Params::OverlayCheck_Params( ...@@ -31,6 +31,7 @@ OverlayCheck_Params::OverlayCheck_Params(
format(candidate.format), format(candidate.format),
display_rect(gfx::ToNearestRect(candidate.display_rect)), display_rect(gfx::ToNearestRect(candidate.display_rect)),
crop_rect(candidate.crop_rect), crop_rect(candidate.crop_rect),
is_opaque(candidate.is_opaque),
plane_z_order(candidate.plane_z_order), plane_z_order(candidate.plane_z_order),
is_overlay_candidate(candidate.overlay_handled) {} is_overlay_candidate(candidate.overlay_handled) {}
......
...@@ -65,12 +65,12 @@ struct OverlayCheck_Params { ...@@ -65,12 +65,12 @@ struct OverlayCheck_Params {
OverlayCheck_Params(const OverlayCheck_Params& other); OverlayCheck_Params(const OverlayCheck_Params& other);
~OverlayCheck_Params(); ~OverlayCheck_Params();
gfx::Size buffer_size; gfx::Size buffer_size;
gfx::OverlayTransform transform = gfx::OVERLAY_TRANSFORM_NONE; gfx::OverlayTransform transform = gfx::OVERLAY_TRANSFORM_NONE;
gfx::BufferFormat format = gfx::BufferFormat::BGRA_8888; gfx::BufferFormat format = gfx::BufferFormat::BGRA_8888;
gfx::Rect display_rect; gfx::Rect display_rect;
gfx::RectF crop_rect; gfx::RectF crop_rect;
bool is_opaque = false;
int plane_z_order = 0; int plane_z_order = 0;
// By default we mark this configuration valid for promoting it to an overlay. // By default we mark this configuration valid for promoting it to an overlay.
bool is_overlay_candidate = true; bool is_overlay_candidate = true;
......
...@@ -81,6 +81,7 @@ IPC_STRUCT_TRAITS_BEGIN(ui::OverlayCheck_Params) ...@@ -81,6 +81,7 @@ IPC_STRUCT_TRAITS_BEGIN(ui::OverlayCheck_Params)
IPC_STRUCT_TRAITS_MEMBER(format) IPC_STRUCT_TRAITS_MEMBER(format)
IPC_STRUCT_TRAITS_MEMBER(display_rect) IPC_STRUCT_TRAITS_MEMBER(display_rect)
IPC_STRUCT_TRAITS_MEMBER(crop_rect) IPC_STRUCT_TRAITS_MEMBER(crop_rect)
IPC_STRUCT_TRAITS_MEMBER(is_opaque)
IPC_STRUCT_TRAITS_MEMBER(plane_z_order) IPC_STRUCT_TRAITS_MEMBER(plane_z_order)
IPC_STRUCT_TRAITS_MEMBER(is_overlay_candidate) IPC_STRUCT_TRAITS_MEMBER(is_overlay_candidate)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -288,8 +289,7 @@ HardwareDisplayControllerInfo::HardwareDisplayControllerInfo( ...@@ -288,8 +289,7 @@ HardwareDisplayControllerInfo::HardwareDisplayControllerInfo(
size_t index) size_t index)
: connector_(std::move(connector)), crtc_(std::move(crtc)), index_(index) {} : connector_(std::move(connector)), crtc_(std::move(crtc)), index_(index) {}
HardwareDisplayControllerInfo::~HardwareDisplayControllerInfo() { HardwareDisplayControllerInfo::~HardwareDisplayControllerInfo() = default;
}
std::vector<std::unique_ptr<HardwareDisplayControllerInfo>> std::vector<std::unique_ptr<HardwareDisplayControllerInfo>>
GetAvailableDisplayControllerInfos(int fd) { GetAvailableDisplayControllerInfos(int fd) {
...@@ -587,6 +587,7 @@ OverlaySurfaceCandidateList CreateOverlaySurfaceCandidateListFrom( ...@@ -587,6 +587,7 @@ OverlaySurfaceCandidateList CreateOverlaySurfaceCandidateListFrom(
osc.format = p.format; osc.format = p.format;
osc.display_rect = gfx::RectF(p.display_rect); osc.display_rect = gfx::RectF(p.display_rect);
osc.crop_rect = p.crop_rect; osc.crop_rect = p.crop_rect;
osc.is_opaque = p.is_opaque;
osc.plane_z_order = p.plane_z_order; osc.plane_z_order = p.plane_z_order;
osc.overlay_handled = p.is_overlay_candidate; osc.overlay_handled = p.is_overlay_candidate;
candidates.push_back(osc); candidates.push_back(osc);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ui/ozone/platform/drm/gpu/drm_overlay_validator.h" #include "ui/ozone/platform/drm/gpu/drm_overlay_validator.h"
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -85,7 +86,10 @@ std::vector<OverlayCheckReturn_Params> DrmOverlayValidator::TestPageFlip( ...@@ -85,7 +86,10 @@ std::vector<OverlayCheckReturn_Params> DrmOverlayValidator::TestPageFlip(
scoped_refptr<DrmFramebuffer> buffer = GetBufferForPageFlipTest( scoped_refptr<DrmFramebuffer> buffer = GetBufferForPageFlipTest(
drm, params[i].buffer_size, drm, params[i].buffer_size,
GetFourCCFormatFromBufferFormat(params[i].format), &reusable_buffers); params[i].is_opaque
? GetFourCCFormatForOpaqueFramebuffer(params[i].format)
: GetFourCCFormatFromBufferFormat(params[i].format),
&reusable_buffers);
DrmOverlayPlane plane(buffer, params[i].plane_z_order, params[i].transform, DrmOverlayPlane plane(buffer, params[i].plane_z_order, params[i].transform,
params[i].display_rect, params[i].crop_rect, params[i].display_rect, params[i].crop_rect,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ui/ozone/platform/drm/gpu/drm_overlay_validator.h" #include "ui/ozone/platform/drm/gpu/drm_overlay_validator.h"
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -143,6 +144,7 @@ void DrmOverlayValidatorTest::SetUp() { ...@@ -143,6 +144,7 @@ void DrmOverlayValidatorTest::SetUp() {
ui::OverlayCheck_Params primary_candidate; ui::OverlayCheck_Params primary_candidate;
primary_candidate.buffer_size = primary_rect_.size(); primary_candidate.buffer_size = primary_rect_.size();
primary_candidate.display_rect = primary_rect_; primary_candidate.display_rect = primary_rect_;
primary_candidate.is_opaque = true;
primary_candidate.format = gfx::BufferFormat::BGRX_8888; primary_candidate.format = gfx::BufferFormat::BGRX_8888;
overlay_params_.push_back(primary_candidate); overlay_params_.push_back(primary_candidate);
AddPlane(primary_candidate); AddPlane(primary_candidate);
...@@ -151,6 +153,7 @@ void DrmOverlayValidatorTest::SetUp() { ...@@ -151,6 +153,7 @@ void DrmOverlayValidatorTest::SetUp() {
overlay_candidate.buffer_size = overlay_rect_.size(); overlay_candidate.buffer_size = overlay_rect_.size();
overlay_candidate.display_rect = overlay_rect_; overlay_candidate.display_rect = overlay_rect_;
overlay_candidate.plane_z_order = 1; overlay_candidate.plane_z_order = 1;
primary_candidate.is_opaque = true;
overlay_candidate.format = gfx::BufferFormat::BGRX_8888; overlay_candidate.format = gfx::BufferFormat::BGRX_8888;
overlay_params_.push_back(overlay_candidate); overlay_params_.push_back(overlay_candidate);
AddPlane(overlay_candidate); AddPlane(overlay_candidate);
...@@ -224,7 +227,7 @@ void DrmOverlayValidatorTest::AddPlane(const ui::OverlayCheck_Params& params) { ...@@ -224,7 +227,7 @@ void DrmOverlayValidatorTest::AddPlane(const ui::OverlayCheck_Params& params) {
ui::GetFourCCFormatFromBufferFormat(params.format), params.buffer_size); ui::GetFourCCFormatFromBufferFormat(params.format), params.buffer_size);
plane_list_.push_back(ui::DrmOverlayPlane( plane_list_.push_back(ui::DrmOverlayPlane(
std::move(drm_framebuffer), params.plane_z_order, params.transform, std::move(drm_framebuffer), params.plane_z_order, params.transform,
params.display_rect, params.crop_rect, true, nullptr)); params.display_rect, params.crop_rect, !params.is_opaque, nullptr));
} }
void DrmOverlayValidatorTest::TearDown() { void DrmOverlayValidatorTest::TearDown() {
...@@ -302,6 +305,7 @@ TEST_F(DrmOverlayValidatorTest, OverlayFormat_YUV) { ...@@ -302,6 +305,7 @@ TEST_F(DrmOverlayValidatorTest, OverlayFormat_YUV) {
overlay_params_.back().buffer_size = overlay_rect_.size(); overlay_params_.back().buffer_size = overlay_rect_.size();
overlay_params_.back().display_rect = overlay_rect_; overlay_params_.back().display_rect = overlay_rect_;
overlay_params_.back().crop_rect = crop_rect; overlay_params_.back().crop_rect = crop_rect;
overlay_params_.back().is_opaque = false;
overlay_params_.back().format = gfx::BufferFormat::UYVY_422; overlay_params_.back().format = gfx::BufferFormat::UYVY_422;
plane_list_.pop_back(); plane_list_.pop_back();
AddPlane(overlay_params_.back()); AddPlane(overlay_params_.back());
......
...@@ -32,6 +32,8 @@ struct OverlaySurfaceCandidate { ...@@ -32,6 +32,8 @@ struct OverlaySurfaceCandidate {
gfx.mojom.Rect clip_rect; gfx.mojom.Rect clip_rect;
// If the quad is clipped after composition. // If the quad is clipped after composition.
bool is_clipped; bool is_clipped;
// If the quad doesn't require blending.
bool is_opaque;
// Stacking order of the overlay plane relative to the main surface, // Stacking order of the overlay plane relative to the main surface,
// which is 0. Signed to allow for "underlays". // which is 0. Signed to allow for "underlays".
int32 plane_z_order = 0; int32 plane_z_order = 0;
......
...@@ -80,6 +80,10 @@ struct StructTraits<ui::ozone::mojom::OverlaySurfaceCandidateDataView, ...@@ -80,6 +80,10 @@ struct StructTraits<ui::ozone::mojom::OverlaySurfaceCandidateDataView,
return osc.is_clipped; return osc.is_clipped;
} }
static bool is_opaque(const ui::OverlaySurfaceCandidate& osc) {
return osc.is_opaque;
}
static int plane_z_order(const ui::OverlaySurfaceCandidate& osc) { static int plane_z_order(const ui::OverlaySurfaceCandidate& osc) {
return osc.plane_z_order; return osc.plane_z_order;
} }
...@@ -91,6 +95,7 @@ struct StructTraits<ui::ozone::mojom::OverlaySurfaceCandidateDataView, ...@@ -91,6 +95,7 @@ struct StructTraits<ui::ozone::mojom::OverlaySurfaceCandidateDataView,
static bool Read(ui::ozone::mojom::OverlaySurfaceCandidateDataView data, static bool Read(ui::ozone::mojom::OverlaySurfaceCandidateDataView data,
ui::OverlaySurfaceCandidate* out) { ui::OverlaySurfaceCandidate* out) {
out->is_clipped = data.is_clipped(); out->is_clipped = data.is_clipped();
out->is_opaque = data.is_opaque();
out->plane_z_order = data.plane_z_order(); out->plane_z_order = data.plane_z_order();
out->overlay_handled = data.overlay_handled(); out->overlay_handled = data.overlay_handled();
return data.ReadTransform(&out->transform) && return data.ReadTransform(&out->transform) &&
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/ozone/public/mojom/overlay_surface_candidate_mojom_traits.h"
#include <utility> #include <utility>
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "ui/ozone/public/mojom/overlay_surface_candidate.mojom.h" #include "ui/ozone/public/mojom/overlay_surface_candidate.mojom.h"
#include "ui/ozone/public/mojom/overlay_surface_candidate_mojom_traits.h"
#include "ui/ozone/public/overlay_surface_candidate.h" #include "ui/ozone/public/overlay_surface_candidate.h"
namespace ui { namespace ui {
...@@ -22,6 +23,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FieldsEqual) { ...@@ -22,6 +23,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FieldsEqual) {
input.crop_rect = gfx::RectF(10., 20., 30., 40.); input.crop_rect = gfx::RectF(10., 20., 30., 40.);
input.clip_rect = gfx::Rect(11, 21, 31, 41); input.clip_rect = gfx::Rect(11, 21, 31, 41);
input.is_clipped = true; input.is_clipped = true;
input.is_opaque = true;
input.plane_z_order = 42; input.plane_z_order = 42;
input.overlay_handled = true; input.overlay_handled = true;
...@@ -39,6 +41,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FieldsEqual) { ...@@ -39,6 +41,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FieldsEqual) {
EXPECT_EQ(input.crop_rect, output.crop_rect); EXPECT_EQ(input.crop_rect, output.crop_rect);
EXPECT_EQ(input.clip_rect, output.clip_rect); EXPECT_EQ(input.clip_rect, output.clip_rect);
EXPECT_EQ(input.is_clipped, output.is_clipped); EXPECT_EQ(input.is_clipped, output.is_clipped);
EXPECT_EQ(input.is_opaque, output.is_opaque);
EXPECT_EQ(input.plane_z_order, output.plane_z_order); EXPECT_EQ(input.plane_z_order, output.plane_z_order);
EXPECT_EQ(input.overlay_handled, output.overlay_handled); EXPECT_EQ(input.overlay_handled, output.overlay_handled);
} }
...@@ -47,6 +50,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FalseBools) { ...@@ -47,6 +50,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FalseBools) {
ui::OverlaySurfaceCandidate input; ui::OverlaySurfaceCandidate input;
input.is_clipped = false; input.is_clipped = false;
input.is_opaque = false;
input.overlay_handled = false; input.overlay_handled = false;
ui::OverlaySurfaceCandidate output; ui::OverlaySurfaceCandidate output;
...@@ -56,6 +60,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FalseBools) { ...@@ -56,6 +60,7 @@ TEST(OverlaySurfaceCandidateStructTraitsTest, FalseBools) {
EXPECT_TRUE(success); EXPECT_TRUE(success);
EXPECT_EQ(input.is_clipped, output.is_clipped); EXPECT_EQ(input.is_clipped, output.is_clipped);
EXPECT_EQ(input.is_opaque, output.is_opaque);
EXPECT_EQ(input.overlay_handled, output.overlay_handled); EXPECT_EQ(input.overlay_handled, output.overlay_handled);
} }
......
...@@ -30,7 +30,7 @@ class COMPONENT_EXPORT(OZONE_BASE) OverlaySurfaceCandidate { ...@@ -30,7 +30,7 @@ class COMPONENT_EXPORT(OZONE_BASE) OverlaySurfaceCandidate {
~OverlaySurfaceCandidate(); ~OverlaySurfaceCandidate();
OverlaySurfaceCandidate& operator=(const OverlaySurfaceCandidate& other); OverlaySurfaceCandidate& operator=(const OverlaySurfaceCandidate& other);
// Note that |clip_rect|, |is_clipped| and |overlay_handled| are // Note that |clip_rect|, |is_clipped|, |is_opaque| and |overlay_handled| are
// *not* used as part of the comparison. // *not* used as part of the comparison.
bool operator<(const OverlaySurfaceCandidate& other) const; bool operator<(const OverlaySurfaceCandidate& other) const;
...@@ -53,6 +53,8 @@ class COMPONENT_EXPORT(OZONE_BASE) OverlaySurfaceCandidate { ...@@ -53,6 +53,8 @@ class COMPONENT_EXPORT(OZONE_BASE) OverlaySurfaceCandidate {
gfx::Rect clip_rect; gfx::Rect clip_rect;
// If the quad is clipped after composition. // If the quad is clipped after composition.
bool is_clipped = false; bool is_clipped = false;
// If the quad doesn't require blending.
bool is_opaque = false;
// To be modified by the implementer if this candidate can go into // To be modified by the implementer if this candidate can go into
// an overlay. // an overlay.
......
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