|
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 protocol PCompositable; |
|
10 include protocol PCompositor; |
|
11 include protocol PGrallocBuffer; |
|
12 include protocol PLayer; |
|
13 include protocol PRenderFrame; |
|
14 include protocol PTexture; |
|
15 |
|
16 include "gfxipc/ShadowLayerUtils.h"; |
|
17 include "mozilla/GfxMessageUtils.h"; |
|
18 include "ImageLayers.h"; |
|
19 |
|
20 using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h"; |
|
21 using struct gfxRGBA from "gfxColor.h"; |
|
22 using struct gfxPoint3D from "gfxPoint3D.h"; |
|
23 using class mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h"; |
|
24 using class gfx3DMatrix from "gfx3DMatrix.h"; |
|
25 using nscoord from "nsCoord.h"; |
|
26 using struct nsIntPoint from "nsPoint.h"; |
|
27 using struct nsRect from "nsRect.h"; |
|
28 using struct nsPoint from "nsPoint.h"; |
|
29 using class mozilla::TimeDuration from "mozilla/TimeStamp.h"; |
|
30 using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; |
|
31 using mozilla::ScreenRotation from "mozilla/WidgetUtils.h"; |
|
32 using nsCSSProperty from "nsCSSProperty.h"; |
|
33 using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h"; |
|
34 using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; |
|
35 using mozilla::LayerMargin from "Units.h"; |
|
36 using mozilla::LayerPoint from "Units.h"; |
|
37 using mozilla::LayerRect from "Units.h"; |
|
38 using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h"; |
|
39 using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h"; |
|
40 using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h"; |
|
41 using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; |
|
42 using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h"; |
|
43 using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h"; |
|
44 |
|
45 namespace mozilla { |
|
46 namespace layers { |
|
47 |
|
48 struct TargetConfig { |
|
49 nsIntRect naturalBounds; |
|
50 ScreenRotation rotation; |
|
51 nsIntRect clientBounds; |
|
52 ScreenOrientation orientation; |
|
53 nsIntRegion clearRegion; |
|
54 }; |
|
55 |
|
56 // Create a shadow layer for |layer| |
|
57 struct OpCreateThebesLayer { PLayer layer; }; |
|
58 struct OpCreateContainerLayer { PLayer layer; }; |
|
59 struct OpCreateImageLayer { PLayer layer; }; |
|
60 struct OpCreateColorLayer { PLayer layer; }; |
|
61 struct OpCreateCanvasLayer { PLayer layer; }; |
|
62 struct OpCreateRefLayer { PLayer layer; }; |
|
63 |
|
64 struct OpAttachCompositable { |
|
65 PLayer layer; |
|
66 PCompositable compositable; |
|
67 }; |
|
68 |
|
69 struct OpAttachAsyncCompositable { |
|
70 PLayer layer; |
|
71 uint64_t containerID; |
|
72 }; |
|
73 |
|
74 struct ThebesBufferData { |
|
75 nsIntRect rect; |
|
76 nsIntPoint rotation; |
|
77 }; |
|
78 |
|
79 struct CubicBezierFunction { |
|
80 float x1; |
|
81 float y1; |
|
82 float x2; |
|
83 float y2; |
|
84 }; |
|
85 |
|
86 struct StepFunction { |
|
87 int steps; |
|
88 // 1 = nsTimingFunction::StepStart, 2 = nsTimingFunction::StepEnd |
|
89 int type; |
|
90 }; |
|
91 |
|
92 union TimingFunction { |
|
93 CubicBezierFunction; |
|
94 StepFunction; |
|
95 }; |
|
96 |
|
97 struct LayerColor { gfxRGBA value; }; |
|
98 struct Perspective { float value; }; |
|
99 struct RotationX { float radians; }; |
|
100 struct RotationY { float radians; }; |
|
101 struct RotationZ { float radians; }; |
|
102 struct Rotation { float radians; }; |
|
103 struct Rotation3D { |
|
104 float x; |
|
105 float y; |
|
106 float z; |
|
107 float radians; |
|
108 }; |
|
109 struct Scale { |
|
110 float x; |
|
111 float y; |
|
112 float z; |
|
113 }; |
|
114 struct Skew { float x; float y; }; |
|
115 struct SkewX { float x; }; |
|
116 struct SkewY { float y; }; |
|
117 struct TransformMatrix { Matrix4x4 value; }; |
|
118 struct Translation { |
|
119 float x; |
|
120 float y; |
|
121 float z; |
|
122 }; |
|
123 |
|
124 union TransformFunction { |
|
125 Perspective; |
|
126 RotationX; |
|
127 RotationY; |
|
128 RotationZ; |
|
129 Rotation; |
|
130 Rotation3D; |
|
131 Scale; |
|
132 Skew; |
|
133 SkewX; |
|
134 SkewY; |
|
135 Translation; |
|
136 TransformMatrix; |
|
137 }; |
|
138 |
|
139 union Animatable { |
|
140 float; |
|
141 TransformFunction[]; |
|
142 }; |
|
143 |
|
144 struct AnimationSegment { |
|
145 Animatable startState; |
|
146 Animatable endState; |
|
147 float startPortion; |
|
148 float endPortion; |
|
149 TimingFunction sampleFn; |
|
150 }; |
|
151 |
|
152 // Transforms need extra information to correctly convert the list of transform |
|
153 // functions to a gfx3DMatrix that can be applied directly to the layer. |
|
154 struct TransformData { |
|
155 // the origin of the frame being transformed in app units |
|
156 nsPoint origin; |
|
157 // the transform-origin property for the transform in css pixels |
|
158 gfxPoint3D transformOrigin; |
|
159 // the perspective-origin property for the transform in css pixels |
|
160 gfxPoint3D perspectiveOrigin; |
|
161 nsRect bounds; |
|
162 nscoord perspective; |
|
163 int32_t appUnitsPerDevPixel; |
|
164 }; |
|
165 |
|
166 union AnimationData { |
|
167 null_t; |
|
168 TransformData; |
|
169 }; |
|
170 |
|
171 struct Animation { |
|
172 // Unlike in nsAnimationManager, this start time is at the end of the |
|
173 // delay. If the delay is changed dynamically, the layer's data will |
|
174 // be updated. |
|
175 TimeStamp startTime; |
|
176 TimeDuration duration; |
|
177 // For each frame, the interpolation point is computed based on the |
|
178 // startTime, the direction, the duration, and the current time. |
|
179 // The segments must uniquely cover the portion from 0.0 to 1.0 |
|
180 AnimationSegment[] segments; |
|
181 // How many times to repeat the animation. -1 means "forever". |
|
182 float numIterations; |
|
183 // This uses the NS_STYLE_ANIMATION_DIRECTION_* constants. |
|
184 int32_t direction; |
|
185 nsCSSProperty property; |
|
186 AnimationData data; |
|
187 }; |
|
188 |
|
189 // Change a layer's attributes |
|
190 struct CommonLayerAttributes { |
|
191 nsIntRegion visibleRegion; |
|
192 EventRegions eventRegions; |
|
193 TransformMatrix transform; |
|
194 float postXScale; |
|
195 float postYScale; |
|
196 uint32_t contentFlags; |
|
197 float opacity; |
|
198 bool useClipRect; |
|
199 nsIntRect clipRect; |
|
200 bool isFixedPosition; |
|
201 LayerPoint fixedPositionAnchor; |
|
202 LayerMargin fixedPositionMargin; |
|
203 bool isStickyPosition; |
|
204 uint64_t stickyScrollContainerId; |
|
205 LayerRect stickyScrollRangeOuter; |
|
206 LayerRect stickyScrollRangeInner; |
|
207 uint64_t scrollbarTargetContainerId; |
|
208 uint32_t scrollbarDirection; |
|
209 nullable PLayer maskLayer; |
|
210 // Animated colors will only honored for ColorLayers. |
|
211 Animation[] animations; |
|
212 nsIntRegion invalidRegion; |
|
213 }; |
|
214 |
|
215 struct ThebesLayerAttributes { |
|
216 nsIntRegion validRegion; |
|
217 }; |
|
218 struct ContainerLayerAttributes { |
|
219 FrameMetrics metrics; |
|
220 ViewID scrollParentId; |
|
221 float preXScale; |
|
222 float preYScale; |
|
223 float inheritedXScale; |
|
224 float inheritedYScale; |
|
225 }; |
|
226 struct ColorLayerAttributes { LayerColor color; nsIntRect bounds; }; |
|
227 struct CanvasLayerAttributes { GraphicsFilterType filter; nsIntRect bounds; }; |
|
228 struct RefLayerAttributes { int64_t id; }; |
|
229 struct ImageLayerAttributes { GraphicsFilterType filter; IntSize scaleToSize; ScaleMode scaleMode; }; |
|
230 |
|
231 union SpecificLayerAttributes { |
|
232 null_t; |
|
233 ThebesLayerAttributes; |
|
234 ContainerLayerAttributes; |
|
235 ColorLayerAttributes; |
|
236 CanvasLayerAttributes; |
|
237 RefLayerAttributes; |
|
238 ImageLayerAttributes; |
|
239 }; |
|
240 |
|
241 struct LayerAttributes { |
|
242 CommonLayerAttributes common; |
|
243 SpecificLayerAttributes specific; |
|
244 }; |
|
245 |
|
246 struct OpSetLayerAttributes { |
|
247 PLayer layer; |
|
248 LayerAttributes attrs; |
|
249 }; |
|
250 |
|
251 // Monkey with the tree structure |
|
252 struct OpSetRoot { PLayer root; }; |
|
253 struct OpInsertAfter { PLayer container; PLayer childLayer; PLayer after; }; |
|
254 struct OpPrependChild { PLayer container; PLayer childLayer; }; |
|
255 struct OpRemoveChild { PLayer container; PLayer childLayer; }; |
|
256 struct OpRepositionChild { PLayer container; PLayer childLayer; PLayer after; }; |
|
257 struct OpRaiseToTopChild { PLayer container; PLayer childLayer; }; |
|
258 |
|
259 struct OpSetDiagnosticTypes { DiagnosticTypes diagnostics; }; |
|
260 |
|
261 struct ShmemSection { |
|
262 Shmem shmem; |
|
263 uint32_t offset; |
|
264 size_t size; |
|
265 }; |
|
266 |
|
267 union TileLock { |
|
268 ShmemSection; |
|
269 uintptr_t; |
|
270 }; |
|
271 |
|
272 struct TexturedTileDescriptor { |
|
273 PTexture texture; |
|
274 TileLock sharedLock; |
|
275 }; |
|
276 |
|
277 struct PlaceholderTileDescriptor { |
|
278 }; |
|
279 |
|
280 union TileDescriptor { |
|
281 TexturedTileDescriptor; |
|
282 PlaceholderTileDescriptor; |
|
283 }; |
|
284 |
|
285 struct SurfaceDescriptorTiles { |
|
286 nsIntRegion validRegion; |
|
287 nsIntRegion paintedRegion; |
|
288 TileDescriptor[] tiles; |
|
289 int retainedWidth; |
|
290 int retainedHeight; |
|
291 float resolution; |
|
292 float frameResolution; |
|
293 }; |
|
294 |
|
295 struct OpUseTiledLayerBuffer { |
|
296 PCompositable compositable; |
|
297 SurfaceDescriptorTiles tileLayerDescriptor; |
|
298 }; |
|
299 |
|
300 struct OpCreatedIncrementalTexture { |
|
301 PCompositable compositable; |
|
302 TextureInfo textureInfo; |
|
303 nsIntRect bufferRect; |
|
304 }; |
|
305 |
|
306 struct OpPaintTextureRegion { |
|
307 PCompositable compositable; |
|
308 ThebesBufferData bufferData; |
|
309 nsIntRegion updatedRegion; |
|
310 }; |
|
311 |
|
312 struct OpPaintTextureIncremental { |
|
313 PCompositable compositable; |
|
314 uint32_t textureId; |
|
315 SurfaceDescriptor image; |
|
316 nsIntRegion updatedRegion; |
|
317 nsIntRect bufferRect; |
|
318 nsIntPoint bufferRotation; |
|
319 }; |
|
320 |
|
321 struct OpUpdatePictureRect { |
|
322 PCompositable compositable; |
|
323 nsIntRect picture; |
|
324 }; |
|
325 |
|
326 /** |
|
327 * Tells the CompositableHost to remove the corresponding TextureHost |
|
328 */ |
|
329 struct OpRemoveTexture { |
|
330 PCompositable compositable; |
|
331 PTexture texture; |
|
332 }; |
|
333 |
|
334 /** |
|
335 * Tells the compositor-side which texture to use (for example, as front buffer |
|
336 * if there is several textures for double buffering) |
|
337 */ |
|
338 struct OpUseTexture { |
|
339 PCompositable compositable; |
|
340 PTexture texture; |
|
341 }; |
|
342 |
|
343 struct OpUseComponentAlphaTextures { |
|
344 PCompositable compositable; |
|
345 PTexture textureOnBlack; |
|
346 PTexture textureOnWhite; |
|
347 }; |
|
348 |
|
349 union MaybeRegion { |
|
350 nsIntRegion; |
|
351 null_t; |
|
352 }; |
|
353 |
|
354 struct OpUpdateTexture { |
|
355 PCompositable compositable; |
|
356 PTexture texture; |
|
357 MaybeRegion region; |
|
358 }; |
|
359 |
|
360 union CompositableOperation { |
|
361 OpUpdatePictureRect; |
|
362 |
|
363 OpCreatedIncrementalTexture; |
|
364 |
|
365 OpPaintTextureRegion; |
|
366 OpPaintTextureIncremental; |
|
367 |
|
368 OpUseTiledLayerBuffer; |
|
369 |
|
370 OpRemoveTexture; |
|
371 |
|
372 OpUpdateTexture; |
|
373 OpUseTexture; |
|
374 OpUseComponentAlphaTextures; |
|
375 }; |
|
376 |
|
377 // A unit of a changeset; a set of these comprise a changeset |
|
378 union Edit { |
|
379 OpCreateThebesLayer; |
|
380 OpCreateContainerLayer; |
|
381 OpCreateImageLayer; |
|
382 OpCreateColorLayer; |
|
383 OpCreateCanvasLayer; |
|
384 OpCreateRefLayer; |
|
385 |
|
386 OpSetLayerAttributes; |
|
387 OpSetDiagnosticTypes; |
|
388 |
|
389 OpSetRoot; |
|
390 OpInsertAfter; |
|
391 OpPrependChild; |
|
392 OpRemoveChild; |
|
393 OpRepositionChild; |
|
394 OpRaiseToTopChild; |
|
395 |
|
396 OpAttachCompositable; |
|
397 OpAttachAsyncCompositable; |
|
398 |
|
399 CompositableOperation; |
|
400 }; |
|
401 |
|
402 |
|
403 // Replies to operations |
|
404 |
|
405 struct OpContentBufferSwap { |
|
406 PCompositable compositable; |
|
407 nsIntRegion frontUpdatedRegion; |
|
408 }; |
|
409 |
|
410 struct OpTextureSwap { |
|
411 PCompositable compositable; |
|
412 uint32_t textureId; |
|
413 SurfaceDescriptor image; |
|
414 }; |
|
415 |
|
416 struct ReturnReleaseFence { |
|
417 PCompositable compositable; |
|
418 PTexture texture; |
|
419 FenceHandle fence; |
|
420 }; |
|
421 |
|
422 // Unit of a "changeset reply". This is a weird abstraction, probably |
|
423 // only to be used for buffer swapping. |
|
424 union EditReply { |
|
425 OpContentBufferSwap; |
|
426 OpTextureSwap; |
|
427 |
|
428 ReturnReleaseFence; |
|
429 }; |
|
430 |
|
431 } // namespace |
|
432 } // namespace |