Commit 54f50afd authored by achaulk@chromium.org's avatar achaulk@chromium.org

With the overlay path moving back to passing AcceleratedWidgets, move the...

With the overlay path moving back to passing AcceleratedWidgets, move the implementation back into the surface factory.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288137 0039d316-1c4b-4281-b951-d872f2087c98
parent b90f343f
...@@ -71,11 +71,10 @@ void DriSurface::PresentCanvas(const gfx::Rect& damage) { ...@@ -71,11 +71,10 @@ void DriSurface::PresentCanvas(const gfx::Rect& damage) {
if (!controller_) if (!controller_)
return; return;
std::vector<OverlayPlane> planes( controller_->QueueOverlayPlane(OverlayPlane(buffers_[front_buffer_ ^ 1]));
1, OverlayPlane(buffers_[front_buffer_ ^ 1]));
UpdateNativeSurface(damage); UpdateNativeSurface(damage);
controller_->SchedulePageFlip(planes); controller_->SchedulePageFlip();
controller_->WaitForPageFlipEvent(); controller_->WaitForPageFlipEvent();
// Update our front buffer pointer. // Update our front buffer pointer.
......
...@@ -135,7 +135,7 @@ bool GbmSurface::OnSwapBuffers() { ...@@ -135,7 +135,7 @@ bool GbmSurface::OnSwapBuffers() {
} }
// The primary buffer is a special case. // The primary buffer is a special case.
queued_planes_.push_back(OverlayPlane(primary)); controller_->QueueOverlayPlane(OverlayPlane(primary));
if (!GbmSurfaceless::OnSwapBuffers()) if (!GbmSurfaceless::OnSwapBuffers())
return false; return false;
......
...@@ -123,6 +123,30 @@ scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( ...@@ -123,6 +123,30 @@ scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
return scoped_refptr<GbmPixmap>(new GbmPixmap(buffer)); return scoped_refptr<GbmPixmap>(new GbmPixmap(buffer));
} }
bool GbmSurfaceFactory::ScheduleOverlayPlane(
gfx::AcceleratedWidget widget,
int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) {
scoped_refptr<GbmPixmap> pixmap = static_cast<GbmPixmap*>(buffer.get());
if (!pixmap) {
LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer.";
return false;
}
base::WeakPtr<HardwareDisplayController> hdc =
screen_manager_->GetDisplayController(widget);
if (!hdc)
return true;
hdc->QueueOverlayPlane(OverlayPlane(pixmap->buffer(),
plane_z_order,
plane_transform,
display_bounds,
crop_rect));
return true;
}
bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
return allow_surfaceless_; return allow_surfaceless_;
} }
......
...@@ -32,6 +32,12 @@ class GbmSurfaceFactory : public DriSurfaceFactory { ...@@ -32,6 +32,12 @@ class GbmSurfaceFactory : public DriSurfaceFactory {
virtual scoped_refptr<ui::NativePixmap> CreateNativePixmap( virtual scoped_refptr<ui::NativePixmap> CreateNativePixmap(
gfx::Size size, gfx::Size size,
BufferFormat format) OVERRIDE; BufferFormat format) OVERRIDE;
virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) OVERRIDE;
virtual bool CanShowPrimaryPlaneAsOverlay() OVERRIDE; virtual bool CanShowPrimaryPlaneAsOverlay() OVERRIDE;
private: private:
......
...@@ -29,10 +29,7 @@ bool GbmSurfaceless::OnSwapBuffers() { ...@@ -29,10 +29,7 @@ bool GbmSurfaceless::OnSwapBuffers() {
if (!controller_) if (!controller_)
return true; return true;
bool success = controller_->SchedulePageFlip(queued_planes_); bool success = controller_->SchedulePageFlip();
queued_planes_.clear();
// Even on failure we may have scheduled some planes. Allow the controller to
// wait for the events for the scheduled planes.
controller_->WaitForPageFlipEvent(); controller_->WaitForPageFlipEvent();
return success; return success;
...@@ -42,25 +39,4 @@ scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { ...@@ -42,25 +39,4 @@ scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() {
return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_)); return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_));
} }
bool GbmSurfaceless::ScheduleOverlayPlane(
int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<ui::NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) {
scoped_refptr<GbmPixmap> pixmap =
static_cast<GbmPixmap*>(buffer.get());
if (!pixmap) {
LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer.";
return false;
}
queued_planes_.push_back(OverlayPlane(pixmap->buffer(),
plane_z_order,
plane_transform,
display_bounds,
crop_rect));
return true;
}
} // namespace ui } // namespace ui
...@@ -30,15 +30,8 @@ class GbmSurfaceless : public SurfaceOzoneEGL { ...@@ -30,15 +30,8 @@ class GbmSurfaceless : public SurfaceOzoneEGL {
virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) OVERRIDE; virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) OVERRIDE;
virtual bool OnSwapBuffers() OVERRIDE; virtual bool OnSwapBuffers() OVERRIDE;
virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE;
virtual bool ScheduleOverlayPlane(int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<ui::NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) OVERRIDE;
protected: protected:
base::WeakPtr<HardwareDisplayController> controller_; base::WeakPtr<HardwareDisplayController> controller_;
OverlayPlaneList queued_planes_;
DISALLOW_COPY_AND_ASSIGN(GbmSurfaceless); DISALLOW_COPY_AND_ASSIGN(GbmSurfaceless);
}; };
......
...@@ -111,6 +111,7 @@ bool HardwareDisplayController::Modeset(const OverlayPlane& primary, ...@@ -111,6 +111,7 @@ 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());
OverlayPlane primary = GetPrimaryPlane(current_planes_); OverlayPlane primary = GetPrimaryPlane(current_planes_);
DCHECK(primary.buffer); DCHECK(primary.buffer);
pending_page_flips_ = 0; pending_page_flips_ = 0;
...@@ -130,18 +131,20 @@ void HardwareDisplayController::Disable() { ...@@ -130,18 +131,20 @@ void HardwareDisplayController::Disable() {
} }
} }
bool HardwareDisplayController::SchedulePageFlip( void HardwareDisplayController::QueueOverlayPlane(const OverlayPlane& plane) {
const OverlayPlaneList& overlays) { pending_planes_.push_back(plane);
DCHECK_LE(1u, overlays.size()); }
bool HardwareDisplayController::SchedulePageFlip() {
DCHECK(!pending_planes_.empty());
DCHECK_EQ(0u, pending_page_flips_); DCHECK_EQ(0u, pending_page_flips_);
pending_planes_ = overlays;
bool status = true; bool status = true;
for (size_t i = 0; i < crtc_states_.size(); ++i) { for (size_t i = 0; i < crtc_states_.size(); ++i) {
if (crtc_states_[i]->is_disabled()) if (crtc_states_[i]->is_disabled())
continue; continue;
status &= SchedulePageFlipOnCrtc(overlays, crtc_states_[i]); status &= SchedulePageFlipOnCrtc(pending_planes_, crtc_states_[i]);
} }
return status; return status;
......
...@@ -120,6 +120,8 @@ class HardwareDisplayController ...@@ -120,6 +120,8 @@ class HardwareDisplayController
// Disables the CRTC. // Disables the CRTC.
void Disable(); void Disable();
void QueueOverlayPlane(const OverlayPlane& plane);
// Schedules the |overlays|' framebuffers to be displayed on the next vsync // Schedules the |overlays|' framebuffers to be displayed on the next vsync
// event. The event will be posted on the graphics card file descriptor |fd_| // event. The event will be posted on the graphics card file descriptor |fd_|
// and it can be read and processed by |drmHandleEvent|. That function can // and it can be read and processed by |drmHandleEvent|. That function can
...@@ -136,7 +138,7 @@ class HardwareDisplayController ...@@ -136,7 +138,7 @@ class HardwareDisplayController
// called again before the page flip occurrs. // called again before the page flip occurrs.
// //
// Returns true if the page flip was successfully registered, false otherwise. // Returns true if the page flip was successfully registered, false otherwise.
bool SchedulePageFlip(const OverlayPlaneList& overlays); bool SchedulePageFlip();
// TODO(dnicoara) This should be on the MessageLoop when Ozone can have // TODO(dnicoara) This should be on the MessageLoop when Ozone can have
// BeginFrame can be triggered explicitly by Ozone. // BeginFrame can be triggered explicitly by Ozone.
......
...@@ -180,14 +180,6 @@ class SurfaceOzoneEgltest : public SurfaceOzoneEGL { ...@@ -180,14 +180,6 @@ class SurfaceOzoneEgltest : public SurfaceOzoneEGL {
return scoped_ptr<gfx::VSyncProvider>(); return scoped_ptr<gfx::VSyncProvider>();
} }
virtual bool ScheduleOverlayPlane(int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<ui::NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) OVERRIDE {
return false;
}
private: private:
LibeglplatformShimLoader* eglplatform_shim_; LibeglplatformShimLoader* eglplatform_shim_;
intptr_t native_window_; intptr_t native_window_;
......
...@@ -63,6 +63,16 @@ scoped_refptr<ui::NativePixmap> SurfaceFactoryOzone::CreateNativePixmap( ...@@ -63,6 +63,16 @@ scoped_refptr<ui::NativePixmap> SurfaceFactoryOzone::CreateNativePixmap(
return NULL; return NULL;
} }
bool SurfaceFactoryOzone::ScheduleOverlayPlane(
gfx::AcceleratedWidget widget,
int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) {
return false;
}
bool SurfaceFactoryOzone::CanShowPrimaryPlaneAsOverlay() { bool SurfaceFactoryOzone::CanShowPrimaryPlaneAsOverlay() {
return false; return false;
} }
......
...@@ -119,6 +119,24 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone { ...@@ -119,6 +119,24 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone {
gfx::Size size, gfx::Size size,
BufferFormat format); BufferFormat format);
// Sets the overlay plane to switch to at the next page flip.
// |w| specifies the screen to display this overlay plane on.
// |plane_z_order| specifies the stacking order of the plane relative to the
// main framebuffer located at index 0.
// |plane_transform| specifies how the buffer is to be transformed during.
// composition.
// |buffer| to be presented by the overlay.
// |display_bounds| specify where it is supposed to be on the screen.
// |crop_rect| specifies the region within the buffer to be placed
// inside |display_bounds|. This is specified in texture coordinates, in the
// range of [0,1].
virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect);
// Returns true if overlays can be shown at z-index 0, replacing the main // Returns true if overlays can be shown at z-index 0, replacing the main
// surface. Combined with surfaceless extensions, it allows for an // surface. Combined with surfaceless extensions, it allows for an
// overlay-only mode. // overlay-only mode.
......
...@@ -44,22 +44,6 @@ class OZONE_BASE_EXPORT SurfaceOzoneEGL { ...@@ -44,22 +44,6 @@ class OZONE_BASE_EXPORT SurfaceOzoneEGL {
// outside of the sandbox, they must have been completed in // outside of the sandbox, they must have been completed in
// InitializeHardware. Returns an empty scoped_ptr on error. // InitializeHardware. Returns an empty scoped_ptr on error.
virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() = 0; virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() = 0;
// Sets the overlay plane to switch to at the next page flip.
// |plane_z_order| specifies the stacking order of the plane relative to the
// main framebuffer located at index 0.
// |plane_transform| specifies how the buffer is to be transformed during.
// composition.
// |buffer| to be presented by the overlay.
// |display_bounds| specify where it is supposed to be on the screen.
// |crop_rect| specifies the region within the buffer to be placed
// inside |display_bounds|. This is specified in texture coordinates, in the
// range of [0,1].
virtual bool ScheduleOverlayPlane(int plane_z_order,
gfx::OverlayTransform plane_transform,
scoped_refptr<NativePixmap> buffer,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) = 0;
}; };
} // namespace ui } // namespace ui
......
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