| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_OZONE_PLATFORM_DRI_SCANOUT_SURFACE_H_ | |
| 6 #define UI_OZONE_PLATFORM_DRI_SCANOUT_SURFACE_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 namespace gfx { | |
| 11 class Size; | |
| 12 } | |
| 13 | |
| 14 namespace ui { | |
| 15 | |
| 16 // ScanoutSurface is an interface for a surface that can be scanned out to a | |
| 17 // monitor using the DRM/KMS API. Implementations will store the internal state | |
| 18 // associated with the drawing surface. Implementations are also required to | |
| 19 // performs all the needed operations to initialize and update the drawing | |
| 20 // surface. | |
| 21 // | |
| 22 // The typical usage pattern is: | |
| 23 // ----------------------------------------------------------------------------- | |
| 24 // HardwareDisplayController controller; | |
| 25 // // Initialize controller | |
| 26 // | |
| 27 // ScanoutSurface* surface = new ScanoutSurfaceImpl(size); | |
| 28 // surface.Initialize(); | |
| 29 // controller.BindSurfaceToController(surface); | |
| 30 // | |
| 31 // while (true) { | |
| 32 // DrawIntoSurface(surface); | |
| 33 // controller.SchedulePageFlip(); | |
| 34 // | |
| 35 // Wait for page flip event. The DRM page flip handler will call | |
| 36 // surface.SwapBuffers(); | |
| 37 // } | |
| 38 // | |
| 39 // delete surface; | |
| 40 // ----------------------------------------------------------------------------- | |
| 41 // In the above example the wait consists of reading a DRM pageflip event from | |
| 42 // the graphics card file descriptor. This is done by calling |drmHandleEvent|, | |
| 43 // which will read and process the event. |drmHandleEvent| will call a callback | |
| 44 // registered by |SchedulePageFlip| which will update the internal state. | |
| 45 // | |
| 46 // |SchedulePageFlip| can also be used to limit drawing to the screen's vsync | |
| 47 // since page flips only happen on vsync. In a threaded environment a message | |
| 48 // loop would listen on the graphics card file descriptor for an event and | |
| 49 // |drmHandleEvent| would be called from the message loop. The event handler | |
| 50 // would also be responsible for updating the renderer's state and signal that | |
| 51 // it is OK to start drawing the next frame. | |
| 52 class ScanoutSurface { | |
| 53 public: | |
| 54 virtual ~ScanoutSurface() {} | |
| 55 | |
| 56 // Used to allocate all necessary buffers for this surface. If the | |
| 57 // initialization succeeds, the device is ready to be used for drawing | |
| 58 // operations. | |
| 59 // Returns true if the initialization is successful, false otherwise. | |
| 60 virtual bool Initialize() = 0; | |
| 61 | |
| 62 // Prepare the surface to be displayed. | |
| 63 virtual void PreSwapBuffers() = 0; | |
| 64 | |
| 65 // Swaps the back buffer with the front buffer. | |
| 66 virtual void SwapBuffers() = 0; | |
| 67 | |
| 68 // Returns the ID of the current backbuffer. | |
| 69 virtual uint32_t GetFramebufferId() const = 0; | |
| 70 | |
| 71 // Returns the handle of the current backbuffer. | |
| 72 virtual uint32_t GetHandle() const = 0; | |
| 73 | |
| 74 // Returns the surface size. | |
| 75 virtual gfx::Size Size() const = 0; | |
| 76 }; | |
| 77 | |
| 78 class ScanoutSurfaceGenerator { | |
| 79 public: | |
| 80 virtual ~ScanoutSurfaceGenerator() {} | |
| 81 | |
| 82 virtual ScanoutSurface* Create(const gfx::Size& size) = 0; | |
| 83 }; | |
| 84 | |
| 85 } // namespace ui | |
| 86 | |
| 87 #endif // UI_OZONE_PLATFORM_DRI_SCANOUT_SURFACE_H_ | |
| OLD | NEW |