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_CACA_CACA_CONNECTION_H_ | 5 #ifndef UI_OZONE_PLATFORM_CACA_CACA_CONNECTION_H_ |
6 #define UI_OZONE_PLATFORM_CACA_CACA_CONNECTION_H_ | 6 #define UI_OZONE_PLATFORM_CACA_CACA_CONNECTION_H_ |
7 | 7 |
8 #include <caca.h> | 8 #include <caca.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "ui/gfx/geometry/size.h" | 11 #include "ui/gfx/geometry/size.h" |
| 12 #include "ui/ozone/platform/caca/scoped_caca_types.h" |
12 | 13 |
13 namespace ui { | 14 namespace ui { |
14 | 15 |
15 // Basic initialization of Libcaca. This needs to be shared between SFO and EFO | 16 // Basic initialization of Libcaca. This needs to be shared between SFO and EFO |
16 // since both need the |display_| to draw and process events respectively. | 17 // since both need the |display_| to draw and process events respectively. |
17 // Note, |canvas_| needs to be here since it is needed for creating a | 18 // Note, |canvas_| needs to be here since it is needed for creating a |
18 // |display_|. | 19 // |display_|. |
19 class CacaConnection { | 20 class CacaConnection { |
20 public: | 21 public: |
21 CacaConnection(); | 22 CacaConnection(); |
22 ~CacaConnection(); | 23 ~CacaConnection(); |
23 | 24 |
24 void Initialize(); | 25 bool Initialize(); |
25 | 26 |
26 // This is the Caca canvas size. | 27 // This is the Caca canvas size. |
27 gfx::Size physical_size() const { return physical_size_; } | 28 gfx::Size physical_size() const { return physical_size_; } |
28 gfx::Size bitmap_size() const { return bitmap_size_; } | 29 gfx::Size bitmap_size() const { return bitmap_size_; } |
29 caca_display_t* display() const { return display_; } | 30 caca_display_t* display() const { return display_.get(); } |
30 | 31 |
31 private: | 32 private: |
32 caca_canvas_t* canvas_; | 33 // Sync sizes with libcaca. |
33 caca_display_t* display_; | 34 void UpdateDisplaySize(); |
| 35 |
| 36 ScopedCacaCanvas canvas_; |
| 37 ScopedCacaDisplay display_; |
34 | 38 |
35 // Size of the console in characters. This can be changed by setting | 39 // Size of the console in characters. This can be changed by setting |
36 // CACA_GEOMETRY environment variable. | 40 // CACA_GEOMETRY environment variable. |
37 gfx::Size physical_size_; | 41 gfx::Size physical_size_; |
38 | 42 |
39 // Size of the backing buffer we draw into. Size in pixels. | 43 // Size of the backing buffer we draw into. Size in pixels. |
40 gfx::Size bitmap_size_; | 44 gfx::Size bitmap_size_; |
41 | 45 |
42 DISALLOW_COPY_AND_ASSIGN(CacaConnection); | 46 DISALLOW_COPY_AND_ASSIGN(CacaConnection); |
43 }; | 47 }; |
44 | 48 |
45 } // namespace ui | 49 } // namespace ui |
46 | 50 |
47 #endif // UI_OZONE_PLATFORM_CACA_CACA_CONNECTION_H_ | 51 #endif // UI_OZONE_PLATFORM_CACA_CACA_CONNECTION_H_ |
OLD | NEW |