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_GBM_SURFACE_H_ |
| 6 #define UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/geometry/size.h" |
| 11 #include "ui/ozone/platform/dri/scanout_surface.h" |
| 12 |
| 13 struct gbm_bo; |
| 14 struct gbm_device; |
| 15 struct gbm_surface; |
| 16 |
| 17 namespace ui { |
| 18 |
| 19 class DriBuffer; |
| 20 class DriWrapper; |
| 21 |
| 22 // Implement the ScanoutSurface interface on top of GBM (Generic Buffer |
| 23 // Manager). GBM provides generic access to hardware accelerated surfaces which |
| 24 // can be used in association with EGL to provide accelerated drawing. |
| 25 class GbmSurface : public ScanoutSurface { |
| 26 public: |
| 27 GbmSurface(gbm_device* device, DriWrapper* dri, const gfx::Size& size); |
| 28 virtual ~GbmSurface(); |
| 29 |
| 30 // ScanoutSurface: |
| 31 virtual bool Initialize() OVERRIDE; |
| 32 virtual uint32_t GetFramebufferId() const OVERRIDE; |
| 33 virtual uint32_t GetHandle() const OVERRIDE; |
| 34 virtual gfx::Size Size() const OVERRIDE; |
| 35 virtual void SwapBuffers() OVERRIDE; |
| 36 |
| 37 // Before scheduling the backbuffer to be scanned out we need to "lock" it. |
| 38 // When we lock it, GBM will give a pointer to a buffer representing the |
| 39 // backbuffer. It will also update its information on which buffers can not be |
| 40 // used for drawing. The buffer will be released when the page flip event |
| 41 // occurs (see SwapBuffers). This is called from GbmSurfaceFactory before |
| 42 // scheduling a page flip. |
| 43 void LockCurrentDrawable(); |
| 44 |
| 45 gbm_surface* native_surface() { return native_surface_; }; |
| 46 |
| 47 private: |
| 48 gbm_device* gbm_device_; |
| 49 |
| 50 DriWrapper* dri_; |
| 51 |
| 52 gfx::Size size_; |
| 53 |
| 54 // The native GBM surface. In EGL this represents the EGLNativeWindowType. |
| 55 gbm_surface* native_surface_; |
| 56 |
| 57 // Backing GBM buffers. One is the current front buffer. The other is the |
| 58 // current backbuffer that is pending scan out. |
| 59 gbm_bo* buffers_[2]; |
| 60 |
| 61 // Index to the front buffer. |
| 62 int front_buffer_; |
| 63 |
| 64 // We can't lock (and get) an accelerated buffer from the GBM surface until |
| 65 // after something draws into it. But modesetting needs to happen earlier, |
| 66 // before an actual window is created and draws. So, we create a dumb buffer |
| 67 // for this purpose. |
| 68 scoped_ptr<DriBuffer> dumb_buffer_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(GbmSurface); |
| 71 }; |
| 72 |
| 73 } // namespace ui |
| 74 |
| 75 #endif // UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ |
OLD | NEW |