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

Unified Diff: ui/ozone/platform/dri/scanout_surface.h

Issue 106633002: GBM Ozone implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_gbm.cc ('k') | ui/ozone/platform/dri/screen_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/dri/scanout_surface.h
diff --git a/ui/ozone/platform/dri/scanout_surface.h b/ui/ozone/platform/dri/scanout_surface.h
new file mode 100644
index 0000000000000000000000000000000000000000..d362ae18e812e306ee500e4f4f651bd83d322c19
--- /dev/null
+++ b/ui/ozone/platform/dri/scanout_surface.h
@@ -0,0 +1,84 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_PLATFORM_DRI_SCANOUT_SURFACE_H_
+#define UI_OZONE_PLATFORM_DRI_SCANOUT_SURFACE_H_
+
+#include <stdint.h>
+
+namespace gfx {
+class Size;
+}
+
+namespace ui {
+
+// ScanoutSurface is an interface for a surface that can be scanned out to a
+// monitor using the DRM/KMS API. Implementations will store the internal state
+// associated with the drawing surface. Implementations are also required to
+// performs all the needed operations to initialize and update the drawing
+// surface.
+//
+// The typical usage pattern is:
+// -----------------------------------------------------------------------------
+// HardwareDisplayController controller;
+// // Initialize controller
+//
+// ScanoutSurface* surface = new ScanoutSurfaceImpl(size);
+// surface.Initialize();
+// controller.BindSurfaceToController(surface);
+//
+// while (true) {
+// DrawIntoSurface(surface);
+// controller.SchedulePageFlip();
+//
+// Wait for page flip event. The DRM page flip handler will call
+// surface.SwapBuffers();
+// }
+//
+// delete surface;
+// -----------------------------------------------------------------------------
+// In the above example the wait consists of reading a DRM pageflip event from
+// the graphics card file descriptor. This is done by calling |drmHandleEvent|,
+// which will read and process the event. |drmHandleEvent| will call a callback
+// registered by |SchedulePageFlip| which will update the internal state.
+//
+// |SchedulePageFlip| can also be used to limit drawing to the screen's vsync
+// since page flips only happen on vsync. In a threaded environment a message
+// loop would listen on the graphics card file descriptor for an event and
+// |drmHandleEvent| would be called from the message loop. The event handler
+// would also be responsible for updating the renderer's state and signal that
+// it is OK to start drawing the next frame.
+class ScanoutSurface {
+ public:
+ virtual ~ScanoutSurface() {}
+
+ // Used to allocate all necessary buffers for this surface. If the
+ // initialization succeeds, the device is ready to be used for drawing
+ // operations.
+ // Returns true if the initialization is successful, false otherwise.
+ virtual bool Initialize() = 0;
+
+ // Swaps the back buffer with the front buffer.
+ virtual void SwapBuffers() = 0;
+
+ // Returns the ID of the current backbuffer.
+ virtual uint32_t GetFramebufferId() const = 0;
+
+ // Returns the handle of the current backbuffer.
+ virtual uint32_t GetHandle() const = 0;
+
+ // Returns the surface size.
+ virtual gfx::Size Size() const = 0;
+};
+
+class ScanoutSurfaceGenerator {
+ public:
+ virtual ~ScanoutSurfaceGenerator() {}
+
+ virtual ScanoutSurface* Create(const gfx::Size& size) = 0;
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_DRI_SCANOUT_SURFACE_H_
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_gbm.cc ('k') | ui/ozone/platform/dri/screen_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698