Commit a58e3721 authored by achaulk's avatar achaulk Committed by Commit bot

Re-upload - Fix crash when we don't have a plane to display

Review URL: https://codereview.chromium.org/794323006

Cr-Commit-Position: refs/heads/master@{#308364}
parent 7a8bd879
......@@ -63,13 +63,17 @@ bool CrtcController::SchedulePageFlip(HardwareDisplayPlaneList* plane_list,
const OverlayPlaneList& overlays) {
DCHECK(!page_flip_pending_);
DCHECK(!is_disabled_);
const OverlayPlane& primary = OverlayPlane::GetPrimaryPlane(overlays);
DCHECK(primary.buffer.get());
const OverlayPlane* primary = OverlayPlane::GetPrimaryPlane(overlays);
if (!primary) {
LOG(ERROR) << "No primary plane to display on crtc " << crtc_;
return true;
}
DCHECK(primary->buffer.get());
if (primary.buffer->GetSize() != gfx::Size(mode_.hdisplay, mode_.vdisplay)) {
if (primary->buffer->GetSize() != gfx::Size(mode_.hdisplay, mode_.vdisplay)) {
LOG(WARNING) << "Trying to pageflip a buffer with the wrong size. Expected "
<< mode_.hdisplay << "x" << mode_.vdisplay << " got "
<< primary.buffer->GetSize().ToString() << " for"
<< primary->buffer->GetSize().ToString() << " for"
<< " crtc=" << crtc_ << " connector=" << connector_;
return true;
}
......
......@@ -74,11 +74,11 @@ bool HardwareDisplayController::Modeset(const OverlayPlane& primary,
bool HardwareDisplayController::Enable() {
TRACE_EVENT0("dri", "HDC::Enable");
DCHECK(!current_planes_.empty());
OverlayPlane primary = OverlayPlane::GetPrimaryPlane(current_planes_);
DCHECK(primary.buffer.get());
const OverlayPlane* primary = OverlayPlane::GetPrimaryPlane(current_planes_);
DCHECK(primary->buffer.get());
bool status = true;
for (size_t i = 0; i < crtc_controllers_.size(); ++i)
status &= crtc_controllers_[i]->Modeset(primary, mode_);
status &= crtc_controllers_[i]->Modeset(*primary, mode_);
return status;
}
......
......@@ -32,15 +32,14 @@ OverlayPlane::~OverlayPlane() {
}
// static
const OverlayPlane& OverlayPlane::GetPrimaryPlane(
const OverlayPlane* OverlayPlane::GetPrimaryPlane(
const OverlayPlaneList& overlays) {
for (size_t i = 0; i < overlays.size(); ++i) {
if (overlays[i].z_order == 0)
return overlays[i];
return &overlays[i];
}
NOTREACHED();
return overlays[0];
return nullptr;
}
} // namespace ui
......@@ -31,7 +31,7 @@ struct OverlayPlane {
~OverlayPlane();
// Returns the primary plane in |overlays|.
static const OverlayPlane& GetPrimaryPlane(const OverlayPlaneList& overlays);
static const OverlayPlane* GetPrimaryPlane(const OverlayPlaneList& overlays);
scoped_refptr<ScanoutBuffer> buffer;
int z_order;
......
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