Index: ui/ozone/platform/dri/dri_surface.h |
diff --git a/ui/ozone/platform/dri/dri_surface.h b/ui/ozone/platform/dri/dri_surface.h |
index 2fde4d40fb6129fb03d0bc69bf7cf28a897f99b0..2abae45811eff73149a2d5c4f36551236aa4dc9b 100644 |
--- a/ui/ozone/platform/dri/dri_surface.h |
+++ b/ui/ozone/platform/dri/dri_surface.h |
@@ -10,6 +10,7 @@ |
#include "ui/gfx/geometry/size.h" |
#include "ui/gfx/skia_util.h" |
#include "ui/ozone/ozone_export.h" |
+#include "ui/ozone/platform/dri/scanout_surface.h" |
class SkCanvas; |
@@ -18,129 +19,22 @@ namespace ui { |
class DriBuffer; |
class DriWrapper; |
-// DriSurface is used to represent a surface that can be scanned out |
-// to a monitor. It will store the internal state associated with the drawing |
-// surface associated with it. DriSurface also performs all the needed |
-// operations to initialize and update the drawing surface. |
-// |
-// The implementation uses dumb buffers, which is used for software rendering. |
-// The intent is to have one DriSurface implementation for a |
-// HardwareDisplayController. |
-// |
-// DoubleBufferedSurface is intended to be the software analog to |
-// EGLNativeSurface while DriSurface is intended to provide the glue |
-// necessary to initialize and display the surface to the screen. |
-// |
-// The typical usage pattern is: |
-// ----------------------------------------------------------------------------- |
-// HardwareDisplayController controller; |
-// // Initialize controller |
-// |
-// DriSurface* surface = new DriSurface(dri_wrapper, size); |
-// surface.Initialize(); |
-// controller.BindSurfaceToController(surface); |
-// |
-// while (true) { |
-// SkCanvas* canvas = surface->GetDrawableForWidget(); |
-// DrawStuff(canvas); |
-// 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. |
-// |
-// The following example will illustrate the system state transitions in one |
-// iteration of the above loop. |
-// |
-// 1. Both buffers contain the same image with b[0] being the front buffer |
-// (star will represent the frontbuffer). |
-// ------- ------- |
-// | | | | |
-// | | | | |
-// | | | | |
-// | | | | |
-// ------- ------- |
-// b[0]* b[1] |
-// |
-// 2. Call |GetBackbuffer| to get a SkCanvas wrapper for the backbuffer and draw |
-// to it. |
-// ------- ------- |
-// | | | | |
-// | | | d | |
-// | | | | |
-// | | | | |
-// ------- ------- |
-// b[0]* b[1] |
-// |
-// 3. Call |SchedulePageFlip| to display the backbuffer. At this point we can't |
-// modify b[0] because it is the frontbuffer and we can't modify b[1] since it |
-// has been scheduled for pageflip. If we do draw in b[1] it is possible that |
-// the pageflip and draw happen at the same time and we could get tearing. |
-// |
-// 4. The pageflip callback is called which will call |SwapSurfaces|. Before |
-// |SwapSurfaces| is called the state is as following from the hardware's |
-// perspective: |
-// ------- ------- |
-// | | | | |
-// | | | d | |
-// | | | | |
-// | | | | |
-// ------- ------- |
-// b[0] b[1]* |
-// |
-// 5. |SwapSurfaces| will update out internal reference to the front buffer and |
-// synchronize the damaged area such that both buffers are identical. The |
-// damaged area is used from the SkCanvas clip. |
-// ------- ------- |
-// | | | | |
-// | d | | d | |
-// | | | | |
-// | | | | |
-// ------- ------- |
-// b[0] b[1]* |
-// |
-// The synchronization consists of copying the damaged area from the frontbuffer |
-// to the backbuffer. |
-// |
-// At this point we're back to step 1 and can start a new draw iteration. |
-class OZONE_EXPORT DriSurface { |
+// An implementation of ScanoutSurface which uses dumb buffers (used for |
+// software rendering). |
+class OZONE_EXPORT DriSurface : public ScanoutSurface { |
public: |
DriSurface(DriWrapper* dri, const gfx::Size& size); |
virtual ~DriSurface(); |
- // 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. |
- bool Initialize(); |
- |
- // Returns the ID of the current backbuffer. |
- uint32_t GetFramebufferId() const; |
- |
- // Returns the handle for the current backbuffer. |
- uint32_t GetHandle() const; |
- |
- // Synchronizes and swaps the back buffer with the front buffer. |
- void SwapBuffers(); |
- |
// Get a Skia canvas for a backbuffer. |
SkCanvas* GetDrawableForWidget(); |
- const gfx::Size& size() const { return size_; } |
+ // ScanoutSurface: |
+ virtual bool Initialize() OVERRIDE; |
+ virtual uint32_t GetFramebufferId() const OVERRIDE; |
+ virtual uint32_t GetHandle() const OVERRIDE; |
+ virtual void SwapBuffers() OVERRIDE; |
+ virtual gfx::Size Size() const OVERRIDE; |
private: |
DriBuffer* frontbuffer() const { return bitmaps_[front_buffer_].get(); } |