| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ | |
| 6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 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" | |
| 16 | |
| 17 namespace ui { | |
| 18 | |
| 19 class DriBuffer; | |
| 20 class DriWindowDelegateManager; | |
| 21 class DriWrapper; | |
| 22 class ScreenManager; | |
| 23 class SurfaceOzoneCanvas; | |
| 24 | |
| 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; | |
| 32 | |
| 33 DriSurfaceFactory(DriWrapper* drm, | |
| 34 ScreenManager* screen_manager, | |
| 35 DriWindowDelegateManager* window_manager); | |
| 36 virtual ~DriSurfaceFactory(); | |
| 37 | |
| 38 // Describes the state of the hardware after initialization. | |
| 39 enum HardwareState { | |
| 40 UNINITIALIZED, | |
| 41 INITIALIZED, | |
| 42 FAILED, | |
| 43 }; | |
| 44 | |
| 45 // Open the display device. | |
| 46 HardwareState InitializeHardware(); | |
| 47 | |
| 48 // Close the display device. | |
| 49 void ShutdownHardware(); | |
| 50 | |
| 51 // SurfaceFactoryOzone: | |
| 52 virtual scoped_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget( | |
| 53 gfx::AcceleratedWidget widget) override; | |
| 54 virtual bool LoadEGLGLES2Bindings( | |
| 55 AddGLLibraryCallback add_gl_library, | |
| 56 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; | |
| 57 | |
| 58 // HardwareCursorDelegate: | |
| 59 virtual void SetHardwareCursor(gfx::AcceleratedWidget widget, | |
| 60 const std::vector<SkBitmap>& bitmaps, | |
| 61 const gfx::Point& location, | |
| 62 int frame_delay_ms) override; | |
| 63 virtual void MoveHardwareCursor(gfx::AcceleratedWidget window, | |
| 64 const gfx::Point& location) override; | |
| 65 | |
| 66 protected: | |
| 67 // Draw the last set cursor & update the cursor plane. | |
| 68 void ResetCursor(); | |
| 69 | |
| 70 // Draw next frame in an animated cursor. | |
| 71 void OnCursorAnimationTimeout(); | |
| 72 | |
| 73 DriWrapper* drm_; // Not owned. | |
| 74 ScreenManager* screen_manager_; // Not owned. | |
| 75 DriWindowDelegateManager* window_manager_; // Not owned. | |
| 76 HardwareState state_; | |
| 77 | |
| 78 scoped_refptr<DriBuffer> cursor_buffers_[2]; | |
| 79 int cursor_frontbuffer_; | |
| 80 | |
| 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_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory); | |
| 89 }; | |
| 90 | |
| 91 } // namespace ui | |
| 92 | |
| 93 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_ | |
| OLD | NEW |