2010-07-21 14:17:33 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 04:12:37 -07: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 14:17:33 -07:00
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
include LayersSurfaces;
|
2012-01-19 06:45:37 -08:00
|
|
|
include protocol PCompositor;
|
2012-07-12 05:51:58 -07:00
|
|
|
include protocol PGrallocBuffer;
|
2010-07-21 14:17:33 -07:00
|
|
|
include protocol PLayer;
|
2010-08-20 16:24:41 -07:00
|
|
|
include protocol PRenderFrame;
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2012-01-03 11:36:00 -08:00
|
|
|
include "gfxipc/ShadowLayerUtils.h";
|
2012-07-24 12:01:09 -07:00
|
|
|
include "mozilla/WidgetUtils.h";
|
2012-07-31 10:28:20 -07:00
|
|
|
include "mozilla/TimeStamp.h";
|
2012-08-20 06:35:41 -07:00
|
|
|
include "nsCSSProperty.h";
|
2012-07-31 10:28:20 -07:00
|
|
|
|
|
|
|
using gfxPoint3D;
|
|
|
|
using nscoord;
|
|
|
|
using nsRect;
|
|
|
|
using nsPoint;
|
|
|
|
using mozilla::TimeDuration;
|
|
|
|
using mozilla::TimeStamp;
|
2012-08-20 06:35:41 -07:00
|
|
|
using mozilla::ScreenRotation;
|
|
|
|
using nsCSSProperty;
|
2010-09-03 13:10:45 -07:00
|
|
|
|
2010-07-21 14:17:33 -07: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 12:01:09 -07:00
|
|
|
struct TargetConfig {
|
|
|
|
nsIntRect naturalBounds;
|
|
|
|
ScreenRotation rotation;
|
|
|
|
};
|
|
|
|
|
2010-07-21 14:17:33 -07: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 16:59:45 -07:00
|
|
|
struct OpCreateRefLayer { PLayer layer; };
|
2011-08-09 12:38:26 -07:00
|
|
|
|
2010-09-28 15:05:30 -07:00
|
|
|
struct ThebesBuffer {
|
|
|
|
SurfaceDescriptor buffer;
|
|
|
|
nsIntRect rect;
|
2012-07-31 10:28:20 -07:00
|
|
|
nsIntPoint rotation;
|
2010-09-28 15:05:30 -07:00
|
|
|
};
|
2010-11-05 00:17:07 -07:00
|
|
|
union OptionalThebesBuffer { ThebesBuffer; null_t; };
|
2010-09-28 15:05:30 -07:00
|
|
|
|
2011-09-27 15:19:28 -07:00
|
|
|
union CanvasSurface {
|
|
|
|
SurfaceDescriptor;
|
|
|
|
null_t;
|
|
|
|
};
|
|
|
|
|
2012-07-31 10:28:20 -07: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 06:35:41 -07:00
|
|
|
float;
|
2012-07-31 10:28:20 -07: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 {
|
|
|
|
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 06:35:41 -07:00
|
|
|
nsCSSProperty property;
|
2012-07-31 10:28:20 -07:00
|
|
|
AnimationData data;
|
|
|
|
};
|
|
|
|
|
2012-07-30 11:36:12 -07:00
|
|
|
// Change a layer's attributes
|
2010-07-21 14:17:33 -07:00
|
|
|
struct CommonLayerAttributes {
|
|
|
|
nsIntRegion visibleRegion;
|
2012-07-31 10:28:20 -07:00
|
|
|
TransformMatrix transform;
|
2012-08-03 14:29:22 -07:00
|
|
|
float postXScale;
|
|
|
|
float postYScale;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t contentFlags;
|
2012-08-20 06:35:41 -07:00
|
|
|
float opacity;
|
2010-07-21 14:17:33 -07:00
|
|
|
bool useClipRect;
|
|
|
|
nsIntRect clipRect;
|
2011-04-05 22:00:25 -07:00
|
|
|
bool isFixedPosition;
|
2012-06-27 08:43:57 -07:00
|
|
|
gfxPoint fixedPositionAnchor;
|
2012-03-18 16:02:38 -07:00
|
|
|
nullable PLayer maskLayer;
|
2012-07-31 10:28:20 -07:00
|
|
|
// Animated colors will only honored for ColorLayers.
|
|
|
|
Animation[] animations;
|
|
|
|
};
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2010-09-03 13:10:46 -07:00
|
|
|
struct ThebesLayerAttributes {
|
|
|
|
nsIntRegion validRegion;
|
|
|
|
};
|
2012-08-03 14:29:22 -07:00
|
|
|
struct ContainerLayerAttributes {
|
|
|
|
FrameMetrics metrics;
|
|
|
|
float preXScale;
|
|
|
|
float preYScale;
|
|
|
|
};
|
|
|
|
struct ColorLayerAttributes { Color color; };
|
|
|
|
struct CanvasLayerAttributes { GraphicsFilterType filter; };
|
|
|
|
struct RefLayerAttributes { int64_t id; };
|
|
|
|
struct ImageLayerAttributes {
|
2012-05-22 16:14:03 -07:00
|
|
|
GraphicsFilterType filter;
|
|
|
|
bool forceSingleTile;
|
|
|
|
};
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
union SpecificLayerAttributes {
|
|
|
|
null_t;
|
|
|
|
ThebesLayerAttributes;
|
2010-09-03 13:10:45 -07:00
|
|
|
ContainerLayerAttributes;
|
2010-07-21 14:17:33 -07:00
|
|
|
ColorLayerAttributes;
|
|
|
|
CanvasLayerAttributes;
|
2012-07-17 16:59:45 -07:00
|
|
|
RefLayerAttributes;
|
2010-07-21 14:17:33 -07:00
|
|
|
ImageLayerAttributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LayerAttributes {
|
|
|
|
CommonLayerAttributes common;
|
|
|
|
SpecificLayerAttributes specific;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OpSetLayerAttributes {
|
|
|
|
PLayer layer;
|
|
|
|
LayerAttributes attrs;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Monkey with the tree structure
|
2012-08-29 03:52:55 -07: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 14:17:33 -07:00
|
|
|
|
|
|
|
|
|
|
|
// Paint (buffer update)
|
|
|
|
struct OpPaintThebesBuffer {
|
|
|
|
PLayer layer;
|
|
|
|
ThebesBuffer newFrontBuffer;
|
2010-09-13 22:23:08 -07:00
|
|
|
nsIntRegion updatedRegion;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
2012-04-13 08:17:39 -07:00
|
|
|
struct OpPaintTiledLayerBuffer {
|
|
|
|
PLayer layer;
|
|
|
|
// Bug 747811
|
|
|
|
// FIXME: We need to support sharing tile across process.
|
|
|
|
uintptr_t tiledLayerBuffer;
|
|
|
|
};
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
struct OpPaintCanvas {
|
|
|
|
PLayer layer;
|
2011-09-27 15:19:28 -07:00
|
|
|
CanvasSurface newFrontBuffer;
|
|
|
|
bool needYFlip;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OpPaintImage {
|
|
|
|
PLayer layer;
|
2011-04-20 16:21:56 -07:00
|
|
|
SharedImage newFrontBuffer;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// A unit of a changeset; a set of these comprise a changeset
|
|
|
|
union Edit {
|
|
|
|
OpCreateThebesLayer;
|
|
|
|
OpCreateContainerLayer;
|
|
|
|
OpCreateImageLayer;
|
|
|
|
OpCreateColorLayer;
|
|
|
|
OpCreateCanvasLayer;
|
2012-07-17 16:59:45 -07:00
|
|
|
OpCreateRefLayer;
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
OpSetLayerAttributes;
|
|
|
|
|
|
|
|
OpSetRoot;
|
|
|
|
OpInsertAfter;
|
|
|
|
OpAppendChild;
|
|
|
|
OpRemoveChild;
|
2012-08-29 03:52:55 -07:00
|
|
|
OpRepositionChild;
|
|
|
|
OpRaiseToTopChild;
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
OpPaintThebesBuffer;
|
2012-04-13 08:17:39 -07:00
|
|
|
OpPaintTiledLayerBuffer;
|
2010-07-21 14:17:33 -07:00
|
|
|
OpPaintCanvas;
|
|
|
|
OpPaintImage;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Replies to operations
|
2011-09-27 15:19:28 -07:00
|
|
|
struct OpBufferSwap { PLayer layer; CanvasSurface newBackBuffer; };
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2011-04-20 21:38:39 -07:00
|
|
|
struct OpImageSwap { PLayer layer; SharedImage newBackImage; };
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
struct OpThebesBufferSwap {
|
|
|
|
PLayer layer;
|
2011-10-10 09:47:27 -07:00
|
|
|
OptionalThebesBuffer newBackBuffer;
|
2010-09-13 22:23:08 -07:00
|
|
|
nsIntRegion newValidRegion;
|
2010-11-05 00:17:07 -07: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 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// Unit of a "changeset reply". This is a weird abstraction, probably
|
|
|
|
// only to be used for buffer swapping.
|
|
|
|
union EditReply {
|
|
|
|
OpBufferSwap;
|
2010-09-13 22:23:08 -07:00
|
|
|
OpThebesBufferSwap;
|
2011-04-20 21:38:39 -07:00
|
|
|
OpImageSwap;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
sync protocol PLayers {
|
2012-01-19 06:45:37 -08:00
|
|
|
manager PRenderFrame or PCompositor;
|
2012-07-12 05:51:58 -07:00
|
|
|
manages PGrallocBuffer;
|
2010-07-21 14:17:33 -07:00
|
|
|
manages PLayer;
|
|
|
|
|
|
|
|
parent:
|
2012-07-12 05:51:58 -07: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 14:17:33 -07:00
|
|
|
async PLayer();
|
|
|
|
|
2012-03-12 08:50:07 -07:00
|
|
|
// The isFirstPaint flag can be used to indicate that this is the first update
|
|
|
|
// for a particular document.
|
2012-07-24 12:01:09 -07:00
|
|
|
sync Update(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint)
|
2010-07-21 14:17:33 -07:00
|
|
|
returns (EditReply[] reply);
|
|
|
|
|
2012-05-01 12:23:39 -07:00
|
|
|
// We don't need to send a sync transaction if
|
|
|
|
// no transaction operate require a swap.
|
2012-07-24 12:01:09 -07:00
|
|
|
async UpdateNoSwap(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint);
|
2012-05-01 12:23:39 -07:00
|
|
|
|
2012-11-07 19:51:55 -08:00
|
|
|
// Drop any front buffers that might be retained on the compositor
|
|
|
|
// side.
|
|
|
|
async ClearCachedResources();
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
async __delete__();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|