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_DRI_SURFACE_H_ 6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ 7 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" 14 15 class SkCanvas; 16 17 namespace ui { 18 19 class DriBuffer; 20 class DriWrapper; 21 22 // An implementation of ScanoutSurface which uses dumb buffers (used for 23 // software rendering). 24 class OZONE_EXPORT DriSurface : public ScanoutSurface { 25 public: 26 DriSurface(DriWrapper* dri, const gfx::Size& size); 27 virtual ~DriSurface(); 28 29 // Get a Skia canvas for a backbuffer. 30 SkCanvas* GetDrawableForWidget(); 31 32 // ScanoutSurface: 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; 38 39 private: 40 DriBuffer* frontbuffer() const { return bitmaps_[front_buffer_].get(); } 41 DriBuffer* backbuffer() const { return bitmaps_[front_buffer_ ^ 1].get(); } 42 43 // Used to create the backing buffers. 44 virtual DriBuffer* CreateBuffer(); 45 46 // Stores the connection to the graphics card. Pointer not owned by this 47 // class. 48 DriWrapper* dri_; 49 50 // The actual buffers used for painting. 51 scoped_ptr<DriBuffer> bitmaps_[2]; 52 53 // Keeps track of which bitmap is |buffers_| is the frontbuffer. 54 int front_buffer_; 55 56 // Surface size. 57 gfx::Size size_; 58 59 DISALLOW_COPY_AND_ASSIGN(DriSurface); 60 }; 61 62 } // namespace ui 63 64 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ 65