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