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.
5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_
6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/gfx/geometry/size.h"
11 #include "ui/gfx/skia_util.h"
12 #include "ui/ozone/ozone_export.h"
13 #include "ui/ozone/platform/dri/scanout_surface.h"
22 // An implementation of ScanoutSurface which uses dumb buffers (used for
23 // software rendering).
24 class OZONE_EXPORT DriSurface
: public ScanoutSurface
{
26 DriSurface(DriWrapper
* dri
, const gfx::Size
& size
);
27 virtual ~DriSurface();
29 // Get a Skia canvas for a backbuffer.
30 SkCanvas
* GetDrawableForWidget();
33 virtual bool Initialize() OVERRIDE
;
34 virtual uint32_t GetFramebufferId() const OVERRIDE
;
35 virtual uint32_t GetHandle() const OVERRIDE
;
36 virtual void SwapBuffers() OVERRIDE
;
37 virtual gfx::Size
Size() const OVERRIDE
;
40 DriBuffer
* frontbuffer() const { return bitmaps_
[front_buffer_
].get(); }
41 DriBuffer
* backbuffer() const { return bitmaps_
[front_buffer_
^ 1].get(); }
43 // Used to create the backing buffers.
44 virtual DriBuffer
* CreateBuffer();
46 // Stores the connection to the graphics card. Pointer not owned by this
50 // The actual buffers used for painting.
51 scoped_ptr
<DriBuffer
> bitmaps_
[2];
53 // Keeps track of which bitmap is |buffers_| is the frontbuffer.
59 DISALLOW_COPY_AND_ASSIGN(DriSurface
);
64 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_