Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / ui / ozone / platform / dri / dri_surface_factory.h
blob2b3eb4fd4232a3cb201c5feeba51c635c7256761
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_
8 #include <map>
9 #include <vector>
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"
17 namespace ui {
19 class DriBuffer;
20 class DriWindowDelegateManager;
21 class DriWrapper;
22 class ScreenManager;
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
27 // path.
28 class DriSurfaceFactory : public SurfaceFactoryOzone,
29 public HardwareCursorDelegate {
30 public:
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.
39 enum HardwareState {
40 UNINITIALIZED,
41 INITIALIZED,
42 FAILED,
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;
66 protected:
67 // Draw the last set cursor & update the cursor plane.
68 void ResetCursor();
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.
76 HardwareState state_;
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_;
84 int cursor_frame_;
85 int cursor_frame_delay_ms_;
86 base::RepeatingTimer<DriSurfaceFactory> cursor_timer_;
88 DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory);
91 } // namespace ui
93 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_