|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * vim: sw=2 ts=8 et : |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 include LayersSurfaces; |
|
9 include LayersMessages; |
|
10 include protocol PCompositable; |
|
11 include protocol PCompositor; |
|
12 include protocol PGrallocBuffer; |
|
13 include protocol PLayer; |
|
14 include protocol PRenderFrame; |
|
15 include protocol PTexture; |
|
16 |
|
17 include "mozilla/GfxMessageUtils.h"; |
|
18 |
|
19 using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; |
|
20 using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; |
|
21 |
|
22 /** |
|
23 * The layers protocol is spoken between thread contexts that manage |
|
24 * layer (sub)trees. The protocol comprises atomically publishing |
|
25 * layer subtrees to a "shadow" thread context (which grafts the |
|
26 * subtree into its own tree), and atomically updating a published |
|
27 * subtree. ("Atomic" in this sense is wrt painting.) |
|
28 */ |
|
29 |
|
30 namespace mozilla { |
|
31 namespace layers { |
|
32 |
|
33 union MaybeTransform { |
|
34 gfx3DMatrix; |
|
35 void_t; |
|
36 }; |
|
37 |
|
38 sync protocol PLayerTransaction { |
|
39 manager PRenderFrame or PCompositor; |
|
40 manages PLayer; |
|
41 manages PCompositable; |
|
42 manages PGrallocBuffer; |
|
43 manages PTexture; |
|
44 |
|
45 parent: |
|
46 /** |
|
47 * Only the parent side has privileges to allocate the buffer. |
|
48 * Allocation may fail (pmem is a scarce resource), and if so null_t |
|
49 * is returned. |
|
50 * |
|
51 * |format| is an Android PixelFormat (see PixelFormat.h) |
|
52 * |
|
53 * commonly used PixelFormats are: |
|
54 * PIXEL_FORMAT_RGBA_8888 |
|
55 * PIXEL_FORMAT_RGBX_8888 |
|
56 * PIXEL_FORMAT_BGRA_8888 |
|
57 * |
|
58 * Note that SurfaceDescriptorGralloc has a "isRBSwapped" boolean |
|
59 * that can treat the R/B bytes as swapped when they are rendered |
|
60 * to the screen, to help with matching the native pixel format |
|
61 * of other rendering engines. |
|
62 * |
|
63 * |usage| is a USAGE_* mask (see GraphicBuffer.h) |
|
64 * |
|
65 * commonly used USAGE flags are: |
|
66 * USAGE_SW_READ_OFTEN | USAGE_SW_WRITE_OFTEN | USAGE_HW_TEXTURE |
|
67 * - used for software rendering to a buffer which the compositor |
|
68 * treats as a texture |
|
69 * USAGE_HW_RENDER | USAGE_HW_TEXTURE |
|
70 * - used for GL rendering to a buffer which the compositor |
|
71 * treats as a texture |
|
72 */ |
|
73 sync PGrallocBuffer(IntSize size, uint32_t format, uint32_t usage) |
|
74 returns (MaybeMagicGrallocBufferHandle handle); |
|
75 async PLayer(); |
|
76 async PCompositable(TextureInfo aTextureInfo); |
|
77 async PTexture(SurfaceDescriptor aSharedData, uint32_t aTextureFlags); |
|
78 |
|
79 // The isFirstPaint flag can be used to indicate that this is the first update |
|
80 // for a particular document. |
|
81 sync Update(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint, bool scheduleComposite) |
|
82 returns (EditReply[] reply); |
|
83 |
|
84 // Testing APIs |
|
85 |
|
86 // Enter test mode, set the sample time to sampleTime, and resample |
|
87 // animations. sampleTime must not be null. |
|
88 sync SetTestSampleTime(TimeStamp sampleTime); |
|
89 // Leave test mode and resume normal compositing |
|
90 sync LeaveTestMode(); |
|
91 |
|
92 sync GetOpacity(PLayer layer) returns (float opacity); |
|
93 |
|
94 // Returns the value of the transform applied to the layer by animation after |
|
95 // factoring out translation components introduced to account for the offset |
|
96 // of the corresponding frame and transform origin and after converting to CSS |
|
97 // pixels. If the layer is not transformed by animation, the return value will |
|
98 // be void_t. |
|
99 sync GetAnimationTransform(PLayer layer) returns (MaybeTransform transform); |
|
100 |
|
101 // The next time this layer is composited, add this async scroll offset in |
|
102 // CSS pixels. |
|
103 // Useful for testing rendering of async scrolling. |
|
104 async SetAsyncScrollOffset(PLayer layer, int32_t x, int32_t y); |
|
105 |
|
106 // We don't need to send a sync transaction if |
|
107 // no transaction operate require a swap. |
|
108 async UpdateNoSwap(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint, bool scheduleComposite); |
|
109 |
|
110 // Drop any front buffers that might be retained on the compositor |
|
111 // side. |
|
112 async ClearCachedResources(); |
|
113 |
|
114 // Schedule a composite if one isn't already scheduled. |
|
115 async ForceComposite(); |
|
116 |
|
117 async __delete__(); |
|
118 }; |
|
119 |
|
120 } // namespace layers |
|
121 } // namespace mozilla |