Index: ui/gfx/ozone/dri/gbm_surface.h |
diff --git a/ui/gfx/ozone/dri/gbm_surface.h b/ui/gfx/ozone/dri/gbm_surface.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4c9e9220d6436e498d852f67be1c59ed6120d05d |
--- /dev/null |
+++ b/ui/gfx/ozone/dri/gbm_surface.h |
@@ -0,0 +1,66 @@ |
+// Copyright 2013 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_GFX_OZONE_DRI_GBM_SURFACE_H_ |
+#define UI_GFX_OZONE_DRI_GBM_SURFACE_H_ |
+ |
+#include "base/compiler_specific.h" |
+#include "ui/gfx/ozone/dri/scanout_surface.h" |
+ |
+struct gbm_bo; |
+struct gbm_device; |
+struct gbm_surface; |
+ |
+namespace gfx { |
+ |
+class HardwareDisplayController; |
+ |
+// Implement the ScanoutSurface interface on top of GBM (Generic Buffer |
+// Manager). GBM provides generic access to hardware accelerated surfaces which |
+// can be used in association with EGL to provide accelerated drawing. |
+class GbmSurface : public ScanoutSurface { |
+ public: |
+ GbmSurface(HardwareDisplayController* controller, |
+ gbm_device* device); |
+ virtual ~GbmSurface(); |
+ |
+ virtual bool Initialize() OVERRIDE; |
+ virtual uint32_t GetFramebufferId() const OVERRIDE; |
+ |
+ // If the |frontbuffer_| is a valid pointer, then we need to unlock it such |
+ // that GBM can re-use the memory for future backbuffers. This is called from |
+ // GbmSurfaceFactory when the page flip event is completed. |
+ virtual void SwapBuffers() OVERRIDE; |
+ |
+ // Before scheduling the backbuffer to be scanned out we need to "lock" it. |
+ // When we lock it, GBM will give a pointer to a buffer representing the |
+ // backbuffer. It will also update its information on which buffers can not be |
+ // used for drawing. The buffer will be released when the page flip event |
+ // occurs (see SwapBuffers). This is called from GbmSurfaceFactory before |
+ // scheduling a page flip. |
+ void LockCurrentDrawable(); |
+ |
+ gbm_surface* get_native_surface() { return native_surface_; }; |
+ |
+ private: |
+ HardwareDisplayController* controller_; |
+ |
+ gbm_device* gbm_device_; |
+ |
+ // The native GBM surface. In EGL this represents the EGLNativeWindowType. |
+ gbm_surface* native_surface_; |
+ |
+ // Backing GBM buffers. One is the current front buffer. The other is the |
+ // current backbuffer that is pending scan out. |
+ gbm_bo* buffers_[2]; |
+ |
+ // Index to the front buffer. |
+ int front_buffer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GbmSurface); |
+}; |
+ |
+} // namespace gfx |
+ |
+#endif // UI_GFX_OZONE_DRI_GBM_SURFACE_H_ |