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";
|
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 {
|
|
|
|
|
|
|
|
// 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; };
|
2011-08-09 19:38:26 +00:00
|
|
|
|
2010-09-28 22:05:30 +00:00
|
|
|
struct ThebesBuffer {
|
|
|
|
SurfaceDescriptor buffer;
|
|
|
|
nsIntRect rect;
|
|
|
|
nsIntPoint rotation;
|
|
|
|
};
|
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;
|
|
|
|
};
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
// Change a layer's attributes
|
|
|
|
struct CommonLayerAttributes {
|
|
|
|
nsIntRegion visibleRegion;
|
|
|
|
gfx3DMatrix transform;
|
2010-09-02 09:18:40 +00:00
|
|
|
PRUint32 contentFlags;
|
2010-07-21 21:17:33 +00:00
|
|
|
float opacity;
|
|
|
|
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;
|
2010-07-21 21:17:33 +00:00
|
|
|
};
|
|
|
|
|
2010-09-03 20:10:46 +00:00
|
|
|
struct ThebesLayerAttributes {
|
|
|
|
nsIntRegion validRegion;
|
|
|
|
};
|
2010-09-03 20:10:45 +00:00
|
|
|
struct ContainerLayerAttributes{ FrameMetrics metrics; };
|
2010-07-21 21:17:33 +00:00
|
|
|
struct ColorLayerAttributes { gfxRGBA color; };
|
|
|
|
struct CanvasLayerAttributes { GraphicsFilterType filter; };
|
2012-05-22 23:14:03 +00:00
|
|
|
struct ImageLayerAttributes {
|
|
|
|
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;
|
|
|
|
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-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;
|
|
|
|
|
|
|
|
OpSetLayerAttributes;
|
|
|
|
|
|
|
|
OpSetRoot;
|
|
|
|
OpInsertAfter;
|
|
|
|
OpAppendChild;
|
|
|
|
OpRemoveChild;
|
|
|
|
|
|
|
|
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.
|
|
|
|
sync Update(Edit[] cset, bool isFirstPaint)
|
2010-07-21 21:17:33 +00:00
|
|
|
returns (EditReply[] reply);
|
|
|
|
|
2012-06-01 12:42:34 +00:00
|
|
|
// Composite the layer tree to the given surface, and return the surface.
|
|
|
|
sync DrawToSurface(SurfaceDescriptor surfaceIn)
|
|
|
|
returns (SurfaceDescriptor surfaceOut);
|
|
|
|
|
2012-05-01 19:23:39 +00: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 21:17:33 +00:00
|
|
|
async __delete__();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|