michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: include LayersSurfaces; michael@0: include protocol PCompositable; michael@0: include protocol PCompositor; michael@0: include protocol PGrallocBuffer; michael@0: include protocol PLayer; michael@0: include protocol PRenderFrame; michael@0: include protocol PTexture; michael@0: michael@0: include "gfxipc/ShadowLayerUtils.h"; michael@0: include "mozilla/GfxMessageUtils.h"; michael@0: include "ImageLayers.h"; michael@0: michael@0: using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h"; michael@0: using struct gfxRGBA from "gfxColor.h"; michael@0: using struct gfxPoint3D from "gfxPoint3D.h"; michael@0: using class mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h"; michael@0: using class gfx3DMatrix from "gfx3DMatrix.h"; michael@0: using nscoord from "nsCoord.h"; michael@0: using struct nsIntPoint from "nsPoint.h"; michael@0: using struct nsRect from "nsRect.h"; michael@0: using struct nsPoint from "nsPoint.h"; michael@0: using class mozilla::TimeDuration from "mozilla/TimeStamp.h"; michael@0: using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; michael@0: using mozilla::ScreenRotation from "mozilla/WidgetUtils.h"; michael@0: using nsCSSProperty from "nsCSSProperty.h"; michael@0: using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h"; michael@0: using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; michael@0: using mozilla::LayerMargin from "Units.h"; michael@0: using mozilla::LayerPoint from "Units.h"; michael@0: using mozilla::LayerRect from "Units.h"; michael@0: using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h"; michael@0: using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h"; michael@0: using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h"; michael@0: using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; michael@0: using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h"; michael@0: using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h"; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: struct TargetConfig { michael@0: nsIntRect naturalBounds; michael@0: ScreenRotation rotation; michael@0: nsIntRect clientBounds; michael@0: ScreenOrientation orientation; michael@0: nsIntRegion clearRegion; michael@0: }; michael@0: michael@0: // Create a shadow layer for |layer| michael@0: struct OpCreateThebesLayer { PLayer layer; }; michael@0: struct OpCreateContainerLayer { PLayer layer; }; michael@0: struct OpCreateImageLayer { PLayer layer; }; michael@0: struct OpCreateColorLayer { PLayer layer; }; michael@0: struct OpCreateCanvasLayer { PLayer layer; }; michael@0: struct OpCreateRefLayer { PLayer layer; }; michael@0: michael@0: struct OpAttachCompositable { michael@0: PLayer layer; michael@0: PCompositable compositable; michael@0: }; michael@0: michael@0: struct OpAttachAsyncCompositable { michael@0: PLayer layer; michael@0: uint64_t containerID; michael@0: }; michael@0: michael@0: struct ThebesBufferData { michael@0: nsIntRect rect; michael@0: nsIntPoint rotation; michael@0: }; michael@0: michael@0: struct CubicBezierFunction { michael@0: float x1; michael@0: float y1; michael@0: float x2; michael@0: float y2; michael@0: }; michael@0: michael@0: struct StepFunction { michael@0: int steps; michael@0: // 1 = nsTimingFunction::StepStart, 2 = nsTimingFunction::StepEnd michael@0: int type; michael@0: }; michael@0: michael@0: union TimingFunction { michael@0: CubicBezierFunction; michael@0: StepFunction; michael@0: }; michael@0: michael@0: struct LayerColor { gfxRGBA value; }; michael@0: struct Perspective { float value; }; michael@0: struct RotationX { float radians; }; michael@0: struct RotationY { float radians; }; michael@0: struct RotationZ { float radians; }; michael@0: struct Rotation { float radians; }; michael@0: struct Rotation3D { michael@0: float x; michael@0: float y; michael@0: float z; michael@0: float radians; michael@0: }; michael@0: struct Scale { michael@0: float x; michael@0: float y; michael@0: float z; michael@0: }; michael@0: struct Skew { float x; float y; }; michael@0: struct SkewX { float x; }; michael@0: struct SkewY { float y; }; michael@0: struct TransformMatrix { Matrix4x4 value; }; michael@0: struct Translation { michael@0: float x; michael@0: float y; michael@0: float z; michael@0: }; michael@0: michael@0: union TransformFunction { michael@0: Perspective; michael@0: RotationX; michael@0: RotationY; michael@0: RotationZ; michael@0: Rotation; michael@0: Rotation3D; michael@0: Scale; michael@0: Skew; michael@0: SkewX; michael@0: SkewY; michael@0: Translation; michael@0: TransformMatrix; michael@0: }; michael@0: michael@0: union Animatable { michael@0: float; michael@0: TransformFunction[]; michael@0: }; michael@0: michael@0: struct AnimationSegment { michael@0: Animatable startState; michael@0: Animatable endState; michael@0: float startPortion; michael@0: float endPortion; michael@0: TimingFunction sampleFn; michael@0: }; michael@0: michael@0: // Transforms need extra information to correctly convert the list of transform michael@0: // functions to a gfx3DMatrix that can be applied directly to the layer. michael@0: struct TransformData { michael@0: // the origin of the frame being transformed in app units michael@0: nsPoint origin; michael@0: // the transform-origin property for the transform in css pixels michael@0: gfxPoint3D transformOrigin; michael@0: // the perspective-origin property for the transform in css pixels michael@0: gfxPoint3D perspectiveOrigin; michael@0: nsRect bounds; michael@0: nscoord perspective; michael@0: int32_t appUnitsPerDevPixel; michael@0: }; michael@0: michael@0: union AnimationData { michael@0: null_t; michael@0: TransformData; michael@0: }; michael@0: michael@0: struct Animation { michael@0: // Unlike in nsAnimationManager, this start time is at the end of the michael@0: // delay. If the delay is changed dynamically, the layer's data will michael@0: // be updated. michael@0: TimeStamp startTime; michael@0: TimeDuration duration; michael@0: // For each frame, the interpolation point is computed based on the michael@0: // startTime, the direction, the duration, and the current time. michael@0: // The segments must uniquely cover the portion from 0.0 to 1.0 michael@0: AnimationSegment[] segments; michael@0: // How many times to repeat the animation. -1 means "forever". michael@0: float numIterations; michael@0: // This uses the NS_STYLE_ANIMATION_DIRECTION_* constants. michael@0: int32_t direction; michael@0: nsCSSProperty property; michael@0: AnimationData data; michael@0: }; michael@0: michael@0: // Change a layer's attributes michael@0: struct CommonLayerAttributes { michael@0: nsIntRegion visibleRegion; michael@0: EventRegions eventRegions; michael@0: TransformMatrix transform; michael@0: float postXScale; michael@0: float postYScale; michael@0: uint32_t contentFlags; michael@0: float opacity; michael@0: bool useClipRect; michael@0: nsIntRect clipRect; michael@0: bool isFixedPosition; michael@0: LayerPoint fixedPositionAnchor; michael@0: LayerMargin fixedPositionMargin; michael@0: bool isStickyPosition; michael@0: uint64_t stickyScrollContainerId; michael@0: LayerRect stickyScrollRangeOuter; michael@0: LayerRect stickyScrollRangeInner; michael@0: uint64_t scrollbarTargetContainerId; michael@0: uint32_t scrollbarDirection; michael@0: nullable PLayer maskLayer; michael@0: // Animated colors will only honored for ColorLayers. michael@0: Animation[] animations; michael@0: nsIntRegion invalidRegion; michael@0: }; michael@0: michael@0: struct ThebesLayerAttributes { michael@0: nsIntRegion validRegion; michael@0: }; michael@0: struct ContainerLayerAttributes { michael@0: FrameMetrics metrics; michael@0: ViewID scrollParentId; michael@0: float preXScale; michael@0: float preYScale; michael@0: float inheritedXScale; michael@0: float inheritedYScale; michael@0: }; michael@0: struct ColorLayerAttributes { LayerColor color; nsIntRect bounds; }; michael@0: struct CanvasLayerAttributes { GraphicsFilterType filter; nsIntRect bounds; }; michael@0: struct RefLayerAttributes { int64_t id; }; michael@0: struct ImageLayerAttributes { GraphicsFilterType filter; IntSize scaleToSize; ScaleMode scaleMode; }; michael@0: michael@0: union SpecificLayerAttributes { michael@0: null_t; michael@0: ThebesLayerAttributes; michael@0: ContainerLayerAttributes; michael@0: ColorLayerAttributes; michael@0: CanvasLayerAttributes; michael@0: RefLayerAttributes; michael@0: ImageLayerAttributes; michael@0: }; michael@0: michael@0: struct LayerAttributes { michael@0: CommonLayerAttributes common; michael@0: SpecificLayerAttributes specific; michael@0: }; michael@0: michael@0: struct OpSetLayerAttributes { michael@0: PLayer layer; michael@0: LayerAttributes attrs; michael@0: }; michael@0: michael@0: // Monkey with the tree structure michael@0: struct OpSetRoot { PLayer root; }; michael@0: struct OpInsertAfter { PLayer container; PLayer childLayer; PLayer after; }; michael@0: struct OpPrependChild { PLayer container; PLayer childLayer; }; michael@0: struct OpRemoveChild { PLayer container; PLayer childLayer; }; michael@0: struct OpRepositionChild { PLayer container; PLayer childLayer; PLayer after; }; michael@0: struct OpRaiseToTopChild { PLayer container; PLayer childLayer; }; michael@0: michael@0: struct OpSetDiagnosticTypes { DiagnosticTypes diagnostics; }; michael@0: michael@0: struct ShmemSection { michael@0: Shmem shmem; michael@0: uint32_t offset; michael@0: size_t size; michael@0: }; michael@0: michael@0: union TileLock { michael@0: ShmemSection; michael@0: uintptr_t; michael@0: }; michael@0: michael@0: struct TexturedTileDescriptor { michael@0: PTexture texture; michael@0: TileLock sharedLock; michael@0: }; michael@0: michael@0: struct PlaceholderTileDescriptor { michael@0: }; michael@0: michael@0: union TileDescriptor { michael@0: TexturedTileDescriptor; michael@0: PlaceholderTileDescriptor; michael@0: }; michael@0: michael@0: struct SurfaceDescriptorTiles { michael@0: nsIntRegion validRegion; michael@0: nsIntRegion paintedRegion; michael@0: TileDescriptor[] tiles; michael@0: int retainedWidth; michael@0: int retainedHeight; michael@0: float resolution; michael@0: float frameResolution; michael@0: }; michael@0: michael@0: struct OpUseTiledLayerBuffer { michael@0: PCompositable compositable; michael@0: SurfaceDescriptorTiles tileLayerDescriptor; michael@0: }; michael@0: michael@0: struct OpCreatedIncrementalTexture { michael@0: PCompositable compositable; michael@0: TextureInfo textureInfo; michael@0: nsIntRect bufferRect; michael@0: }; michael@0: michael@0: struct OpPaintTextureRegion { michael@0: PCompositable compositable; michael@0: ThebesBufferData bufferData; michael@0: nsIntRegion updatedRegion; michael@0: }; michael@0: michael@0: struct OpPaintTextureIncremental { michael@0: PCompositable compositable; michael@0: uint32_t textureId; michael@0: SurfaceDescriptor image; michael@0: nsIntRegion updatedRegion; michael@0: nsIntRect bufferRect; michael@0: nsIntPoint bufferRotation; michael@0: }; michael@0: michael@0: struct OpUpdatePictureRect { michael@0: PCompositable compositable; michael@0: nsIntRect picture; michael@0: }; michael@0: michael@0: /** michael@0: * Tells the CompositableHost to remove the corresponding TextureHost michael@0: */ michael@0: struct OpRemoveTexture { michael@0: PCompositable compositable; michael@0: PTexture texture; michael@0: }; michael@0: michael@0: /** michael@0: * Tells the compositor-side which texture to use (for example, as front buffer michael@0: * if there is several textures for double buffering) michael@0: */ michael@0: struct OpUseTexture { michael@0: PCompositable compositable; michael@0: PTexture texture; michael@0: }; michael@0: michael@0: struct OpUseComponentAlphaTextures { michael@0: PCompositable compositable; michael@0: PTexture textureOnBlack; michael@0: PTexture textureOnWhite; michael@0: }; michael@0: michael@0: union MaybeRegion { michael@0: nsIntRegion; michael@0: null_t; michael@0: }; michael@0: michael@0: struct OpUpdateTexture { michael@0: PCompositable compositable; michael@0: PTexture texture; michael@0: MaybeRegion region; michael@0: }; michael@0: michael@0: union CompositableOperation { michael@0: OpUpdatePictureRect; michael@0: michael@0: OpCreatedIncrementalTexture; michael@0: michael@0: OpPaintTextureRegion; michael@0: OpPaintTextureIncremental; michael@0: michael@0: OpUseTiledLayerBuffer; michael@0: michael@0: OpRemoveTexture; michael@0: michael@0: OpUpdateTexture; michael@0: OpUseTexture; michael@0: OpUseComponentAlphaTextures; michael@0: }; michael@0: michael@0: // A unit of a changeset; a set of these comprise a changeset michael@0: union Edit { michael@0: OpCreateThebesLayer; michael@0: OpCreateContainerLayer; michael@0: OpCreateImageLayer; michael@0: OpCreateColorLayer; michael@0: OpCreateCanvasLayer; michael@0: OpCreateRefLayer; michael@0: michael@0: OpSetLayerAttributes; michael@0: OpSetDiagnosticTypes; michael@0: michael@0: OpSetRoot; michael@0: OpInsertAfter; michael@0: OpPrependChild; michael@0: OpRemoveChild; michael@0: OpRepositionChild; michael@0: OpRaiseToTopChild; michael@0: michael@0: OpAttachCompositable; michael@0: OpAttachAsyncCompositable; michael@0: michael@0: CompositableOperation; michael@0: }; michael@0: michael@0: michael@0: // Replies to operations michael@0: michael@0: struct OpContentBufferSwap { michael@0: PCompositable compositable; michael@0: nsIntRegion frontUpdatedRegion; michael@0: }; michael@0: michael@0: struct OpTextureSwap { michael@0: PCompositable compositable; michael@0: uint32_t textureId; michael@0: SurfaceDescriptor image; michael@0: }; michael@0: michael@0: struct ReturnReleaseFence { michael@0: PCompositable compositable; michael@0: PTexture texture; michael@0: FenceHandle fence; michael@0: }; michael@0: michael@0: // Unit of a "changeset reply". This is a weird abstraction, probably michael@0: // only to be used for buffer swapping. michael@0: union EditReply { michael@0: OpContentBufferSwap; michael@0: OpTextureSwap; michael@0: michael@0: ReturnReleaseFence; michael@0: }; michael@0: michael@0: } // namespace michael@0: } // namespace