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_FACTORY_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ |
6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ | 6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h" | 12 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h" |
13 #include "ui/ozone/public/surface_factory_ozone.h" | 13 #include "ui/ozone/public/surface_factory_ozone.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 class DriBuffer; | 17 class DriBuffer; |
| 18 class DriWindowManager; |
18 class DriWrapper; | 19 class DriWrapper; |
19 class ScreenManager; | 20 class ScreenManager; |
20 class SurfaceOzoneCanvas; | 21 class SurfaceOzoneCanvas; |
21 | 22 |
22 // SurfaceFactoryOzone implementation on top of DRM/KMS using dumb buffers. | 23 // SurfaceFactoryOzone implementation on top of DRM/KMS using dumb buffers. |
23 // This implementation is used in conjunction with the software rendering | 24 // This implementation is used in conjunction with the software rendering |
24 // path. | 25 // path. |
25 class DriSurfaceFactory : public ui::SurfaceFactoryOzone, | 26 class DriSurfaceFactory : public SurfaceFactoryOzone, |
26 public HardwareCursorDelegate { | 27 public HardwareCursorDelegate { |
27 public: | 28 public: |
28 static const gfx::AcceleratedWidget kDefaultWidgetHandle; | 29 static const gfx::AcceleratedWidget kDefaultWidgetHandle; |
29 | 30 |
30 DriSurfaceFactory(DriWrapper* drm, ScreenManager* screen_manager); | 31 DriSurfaceFactory(DriWrapper* drm, |
| 32 ScreenManager* screen_manager, |
| 33 DriWindowManager* window_manager); |
31 virtual ~DriSurfaceFactory(); | 34 virtual ~DriSurfaceFactory(); |
32 | 35 |
33 // Describes the state of the hardware after initialization. | 36 // Describes the state of the hardware after initialization. |
34 enum HardwareState { | 37 enum HardwareState { |
35 UNINITIALIZED, | 38 UNINITIALIZED, |
36 INITIALIZED, | 39 INITIALIZED, |
37 FAILED, | 40 FAILED, |
38 }; | 41 }; |
39 | 42 |
40 // Open the display device. | 43 // Open the display device. |
41 virtual HardwareState InitializeHardware(); | 44 HardwareState InitializeHardware(); |
42 | 45 |
43 // Close the display device. | 46 // Close the display device. |
44 virtual void ShutdownHardware(); | 47 void ShutdownHardware(); |
45 | 48 |
46 virtual scoped_ptr<ui::SurfaceOzoneCanvas> CreateCanvasForWidget( | 49 // SurfaceFactoryOzone: |
47 gfx::AcceleratedWidget w) OVERRIDE; | 50 virtual scoped_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget( |
| 51 gfx::AcceleratedWidget widget) OVERRIDE; |
48 virtual bool LoadEGLGLES2Bindings( | 52 virtual bool LoadEGLGLES2Bindings( |
49 AddGLLibraryCallback add_gl_library, | 53 AddGLLibraryCallback add_gl_library, |
50 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE; | 54 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE; |
51 | 55 |
52 // Create a new window/surface/widget identifier. | |
53 gfx::AcceleratedWidget GetAcceleratedWidget(); | |
54 | |
55 // Determine dimensions of a widget. | |
56 gfx::Size GetWidgetSize(gfx::AcceleratedWidget w); | |
57 | |
58 // HardwareCursorDelegate: | 56 // HardwareCursorDelegate: |
59 virtual void SetHardwareCursor(gfx::AcceleratedWidget window, | 57 virtual void SetHardwareCursor(gfx::AcceleratedWidget window, |
60 const SkBitmap& image, | 58 const SkBitmap& image, |
61 const gfx::Point& location) OVERRIDE; | 59 const gfx::Point& location) OVERRIDE; |
62 virtual void MoveHardwareCursor(gfx::AcceleratedWidget window, | 60 virtual void MoveHardwareCursor(gfx::AcceleratedWidget window, |
63 const gfx::Point& location) OVERRIDE; | 61 const gfx::Point& location) OVERRIDE; |
64 | 62 |
65 protected: | 63 protected: |
66 // Draw the last set cursor & update the cursor plane. | 64 // Draw the last set cursor & update the cursor plane. |
67 void ResetCursor(gfx::AcceleratedWidget w); | 65 void ResetCursor(gfx::AcceleratedWidget w); |
68 | 66 |
69 DriWrapper* drm_; // Not owned. | 67 DriWrapper* drm_; // Not owned. |
70 ScreenManager* screen_manager_; // Not owned. | 68 ScreenManager* screen_manager_; // Not owned. |
| 69 DriWindowManager* window_manager_; // Not owned. |
71 HardwareState state_; | 70 HardwareState state_; |
72 | 71 |
73 // Active outputs. | |
74 int allocated_widgets_; | |
75 | |
76 scoped_refptr<DriBuffer> cursor_buffers_[2]; | 72 scoped_refptr<DriBuffer> cursor_buffers_[2]; |
77 int cursor_frontbuffer_; | 73 int cursor_frontbuffer_; |
78 | 74 |
79 SkBitmap cursor_bitmap_; | 75 SkBitmap cursor_bitmap_; |
80 gfx::Point cursor_location_; | 76 gfx::Point cursor_location_; |
81 | 77 |
82 DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory); | 78 DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory); |
83 }; | 79 }; |
84 | 80 |
85 } // namespace ui | 81 } // namespace ui |
86 | 82 |
87 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ | 83 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ |
OLD | NEW |