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 8include LayersSurfaces; 9include protocol PCompositable; 10include protocol PCompositorBridge; 11include protocol PLayer; 12include protocol PImageContainer; 13include protocol PRenderFrame; 14include protocol PTexture; 15 16include "gfxipc/ShadowLayerUtils.h"; 17include "mozilla/GfxMessageUtils.h"; 18include "ImageLayers.h"; 19 20using mozilla::gfx::SamplingFilter from "mozilla/gfx/2D.h"; 21using struct mozilla::gfx::Color from "mozilla/gfx/2D.h"; 22using struct mozilla::gfx::Point3D from "mozilla/gfx/Point.h"; 23using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h"; 24using class mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h"; 25using nscoord from "nsCoord.h"; 26using struct nsRect from "nsRect.h"; 27using struct nsPoint from "nsPoint.h"; 28using class mozilla::TimeDuration from "mozilla/TimeStamp.h"; 29using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; 30using mozilla::ScreenRotation from "mozilla/WidgetUtils.h"; 31using nsCSSPropertyID from "nsCSSPropertyID.h"; 32using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h"; 33using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; 34using mozilla::LayerMargin from "Units.h"; 35using mozilla::LayerPoint from "Units.h"; 36using mozilla::LayerRect from "Units.h"; 37using mozilla::LayerIntRegion from "Units.h"; 38using mozilla::ParentLayerIntRect from "Units.h"; 39using mozilla::LayoutDeviceIntRect from "Units.h"; 40using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h"; 41using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h"; 42using mozilla::layers::EventRegionsOverride from "mozilla/layers/LayersTypes.h"; 43using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h"; 44using struct mozilla::layers::ScrollMetadata from "FrameMetrics.h"; 45using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h"; 46using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; 47using mozilla::layers::MaybeLayerClip from "FrameMetrics.h"; 48 49namespace mozilla { 50namespace layers { 51 52struct TargetConfig { 53 IntRect naturalBounds; 54 ScreenRotation rotation; 55 ScreenOrientationInternal orientation; 56 nsIntRegion clearRegion; 57}; 58 59// Create a shadow layer for |layer| 60struct OpCreatePaintedLayer { PLayer layer; }; 61struct OpCreateContainerLayer { PLayer layer; }; 62struct OpCreateImageLayer { PLayer layer; }; 63struct OpCreateColorLayer { PLayer layer; }; 64struct OpCreateCanvasLayer { PLayer layer; }; 65struct OpCreateRefLayer { PLayer layer; }; 66 67struct OpAttachCompositable { 68 PLayer layer; 69 PCompositable compositable; 70}; 71 72struct OpAttachAsyncCompositable { 73 PLayer layer; 74 uint64_t containerID; 75}; 76 77struct ThebesBufferData { 78 IntRect rect; 79 IntPoint rotation; 80}; 81 82struct CubicBezierFunction { 83 float x1; 84 float y1; 85 float x2; 86 float y2; 87}; 88 89struct StepFunction { 90 int steps; 91 // 1 = nsTimingFunction::StepStart, 2 = nsTimingFunction::StepEnd 92 int type; 93}; 94 95union TimingFunction { 96 null_t; 97 CubicBezierFunction; 98 StepFunction; 99}; 100 101// Send the angle with units rather than sending all angles in radians 102// to avoid having floating point error introduced by unit switching. 103struct CSSAngle { 104 float value; 105 int unit; // an nsCSSUnit that is valid for angles 106}; 107 108struct LayerColor { Color value; }; 109struct Perspective { float value; }; 110struct RotationX { CSSAngle angle; }; 111struct RotationY { CSSAngle angle; }; 112struct RotationZ { CSSAngle angle; }; 113struct Rotation { CSSAngle angle; }; 114struct Rotation3D { 115 float x; 116 float y; 117 float z; 118 CSSAngle angle; 119}; 120struct Scale { 121 float x; 122 float y; 123 float z; 124}; 125struct Skew { CSSAngle x; CSSAngle y; }; 126struct SkewX { CSSAngle x; }; 127struct SkewY { CSSAngle y; }; 128struct TransformMatrix { Matrix4x4 value; }; 129struct Translation { 130 float x; 131 float y; 132 float z; 133}; 134 135union TransformFunction { 136 Perspective; 137 RotationX; 138 RotationY; 139 RotationZ; 140 Rotation; 141 Rotation3D; 142 Scale; 143 Skew; 144 SkewX; 145 SkewY; 146 Translation; 147 TransformMatrix; 148}; 149 150union Animatable { 151 float; 152 TransformFunction[]; 153}; 154 155struct AnimationSegment { 156 Animatable startState; 157 Animatable endState; 158 float startPortion; 159 float endPortion; 160 TimingFunction sampleFn; 161}; 162 163// Transforms need extra information to correctly convert the list of transform 164// functions to a Matrix4x4 that can be applied directly to the layer. 165struct TransformData { 166 // the origin of the frame being transformed in app units 167 nsPoint origin; 168 // the transform-origin property for the transform in device pixels 169 Point3D transformOrigin; 170 nsRect bounds; 171 int32_t appUnitsPerDevPixel; 172}; 173 174union AnimationData { 175 null_t; 176 TransformData; 177}; 178 179struct Animation { 180 TimeStamp startTime; 181 TimeDuration delay; 182 // The value of the animation's current time at the moment it was created. 183 // For animations that are waiting to start, their startTime will be null. 184 // Once the animation is ready to start, we calculate an appropriate value 185 // of startTime such that we begin playback from initialCurrentTime. 186 TimeDuration initialCurrentTime; 187 TimeDuration duration; 188 // For each frame, the interpolation point is computed based on the 189 // startTime, the direction, the duration, and the current time. 190 // The segments must uniquely cover the portion from 0.0 to 1.0 191 AnimationSegment[] segments; 192 // Number of times to repeat the animation, including positive infinity. 193 // Values <= 0 mean the animation will not play (although events are still 194 // dispatched on the main thread). 195 float iterations; 196 float iterationStart; 197 // This uses the NS_STYLE_ANIMATION_DIRECTION_* constants. 198 uint8_t direction; 199 // This uses dom::FillMode. 200 uint8_t fillMode; 201 nsCSSPropertyID property; 202 AnimationData data; 203 float playbackRate; 204 // This is used in the transformed progress calculation. 205 TimingFunction easingFunction; 206 uint8_t iterationComposite; 207}; 208 209// Change a layer's attributes 210struct CommonLayerAttributes { 211 IntRect layerBounds; 212 LayerIntRegion visibleRegion; 213 EventRegions eventRegions; 214 TransformMatrix transform; 215 bool transformIsPerspective; 216 float postXScale; 217 float postYScale; 218 uint32_t contentFlags; 219 float opacity; 220 bool useClipRect; 221 ParentLayerIntRect clipRect; 222 MaybeLayerClip scrolledClip; 223 bool isFixedPosition; 224 uint64_t fixedPositionScrollContainerId; 225 LayerPoint fixedPositionAnchor; 226 int32_t fixedPositionSides; 227 bool isStickyPosition; 228 uint64_t stickyScrollContainerId; 229 LayerRect stickyScrollRangeOuter; 230 LayerRect stickyScrollRangeInner; 231 uint64_t scrollbarTargetContainerId; 232 uint32_t scrollbarDirection; 233 float scrollbarThumbRatio; 234 bool isScrollbarContainer; 235 int8_t mixBlendMode; 236 bool forceIsolatedGroup; 237 nullable PLayer maskLayer; 238 PLayer[] ancestorMaskLayers; 239 // Animated colors will only honored for ColorLayers. 240 Animation[] animations; 241 nsIntRegion invalidRegion; 242 ScrollMetadata[] scrollMetadata; 243 nsCString displayListLog; 244}; 245 246struct PaintedLayerAttributes { 247 nsIntRegion validRegion; 248}; 249struct ContainerLayerAttributes { 250 float preXScale; 251 float preYScale; 252 float inheritedXScale; 253 float inheritedYScale; 254 float presShellResolution; 255 bool scaleToResolution; 256 EventRegionsOverride eventRegionsOverride; 257}; 258struct ColorLayerAttributes { LayerColor color; IntRect bounds; }; 259struct CanvasLayerAttributes { SamplingFilter samplingFilter; IntRect bounds; }; 260struct RefLayerAttributes { 261 int64_t id; 262 // TODO: Once bug 1132895 is fixed we shouldn't need to propagate the override 263 // explicitly here. 264 EventRegionsOverride eventRegionsOverride; 265}; 266struct ImageLayerAttributes { SamplingFilter samplingFilter; IntSize scaleToSize; ScaleMode scaleMode; }; 267 268union SpecificLayerAttributes { 269 null_t; 270 PaintedLayerAttributes; 271 ContainerLayerAttributes; 272 ColorLayerAttributes; 273 CanvasLayerAttributes; 274 RefLayerAttributes; 275 ImageLayerAttributes; 276}; 277 278struct LayerAttributes { 279 CommonLayerAttributes common; 280 SpecificLayerAttributes specific; 281}; 282 283// See nsIWidget Configurations 284struct PluginWindowData { 285 uintptr_t windowId; 286 LayoutDeviceIntRect[] clip; 287 LayoutDeviceIntRect bounds; 288 bool visible; 289}; 290 291struct OpSetLayerAttributes { 292 PLayer layer; 293 LayerAttributes attrs; 294}; 295 296// Monkey with the tree structure 297struct OpSetRoot { PLayer root; }; 298struct OpInsertAfter { PLayer container; PLayer childLayer; PLayer after; }; 299struct OpPrependChild { PLayer container; PLayer childLayer; }; 300struct OpRemoveChild { PLayer container; PLayer childLayer; }; 301struct OpRepositionChild { PLayer container; PLayer childLayer; PLayer after; }; 302struct OpRaiseToTopChild { PLayer container; PLayer childLayer; }; 303 304struct OpSetDiagnosticTypes { DiagnosticTypes diagnostics; }; 305struct OpWindowOverlayChanged { }; 306 307struct ShmemSection { 308 Shmem shmem; 309 uint32_t offset; 310 size_t size; 311}; 312 313union ReadLockDescriptor { 314 ShmemSection; 315 uintptr_t; 316 null_t; 317}; 318 319union MaybeTexture { 320 PTexture; 321 null_t; 322}; 323 324struct TexturedTileDescriptor { 325 PTexture texture; 326 MaybeTexture textureOnWhite; 327 IntRect updateRect; 328 ReadLockDescriptor sharedLock; 329 ReadLockDescriptor sharedLockOnWhite; 330 bool wasPlaceholder; 331}; 332 333struct PlaceholderTileDescriptor { 334}; 335 336union TileDescriptor { 337 TexturedTileDescriptor; 338 PlaceholderTileDescriptor; 339}; 340 341struct SurfaceDescriptorTiles { 342 nsIntRegion validRegion; 343 TileDescriptor[] tiles; 344 IntPoint tileOrigin; 345 IntSize tileSize; 346 int firstTileX; 347 int firstTileY; 348 int retainedWidth; 349 int retainedHeight; 350 float resolution; 351 float frameXResolution; 352 float frameYResolution; 353 bool isProgressive; 354}; 355 356struct OpUseTiledLayerBuffer { 357 SurfaceDescriptorTiles tileLayerDescriptor; 358}; 359 360struct OpUseOverlaySource { 361 OverlaySource overlay; 362 IntRect picture; 363}; 364 365struct OpPaintTextureRegion { 366 ThebesBufferData bufferData; 367 nsIntRegion updatedRegion; 368}; 369 370/** 371 * Tells the CompositableHost to remove the corresponding TextureHost 372 */ 373struct OpRemoveTexture { 374 PTexture texture; 375}; 376 377struct TimedTexture { 378 PTexture texture; 379 ReadLockDescriptor sharedLock; 380 TimeStamp timeStamp; 381 IntRect picture; 382 uint32_t frameID; 383 uint32_t producerID; 384}; 385 386/** 387 * Tells the compositor-side which textures to use (for example, as front buffer 388 * if there are several textures for double buffering). 389 * This provides a list of textures with timestamps, ordered by timestamp. 390 * The newest texture whose timestamp is <= the current time is rendered 391 * (where null is considered less than every other timestamp). If there is no 392 * such texture, the first texture is rendered. 393 * The first timestamp value can be null, but the others must not be. 394 * The list must not be empty. 395 */ 396struct OpUseTexture { 397 TimedTexture[] textures; 398}; 399 400struct OpUseComponentAlphaTextures { 401 PTexture textureOnBlack; 402 PTexture textureOnWhite; 403 ReadLockDescriptor sharedLockBlack; 404 ReadLockDescriptor sharedLockWhite; 405}; 406 407union MaybeRegion { 408 nsIntRegion; 409 null_t; 410}; 411 412struct OpNotifyNotUsed { 413 uint64_t TextureId; 414 uint64_t fwdTransactionId; 415}; 416 417union CompositableOperationDetail { 418 OpPaintTextureRegion; 419 420 OpUseTiledLayerBuffer; 421 422 OpRemoveTexture; 423 424 OpUseTexture; 425 OpUseComponentAlphaTextures; 426 OpUseOverlaySource; 427}; 428 429struct CompositableOperation { 430 PCompositable compositable; 431 CompositableOperationDetail detail; 432}; 433 434// A unit of a changeset; a set of these comprise a changeset 435// If adding a new edit type that requires the hit testing tree to be updated, 436// set the updateHitTestingTree flag to true in RecvUpdate() 437union Edit { 438 OpCreatePaintedLayer; 439 OpCreateContainerLayer; 440 OpCreateImageLayer; 441 OpCreateColorLayer; 442 OpCreateCanvasLayer; 443 OpCreateRefLayer; 444 445 OpSetLayerAttributes; 446 OpSetDiagnosticTypes; 447 OpWindowOverlayChanged; 448 449 OpSetRoot; 450 OpInsertAfter; 451 OpPrependChild; 452 OpRemoveChild; 453 OpRepositionChild; 454 OpRaiseToTopChild; 455 456 OpAttachCompositable; 457 OpAttachAsyncCompositable; 458 459 CompositableOperation; 460}; 461 462// Operations related to destroying resources, always handled after the other 463// operations for safety. 464union OpDestroy { 465 PTexture; 466 PCompositable; 467}; 468 469// Replies to operations 470 471struct OpContentBufferSwap { 472 PCompositable compositable; 473 nsIntRegion frontUpdatedRegion; 474}; 475 476/** 477 * An ImageCompositeNotification is sent the first time a particular 478 * image is composited by an ImageHost. 479 */ 480struct ImageCompositeNotification { 481 PImageContainer imageContainer; 482 TimeStamp imageTimeStamp; 483 TimeStamp firstCompositeTimeStamp; 484 uint32_t frameID; 485 uint32_t producerID; 486}; 487 488// Unit of a "changeset reply". This is a weird abstraction, probably 489// only to be used for buffer swapping. 490union EditReply { 491 OpContentBufferSwap; 492}; 493 494union AsyncParentMessageData { 495 OpNotifyNotUsed; 496}; 497 498} // namespace 499} // namespace 500