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
3 // found in the LICENSE file.
5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_
6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer/timer.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h"
15 #include "ui/ozone/public/surface_factory_ozone.h"
20 class DriWindowDelegateManager
;
23 class SurfaceOzoneCanvas
;
25 // SurfaceFactoryOzone implementation on top of DRM/KMS using dumb buffers.
26 // This implementation is used in conjunction with the software rendering
28 class DriSurfaceFactory
: public SurfaceFactoryOzone
,
29 public HardwareCursorDelegate
{
31 static const gfx::AcceleratedWidget kDefaultWidgetHandle
;
33 DriSurfaceFactory(DriWrapper
* drm
,
34 ScreenManager
* screen_manager
,
35 DriWindowDelegateManager
* window_manager
);
36 ~DriSurfaceFactory() override
;
38 // Describes the state of the hardware after initialization.
45 // Open the display device.
46 HardwareState
InitializeHardware();
48 // Close the display device.
49 void ShutdownHardware();
51 // SurfaceFactoryOzone:
52 scoped_ptr
<SurfaceOzoneCanvas
> CreateCanvasForWidget(
53 gfx::AcceleratedWidget widget
) override
;
54 bool LoadEGLGLES2Bindings(
55 AddGLLibraryCallback add_gl_library
,
56 SetGLGetProcAddressProcCallback set_gl_get_proc_address
) override
;
58 // HardwareCursorDelegate:
59 void SetHardwareCursor(gfx::AcceleratedWidget widget
,
60 const std::vector
<SkBitmap
>& bitmaps
,
61 const gfx::Point
& location
,
62 int frame_delay_ms
) override
;
63 void MoveHardwareCursor(gfx::AcceleratedWidget window
,
64 const gfx::Point
& location
) override
;
67 // Draw the last set cursor & update the cursor plane.
70 // Draw next frame in an animated cursor.
71 void OnCursorAnimationTimeout();
73 DriWrapper
* drm_
; // Not owned.
74 ScreenManager
* screen_manager_
; // Not owned.
75 DriWindowDelegateManager
* window_manager_
; // Not owned.
78 scoped_refptr
<DriBuffer
> cursor_buffers_
[2];
79 int cursor_frontbuffer_
;
81 gfx::AcceleratedWidget cursor_widget_
;
82 std::vector
<SkBitmap
> cursor_bitmaps_
;
83 gfx::Point cursor_location_
;
85 int cursor_frame_delay_ms_
;
86 base::RepeatingTimer
<DriSurfaceFactory
> cursor_timer_
;
88 DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory
);
93 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_