blob: c182bf92907a6992004b41317986867090e735fb [file] [log] [blame]
Alex Vakulenkoa8a92782017-01-27 14:41:57 -08001#ifndef ANDROID_DVR_SERVICES_DISPLAYD_HARDWARE_COMPOSER_H_
2#define ANDROID_DVR_SERVICES_DISPLAYD_HARDWARE_COMPOSER_H_
3
Corey Tabaka2251d822017-04-20 16:04:07 -07004#include <ui/GraphicBuffer.h>
5#include "DisplayHardware/ComposerHal.h"
6#include "hwc_types.h"
Alex Vakulenkoa8a92782017-01-27 14:41:57 -08007
Corey Tabaka2251d822017-04-20 16:04:07 -07008#include <hardware/gralloc.h>
9#include <log/log.h>
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080010
11#include <array>
12#include <condition_variable>
13#include <memory>
14#include <mutex>
15#include <thread>
16#include <tuple>
17#include <vector>
18
John Bates954796e2017-05-11 11:00:31 -070019#include <dvr/dvr_vrflinger_config_buffer.h>
Corey Tabaka2251d822017-04-20 16:04:07 -070020#include <dvr/pose_client.h>
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080021#include <pdx/file_handle.h>
Corey Tabaka2251d822017-04-20 16:04:07 -070022#include <pdx/rpc/variant.h>
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080023#include <private/dvr/buffer_hub_client.h>
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080024
25#include "acquired_buffer.h"
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080026#include "display_surface.h"
27
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080028// Hardware composer HAL doesn't define HWC_TRANSFORM_NONE as of this writing.
29#ifndef HWC_TRANSFORM_NONE
30#define HWC_TRANSFORM_NONE static_cast<hwc_transform_t>(0)
31#endif
32
33namespace android {
34namespace dvr {
35
36// Basic display metrics for physical displays. Dimensions and densities are
37// relative to the physical display orientation, which may be different from the
38// logical display orientation exposed to applications.
39struct HWCDisplayMetrics {
40 int width;
41 int height;
42 struct {
43 int x;
44 int y;
45 } dpi;
46 int vsync_period_ns;
47};
48
49// Layer represents the connection between a hardware composer layer and the
50// source supplying buffers for the layer's contents.
51class Layer {
52 public:
Corey Tabaka2251d822017-04-20 16:04:07 -070053 Layer() {}
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080054
Corey Tabaka2251d822017-04-20 16:04:07 -070055 // Sets up the global state used by all Layer instances. This must be called
56 // before using any Layer methods.
57 static void InitializeGlobals(Hwc2::Composer* hwc2_hidl,
58 const HWCDisplayMetrics* metrics);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080059
60 // Releases any shared pointers and fence handles held by this instance.
61 void Reset();
62
63 // Sets up the layer to use a display surface as its content source. The Layer
Corey Tabaka2251d822017-04-20 16:04:07 -070064 // automatically handles ACQUIRE/RELEASE phases for the surface's buffer train
65 // every frame.
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080066 //
67 // |blending| receives HWC_BLENDING_* values.
68 // |transform| receives HWC_TRANSFORM_* values.
69 // |composition_type| receives either HWC_FRAMEBUFFER for most layers or
70 // HWC_FRAMEBUFFER_TARGET (unless you know what you are doing).
Corey Tabaka2251d822017-04-20 16:04:07 -070071 // |index| is the index of this surface in the DirectDisplaySurface array.
72 void Setup(const std::shared_ptr<DirectDisplaySurface>& surface,
73 HWC::BlendMode blending, HWC::Transform transform,
74 HWC::Composition composition_type, size_t z_roder);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080075
76 // Sets up the layer to use a direct buffer as its content source. No special
77 // handling of the buffer is performed; responsibility for updating or
78 // changing the buffer each frame is on the caller.
79 //
80 // |blending| receives HWC_BLENDING_* values.
81 // |transform| receives HWC_TRANSFORM_* values.
82 // |composition_type| receives either HWC_FRAMEBUFFER for most layers or
83 // HWC_FRAMEBUFFER_TARGET (unless you know what you are doing).
Corey Tabaka2251d822017-04-20 16:04:07 -070084 void Setup(const std::shared_ptr<IonBuffer>& buffer, HWC::BlendMode blending,
85 HWC::Transform transform, HWC::Composition composition_type,
86 size_t z_order);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080087
88 // Layers that use a direct IonBuffer should call this each frame to update
89 // which buffer will be used for the next PostLayers.
Corey Tabaka2251d822017-04-20 16:04:07 -070090 void UpdateBuffer(const std::shared_ptr<IonBuffer>& buffer);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -080091
92 // Sets up the hardware composer layer for the next frame. When the layer is
93 // associated with a display surface, this method automatically ACQUIRES a new
94 // buffer if one is available.
95 void Prepare();
96
97 // After calling prepare, if this frame is to be dropped instead of passing
98 // along to the HWC, call Drop to close the contained fence(s).
99 void Drop();
100
101 // Performs fence bookkeeping after the frame has been posted to hardware
102 // composer.
103 void Finish(int release_fence_fd);
104
105 // Sets the blending for the layer. |blending| receives HWC_BLENDING_* values.
Corey Tabaka2251d822017-04-20 16:04:07 -0700106 void SetBlending(HWC::BlendMode blending);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800107
Corey Tabaka2251d822017-04-20 16:04:07 -0700108 // Sets the z-order of this layer
109 void SetZOrder(size_t z_order);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800110
111 // Gets the current IonBuffer associated with this layer. Ownership of the
112 // buffer DOES NOT pass to the caller and the pointer is not guaranteed to
113 // remain valid across calls to Layer::Setup(), Layer::Prepare(), or
114 // Layer::Reset(). YOU HAVE BEEN WARNED.
115 IonBuffer* GetBuffer();
116
Corey Tabaka2251d822017-04-20 16:04:07 -0700117 HWC::Composition GetCompositionType() const { return composition_type_; }
118 HWC::Layer GetLayerHandle() const { return hardware_composer_layer_; }
119 bool IsLayerSetup() const { return !source_.empty(); }
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800120
121 // Applies all of the settings to this layer using the hwc functions
122 void UpdateLayerSettings();
123
124 int GetSurfaceId() const {
Corey Tabaka2251d822017-04-20 16:04:07 -0700125 int surface_id = -1;
126 pdx::rpc::IfAnyOf<SourceSurface>::Call(
127 &source_, [&surface_id](const SourceSurface& surface_source) {
128 surface_id = surface_source.surface->surface_id();
129 });
130 return surface_id;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800131 }
132
133 private:
134 void CommonLayerSetup();
135
Corey Tabaka2251d822017-04-20 16:04:07 -0700136 static Hwc2::Composer* hwc2_hidl_;
137 static const HWCDisplayMetrics* display_metrics_;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800138
139 // The hardware composer layer and metrics to use during the prepare cycle.
Corey Tabaka2251d822017-04-20 16:04:07 -0700140 hwc2_layer_t hardware_composer_layer_ = 0;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800141
142 // Layer properties used to setup the hardware composer layer during the
143 // Prepare phase.
Corey Tabaka2251d822017-04-20 16:04:07 -0700144 size_t z_order_ = 0;
145 HWC::BlendMode blending_ = HWC::BlendMode::None;
146 HWC::Transform transform_ = HWC::Transform::None;
147 HWC::Composition composition_type_ = HWC::Composition::Invalid;
148 HWC::Composition target_composition_type_ = HWC::Composition::Device;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800149
Corey Tabaka2251d822017-04-20 16:04:07 -0700150 // State when the layer is connected to a surface. Provides the same interface
151 // as SourceBuffer to simplify internal use by Layer.
152 struct SourceSurface {
153 std::shared_ptr<DirectDisplaySurface> surface;
154 AcquiredBuffer acquired_buffer;
155 pdx::LocalHandle release_fence;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800156
Corey Tabaka2251d822017-04-20 16:04:07 -0700157 SourceSurface(const std::shared_ptr<DirectDisplaySurface>& surface)
158 : surface(surface) {}
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800159
Corey Tabaka2251d822017-04-20 16:04:07 -0700160 // Attempts to acquire a new buffer from the surface and return a tuple with
161 // width, height, buffer handle, and fence. If a new buffer is not available
162 // the previous buffer is returned or an empty value if no buffer has ever
163 // been posted. When a new buffer is acquired the previous buffer's release
164 // fence is passed out automatically.
165 std::tuple<int, int, sp<GraphicBuffer>, pdx::LocalHandle> Acquire() {
166 if (surface->IsBufferAvailable()) {
167 acquired_buffer.Release(std::move(release_fence));
168 acquired_buffer = surface->AcquireCurrentBuffer();
169 ATRACE_ASYNC_END("BufferPost", acquired_buffer.buffer()->id());
170 }
171 if (!acquired_buffer.IsEmpty()) {
172 return std::make_tuple(acquired_buffer.buffer()->width(),
173 acquired_buffer.buffer()->height(),
174 acquired_buffer.buffer()->buffer()->buffer(),
175 acquired_buffer.ClaimAcquireFence());
176 } else {
177 return std::make_tuple(0, 0, nullptr, pdx::LocalHandle{});
178 }
179 }
180
181 void Finish(pdx::LocalHandle fence) { release_fence = std::move(fence); }
182
183 // Gets a pointer to the current acquired buffer or returns nullptr if there
184 // isn't one.
185 IonBuffer* GetBuffer() {
186 if (acquired_buffer.IsAvailable())
187 return acquired_buffer.buffer()->buffer();
188 else
189 return nullptr;
190 }
191
192 // Returns the surface id of the surface.
193 int GetSurfaceId() { return surface->surface_id(); }
194 };
195
196 // State when the layer is connected to a buffer. Provides the same interface
197 // as SourceSurface to simplify internal use by Layer.
198 struct SourceBuffer {
199 std::shared_ptr<IonBuffer> buffer;
200
201 std::tuple<int, int, sp<GraphicBuffer>, pdx::LocalHandle> Acquire() {
202 if (buffer)
203 return std::make_tuple(buffer->width(), buffer->height(),
204 buffer->buffer(), pdx::LocalHandle{});
205 else
206 return std::make_tuple(0, 0, nullptr, pdx::LocalHandle{});
207 }
208
209 void Finish(pdx::LocalHandle /*fence*/) {}
210
211 IonBuffer* GetBuffer() { return buffer.get(); }
212
213 int GetSurfaceId() const { return -1; }
214 };
215
216 // The underlying hardware composer layer is supplied buffers either from a
217 // surface buffer train or from a buffer directly.
218 pdx::rpc::Variant<SourceSurface, SourceBuffer> source_;
219
220 pdx::LocalHandle acquire_fence_;
221 bool surface_rect_functions_applied_ = false;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800222
223 Layer(const Layer&) = delete;
224 void operator=(const Layer&) = delete;
225};
226
227// HardwareComposer encapsulates the hardware composer HAL, exposing a
228// simplified API to post buffers to the display.
Steven Thomas050b2c82017-03-06 11:45:16 -0800229//
230// HardwareComposer is accessed by both the vr flinger dispatcher thread and the
231// surface flinger main thread, in addition to internally running a separate
232// thread for compositing/EDS and posting layers to the HAL. When changing how
233// variables are used or adding new state think carefully about which threads
234// will access the state and whether it needs to be synchronized.
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800235class HardwareComposer {
236 public:
237 // Type for vsync callback.
238 using VSyncCallback = std::function<void(int, int64_t, int64_t, uint32_t)>;
Corey Tabaka2251d822017-04-20 16:04:07 -0700239 using RequestDisplayCallback = std::function<void(bool)>;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800240
241 // Since there is no universal way to query the number of hardware layers,
242 // just set it to 4 for now.
Corey Tabaka2251d822017-04-20 16:04:07 -0700243 static constexpr size_t kMaxHardwareLayers = 4;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800244
245 HardwareComposer();
Corey Tabaka2251d822017-04-20 16:04:07 -0700246 HardwareComposer(Hwc2::Composer* hidl,
247 RequestDisplayCallback request_display_callback);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800248 ~HardwareComposer();
249
Stephen Kiazyk016e5e32017-02-21 17:09:22 -0800250 bool Initialize();
251
252 bool IsInitialized() const { return initialized_; }
253
Steven Thomas050b2c82017-03-06 11:45:16 -0800254 // Start the post thread if there's work to do (i.e. visible layers). This
255 // should only be called from surface flinger's main thread.
256 void Enable();
257 // Pause the post thread, blocking until the post thread has signaled that
258 // it's paused. This should only be called from surface flinger's main thread.
259 void Disable();
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800260
261 // Get the HMD display metrics for the current display.
Corey Tabaka2251d822017-04-20 16:04:07 -0700262 display::Metrics GetHmdDisplayMetrics() const;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800263
Corey Tabaka2251d822017-04-20 16:04:07 -0700264 HWC::Error GetDisplayAttribute(hwc2_display_t display, hwc2_config_t config,
265 hwc2_attribute_t attributes,
266 int32_t* out_value) const;
267 HWC::Error GetDisplayMetrics(hwc2_display_t display, hwc2_config_t config,
268 HWCDisplayMetrics* out_metrics) const;
269 std::string Dump();
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800270
271 void SetVSyncCallback(VSyncCallback callback);
272
273 // Metrics of the logical display, which is always landscape.
274 int DisplayWidth() const { return display_metrics_.width; }
275 int DisplayHeight() const { return display_metrics_.height; }
276 HWCDisplayMetrics display_metrics() const { return display_metrics_; }
277
278 // Metrics of the native display, which depends on the specific hardware
279 // implementation of the display.
280 HWCDisplayMetrics native_display_metrics() const {
281 return native_display_metrics_;
282 }
283
Corey Tabaka2251d822017-04-20 16:04:07 -0700284 // Sets the display surfaces to compose the hardware layer stack.
Steven Thomas050b2c82017-03-06 11:45:16 -0800285 void SetDisplaySurfaces(
Corey Tabaka2251d822017-04-20 16:04:07 -0700286 std::vector<std::shared_ptr<DirectDisplaySurface>> surfaces);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800287
John Bates954796e2017-05-11 11:00:31 -0700288 int OnNewGlobalBuffer(DvrGlobalBufferKey key, IonBuffer& ion_buffer);
289 void OnDeletedGlobalBuffer(DvrGlobalBufferKey key);
290
Steven Thomas3cfac282017-02-06 12:29:30 -0800291 void OnHardwareComposerRefresh();
292
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800293 private:
294 int32_t EnableVsync(bool enabled);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800295
296 class ComposerCallback : public Hwc2::IComposerCallback {
297 public:
298 ComposerCallback() {}
299
300 hardware::Return<void> onHotplug(Hwc2::Display /*display*/,
301 Connection /*connected*/) override {
302 // TODO(skiazyk): depending on how the server is implemented, we might
303 // have to set it up to synchronize with receiving this event, as it can
304 // potentially be a critical event for setting up state within the
305 // hwc2 module. That is, we (technically) should not call any other hwc
306 // methods until this method has been called after registering the
307 // callbacks.
308 return hardware::Void();
309 }
310
311 hardware::Return<void> onRefresh(Hwc2::Display /*display*/) override {
312 return hardware::Void();
313 }
314
315 hardware::Return<void> onVsync(Hwc2::Display /*display*/,
316 int64_t /*timestamp*/) override {
317 return hardware::Void();
318 }
319 };
320
Corey Tabaka2251d822017-04-20 16:04:07 -0700321 HWC::Error Validate(hwc2_display_t display);
322 HWC::Error Present(hwc2_display_t display);
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800323
324 void SetBacklightBrightness(int brightness);
325
Corey Tabaka2251d822017-04-20 16:04:07 -0700326 void PostLayers();
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800327 void PostThread();
328
Corey Tabaka2251d822017-04-20 16:04:07 -0700329 // The post thread has two controlling states:
330 // 1. Idle: no work to do (no visible surfaces).
331 // 2. Suspended: explicitly halted (system is not in VR mode).
332 // When either #1 or #2 is true then the post thread is quiescent, otherwise
333 // it is active.
334 using PostThreadStateType = uint32_t;
335 struct PostThreadState {
336 enum : PostThreadStateType {
337 Active = 0,
338 Idle = (1 << 0),
339 Suspended = (1 << 1),
340 Quit = (1 << 2),
341 };
342 };
343
344 void UpdatePostThreadState(uint32_t state, bool suspend);
345
Steven Thomas050b2c82017-03-06 11:45:16 -0800346 // Blocks until either event_fd becomes readable, or we're interrupted by a
347 // control thread. Any errors are returned as negative errno values. If we're
348 // interrupted, kPostThreadInterrupted will be returned.
Corey Tabaka2251d822017-04-20 16:04:07 -0700349 int PostThreadPollInterruptible(const pdx::LocalHandle& event_fd,
350 int requested_events);
Steven Thomas050b2c82017-03-06 11:45:16 -0800351
352 // BlockUntilVSync, WaitForVSync, and SleepUntil are all blocking calls made
353 // on the post thread that can be interrupted by a control thread. If
354 // interrupted, these calls return kPostThreadInterrupted.
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800355 int ReadWaitPPState();
Steven Thomas050b2c82017-03-06 11:45:16 -0800356 int BlockUntilVSync();
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800357 int ReadVSyncTimestamp(int64_t* timestamp);
358 int WaitForVSync(int64_t* timestamp);
359 int SleepUntil(int64_t wakeup_timestamp);
360
361 bool IsFramePendingInDriver() { return ReadWaitPPState() == 1; }
362
Corey Tabaka2251d822017-04-20 16:04:07 -0700363 // Reconfigures the layer stack if the display surfaces changed since the last
364 // frame. Called only from the post thread.
Steven Thomas050b2c82017-03-06 11:45:16 -0800365 bool UpdateLayerConfig();
Steven Thomas050b2c82017-03-06 11:45:16 -0800366
367 // Called on the post thread when the post thread is resumed.
368 void OnPostThreadResumed();
369 // Called on the post thread when the post thread is paused or quits.
370 void OnPostThreadPaused();
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800371
John Bates954796e2017-05-11 11:00:31 -0700372 // Map the given shared memory buffer to our broadcast ring to track updates
373 // to the config parameters.
374 int MapConfigBuffer(IonBuffer& ion_buffer);
375 void ConfigBufferDeleted();
376 // Poll for config udpates.
377 void UpdateConfigBuffer();
378
Stephen Kiazyk016e5e32017-02-21 17:09:22 -0800379 bool initialized_;
380
Corey Tabaka2251d822017-04-20 16:04:07 -0700381 // Hardware composer HAL device from SurfaceFlinger. VrFlinger does not own
382 // this pointer.
383 Hwc2::Composer* hwc2_hidl_;
384 RequestDisplayCallback request_display_callback_;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800385 sp<ComposerCallback> callbacks_;
386
387 // Display metrics of the physical display.
388 HWCDisplayMetrics native_display_metrics_;
389 // Display metrics of the logical display, adjusted so that orientation is
390 // landscape.
391 HWCDisplayMetrics display_metrics_;
392 // Transform required to get from native to logical display orientation.
Corey Tabaka2251d822017-04-20 16:04:07 -0700393 HWC::Transform display_transform_ = HWC::Transform::None;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800394
Corey Tabaka2251d822017-04-20 16:04:07 -0700395 // Pending surface list. Set by the display service when DirectSurfaces are
396 // added, removed, or change visibility. Written by the message dispatch
397 // thread and read by the post thread.
398 std::vector<std::shared_ptr<DirectDisplaySurface>> pending_surfaces_;
Steven Thomas050b2c82017-03-06 11:45:16 -0800399
400 // The surfaces displayed by the post thread. Used exclusively by the post
401 // thread.
Corey Tabaka2251d822017-04-20 16:04:07 -0700402 std::vector<std::shared_ptr<DirectDisplaySurface>> display_surfaces_;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800403
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800404 // Layer array for handling buffer flow into hardware composer layers.
Corey Tabaka2251d822017-04-20 16:04:07 -0700405 std::array<Layer, kMaxHardwareLayers> layers_;
406 size_t active_layer_count_ = 0;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800407
408 // Handler to hook vsync events outside of this class.
409 VSyncCallback vsync_callback_;
410
Steven Thomas282a5ed2017-02-07 18:07:01 -0800411 // The layer posting thread. This thread wakes up a short time before vsync to
Corey Tabaka2251d822017-04-20 16:04:07 -0700412 // hand buffers to hardware composer.
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800413 std::thread post_thread_;
414
Corey Tabaka2251d822017-04-20 16:04:07 -0700415 // Post thread state machine and synchronization primitives.
416 PostThreadStateType post_thread_state_{PostThreadState::Idle};
417 std::atomic<bool> post_thread_quiescent_{true};
418 bool post_thread_resumed_{false};
419 pdx::LocalHandle post_thread_event_fd_;
420 std::mutex post_thread_mutex_;
421 std::condition_variable post_thread_wait_;
422 std::condition_variable post_thread_ready_;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800423
424 // Backlight LED brightness sysfs node.
425 pdx::LocalHandle backlight_brightness_fd_;
426
427 // Primary display vsync event sysfs node.
428 pdx::LocalHandle primary_display_vsync_event_fd_;
429
430 // Primary display wait_pingpong state sysfs node.
431 pdx::LocalHandle primary_display_wait_pp_fd_;
432
433 // VSync sleep timerfd.
434 pdx::LocalHandle vsync_sleep_timer_fd_;
435
436 // The timestamp of the last vsync.
Corey Tabaka2251d822017-04-20 16:04:07 -0700437 int64_t last_vsync_timestamp_ = 0;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800438
439 // Vsync count since display on.
Corey Tabaka2251d822017-04-20 16:04:07 -0700440 uint32_t vsync_count_ = 0;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800441
442 // Counter tracking the number of skipped frames.
Corey Tabaka2251d822017-04-20 16:04:07 -0700443 int frame_skip_count_ = 0;
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800444
445 // Fd array for tracking retire fences that are returned by hwc. This allows
446 // us to detect when the display driver begins queuing frames.
447 std::vector<pdx::LocalHandle> retire_fence_fds_;
448
449 // Pose client for frame count notifications. Pose client predicts poses
450 // out to display frame boundaries, so we need to tell it about vsyncs.
Corey Tabaka2251d822017-04-20 16:04:07 -0700451 DvrPose* pose_client_ = nullptr;
Steven Thomas050b2c82017-03-06 11:45:16 -0800452
John Bates954796e2017-05-11 11:00:31 -0700453 // Broadcast ring for receiving config data from the DisplayManager.
454 DvrVrFlingerConfigRing shared_config_ring_;
455 uint32_t shared_config_ring_sequence_{0};
456 // Config buffer for reading from the post thread.
457 DvrVrFlingerConfigBuffer post_thread_config_;
458 std::mutex shared_config_mutex_;
459
Steven Thomas050b2c82017-03-06 11:45:16 -0800460 static constexpr int kPostThreadInterrupted = 1;
461
Alex Vakulenkoa8a92782017-01-27 14:41:57 -0800462 static void HwcRefresh(hwc2_callback_data_t data, hwc2_display_t display);
463 static void HwcVSync(hwc2_callback_data_t data, hwc2_display_t display,
464 int64_t timestamp);
465 static void HwcHotplug(hwc2_callback_data_t callbackData,
466 hwc2_display_t display, hwc2_connection_t connected);
467
468 HardwareComposer(const HardwareComposer&) = delete;
469 void operator=(const HardwareComposer&) = delete;
470};
471
472} // namespace dvr
473} // namespace android
474
475#endif // ANDROID_DVR_SERVICES_DISPLAYD_HARDWARE_COMPOSER_H_