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_WINDOW_H_ |
6 #define UI_OZONE_PLATFORM_CACA_CACA_CONNECTION_H_ | 6 #define UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_ |
7 | 7 |
8 #include <caca.h> | 8 #include <caca.h> |
9 | 9 |
| 10 #include "base/debug/stack_trace.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
11 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/ozone/common/platform_window_base.h" |
12 #include "ui/ozone/platform/caca/scoped_caca_types.h" | 15 #include "ui/ozone/platform/caca/scoped_caca_types.h" |
13 | 16 |
14 namespace ui { | 17 namespace ui { |
15 | 18 |
| 19 class CacaEventFactory; |
| 20 class CacaWindowManager; |
| 21 class PlatformWindowDelegate; |
| 22 |
16 // Basic initialization of Libcaca. This needs to be shared between SFO and EFO | 23 // Basic initialization of Libcaca. This needs to be shared between SFO and EFO |
17 // since both need the |display_| to draw and process events respectively. | 24 // since both need the |display_| to draw and process events respectively. |
18 // Note, |canvas_| needs to be here since it is needed for creating a | 25 // Note, |canvas_| needs to be here since it is needed for creating a |
19 // |display_|. | 26 // |display_|. |
20 class CacaConnection { | 27 class CacaWindow : public PlatformWindowBase { |
21 public: | 28 public: |
22 CacaConnection(); | 29 CacaWindow(PlatformWindowDelegate* delegate, |
23 ~CacaConnection(); | 30 CacaWindowManager* manager, |
| 31 CacaEventFactory* event_factory, |
| 32 const gfx::Rect& bounds); |
| 33 virtual ~CacaWindow(); |
24 | 34 |
25 bool Initialize(); | 35 bool Initialize(); |
26 | 36 |
| 37 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
| 38 |
| 39 virtual gfx::Rect GetBounds() const OVERRIDE; |
| 40 |
| 41 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE {} |
| 42 |
| 43 void OnCacaQuit(); |
| 44 |
| 45 void OnCacaResize(); |
| 46 |
27 // This is the Caca canvas size. | 47 // This is the Caca canvas size. |
28 gfx::Size physical_size() const { return physical_size_; } | 48 gfx::Size physical_size() const { return physical_size_; } |
29 gfx::Size bitmap_size() const { return bitmap_size_; } | 49 gfx::Size bitmap_size() const { return bitmap_size_; } |
30 caca_display_t* display() const { return display_.get(); } | 50 caca_display_t* display() const { return display_.get(); } |
31 | 51 |
32 private: | 52 private: |
| 53 // Event polling. |
| 54 void TryProcessingEvent(); |
| 55 |
33 // Sync sizes with libcaca. | 56 // Sync sizes with libcaca. |
34 void UpdateDisplaySize(); | 57 void UpdateDisplaySize(); |
35 | 58 |
| 59 PlatformWindowDelegate* delegate_; |
| 60 CacaWindowManager* manager_; |
| 61 CacaEventFactory* event_factory_; |
| 62 gfx::AcceleratedWidget widget_; |
| 63 |
36 ScopedCacaCanvas canvas_; | 64 ScopedCacaCanvas canvas_; |
37 ScopedCacaDisplay display_; | 65 ScopedCacaDisplay display_; |
38 | 66 |
39 // Size of the console in characters. This can be changed by setting | 67 // Size of the console in characters. This can be changed by setting |
40 // CACA_GEOMETRY environment variable. | 68 // CACA_GEOMETRY environment variable. |
41 gfx::Size physical_size_; | 69 gfx::Size physical_size_; |
42 | 70 |
43 // Size of the backing buffer we draw into. Size in pixels. | 71 // Size of the backing buffer we draw into. Size in pixels. |
44 gfx::Size bitmap_size_; | 72 gfx::Size bitmap_size_; |
45 | 73 |
46 DISALLOW_COPY_AND_ASSIGN(CacaConnection); | 74 base::WeakPtrFactory<CacaWindow> weak_ptr_factory_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(CacaWindow); |
47 }; | 77 }; |
48 | 78 |
49 } // namespace ui | 79 } // namespace ui |
50 | 80 |
51 #endif // UI_OZONE_PLATFORM_CACA_CACA_CONNECTION_H_ | 81 #endif // UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_ |
OLD | NEW |