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_
10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h"
13 #include "ui/ozone/public/surface_factory_ozone.h"
20 class SurfaceOzoneCanvas;
22 // SurfaceFactoryOzone implementation on top of DRM/KMS using dumb buffers.
23 // This implementation is used in conjunction with the software rendering
25 class DriSurfaceFactory : public ui::SurfaceFactoryOzone,
26 public HardwareCursorDelegate {
28 static const gfx::AcceleratedWidget kDefaultWidgetHandle;
30 DriSurfaceFactory(DriWrapper* drm, ScreenManager* screen_manager);
31 virtual ~DriSurfaceFactory();
33 // Describes the state of the hardware after initialization.
40 // Open the display device.
41 virtual HardwareState InitializeHardware();
43 // Close the display device.
44 virtual void ShutdownHardware();
46 virtual scoped_ptr<ui::SurfaceOzoneCanvas> CreateCanvasForWidget(
47 gfx::AcceleratedWidget w) OVERRIDE;
48 virtual bool LoadEGLGLES2Bindings(
49 AddGLLibraryCallback add_gl_library,
50 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE;
52 // Create a new window/surface/widget identifier.
53 gfx::AcceleratedWidget GetAcceleratedWidget();
55 // Determine dimensions of a widget.
56 gfx::Size GetWidgetSize(gfx::AcceleratedWidget w);
58 // HardwareCursorDelegate:
59 virtual void SetHardwareCursor(gfx::AcceleratedWidget window,
60 const SkBitmap& image,
61 const gfx::Point& location) OVERRIDE;
62 virtual void MoveHardwareCursor(gfx::AcceleratedWidget window,
63 const gfx::Point& location) OVERRIDE;
66 // Draw the last set cursor & update the cursor plane.
67 void ResetCursor(gfx::AcceleratedWidget w);
69 DriWrapper* drm_; // Not owned.
70 ScreenManager* screen_manager_; // Not owned.
74 int allocated_widgets_;
76 scoped_refptr<DriBuffer> cursor_buffers_[2];
77 int cursor_frontbuffer_;
79 SkBitmap cursor_bitmap_;
80 gfx::Point cursor_location_;
82 DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory);
87 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_FACTORY_H_