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-01-19 06:45:37 -08:00
|
|
|
include protocol PCompositor;
|
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
|
|
|
using gfx3DMatrix;
|
2012-06-27 08:43:57 -07:00
|
|
|
using gfxPoint;
|
2010-07-21 14:17:33 -07:00
|
|
|
using gfxRGBA;
|
|
|
|
using nsIntPoint;
|
|
|
|
using nsIntRect;
|
|
|
|
using nsIntRegion;
|
|
|
|
using nsIntSize;
|
|
|
|
using mozilla::GraphicsFilterType;
|
2010-09-03 13:10:45 -07:00
|
|
|
using mozilla::layers::FrameMetrics;
|
2010-09-13 22:23:08 -07:00
|
|
|
using mozilla::layers::SurfaceDescriptorX11;
|
2010-07-21 14:17:33 -07:00
|
|
|
using mozilla::null_t;
|
2011-08-09 12:38:26 -07:00
|
|
|
using mozilla::WindowsHandle;
|
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; };
|
2011-08-09 12:38:26 -07:00
|
|
|
|
|
|
|
struct SurfaceDescriptorD3D10 {
|
|
|
|
WindowsHandle handle;
|
|
|
|
};
|
2010-09-13 22:23:08 -07:00
|
|
|
|
|
|
|
union SurfaceDescriptor {
|
|
|
|
Shmem;
|
2011-08-09 12:38:26 -07:00
|
|
|
SurfaceDescriptorD3D10;
|
2010-09-13 22:23:08 -07:00
|
|
|
SurfaceDescriptorX11;
|
|
|
|
};
|
|
|
|
|
2011-04-20 21:38:39 -07:00
|
|
|
struct YUVImage {
|
|
|
|
Shmem Ydata;
|
|
|
|
Shmem Udata;
|
|
|
|
Shmem Vdata;
|
2011-07-04 19:52:00 -07:00
|
|
|
nsIntRect picture;
|
2011-04-20 21:38:39 -07:00
|
|
|
};
|
|
|
|
|
2011-04-20 16:21:56 -07:00
|
|
|
union SharedImage {
|
|
|
|
SurfaceDescriptor;
|
2011-04-20 21:38:39 -07:00
|
|
|
YUVImage;
|
2011-09-27 15:19:26 -07:00
|
|
|
null_t;
|
2011-04-20 16:21:56 -07:00
|
|
|
};
|
|
|
|
|
2010-09-28 15:05:30 -07:00
|
|
|
struct ThebesBuffer {
|
|
|
|
SurfaceDescriptor buffer;
|
|
|
|
nsIntRect rect;
|
|
|
|
nsIntPoint rotation;
|
|
|
|
};
|
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;
|
|
|
|
};
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
// Change a layer's attributes
|
|
|
|
struct CommonLayerAttributes {
|
|
|
|
nsIntRegion visibleRegion;
|
|
|
|
gfx3DMatrix transform;
|
2010-09-02 02:18:40 -07:00
|
|
|
PRUint32 contentFlags;
|
2010-07-21 14:17:33 -07:00
|
|
|
float opacity;
|
|
|
|
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; };
|
2010-07-21 14:17:33 -07:00
|
|
|
struct ColorLayerAttributes { gfxRGBA color; };
|
|
|
|
struct CanvasLayerAttributes { GraphicsFilterType filter; };
|
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
2010-07-21 14:17:33 -07:00
|
|
|
manages PLayer;
|
|
|
|
|
|
|
|
parent:
|
|
|
|
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
|