2010-07-21 21:17:33 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
include LayersSurfaces;
|
2012-01-19 14:45:37 +00:00
|
|
|
include protocol PCompositor;
|
2012-07-12 12:51:58 +00:00
|
|
|
include protocol PGrallocBuffer;
|
2010-07-21 21:17:33 +00:00
|
|
|
include protocol PLayer;
|
2010-08-20 23:24:41 +00:00
|
|
|
include protocol PRenderFrame;
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2012-01-03 19:36:00 +00:00
|
|
|
include "gfxipc/ShadowLayerUtils.h";
|
2012-07-24 19:01:09 +00:00
|
|
|
include "mozilla/WidgetUtils.h";
|
2012-07-31 17:28:20 +00:00
|
|
|
include "mozilla/TimeStamp.h";
|
2012-11-22 02:40:57 +00:00
|
|
|
include "mozilla/dom/ScreenOrientation.h";
|
2012-08-20 13:35:41 +00:00
|
|
|
include "nsCSSProperty.h";
|
2012-07-31 17:28:20 +00:00
|
|
|
|
|
|
|
using gfxPoint3D;
|
|
|
|
using nscoord;
|
|
|
|
using nsRect;
|
|
|
|
using nsPoint;
|
|
|
|
using mozilla::TimeDuration;
|
|
|
|
using mozilla::TimeStamp;
|
2012-08-20 13:35:41 +00:00
|
|
|
using mozilla::ScreenRotation;
|
|
|
|
using nsCSSProperty;
|
2012-11-22 02:40:57 +00:00
|
|
|
using mozilla::dom::ScreenOrientation;
|
2010-09-03 20:10:45 +00:00
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
/**
|
|
|
|
* The layers protocol is spoken between thread contexts that manage
|
|
|
|
* layer (sub)trees. The protocol comprises atomically publishing
|
|
|
|
* layer subtrees to a "shadow" thread context (which grafts the
|
|
|
|
* subtree into its own tree), and atomically updating a published
|
|
|
|
* subtree. ("Atomic" in this sense is wrt painting.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2012-07-24 19:01:09 +00:00
|
|
|
struct TargetConfig {
|
|
|
|
nsIntRect naturalBounds;
|
|
|
|
ScreenRotation rotation;
|
2012-11-22 02:40:57 +00:00
|
|
|
nsIntRect clientBounds;
|
|
|
|
ScreenOrientation orientation;
|
2012-07-24 19:01:09 +00:00
|
|
|
};
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
// Create a shadow layer for |layer|
|
|
|
|
struct OpCreateThebesLayer { PLayer layer; };
|
|
|
|
struct OpCreateContainerLayer { PLayer layer; };
|
|
|
|
struct OpCreateImageLayer { PLayer layer; };
|
|
|
|
struct OpCreateColorLayer { PLayer layer; };
|
|
|
|
struct OpCreateCanvasLayer { PLayer layer; };
|
2012-07-17 23:59:45 +00:00
|
|
|
struct OpCreateRefLayer { PLayer layer; };
|
2011-08-09 19:38:26 +00:00
|
|
|
|
2010-09-28 22:05:30 +00:00
|
|
|
struct ThebesBuffer {
|
|
|
|
SurfaceDescriptor buffer;
|
|
|
|
nsIntRect rect;
|
2012-07-31 17:28:20 +00:00
|
|
|
nsIntPoint rotation;
|
2010-09-28 22:05:30 +00:00
|
|
|
};
|
2010-11-05 07:17:07 +00:00
|
|
|
union OptionalThebesBuffer { ThebesBuffer; null_t; };
|
2010-09-28 22:05:30 +00:00
|
|
|
|
2011-09-27 22:19:28 +00:00
|
|
|
union CanvasSurface {
|
|
|
|
SurfaceDescriptor;
|
|
|
|
null_t;
|
|
|
|
};
|
|
|
|
|
2012-07-31 17:28:20 +00:00
|
|
|
struct CubicBezierFunction {
|
|
|
|
float x1;
|
|
|
|
float y1;
|
|
|
|
float x2;
|
|
|
|
float y2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StepFunction {
|
|
|
|
int steps;
|
|
|
|
// 1 = nsTimingFunction::StepStart, 2 = nsTimingFunction::StepEnd
|
|
|
|
int type;
|
|
|
|
};
|
|
|
|
|
|
|
|
union TimingFunction {
|
|
|
|
CubicBezierFunction;
|
|
|
|
StepFunction;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Color { gfxRGBA value; };
|
|
|
|
struct Perspective { float value; };
|
|
|
|
struct RotationX { float radians; };
|
|
|
|
struct RotationY { float radians; };
|
|
|
|
struct RotationZ { float radians; };
|
|
|
|
struct Rotation { float radians; };
|
|
|
|
struct Rotation3D {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
float radians;
|
|
|
|
};
|
|
|
|
struct Scale {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
};
|
|
|
|
struct SkewX { float x; };
|
|
|
|
struct SkewY { float y; };
|
|
|
|
struct TransformMatrix { gfx3DMatrix value; };
|
|
|
|
struct Translation {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
};
|
|
|
|
|
|
|
|
union TransformFunction {
|
|
|
|
Perspective;
|
|
|
|
RotationX;
|
|
|
|
RotationY;
|
|
|
|
RotationZ;
|
|
|
|
Rotation;
|
|
|
|
Rotation3D;
|
|
|
|
Scale;
|
|
|
|
SkewX;
|
|
|
|
SkewY;
|
|
|
|
Translation;
|
|
|
|
TransformMatrix;
|
|
|
|
};
|
|
|
|
|
|
|
|
union Animatable {
|
2012-08-20 13:35:41 +00:00
|
|
|
float;
|
2012-07-31 17:28:20 +00:00
|
|
|
TransformFunction[];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimationSegment {
|
|
|
|
Animatable startState;
|
|
|
|
Animatable endState;
|
|
|
|
float startPortion;
|
|
|
|
float endPortion;
|
|
|
|
TimingFunction sampleFn;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Transforms need extra information to correctly convert the list of transform
|
|
|
|
// functions to a gfx3DMatrix that can be applied directly to the layer.
|
|
|
|
struct TransformData {
|
|
|
|
nsPoint origin;
|
|
|
|
gfxPoint3D mozOrigin;
|
|
|
|
gfxPoint3D perspectiveOrigin;
|
|
|
|
nsRect bounds;
|
|
|
|
nscoord perspective;
|
|
|
|
};
|
|
|
|
|
|
|
|
union AnimationData {
|
|
|
|
null_t;
|
|
|
|
TransformData;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Animation {
|
2013-01-11 05:14:51 +00:00
|
|
|
// Unlike in nsAnimationManager, this start time is at the end of the
|
|
|
|
// delay. If the delay is changed dynamically, the layer's data will
|
|
|
|
// be updated.
|
2012-07-31 17:28:20 +00:00
|
|
|
TimeStamp startTime;
|
|
|
|
TimeDuration duration;
|
|
|
|
// For each frame, the interpolation point is computed based on the
|
|
|
|
// startTime, the direction, the duration, and the current time.
|
|
|
|
// The segments must uniquely cover the portion from 0.0 to 1.0
|
|
|
|
AnimationSegment[] segments;
|
|
|
|
// How many times to repeat the animation. < 0 means "forever".
|
|
|
|
float numIterations;
|
|
|
|
// This uses the NS_STYLE_ANIMATION_DIRECTION_* constants.
|
|
|
|
int32_t direction;
|
2012-08-20 13:35:41 +00:00
|
|
|
nsCSSProperty property;
|
2012-07-31 17:28:20 +00:00
|
|
|
AnimationData data;
|
|
|
|
};
|
|
|
|
|
2012-07-30 18:36:12 +00:00
|
|
|
// Change a layer's attributes
|
2010-07-21 21:17:33 +00:00
|
|
|
struct CommonLayerAttributes {
|
|
|
|
nsIntRegion visibleRegion;
|
2012-07-31 17:28:20 +00:00
|
|
|
TransformMatrix transform;
|
2012-08-03 21:29:22 +00:00
|
|
|
float postXScale;
|
|
|
|
float postYScale;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t contentFlags;
|
2012-08-20 13:35:41 +00:00
|
|
|
float opacity;
|
2010-07-21 21:17:33 +00:00
|
|
|
bool useClipRect;
|
|
|
|
nsIntRect clipRect;
|
2011-04-06 05:00:25 +00:00
|
|
|
bool isFixedPosition;
|
2012-06-27 15:43:57 +00:00
|
|
|
gfxPoint fixedPositionAnchor;
|
2012-03-18 23:02:38 +00:00
|
|
|
nullable PLayer maskLayer;
|
2012-07-31 17:28:20 +00:00
|
|
|
// Animated colors will only honored for ColorLayers.
|
|
|
|
Animation[] animations;
|
|
|
|
};
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2010-09-03 20:10:46 +00:00
|
|
|
struct ThebesLayerAttributes {
|
|
|
|
nsIntRegion validRegion;
|
|
|
|
};
|
2012-08-03 21:29:22 +00:00
|
|
|
struct ContainerLayerAttributes {
|
|
|
|
FrameMetrics metrics;
|
|
|
|
float preXScale;
|
|
|
|
float preYScale;
|
2013-01-08 09:39:12 +00:00
|
|
|
float inheritedXScale;
|
|
|
|
float inheritedYScale;
|
2012-08-03 21:29:22 +00:00
|
|
|
};
|
|
|
|
struct ColorLayerAttributes { Color color; };
|
|
|
|
struct CanvasLayerAttributes { GraphicsFilterType filter; };
|
|
|
|
struct RefLayerAttributes { int64_t id; };
|
|
|
|
struct ImageLayerAttributes {
|
2012-05-22 23:14:03 +00:00
|
|
|
GraphicsFilterType filter;
|
|
|
|
bool forceSingleTile;
|
|
|
|
};
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
union SpecificLayerAttributes {
|
|
|
|
null_t;
|
|
|
|
ThebesLayerAttributes;
|
2010-09-03 20:10:45 +00:00
|
|
|
ContainerLayerAttributes;
|
2010-07-21 21:17:33 +00:00
|
|
|
ColorLayerAttributes;
|
|
|
|
CanvasLayerAttributes;
|
2012-07-17 23:59:45 +00:00
|
|
|
RefLayerAttributes;
|
2010-07-21 21:17:33 +00:00
|
|
|
ImageLayerAttributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LayerAttributes {
|
|
|
|
CommonLayerAttributes common;
|
|
|
|
SpecificLayerAttributes specific;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OpSetLayerAttributes {
|
|
|
|
PLayer layer;
|
|
|
|
LayerAttributes attrs;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Monkey with the tree structure
|
2012-08-29 10:52:55 +00:00
|
|
|
struct OpSetRoot { PLayer root; };
|
|
|
|
struct OpInsertAfter { PLayer container; PLayer childLayer; PLayer after; };
|
|
|
|
struct OpAppendChild { PLayer container; PLayer childLayer; };
|
|
|
|
struct OpRemoveChild { PLayer container; PLayer childLayer; };
|
|
|
|
struct OpRepositionChild { PLayer container; PLayer childLayer; PLayer after; };
|
|
|
|
struct OpRaiseToTopChild { PLayer container; PLayer childLayer; };
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Paint (buffer update)
|
|
|
|
struct OpPaintThebesBuffer {
|
|
|
|
PLayer layer;
|
|
|
|
ThebesBuffer newFrontBuffer;
|
2010-09-14 05:23:08 +00:00
|
|
|
nsIntRegion updatedRegion;
|
2010-07-21 21:17:33 +00:00
|
|
|
};
|
|
|
|
|
2012-04-13 15:17:39 +00:00
|
|
|
struct OpPaintTiledLayerBuffer {
|
|
|
|
PLayer layer;
|
|
|
|
// Bug 747811
|
|
|
|
// FIXME: We need to support sharing tile across process.
|
|
|
|
uintptr_t tiledLayerBuffer;
|
|
|
|
};
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
struct OpPaintCanvas {
|
|
|
|
PLayer layer;
|
2011-09-27 22:19:28 +00:00
|
|
|
CanvasSurface newFrontBuffer;
|
|
|
|
bool needYFlip;
|
2010-07-21 21:17:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OpPaintImage {
|
|
|
|
PLayer layer;
|
2011-04-20 23:21:56 +00:00
|
|
|
SharedImage newFrontBuffer;
|
2010-07-21 21:17:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// A unit of a changeset; a set of these comprise a changeset
|
|
|
|
union Edit {
|
|
|
|
OpCreateThebesLayer;
|
|
|
|
OpCreateContainerLayer;
|
|
|
|
OpCreateImageLayer;
|
|
|
|
OpCreateColorLayer;
|
|
|
|
OpCreateCanvasLayer;
|
2012-07-17 23:59:45 +00:00
|
|
|
OpCreateRefLayer;
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
OpSetLayerAttributes;
|
|
|
|
|
|
|
|
OpSetRoot;
|
|
|
|
OpInsertAfter;
|
|
|
|
OpAppendChild;
|
|
|
|
OpRemoveChild;
|
2012-08-29 10:52:55 +00:00
|
|
|
OpRepositionChild;
|
|
|
|
OpRaiseToTopChild;
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
OpPaintThebesBuffer;
|
2012-04-13 15:17:39 +00:00
|
|
|
OpPaintTiledLayerBuffer;
|
2010-07-21 21:17:33 +00:00
|
|
|
OpPaintCanvas;
|
|
|
|
OpPaintImage;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Replies to operations
|
2011-09-27 22:19:28 +00:00
|
|
|
struct OpBufferSwap { PLayer layer; CanvasSurface newBackBuffer; };
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2011-04-21 04:38:39 +00:00
|
|
|
struct OpImageSwap { PLayer layer; SharedImage newBackImage; };
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
struct OpThebesBufferSwap {
|
|
|
|
PLayer layer;
|
2011-10-10 16:47:27 +00:00
|
|
|
OptionalThebesBuffer newBackBuffer;
|
2010-09-14 05:23:08 +00:00
|
|
|
nsIntRegion newValidRegion;
|
2010-11-05 07:17:07 +00:00
|
|
|
// If the parent took the child's old back buffer and returned its
|
|
|
|
// old front buffer, |readOnlyFrontBuffer| may (if non-null) contain
|
|
|
|
// the child's old back buffer (parent's new front buffer). This
|
|
|
|
// buffer can be used to read back the newly updated region into the
|
|
|
|
// child's new back buffer. This buffer must be considered
|
|
|
|
// read-only, but sadly that's not enforced.
|
|
|
|
OptionalThebesBuffer readOnlyFrontBuffer;
|
|
|
|
nsIntRegion frontUpdatedRegion;
|
2010-07-21 21:17:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Unit of a "changeset reply". This is a weird abstraction, probably
|
|
|
|
// only to be used for buffer swapping.
|
|
|
|
union EditReply {
|
|
|
|
OpBufferSwap;
|
2010-09-14 05:23:08 +00:00
|
|
|
OpThebesBufferSwap;
|
2011-04-21 04:38:39 +00:00
|
|
|
OpImageSwap;
|
2010-07-21 21:17:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
sync protocol PLayers {
|
2012-01-19 14:45:37 +00:00
|
|
|
manager PRenderFrame or PCompositor;
|
2012-07-12 12:51:58 +00:00
|
|
|
manages PGrallocBuffer;
|
2010-07-21 21:17:33 +00:00
|
|
|
manages PLayer;
|
|
|
|
|
|
|
|
parent:
|
2012-07-12 12:51:58 +00:00
|
|
|
/**
|
|
|
|
* Only the parent side has privileges to allocate the buffer.
|
|
|
|
* Allocation may fail (pmem is a scarce resource), and if so null_t
|
|
|
|
* is returned.
|
|
|
|
*/
|
|
|
|
sync PGrallocBuffer(gfxIntSize size, gfxContentType content)
|
|
|
|
returns (MaybeMagicGrallocBufferHandle handle);
|
2010-07-21 21:17:33 +00:00
|
|
|
async PLayer();
|
|
|
|
|
2012-03-12 15:50:07 +00:00
|
|
|
// The isFirstPaint flag can be used to indicate that this is the first update
|
|
|
|
// for a particular document.
|
2012-07-24 19:01:09 +00:00
|
|
|
sync Update(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint)
|
2010-07-21 21:17:33 +00:00
|
|
|
returns (EditReply[] reply);
|
|
|
|
|
2012-05-01 19:23:39 +00:00
|
|
|
// We don't need to send a sync transaction if
|
|
|
|
// no transaction operate require a swap.
|
2012-07-24 19:01:09 +00:00
|
|
|
async UpdateNoSwap(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint);
|
2012-05-01 19:23:39 +00:00
|
|
|
|
2012-11-08 03:51:55 +00:00
|
|
|
// Drop any front buffers that might be retained on the compositor
|
|
|
|
// side.
|
|
|
|
async ClearCachedResources();
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
async __delete__();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|