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";
|
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 {
|
|
|
|
|
|
|
|
// 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-23 20:25:51 -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-23 20:25:51 -07:00
|
|
|
// Change a layer's attributes
|
2010-07-21 14:17:33 -07:00
|
|
|
struct CommonLayerAttributes {
|
|
|
|
nsIntRegion visibleRegion;
|
2012-07-23 20:25:51 -07:00
|
|
|
gfx3DMatrix transform;
|
2010-09-02 02:18:40 -07:00
|
|
|
PRUint32 contentFlags;
|
2012-07-23 20:25:51 -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;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
2010-09-03 13:10:46 -07:00
|
|
|
struct ThebesLayerAttributes {
|
|
|
|
nsIntRegion validRegion;
|
|
|
|
};
|
2010-09-03 13:10:45 -07:00
|
|
|
struct ContainerLayerAttributes{ FrameMetrics metrics; };
|
2012-07-23 20:25:51 -07:00
|
|
|
struct ColorLayerAttributes { gfxRGBA color; };
|
2010-07-21 14:17:33 -07:00
|
|
|
struct CanvasLayerAttributes { GraphicsFilterType filter; };
|
2012-07-17 16:59:45 -07:00
|
|
|
struct RefLayerAttributes { int64_t id; };
|
2012-05-22 16:14:03 -07:00
|
|
|
struct ImageLayerAttributes {
|
|
|
|
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
|
|
|
|
struct OpSetRoot { PLayer root; };
|
|
|
|
struct OpInsertAfter { PLayer container; PLayer childLayer; PLayer after; };
|
|
|
|
struct OpAppendChild { PLayer container; PLayer childLayer; };
|
|
|
|
struct OpRemoveChild { PLayer container; PLayer childLayer; };
|
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
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.
|
|
|
|
sync Update(Edit[] cset, bool isFirstPaint)
|
2010-07-21 14:17:33 -07:00
|
|
|
returns (EditReply[] reply);
|
|
|
|
|
2012-06-01 05:42:34 -07:00
|
|
|
// Composite the layer tree to the given surface, and return the surface.
|
|
|
|
sync DrawToSurface(SurfaceDescriptor surfaceIn)
|
|
|
|
returns (SurfaceDescriptor surfaceOut);
|
|
|
|
|
2012-05-01 12:23:39 -07:00
|
|
|
// We don't need to send a sync transaction if
|
|
|
|
// no transaction operate require a swap.
|
|
|
|
async UpdateNoSwap(Edit[] cset, bool isFirstPaint);
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
async __delete__();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|