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