Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: ui/ozone/platform/dri/hardware_display_controller.cc

Issue 393233005: [Ozone-DRI] Convert HardwareDisplayController to use scanout buffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/dri/hardware_display_controller.cc
diff --git a/ui/ozone/platform/dri/hardware_display_controller.cc b/ui/ozone/platform/dri/hardware_display_controller.cc
index 882efc1f58754583c65132af5d0f9379c3df537c..8a2a722e5c14bb7fbe58e7e1bbb08411ac379d3b 100644
--- a/ui/ozone/platform/dri/hardware_display_controller.cc
+++ b/ui/ozone/platform/dri/hardware_display_controller.cc
@@ -18,7 +18,6 @@
#include "ui/gfx/geometry/size.h"
#include "ui/ozone/platform/dri/dri_buffer.h"
#include "ui/ozone/platform/dri/dri_wrapper.h"
-#include "ui/ozone/platform/dri/scanout_surface.h"
#include "ui/ozone/public/native_pixmap.h"
namespace ui {
@@ -45,14 +44,31 @@ void HandlePageFlipEvent(int fd,
->OnPageFlipEvent(frame, seconds, useconds);
}
+const OverlayPlane& GetPrimaryPlane(const OverlayPlaneList& overlays) {
+ for (size_t i = 0; i < overlays.size(); ++i) {
+ if (overlays[i].z_order == 0)
+ return overlays[i];
+ }
+
+ NOTREACHED();
+ return overlays[0];
+}
+
} // namespace
-OzoneOverlayPlane::OzoneOverlayPlane(ScanoutSurface* scanout,
- int z_order,
- gfx::OverlayTransform plane_transform,
- const gfx::Rect& display_bounds,
- const gfx::RectF& crop_rect)
- : scanout(scanout),
+OverlayPlane::OverlayPlane(scoped_refptr<ScanoutBuffer> buffer)
+ : buffer(buffer),
+ z_order(0),
+ display_bounds(gfx::Point(), buffer->GetSize()),
+ crop_rect(0, 0, 1, 1),
+ overlay_plane(0) {}
+
+OverlayPlane::OverlayPlane(scoped_refptr<ScanoutBuffer> buffer,
+ int z_order,
+ gfx::OverlayTransform plane_transform,
+ const gfx::Rect& display_bounds,
+ const gfx::RectF& crop_rect)
+ : buffer(buffer),
z_order(z_order),
plane_transform(plane_transform),
display_bounds(display_bounds),
@@ -60,6 +76,8 @@ OzoneOverlayPlane::OzoneOverlayPlane(ScanoutSurface* scanout,
overlay_plane(0) {
}
+OverlayPlane::~OverlayPlane() {}
+
HardwareDisplayController::HardwareDisplayController(
DriWrapper* drm,
uint32_t connector_id,
@@ -67,7 +85,6 @@ HardwareDisplayController::HardwareDisplayController(
: drm_(drm),
connector_id_(connector_id),
crtc_id_(crtc_id),
- surface_(),
time_of_last_flip_(0),
is_disabled_(true),
saved_crtc_(drm_->GetCrtc(crtc_id_)) {}
@@ -78,45 +95,35 @@ HardwareDisplayController::~HardwareDisplayController() {
// Reset the cursor.
UnsetCursor();
- UnbindSurfaceFromController();
}
-bool
-HardwareDisplayController::BindSurfaceToController(
- scoped_ptr<ScanoutSurface> surface, drmModeModeInfo mode) {
- CHECK(surface);
-
+bool HardwareDisplayController::Modeset(const OverlayPlane& primary,
+ drmModeModeInfo mode) {
+ CHECK(primary.buffer);
if (!drm_->SetCrtc(crtc_id_,
- surface->GetFramebufferId(),
+ primary.buffer->GetFramebufferId(),
&connector_id_,
&mode)) {
LOG(ERROR) << "Failed to modeset: error='" << strerror(errno)
<< "' crtc=" << crtc_id_ << " connector=" << connector_id_
- << " framebuffer_id=" << surface->GetFramebufferId()
+ << " framebuffer_id=" << primary.buffer->GetFramebufferId()
<< " mode=" << mode.hdisplay << "x" << mode.vdisplay << "@"
<< mode.vrefresh;
return false;
}
- surface_.reset(surface.release());
+ current_planes_ = std::vector<OverlayPlane>(1, primary);
+ pending_planes_.clear();
mode_ = mode;
is_disabled_ = false;
return true;
}
-void HardwareDisplayController::UnbindSurfaceFromController() {
- drm_->SetCrtc(crtc_id_, 0, 0, NULL);
- surface_.reset();
- memset(&mode_, 0, sizeof(mode_));
- is_disabled_ = true;
-}
-
bool HardwareDisplayController::Enable() {
- CHECK(surface_);
- if (is_disabled_) {
- scoped_ptr<ScanoutSurface> surface(surface_.release());
- return BindSurfaceToController(surface.Pass(), mode_);
- }
+ OverlayPlane primary = GetPrimaryPlane(current_planes_);
+ CHECK(primary.buffer);
+ if (is_disabled_)
+ return Modeset(primary, mode_);
return true;
}
@@ -126,46 +133,29 @@ void HardwareDisplayController::Disable() {
is_disabled_ = true;
}
-ScanoutSurface* HardwareDisplayController::GetPrimaryPlane(
- const std::vector<OzoneOverlayPlane>& overlays) {
- ScanoutSurface* primary = surface_.get();
- for (size_t i = 0; i < overlays.size(); i++) {
- const OzoneOverlayPlane& plane = overlays[i];
- if (plane.z_order == 0) {
- return plane.scanout;
- }
- }
-
- return primary;
-}
-
bool HardwareDisplayController::SchedulePageFlip(
- const std::vector<OzoneOverlayPlane>& overlays,
- NativePixmapList* references) {
- ScanoutSurface* primary = GetPrimaryPlane(overlays);
- CHECK(primary);
-
- primary->PreSwapBuffers();
+ const OverlayPlaneList& overlays) {
+ CHECK_LE(1u, overlays.size());
+ const OverlayPlane& primary = GetPrimaryPlane(overlays);
+ CHECK(primary.buffer);
if (!is_disabled_ &&
- !drm_->PageFlip(crtc_id_, primary->GetFramebufferId(), this)) {
+ !drm_->PageFlip(crtc_id_, primary.buffer->GetFramebufferId(), this)) {
LOG(ERROR) << "Cannot page flip: " << strerror(errno);
return false;
}
- current_overlay_references_.clear();
- if (references)
- current_overlay_references_.swap(*references);
+ pending_planes_ = overlays;
for (size_t i = 0; i < overlays.size(); i++) {
- const OzoneOverlayPlane& plane = overlays[i];
+ const OverlayPlane& plane = overlays[i];
if (!plane.overlay_plane)
continue;
- const gfx::Size& size = plane.scanout->Size();
+ const gfx::Size& size = plane.buffer->GetSize();
gfx::RectF crop_rect = plane.crop_rect;
crop_rect.Scale(size.width(), size.height());
if (!drm_->PageFlipOverlay(crtc_id_,
- plane.scanout->GetFramebufferId(),
+ plane.buffer->GetFramebufferId(),
plane.display_bounds,
crop_rect,
plane.overlay_plane)) {
@@ -199,7 +189,8 @@ void HardwareDisplayController::OnPageFlipEvent(unsigned int frame,
static_cast<uint64_t>(seconds) * base::Time::kMicrosecondsPerSecond +
useconds;
- surface_->SwapBuffers();
+ current_planes_ = pending_planes_;
+ pending_planes_.clear();
}
bool HardwareDisplayController::SetCursor(scoped_refptr<ScanoutBuffer> buffer) {
« no previous file with comments | « ui/ozone/platform/dri/hardware_display_controller.h ('k') | ui/ozone/platform/dri/hardware_display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698