blob: b0bd8372fda5bdc569ff7210ed1b41df0d238601 [file] [log] [blame]
Chia-I Wubb61a722016-10-24 15:40:20 +08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.graphics.composer@2.1;
18
19import android.hardware.graphics.common@1.0;
20import IComposerCallback;
21
22interface IComposerClient {
23 /* Display attributes queryable through getDisplayAttribute. */
24 enum Attribute : int32_t {
25 INVALID = 0,
26
27 /* Dimensions in pixels */
28 WIDTH = 1,
29 HEIGHT = 2,
30
31 /* Vsync period in nanoseconds */
32 VSYNC_PERIOD = 3,
33
34 /*
35 * Dots per thousand inches (DPI * 1000). Scaling by 1000 allows these
36 * numbers to be stored in an int32_t without losing too much
37 * precision. If the DPI for a configuration is unavailable or is
38 * considered unreliable, the device may return UNSUPPORTED instead.
39 */
40 DPI_X = 4,
41 DPI_Y = 5,
42 };
43
44 /* Display requests returned by getDisplayRequests. */
45 enum DisplayRequest : uint32_t {
46 /*
47 * Instructs the client to provide a new client target buffer, even if
48 * no layers are marked for client composition.
49 */
50 FLIP_CLIENT_TARGET = 1 << 0,
51
52 /*
53 * Instructs the client to write the result of client composition
54 * directly into the virtual display output buffer. If any of the
55 * layers are not marked as Composition::CLIENT or the given display
56 * is not a virtual display, this request has no effect.
57 */
58 WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
59 };
60
61 /* Layer requests returned from getDisplayRequests. */
62 enum LayerRequest : uint32_t {
63 /*
64 * The client must clear its target with transparent pixels where
65 * this layer would be. The client may ignore this request if the
66 * layer must be blended.
67 */
68 CLEAR_CLIENT_TARGET = 1 << 0,
69 };
70
71 /* Power modes for use with setPowerMode. */
72 enum PowerMode : int32_t {
73 /* The display is fully off (blanked). */
74 OFF = 0,
75
76 /*
77 * These are optional low power modes. getDozeSupport may be called to
78 * determine whether a given display supports these modes.
79 */
80
81 /*
82 * The display is turned on and configured in a low power state that
83 * is suitable for presenting ambient information to the user,
84 * possibly with lower fidelity than ON, but with greater efficiency.
85 */
86 DOZE = 1,
87
88 /*
89 * The display is configured as in DOZE but may stop applying display
90 * updates from the client. This is effectively a hint to the device
91 * that drawing to the display has been suspended and that the the
92 * device must remain on in a low power state and continue
93 * displaying its current contents indefinitely until the power mode
94 * changes.
95 *
96 * This mode may also be used as a signal to enable hardware-based
97 * doze functionality. In this case, the device is free to take over
98 * the display and manage it autonomously to implement a low power
99 * always-on display.
100 */
101 DOZE_SUSPEND = 3,
102
103 /* The display is fully on. */
104 ON = 2,
105 };
106
107 /* Vsync values passed to setVsyncEnabled. */
108 enum Vsync : int32_t {
109 INVALID = 0,
110
111 /* Enable vsync. */
112 ENABLE = 1,
113
114 /* Disable vsync. */
115 DISABLE = 2,
116 };
117
118 /* Blend modes, settable per layer. */
119 enum BlendMode : int32_t {
120 INVALID = 0,
121
122 /* colorOut = colorSrc */
123 NONE = 1,
124
125 /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
126 PREMULTIPLIED = 2,
127
128 /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
129 COVERAGE = 3,
130 };
131
132 /* Possible composition types for a given layer. */
133 enum Composition : int32_t {
134 INVALID = 0,
135
136 /*
137 * The client must composite this layer into the client target buffer
138 * (provided to the device through setClientTarget).
139 *
140 * The device must not request any composition type changes for layers
141 * of this type.
142 */
143 CLIENT = 1,
144
145 /*
146 * The device must handle the composition of this layer through a
147 * hardware overlay or other similar means.
148 *
149 * Upon validateDisplay, the device may request a change from this
150 * type to CLIENT.
151 */
152 DEVICE = 2,
153
154 /*
155 * The device must render this layer using the color set through
156 * setLayerColor. If this functionality is not supported on a layer
157 * that the client sets to SOLID_COLOR, the device must request that
158 * the composition type of that layer is changed to CLIENT upon the
159 * next call to validateDisplay.
160 *
161 * Upon validateDisplay, the device may request a change from this
162 * type to CLIENT.
163 */
164 SOLID_COLOR = 3,
165
166 /*
167 * Similar to DEVICE, but the position of this layer may also be set
168 * asynchronously through setCursorPosition. If this functionality is
169 * not supported on a layer that the client sets to CURSOR, the device
170 * must request that the composition type of that layer is changed to
171 * CLIENT upon the next call to validateDisplay.
172 *
173 * Upon validateDisplay, the device may request a change from this
174 * type to either DEVICE or CLIENT. Changing to DEVICE will prevent
175 * the use of setCursorPosition but still permit the device to
176 * composite the layer.
177 */
178 CURSOR = 4,
179
180 /*
181 * The device must handle the composition of this layer, as well as
182 * its buffer updates and content synchronization. Only supported on
183 * devices which provide Capability::SIDEBAND_STREAM.
184 *
185 * Upon validateDisplay, the device may request a change from this
186 * type to either DEVICE or CLIENT, but it is unlikely that content
187 * will display correctly in these cases.
188 */
189 SIDEBAND = 5,
190 };
191
192 /* Display types returned by getDisplayType. */
193 enum DisplayType : int32_t {
194 INVALID = 0,
195
196 /*
197 * All physical displays, including both internal displays and
198 * hotpluggable external displays.
199 */
200 PHYSICAL = 1,
201
202 /* Virtual displays created by createVirtualDisplay. */
203 VIRTUAL = 2,
204 };
205
206 /* Special index values (always negative) for command queue commands. */
207 enum HandleIndex : int32_t {
208 /* No handle */
209 EMPTY = -1,
210
211 /* Use cached handle */
212 CACHED = -2,
213 };
214
215 struct Rect {
216 int32_t left;
217 int32_t top;
218 int32_t right;
219 int32_t bottom;
220 };
221
222 struct FRect {
223 float left;
224 float top;
225 float right;
226 float bottom;
227 };
228
229 struct Color {
230 uint8_t r;
231 uint8_t g;
232 uint8_t b;
233 uint8_t a;
234 };
235
236 /*
237 * Provides a IComposerCallback object for the device to call.
238 *
239 * This function must be called only once.
240 *
241 * @param callback is the IComposerCallback object.
242 */
243 registerCallback(IComposerCallback callback);
244
245 /*
246 * Returns the maximum number of virtual displays supported by this device
247 * (which may be 0). The client must not attempt to create more than this
248 * many virtual displays on this device. This number must not change for
249 * the lifetime of the device.
250 *
251 * @return count is the maximum number of virtual displays supported.
252 */
253 getMaxVirtualDisplayCount() generates (uint32_t count);
254
255 /*
256 * Creates a new virtual display with the given width and height. The
257 * format passed into this function is the default format requested by the
258 * consumer of the virtual display output buffers.
259 *
260 * The display must be assumed to be on from the time the first frame is
261 * presented until the display is destroyed.
262 *
263 * @param width is the width in pixels.
264 * @param height is the height in pixels.
265 * @param formatHint is the default output buffer format selected by
266 * the consumer.
267 * @param outputBufferSlotCount is the number of output buffer slots to be
268 * reserved.
269 * @return error is NONE upon success. Otherwise,
270 * UNSUPPORTED when the width or height is too large for the
271 * device to be able to create a virtual display.
272 * NO_RESOURCES when the device is unable to create a new virtual
273 * display at this time.
274 * @return display is the newly-created virtual display.
275 * @return format is the format of the buffer the device will produce.
276 */
277 createVirtualDisplay(uint32_t width,
278 uint32_t height,
279 PixelFormat formatHint,
280 uint32_t outputBufferSlotCount)
281 generates (Error error,
282 Display display,
283 PixelFormat format);
284
285 /*
286 * Destroys a virtual display. After this call all resources consumed by
287 * this display may be freed by the device and any operations performed on
288 * this display must fail.
289 *
290 * @param display is the virtual display to destroy.
291 * @return error is NONE upon success. Otherwise,
292 * BAD_DISPLAY when an invalid display handle was passed in.
293 * BAD_PARAMETER when the display handle which was passed in does
294 * not refer to a virtual display.
295 */
296 destroyVirtualDisplay(Display display) generates (Error error);
297
298 /*
299 * Creates a new layer on the given display.
300 *
301 * @param display is the display on which to create the layer.
302 * @param bufferSlotCount is the number of buffer slot to be reserved.
303 * @return error is NONE upon success. Otherwise,
304 * BAD_DISPLAY when an invalid display handle was passed in.
305 * NO_RESOURCES when the device was unable to create a layer this
306 * time.
307 * @return layer is the handle of the new layer.
308 */
309 createLayer(Display display,
310 uint32_t bufferSlotCount)
311 generates (Error error,
312 Layer layer);
313
314 /*
315 * Destroys the given layer.
316 *
317 * @param display is the display on which the layer was created.
318 * @param layer is the layer to destroy.
319 * @return error is NONE upon success. Otherwise,
320 * BAD_DISPLAY when an invalid display handle was passed in.
321 * BAD_LAYER when an invalid layer handle was passed in.
322 */
323 destroyLayer(Display display, Layer layer) generates (Error error);
324
325 /*
326 * Retrieves which display configuration is currently active.
327 *
328 * If no display configuration is currently active, this function must
329 * return BAD_CONFIG. It is the responsibility of the client to call
330 * setActiveConfig with a valid configuration before attempting to present
331 * anything on the display.
332 *
333 * @param display is the display to which the active config is queried.
334 * @return error is NONE upon success. Otherwise,
335 * BAD_DISPLAY when an invalid display handle was passed in.
336 * BAD_CONFIG when no configuration is currently active.
337 * @return config is the currently active display configuration.
338 */
339 getActiveConfig(Display display) generates (Error error, Config config);
340
341 /*
342 * Returns whether a client target with the given properties can be
343 * handled by the device.
344 *
345 * This function must return true for a client target with width and
346 * height equal to the active display configuration dimensions,
347 * PixelFormat::RGBA_8888, and Dataspace::UNKNOWN. It is not required to
348 * return true for any other configuration.
349 *
350 * @param display is the display to query.
351 * @param width is the client target width in pixels.
352 * @param height is the client target height in pixels.
353 * @param format is the client target format.
354 * @param dataspace is the client target dataspace, as described in
355 * setLayerDataspace.
356 * @return error is NONE upon success. Otherwise,
357 * BAD_DISPLAY when an invalid display handle was passed in.
358 * UNSUPPORTED when the given configuration is not supported.
359 */
360 getClientTargetSupport(Display display,
361 uint32_t width,
362 uint32_t height,
363 PixelFormat format,
364 Dataspace dataspace)
365 generates (Error error);
366
367 /*
368 * Returns the color modes supported on this display.
369 *
370 * All devices must support at least ColorMode::NATIVE.
371 *
372 * @param display is the display to query.
373 * @return error is NONE upon success. Otherwise,
374 * BAD_DISPLAY when an invalid display handle was passed in.
375 * @return modes is an array of color modes.
376 */
377 getColorModes(Display display)
378 generates (Error error,
379 vec<ColorMode> modes);
380
381 /*
382 * Returns a display attribute value for a particular display
383 * configuration.
384 *
385 * @param display is the display to query.
386 * @param config is the display configuration for which to return
387 * attribute values.
388 * @return error is NONE upon success. Otherwise,
389 * BAD_DISPLAY when an invalid display handle was passed in.
390 * BAD_CONFIG when config does not name a valid configuration for
391 * this display.
392 * BAD_PARAMETER when attribute is unrecognized.
393 * UNSUPPORTED when attribute cannot be queried for the config.
394 * @return value is the value of the attribute.
395 */
396 getDisplayAttribute(Display display,
397 Config config,
398 Attribute attribute)
399 generates (Error error,
400 int32_t value);
401
402 /*
403 * Returns handles for all of the valid display configurations on this
404 * display.
405 *
406 * @param display is the display to query.
407 * @return error is NONE upon success. Otherwise,
408 * BAD_DISPLAY when an invalid display handle was passed in.
409 * @return configs is an array of configuration handles.
410 */
411 getDisplayConfigs(Display display)
412 generates (Error error,
413 vec<Config> configs);
414
415 /*
416 * Returns a human-readable version of the display's name.
417 *
418 * @return error is NONE upon success. Otherwise,
419 * BAD_DISPLAY when an invalid display handle was passed in.
420 * @return name is the name of the display.
421 */
422 getDisplayName(Display display) generates (Error error, string name);
423
424 /*
425 * Returns whether the given display is a physical or virtual display.
426 *
427 * @param display is the display to query.
428 * @return error is NONE upon success. Otherwise,
429 * BAD_DISPLAY when an invalid display handle was passed in.
430 * @return type is the type of the display.
431 */
432 getDisplayType(Display display) generates (Error error, DisplayType type);
433
434 /*
435 * Returns whether the given display supports PowerMode::DOZE and
436 * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
437 * DOZE (see the definition of PowerMode for more information), but if
438 * both DOZE and DOZE_SUSPEND are no different from PowerMode::ON, the
439 * device must not claim support.
440 *
441 * @param display is the display to query.
442 * @return error is NONE upon success. Otherwise,
443 * BAD_DISPLAY when an invalid display handle was passed in.
444 * @return support is true only when the display supports doze modes.
445 */
446 getDozeSupport(Display display) generates (Error error, bool support);
447
448 /*
449 * Returns the high dynamic range (HDR) capabilities of the given display,
450 * which are invariant with regard to the active configuration.
451 *
452 * Displays which are not HDR-capable must return no types.
453 *
454 * @param display is the display to query.
455 * @return error is NONE upon success. Otherwise,
456 * BAD_DISPLAY when an invalid display handle was passed in.
457 * @return types is an array of HDR types, may have 0 elements if the
458 * display is not HDR-capable.
459 * @return maxLuminance is the desired content maximum luminance for this
460 * display in cd/m^2.
461 * @return maxAverageLuminance - the desired content maximum frame-average
462 * luminance for this display in cd/m^2.
463 * @return minLuminance is the desired content minimum luminance for this
464 * display in cd/m^2.
465 */
466 getHdrCapabilities(Display display)
467 generates (Error error,
468 vec<Hdr> types,
469 float maxLuminance,
470 float maxAverageLuminance,
471 float minLuminance);
472
473 /*
474 * Set the number of client target slots to be reserved.
475 *
476 * @param display is the display to which the slots are reserved.
477 * @param clientTargetSlotCount is the slot count for client targets.
478 * @return error is NONE upon success. Otherwise,
479 * BAD_DISPLAY when an invalid display handle was passed in.
480 * NO_RESOURCES when unable to reserve the slots.
481 */
482 setClientTargetSlotCount(Display display,
483 uint32_t clientTargetSlotCount)
484 generates (Error error);
485
486 /*
487 * Sets the active configuration for this display. Upon returning, the
488 * given display configuration must be active and remain so until either
489 * this function is called again or the display is disconnected.
490 *
491 * @param display is the display to which the active config is set.
492 * @param config is the new display configuration.
493 * @return error is NONE upon success. Otherwise,
494 * BAD_DISPLAY when an invalid display handle was passed in.
495 * BAD_CONFIG when the configuration handle passed in is not valid
496 * for this display.
497 */
498 setActiveConfig(Display display, Config config) generates (Error error);
499
500 /*
501 * Sets the color mode of the given display.
502 *
503 * Upon returning from this function, the color mode change must have
504 * fully taken effect.
505 *
506 * All devices must support at least ColorMode::NATIVE, and displays are
507 * assumed to be in this mode upon hotplug.
508 *
509 * @param display is the display to which the color mode is set.
510 * @param mode is the mode to set to.
511 * @return error is NONE upon success. Otherwise,
512 * BAD_DISPLAY when an invalid display handle was passed in.
513 * BAD_PARAMETER when mode is not a valid color mode.
514 * UNSUPPORTED when mode is not supported on this display.
515 */
516 setColorMode(Display display, ColorMode mode) generates (Error error);
517
518 /*
519 * Sets the power mode of the given display. The transition must be
520 * complete when this function returns. It is valid to call this function
521 * multiple times with the same power mode.
522 *
523 * All displays must support PowerMode::ON and PowerMode::OFF. Whether a
524 * display supports PowerMode::DOZE or PowerMode::DOZE_SUSPEND may be
525 * queried using getDozeSupport.
526 *
527 * @param display is the display to which the power mode is set.
528 * @param mode is the new power mode.
529 * @return error is NONE upon success. Otherwise,
530 * BAD_DISPLAY when an invalid display handle was passed in.
531 * BAD_PARAMETER when mode was not a valid power mode.
532 * UNSUPPORTED when mode is not supported on this display.
533 */
534 setPowerMode(Display display, PowerMode mode) generates (Error error);
535
536 /*
537 * Enables or disables the vsync signal for the given display. Virtual
538 * displays never generate vsync callbacks, and any attempt to enable
539 * vsync for a virtual display though this function must succeed and have
540 * no other effect.
541 *
542 * @param display is the display to which the vsync mode is set.
543 * @param enabled indicates whether to enable or disable vsync
544 * @return error is NONE upon success. Otherwise,
545 * BAD_DISPLAY when an invalid display handle was passed in.
546 * BAD_PARAMETER when enabled was an invalid value.
547 */
548 setVsyncEnabled(Display display, Vsync enabled) generates (Error error);
549
550 /*
551 * Sets the input command message queue.
552 *
553 * @param descriptor is the descriptor of the input command message queue.
554 * @return error is NONE upon success. Otherwise,
555 * NO_RESOURCES when failed to set the queue temporarily.
556 */
Hridya Valsaraju33351da2016-12-27 12:40:01 -0800557 setInputCommandQueue(fmq_sync<uint32_t> descriptor)
Chia-I Wubb61a722016-10-24 15:40:20 +0800558 generates (Error error);
559
560 /*
561 * Gets the output command message queue.
562 *
563 * This function must only be called inside executeCommands closure.
564 *
565 * @return error is NONE upon success. Otherwise,
566 * NO_RESOURCES when failed to get the queue temporarily.
567 * @return descriptor is the descriptor of the output command queue.
568 */
569 getOutputCommandQueue()
570 generates (Error error,
Hridya Valsaraju33351da2016-12-27 12:40:01 -0800571 fmq_sync<uint32_t> descriptor);
Chia-I Wubb61a722016-10-24 15:40:20 +0800572
573 /*
574 * Executes commands from the input command message queue. Return values
575 * generated by the input commands are written to the output command
576 * message queue in the form of value commands.
577 *
578 * @param inLength is the length of input commands.
579 * @param inHandles is an array of handles referenced by the input
580 * commands.
581 * @return error is NONE upon success. Otherwise,
582 * BAD_PARAMETER when inLength is not equal to the length of
583 * commands in the input command message queue.
584 * NO_RESOURCES when the output command message queue was not
585 * properly drained.
586 * @param outQueueChanged indicates whether the output command message
587 * queue has changed.
588 * @param outLength is the length of output commands.
589 * @param outHandles is an array of handles referenced by the output
590 * commands.
591 */
592 executeCommands(uint32_t inLength,
593 vec<handle> inHandles)
594 generates (Error error,
595 bool outQueueChanged,
596 uint32_t outLength,
597 vec<handle> outHandles);
598
599 /*
600 * SELECT_DISPLAY has this pseudo prototype
601 *
602 * selectDisplay(Display display);
603 *
604 * Selects the current display implied by all other commands.
605 *
606 * @param display is the newly selected display.
607 *
608 *
609 * SELECT_LAYER has this pseudo prototype
610 *
611 * selectLayer(Layer layer);
612 *
613 * Selects the current layer implied by all implicit layer commands.
614 *
615 * @param layer is the newly selected layer.
616 *
617 *
618 * SET_ERROR has this pseudo prototype
619 *
620 * setError(uint32_t location, Error error);
621 *
622 * Indicates an error generated by a command.
623 *
624 * @param location is the offset of the command in the input command
625 * message queue.
626 * @param error is the error generated by the command.
627 *
628 *
629 * SET_CHANGED_COMPOSITION_TYPES has this pseudo prototype
630 *
631 * setChangedCompositionTypes(vec<Layer> layers,
632 * vec<Composition> types);
633 *
634 * Sets the layers for which the device requires a different composition
635 * type than had been set prior to the last call to VALIDATE_DISPLAY. The
636 * client must either update its state with these types and call
637 * ACCEPT_DISPLAY_CHANGES, or must set new types and attempt to validate
638 * the display again.
639 *
640 * @param layers is an array of layer handles.
641 * @param types is an array of composition types, each corresponding to
642 * an element of layers.
643 *
644 *
645 * SET_DISPLAY_REQUESTS has this pseudo prototype
646 *
647 * setDisplayRequests(uint32_t displayRequestMask,
648 * vec<Layer> layers,
649 * vec<uint32_t> layerRequestMasks);
650 *
651 * Sets the display requests and the layer requests required for the last
652 * validated configuration.
653 *
654 * Display requests provide information about how the client must handle
655 * the client target. Layer requests provide information about how the
656 * client must handle an individual layer.
657 *
658 * @param displayRequestMask is the display requests for the current
659 * validated state.
660 * @param layers is an array of layers which all have at least one
661 * request.
662 * @param layerRequestMasks is the requests corresponding to each element
663 * of layers.
664 *
665 *
666 * SET_PRESENT_FENCE has this pseudo prototype
667 *
668 * setPresentFence(int32_t presentFenceIndex);
669 *
670 * Sets the present fence as a result of PRESENT_DISPLAY. For physical
671 * displays, this fence must be signaled at the vsync when the result
672 * of composition of this frame starts to appear (for video-mode panels)
673 * or starts to transfer to panel memory (for command-mode panels). For
674 * virtual displays, this fence must be signaled when writes to the output
675 * buffer have completed and it is safe to read from it.
676 *
677 * @param presentFenceIndex is an index into outHandles array.
678 *
679 *
680 * SET_RELEASE_FENCES has this pseudo prototype
681 *
682 * setReleaseFences(vec<Layer> layers,
683 * vec<int32_t> releaseFenceIndices);
684 *
685 * Sets the release fences for device layers on this display which will
686 * receive new buffer contents this frame.
687 *
688 * A release fence is a file descriptor referring to a sync fence object
689 * which must be signaled after the device has finished reading from the
690 * buffer presented in the prior frame. This indicates that it is safe to
691 * start writing to the buffer again. If a given layer's fence is not
692 * returned from this function, it must be assumed that the buffer
693 * presented on the previous frame is ready to be written.
694 *
695 * The fences returned by this function must be unique for each layer
696 * (even if they point to the same underlying sync object).
697 *
698 * @param layers is an array of layer handles.
699 * @param releaseFenceIndices are indices into outHandles array, each
700 * corresponding to an element of layers.
701 *
702 *
703 * SET_COLOR_TRANSFORM has this pseudo prototype
704 *
705 * setColorTransform(float[16] matrix,
706 * ColorTransform hint);
707 *
708 * Sets a color transform which will be applied after composition.
709 *
710 * If hint is not ColorTransform::ARBITRARY, then the device may use the
711 * hint to apply the desired color transform instead of using the color
712 * matrix directly.
713 *
714 * If the device is not capable of either using the hint or the matrix to
715 * apply the desired color transform, it must force all layers to client
716 * composition during VALIDATE_DISPLAY.
717 *
718 * If IComposer::Capability::SKIP_CLIENT_COLOR_TRANSFORM is present, then
719 * the client must never apply the color transform during client
720 * composition, even if all layers are being composed by the client.
721 *
722 * The matrix provided is an affine color transformation of the following
723 * form:
724 *
725 * |r.r r.g r.b 0|
726 * |g.r g.g g.b 0|
727 * |b.r b.g b.b 0|
728 * |Tr Tg Tb 1|
729 *
730 * This matrix must be provided in row-major form:
731 *
732 * {r.r, r.g, r.b, 0, g.r, ...}.
733 *
734 * Given a matrix of this form and an input color [R_in, G_in, B_in], the
735 * output color [R_out, G_out, B_out] will be:
736 *
737 * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
738 * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
739 * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
740 *
741 * @param matrix is a 4x4 transform matrix (16 floats) as described above.
742 * @param hint is a hint value which may be used instead of the given
743 * matrix unless it is ColorTransform::ARBITRARY.
744 *
745 *
746 * SET_CLIENT_TARGET has this pseudo prototype
747 *
748 * setClientTarget(uint32_t targetSlot,
749 * int32_t targetIndex,
750 * int32_t acquireFenceIndex,
751 * Dataspace dataspace,
752 * vec<Rect> damage);
753 *
754 * Sets the buffer handle which will receive the output of client
755 * composition. Layers marked as Composition::CLIENT must be composited
756 * into this buffer prior to the call to PRESENT_DISPLAY, and layers not
757 * marked as Composition::CLIENT must be composited with this buffer by
758 * the device.
759 *
760 * The buffer handle provided may be empty if no layers are being
761 * composited by the client. This must not result in an error (unless an
762 * invalid display handle is also provided).
763 *
764 * Also provides a file descriptor referring to an acquire sync fence
765 * object, which must be signaled when it is safe to read from the client
766 * target buffer. If it is already safe to read from this buffer, an
767 * empty handle may be passed instead.
768 *
769 * For more about dataspaces, see SET_LAYER_DATASPACE.
770 *
771 * The damage parameter describes a surface damage region as defined in
772 * the description of SET_LAYER_SURFACE_DAMAGE.
773 *
774 * Will be called before PRESENT_DISPLAY if any of the layers are marked
775 * as Composition::CLIENT. If no layers are so marked, then it is not
776 * necessary to call this function. It is not necessary to call
777 * validateDisplay after changing the target through this function.
778 *
779 * @param targetSlot is the client target buffer slot to use.
780 * @param targetIndex is an index into inHandles for the new target
781 * buffer.
782 * @param acquireFenceIndex is an index into inHandles for a sync fence
783 * file descriptor as described above.
784 * @param dataspace is the dataspace of the buffer, as described in
785 * setLayerDataspace.
786 * @param damage is the surface damage region.
787 *
788 *
789 * SET_OUTPUT_BUFFER has this pseudo prototype
790 *
791 * setOutputBuffer(uint32_t bufferSlot,
792 * int32_t bufferIndex,
793 * int32_t releaseFenceIndex);
794 *
795 * Sets the output buffer for a virtual display. That is, the buffer to
796 * which the composition result will be written.
797 *
798 * Also provides a file descriptor referring to a release sync fence
799 * object, which must be signaled when it is safe to write to the output
800 * buffer. If it is already safe to write to the output buffer, an empty
801 * handle may be passed instead.
802 *
803 * Must be called at least once before PRESENT_DISPLAY, but does not have
804 * any interaction with layer state or display validation.
805 *
806 * @param bufferSlot is the new output buffer.
807 * @param bufferIndex is the new output buffer.
808 * @param releaseFenceIndex is a sync fence file descriptor as described
809 * above.
810 *
811 *
812 * VALIDATE_DISPLAY has this pseudo prototype
813 *
814 * validateDisplay();
815 *
816 * Instructs the device to inspect all of the layer state and determine if
817 * there are any composition type changes necessary before presenting the
818 * display. Permitted changes are described in the definition of
819 * Composition above.
820 *
821 *
822 * ACCEPT_DISPLAY_CHANGES has this pseudo prototype
823 *
824 * acceptDisplayChanges();
825 *
826 * Accepts the changes required by the device from the previous
827 * validateDisplay call (which may be queried using
828 * getChangedCompositionTypes) and revalidates the display. This function
829 * is equivalent to requesting the changed types from
830 * getChangedCompositionTypes, setting those types on the corresponding
831 * layers, and then calling validateDisplay again.
832 *
833 * After this call it must be valid to present this display. Calling this
834 * after validateDisplay returns 0 changes must succeed with NONE, but
835 * must have no other effect.
836 *
837 *
838 * PRESENT_DISPLAY has this pseudo prototype
839 *
840 * presentDisplay();
841 *
842 * Presents the current display contents on the screen (or in the case of
843 * virtual displays, into the output buffer).
844 *
845 * Prior to calling this function, the display must be successfully
846 * validated with validateDisplay. Note that setLayerBuffer and
847 * setLayerSurfaceDamage specifically do not count as layer state, so if
848 * there are no other changes to the layer state (or to the buffer's
849 * properties as described in setLayerBuffer), then it is safe to call
850 * this function without first validating the display.
851 *
852 *
853 * SET_LAYER_CURSOR_POSITION has this pseudo prototype
854 *
855 * setLayerCursorPosition(int32_t x, int32_t y);
856 *
857 * Asynchronously sets the position of a cursor layer.
858 *
859 * Prior to validateDisplay, a layer may be marked as Composition::CURSOR.
860 * If validation succeeds (i.e., the device does not request a composition
861 * change for that layer), then once a buffer has been set for the layer
862 * and it has been presented, its position may be set by this function at
863 * any time between presentDisplay and any subsequent validateDisplay
864 * calls for this display.
865 *
866 * Once validateDisplay is called, this function must not be called again
867 * until the validate/present sequence is completed.
868 *
869 * May be called from any thread so long as it is not interleaved with the
870 * validate/present sequence as described above.
871 *
872 * @param layer is the layer to which the position is set.
873 * @param x is the new x coordinate (in pixels from the left of the
874 * screen).
875 * @param y is the new y coordinate (in pixels from the top of the
876 * screen).
877 *
878 *
879 * SET_LAYER_BUFFER has this pseudo prototype
880 *
881 * setLayerBuffer(uint32_t bufferSlot,
882 * int32_t bufferIndex,
883 * int32_t acquireFenceIndex);
884 *
885 * Sets the buffer handle to be displayed for this layer. If the buffer
886 * properties set at allocation time (width, height, format, and usage)
887 * have not changed since the previous frame, it is not necessary to call
888 * validateDisplay before calling presentDisplay unless new state needs to
889 * be validated in the interim.
890 *
891 * Also provides a file descriptor referring to an acquire sync fence
892 * object, which must be signaled when it is safe to read from the given
893 * buffer. If it is already safe to read from the buffer, an empty handle
894 * may be passed instead.
895 *
896 * This function must return NONE and have no other effect if called for a
897 * layer with a composition type of Composition::SOLID_COLOR (because it
898 * has no buffer) or Composition::SIDEBAND or Composition::CLIENT (because
899 * synchronization and buffer updates for these layers are handled
900 * elsewhere).
901 *
902 * @param layer is the layer to which the buffer is set.
903 * @param bufferSlot is the buffer slot to use.
904 * @param bufferIndex is the buffer handle to set.
905 * @param acquireFenceIndex is a sync fence file descriptor as described above.
906 *
907 *
908 * SET_LAYER_SURFACE_DAMAGE has this pseudo prototype
909 *
910 * setLayerSurfaceDamage(vec<Rect> damage);
911 *
912 * Provides the region of the source buffer which has been modified since
913 * the last frame. This region does not need to be validated before
914 * calling presentDisplay.
915 *
916 * Once set through this function, the damage region remains the same
917 * until a subsequent call to this function.
918 *
919 * If damage is non-empty, then it may be assumed that any portion of the
920 * source buffer not covered by one of the rects has not been modified
921 * this frame. If damage is empty, then the whole source buffer must be
922 * treated as if it has been modified.
923 *
924 * If the layer's contents are not modified relative to the prior frame,
925 * damage must contain exactly one empty rect([0, 0, 0, 0]).
926 *
927 * The damage rects are relative to the pre-transformed buffer, and their
928 * origin is the top-left corner. They must not exceed the dimensions of
929 * the latched buffer.
930 *
931 * @param layer is the layer to which the damage region is set.
932 * @param damage is the new surface damage region.
933 *
934 *
935 * SET_LAYER_BLEND_MODE has this pseudo prototype
936 *
937 * setLayerBlendMode(BlendMode mode)
938 *
939 * Sets the blend mode of the given layer.
940 *
941 * @param mode is the new blend mode.
942 *
943 *
944 * SET_LAYER_COLOR has this pseudo prototype
945 *
946 * setLayerColor(Color color);
947 *
948 * Sets the color of the given layer. If the composition type of the layer
949 * is not Composition::SOLID_COLOR, this call must succeed and have no
950 * other effect.
951 *
952 * @param color is the new color.
953 *
954 *
955 * SET_LAYER_COMPOSITION_TYPE has this pseudo prototype
956 *
957 * setLayerCompositionType(Composition type);
958 *
959 * Sets the desired composition type of the given layer. During
960 * validateDisplay, the device may request changes to the composition
961 * types of any of the layers as described in the definition of
962 * Composition above.
963 *
964 * @param type is the new composition type.
965 *
966 *
967 * SET_LAYER_DATASPACE has this pseudo prototype
968 *
969 * setLayerDataspace(Dataspace dataspace);
970 *
971 * Sets the dataspace that the current buffer on this layer is in.
972 *
973 * The dataspace provides more information about how to interpret the
974 * buffer contents, such as the encoding standard and color transform.
975 *
976 * See the values of Dataspace for more information.
977 *
978 * @param dataspace is the new dataspace.
979 *
980 *
981 * SET_LAYER_DISPLAY_FRAME has this pseudo prototype
982 *
983 * setLayerDisplayFrame(Rect frame);
984 *
985 * Sets the display frame (the portion of the display covered by a layer)
986 * of the given layer. This frame must not exceed the display dimensions.
987 *
988 * @param frame is the new display frame.
989 *
990 *
991 * SET_LAYER_PLANE_ALPHA has this pseudo prototype
992 *
993 * setLayerPlaneAlpha(float alpha);
994 *
995 * Sets an alpha value (a floating point value in the range [0.0, 1.0])
996 * which will be applied to the whole layer. It can be conceptualized as a
997 * preprocessing step which applies the following function:
998 * if (blendMode == BlendMode::PREMULTIPLIED)
999 * out.rgb = in.rgb * planeAlpha
1000 * out.a = in.a * planeAlpha
1001 *
1002 * If the device does not support this operation on a layer which is
1003 * marked Composition::DEVICE, it must request a composition type change
1004 * to Composition::CLIENT upon the next validateDisplay call.
1005 *
1006 * @param alpha is the plane alpha value to apply.
1007 *
1008 *
1009 * SET_LAYER_SIDEBAND_STREAM has this pseudo prototype
1010 *
1011 * setLayerSidebandStream(int32_t streamIndex)
1012 *
1013 * Sets the sideband stream for this layer. If the composition type of the
1014 * given layer is not Composition::SIDEBAND, this call must succeed and
1015 * have no other effect.
1016 *
1017 * @param streamIndex is the new sideband stream.
1018 *
1019 *
1020 * SET_LAYER_SOURCE_CROP has this pseudo prototype
1021 *
1022 * setLayerSourceCrop(FRect crop);
1023 *
1024 * Sets the source crop (the portion of the source buffer which will fill
1025 * the display frame) of the given layer. This crop rectangle must not
1026 * exceed the dimensions of the latched buffer.
1027 *
1028 * If the device is not capable of supporting a true float source crop
1029 * (i.e., it will truncate or round the floats to integers), it must set
1030 * this layer to Composition::CLIENT when crop is non-integral for the
1031 * most accurate rendering.
1032 *
1033 * If the device cannot support float source crops, but still wants to
1034 * handle the layer, it must use the following code (or similar) to
1035 * convert to an integer crop:
1036 * intCrop.left = (int) ceilf(crop.left);
1037 * intCrop.top = (int) ceilf(crop.top);
1038 * intCrop.right = (int) floorf(crop.right);
1039 * intCrop.bottom = (int) floorf(crop.bottom);
1040 *
1041 * @param crop is the new source crop.
1042 *
1043 *
1044 * SET_LAYER_TRANSFORM has this pseudo prototype
1045 *
1046 * Sets the transform (rotation/flip) of the given layer.
1047 *
1048 * setLayerTransform(Transform transform);
1049 *
1050 * @param transform is the new transform.
1051 *
1052 *
1053 * SET_LAYER_VISIBLE_REGION has this pseudo prototype
1054 *
1055 * setLayerVisibleRegion(vec<Rect> visible);
1056 *
1057 * Specifies the portion of the layer that is visible, including portions
1058 * under translucent areas of other layers. The region is in screen space,
1059 * and must not exceed the dimensions of the screen.
1060 *
1061 * @param visible is the new visible region, in screen space.
1062 *
1063 *
1064 * SET_LAYER_Z_ORDER has this pseudo prototype
1065 *
1066 * setLayerZOrder(uint32_t z);
1067 *
1068 * Sets the desired Z order (height) of the given layer. A layer with a
1069 * greater Z value occludes a layer with a lesser Z value.
1070 *
1071 * @param z is the new Z order.
1072 */
1073 enum Command : int32_t {
1074 LENGTH_MASK = 0xffff,
1075 OPCODE_SHIFT = 16,
1076 OPCODE_MASK = 0xffff << OPCODE_SHIFT,
1077
1078 /* special commands */
1079 SELECT_DISPLAY = 0x000 << OPCODE_SHIFT,
1080 SELECT_LAYER = 0x001 << OPCODE_SHIFT,
1081
1082 /* value commands (for return values) */
1083 SET_ERROR = 0x100 << OPCODE_SHIFT,
1084 SET_CHANGED_COMPOSITION_TYPES = 0x101 << OPCODE_SHIFT,
1085 SET_DISPLAY_REQUESTS = 0x102 << OPCODE_SHIFT,
1086 SET_PRESENT_FENCE = 0x103 << OPCODE_SHIFT,
1087 SET_RELEASE_FENCES = 0x104 << OPCODE_SHIFT,
1088
1089 /* display commands */
1090 SET_COLOR_TRANSFORM = 0x200 << OPCODE_SHIFT,
1091 SET_CLIENT_TARGET = 0x201 << OPCODE_SHIFT,
1092 SET_OUTPUT_BUFFER = 0x202 << OPCODE_SHIFT,
1093 VALIDATE_DISPLAY = 0x203 << OPCODE_SHIFT,
1094 ACCEPT_DISPLAY_CHANGES = 0x204 << OPCODE_SHIFT,
1095 PRESENT_DISPLAY = 0x205 << OPCODE_SHIFT,
1096
1097 /* layer commands (VALIDATE_DISPLAY not required) */
1098 SET_LAYER_CURSOR_POSITION = 0x300 << OPCODE_SHIFT,
1099 SET_LAYER_BUFFER = 0x301 << OPCODE_SHIFT,
1100 SET_LAYER_SURFACE_DAMAGE = 0x302 << OPCODE_SHIFT,
1101
1102 /* layer state commands (VALIDATE_DISPLAY required) */
1103 SET_LAYER_BLEND_MODE = 0x400 << OPCODE_SHIFT,
1104 SET_LAYER_COLOR = 0x401 << OPCODE_SHIFT,
1105 SET_LAYER_COMPOSITION_TYPE = 0x402 << OPCODE_SHIFT,
1106 SET_LAYER_DATASPACE = 0x403 << OPCODE_SHIFT,
1107 SET_LAYER_DISPLAY_FRAME = 0x404 << OPCODE_SHIFT,
1108 SET_LAYER_PLANE_ALPHA = 0x405 << OPCODE_SHIFT,
1109 SET_LAYER_SIDEBAND_STREAM = 0x406 << OPCODE_SHIFT,
1110 SET_LAYER_SOURCE_CROP = 0x407 << OPCODE_SHIFT,
1111 SET_LAYER_TRANSFORM = 0x408 << OPCODE_SHIFT,
1112 SET_LAYER_VISIBLE_REGION = 0x409 << OPCODE_SHIFT,
1113 SET_LAYER_Z_ORDER = 0x40a << OPCODE_SHIFT,
1114
1115 /* 0x800 - 0xfff are reserved for vendor extensions */
1116 /* 0x1000 - 0xffff are reserved */
1117 };
1118};