Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: ui/ozone/platform/dri/dri_wrapper.h

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/dri/dri_window_manager.cc ('k') | ui/ozone/platform/dri/dri_wrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_WRAPPER_H_
6 #define UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_
7
8 #include <stdint.h>
9
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "ui/gfx/overlay_transform.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/rect_f.h"
16 #include "ui/ozone/platform/dri/scoped_drm_types.h"
17
18 typedef struct _drmEventContext drmEventContext;
19 typedef struct _drmModeModeInfo drmModeModeInfo;
20
21 struct SkImageInfo;
22
23 namespace ui {
24
25 // Wraps DRM calls into a nice interface. Used to provide different
26 // implementations of the DRM calls. For the actual implementation the DRM API
27 // would be called. In unit tests this interface would be stubbed.
28 class DriWrapper {
29 public:
30 DriWrapper(const char* device_path);
31 virtual ~DriWrapper();
32
33 // Open device.
34 virtual void Initialize();
35
36 // Get the CRTC state. This is generally used to save state before using the
37 // CRTC. When the user finishes using the CRTC, the user should restore the
38 // CRTC to it's initial state. Use |SetCrtc| to restore the state.
39 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id);
40
41 // Used to configure CRTC with ID |crtc_id| to use the connector in
42 // |connectors|. The CRTC will be configured with mode |mode| and will display
43 // the framebuffer with ID |framebuffer|. Before being able to display the
44 // framebuffer, it should be registered with the CRTC using |AddFramebuffer|.
45 virtual bool SetCrtc(uint32_t crtc_id,
46 uint32_t framebuffer,
47 std::vector<uint32_t> connectors,
48 drmModeModeInfo* mode);
49
50 // Used to set a specific configuration to the CRTC. Normally this function
51 // would be called with a CRTC saved state (from |GetCrtc|) to restore it to
52 // its original configuration.
53 virtual bool SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors);
54
55 virtual bool DisableCrtc(uint32_t crtc_id);
56
57 // Returns the connector properties for |connector_id|.
58 virtual ScopedDrmConnectorPtr GetConnector(uint32_t connector_id);
59
60 // Register a buffer with the CRTC. On successful registration, the CRTC will
61 // assign a framebuffer ID to |framebuffer|.
62 virtual bool AddFramebuffer(uint32_t width,
63 uint32_t height,
64 uint8_t depth,
65 uint8_t bpp,
66 uint32_t stride,
67 uint32_t handle,
68 uint32_t* framebuffer);
69
70 // Deregister the given |framebuffer|.
71 virtual bool RemoveFramebuffer(uint32_t framebuffer);
72
73 // Get the DRM details associated with |framebuffer|.
74 virtual ScopedDrmFramebufferPtr GetFramebuffer(uint32_t framebuffer);
75
76 // Schedules a pageflip for CRTC |crtc_id|. This function will return
77 // immediately. Upon completion of the pageflip event, the CRTC will be
78 // displaying the buffer with ID |framebuffer| and will have a DRM event
79 // queued on |fd_|. |data| is a generic pointer to some information the user
80 // will receive when processing the pageflip event.
81 virtual bool PageFlip(uint32_t crtc_id, uint32_t framebuffer, void* data);
82
83 // Schedule an overlay to be show during the page flip for CRTC |crtc_id|.
84 // |source| location from |framebuffer| will be shown on overlay
85 // |overlay_plane|, in the bounds specified by |location| on the screen.
86 virtual bool PageFlipOverlay(uint32_t crtc_id,
87 uint32_t framebuffer,
88 const gfx::Rect& location,
89 const gfx::RectF& source,
90 int overlay_plane);
91
92 // Returns the property with name |name| associated with |connector|. Returns
93 // NULL if property not found. If the returned value is valid, it must be
94 // released using FreeProperty().
95 virtual ScopedDrmPropertyPtr GetProperty(drmModeConnector* connector,
96 const char* name);
97
98 // Sets the value of property with ID |property_id| to |value|. The property
99 // is applied to the connector with ID |connector_id|.
100 virtual bool SetProperty(uint32_t connector_id,
101 uint32_t property_id,
102 uint64_t value);
103
104 // Return a binary blob associated with |connector|. The binary blob is
105 // associated with the property with name |name|. Return NULL if the property
106 // could not be found or if the property does not have a binary blob. If valid
107 // the returned object must be freed using FreePropertyBlob().
108 virtual ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector,
109 const char* name);
110
111 // Set the cursor to be displayed in CRTC |crtc_id|. (width, height) is the
112 // cursor size pointed by |handle|.
113 virtual bool SetCursor(uint32_t crtc_id,
114 uint32_t handle,
115 const gfx::Size& size);
116
117
118 // Move the cursor on CRTC |crtc_id| to (x, y);
119 virtual bool MoveCursor(uint32_t crtc_id, const gfx::Point& point);
120
121 virtual void HandleEvent(drmEventContext& event);
122
123 virtual bool CreateDumbBuffer(const SkImageInfo& info,
124 uint32_t* handle,
125 uint32_t* stride,
126 void** pixels);
127
128 virtual void DestroyDumbBuffer(const SkImageInfo& info,
129 uint32_t handle,
130 uint32_t stride,
131 void* pixels);
132
133 int get_fd() const { return fd_; }
134
135 protected:
136 // The file descriptor associated with this wrapper. All DRM operations will
137 // be performed using this FD.
138 int fd_;
139
140 private:
141 // Path to DRM device.
142 const char* device_path_;
143
144 DISALLOW_COPY_AND_ASSIGN(DriWrapper);
145 };
146
147 } // namespace ui
148
149 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/dri_window_manager.cc ('k') | ui/ozone/platform/dri/dri_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698