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/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
11 #include "ui/gfx/skia_util.h" | 11 #include "ui/gfx/skia_util.h" |
12 #include "ui/ozone/platform/dri/scanout_surface.h" | 12 #include "ui/ozone/platform/dri/scanout_surface.h" |
13 | 13 |
14 class SkCanvas; | 14 class SkCanvas; |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 class DriBuffer; | 18 class DriBuffer; |
19 class DriWrapper; | 19 class DriWrapper; |
20 | 20 |
21 // An implementation of ScanoutSurface which uses dumb buffers (used for | 21 // An implementation of ScanoutSurface which uses dumb buffers (used for |
22 // software rendering). | 22 // software rendering). |
23 class DriSurface : public ScanoutSurface { | 23 class DriSurface : public ScanoutSurface { |
24 public: | 24 public: |
25 DriSurface(DriWrapper* dri, const gfx::Size& size); | 25 DriSurface(DriWrapper* dri, const gfx::Size& size); |
26 virtual ~DriSurface(); | 26 virtual ~DriSurface(); |
27 | 27 |
28 // Get a Skia canvas for a backbuffer. | 28 // Get a Skia canvas for a backbuffer. |
29 SkCanvas* GetDrawableForWidget(); | 29 SkCanvas* GetDrawableForWidget(); |
| 30 scoped_refptr<DriBuffer> backbuffer() const { |
| 31 return bitmaps_[front_buffer_ ^ 1]; |
| 32 } |
30 | 33 |
31 // ScanoutSurface: | 34 // ScanoutSurface: |
32 virtual bool Initialize() OVERRIDE; | 35 virtual bool Initialize() OVERRIDE; |
33 virtual uint32_t GetFramebufferId() const OVERRIDE; | 36 virtual uint32_t GetFramebufferId() const OVERRIDE; |
34 virtual uint32_t GetHandle() const OVERRIDE; | 37 virtual uint32_t GetHandle() const OVERRIDE; |
35 virtual void PreSwapBuffers() OVERRIDE; | 38 virtual void PreSwapBuffers() OVERRIDE; |
36 virtual void SwapBuffers() OVERRIDE; | 39 virtual void SwapBuffers() OVERRIDE; |
37 virtual gfx::Size Size() const OVERRIDE; | 40 virtual gfx::Size Size() const OVERRIDE; |
38 | 41 |
39 private: | 42 private: |
40 DriBuffer* frontbuffer() const { return bitmaps_[front_buffer_].get(); } | |
41 DriBuffer* backbuffer() const { return bitmaps_[front_buffer_ ^ 1].get(); } | |
42 | |
43 // Stores the connection to the graphics card. Pointer not owned by this | 43 // Stores the connection to the graphics card. Pointer not owned by this |
44 // class. | 44 // class. |
45 DriWrapper* dri_; | 45 DriWrapper* dri_; |
46 | 46 |
47 // The actual buffers used for painting. | 47 // The actual buffers used for painting. |
48 scoped_refptr<DriBuffer> bitmaps_[2]; | 48 scoped_refptr<DriBuffer> bitmaps_[2]; |
49 | 49 |
50 // Keeps track of which bitmap is |buffers_| is the frontbuffer. | 50 // Keeps track of which bitmap is |buffers_| is the frontbuffer. |
51 int front_buffer_; | 51 int front_buffer_; |
52 | 52 |
53 // Surface size. | 53 // Surface size. |
54 gfx::Size size_; | 54 gfx::Size size_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(DriSurface); | 56 DISALLOW_COPY_AND_ASSIGN(DriSurface); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace ui | 59 } // namespace ui |
60 | 60 |
61 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ | 61 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ |
OLD | NEW |