| OLD | NEW | 
|   1 // Copyright 2014 The Chromium Authors. All rights reserved. |   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 |   2 // Use of this source code is governed by a BSD-style license that can be | 
|   3 // found in the LICENSE file. |   3 // found in the LICENSE file. | 
|   4  |   4  | 
|   5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ |   5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ | 
|   6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ |   6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ | 
|   7  |   7  | 
|   8 #include "base/compiler_specific.h" |   8 #include "base/memory/scoped_ptr.h" | 
|   9 #include "base/memory/ref_counted.h" |   9 #include "base/memory/weak_ptr.h" | 
 |  10 #include "ui/gfx/geometry/rect.h" | 
|  10 #include "ui/gfx/geometry/size.h" |  11 #include "ui/gfx/geometry/size.h" | 
|  11 #include "ui/gfx/skia_util.h" |  12 #include "ui/gfx/skia_util.h" | 
|  12 #include "ui/ozone/platform/dri/scanout_surface.h" |  13 #include "ui/ozone/public/surface_ozone_canvas.h" | 
|  13  |  14  | 
|  14 class SkCanvas; |  15 class SkCanvas; | 
 |  16 class SkSurface; | 
|  15  |  17  | 
|  16 namespace ui { |  18 namespace ui { | 
|  17  |  19  | 
|  18 class DriBuffer; |  20 class DriBuffer; | 
|  19 class DriWrapper; |  21 class DriWrapper; | 
 |  22 class HardwareDisplayController; | 
|  20  |  23  | 
|  21 // An implementation of ScanoutSurface which uses dumb buffers (used for |  24 class DriSurface : public SurfaceOzoneCanvas { | 
|  22 // software rendering). |  | 
|  23 class DriSurface : public ScanoutSurface { |  | 
|  24  public: |  25  public: | 
|  25   DriSurface(DriWrapper* dri, const gfx::Size& size); |  26   DriSurface(DriWrapper* dri, | 
 |  27              const base::WeakPtr<HardwareDisplayController>& controller); | 
|  26   virtual ~DriSurface(); |  28   virtual ~DriSurface(); | 
|  27  |  29  | 
|  28   // Get a Skia canvas for a backbuffer. |  30   // SurfaceOzoneCanvas: | 
|  29   SkCanvas* GetDrawableForWidget(); |  31   virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE; | 
|  30   scoped_refptr<DriBuffer> backbuffer() const { |  32   virtual void ResizeCanvas(const gfx::Size& viewport_size) OVERRIDE; | 
|  31     return bitmaps_[front_buffer_ ^ 1]; |  33   virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE; | 
|  32   } |  34   virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; | 
|  33  |  | 
|  34   // ScanoutSurface: |  | 
|  35   virtual bool Initialize() OVERRIDE; |  | 
|  36   virtual uint32_t GetFramebufferId() const OVERRIDE; |  | 
|  37   virtual uint32_t GetHandle() const OVERRIDE; |  | 
|  38   virtual void PreSwapBuffers() OVERRIDE; |  | 
|  39   virtual void SwapBuffers() OVERRIDE; |  | 
|  40   virtual gfx::Size Size() const OVERRIDE; |  | 
|  41  |  35  | 
|  42  private: |  36  private: | 
 |  37   void UpdateNativeSurface(const gfx::Rect& damage); | 
 |  38  | 
|  43   // Stores the connection to the graphics card. Pointer not owned by this |  39   // Stores the connection to the graphics card. Pointer not owned by this | 
|  44   // class. |  40   // class. | 
|  45   DriWrapper* dri_; |  41   DriWrapper* dri_; | 
|  46  |  42  | 
|  47   // The actual buffers used for painting. |  43   // The actual buffers used for painting. | 
|  48   scoped_refptr<DriBuffer> bitmaps_[2]; |  44   scoped_refptr<DriBuffer> buffers_[2]; | 
|  49  |  45  | 
|  50   // Keeps track of which bitmap is |buffers_| is the frontbuffer. |  46   // Keeps track of which bitmap is |buffers_| is the frontbuffer. | 
|  51   int front_buffer_; |  47   int front_buffer_; | 
|  52  |  48  | 
|  53   // Surface size. |  49   skia::RefPtr<SkSurface> surface_; | 
|  54   gfx::Size size_; |  50   gfx::Rect last_damage_; | 
 |  51   base::WeakPtr<HardwareDisplayController> controller_; | 
|  55  |  52  | 
|  56   DISALLOW_COPY_AND_ASSIGN(DriSurface); |  53   DISALLOW_COPY_AND_ASSIGN(DriSurface); | 
|  57 }; |  54 }; | 
|  58  |  55  | 
|  59 }  // namespace ui |  56 }  // namespace ui | 
|  60  |  57  | 
|  61 #endif  // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ |  58 #endif  // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ | 
| OLD | NEW |