1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 /* ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at:
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is Mozilla Code.
19 * The Initial Developer of the Original Code is
20 * The Mozilla Foundation
21 * Portions created by the Initial Developer are Copyright (C) 2010
22 * the Initial Developer. All Rights Reserved.
25 * Chris Jones <jones.chris.g@gmail.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 //include protocol PCompositor;
42 include protocol PLayer;
43 include protocol PRenderFrame;
45 include "IPC/ShadowLayerUtils.h";
53 using mozilla::GraphicsFilterType;
54 using mozilla::layers::FrameMetrics;
55 using mozilla::layers::SurfaceDescriptorX11;
56 using mozilla::null_t;
57 using mozilla::LayersBackend;
60 * The layers protocol is spoken between thread contexts that manage
61 * layer (sub)trees. The protocol comprises atomically publishing
62 * layer subtrees to a "shadow" thread context (which grafts the
63 * subtree into its own tree), and atomically updating a published
64 * subtree. ("Atomic" in this sense is wrt painting.)
70 // Create a shadow layer for |layer|
71 struct OpCreateThebesLayer { PLayer layer; };
72 struct OpCreateContainerLayer { PLayer layer; };
73 struct OpCreateImageLayer { PLayer layer; };
74 struct OpCreateColorLayer { PLayer layer; };
75 struct OpCreateCanvasLayer { PLayer layer; };
77 // For the "buffer creation" operations, we send an initial front
78 // buffer that only contains (transparent) black pixels just so that
79 // we can swap it back after the first OpPaint without a special case.
81 union SurfaceDescriptor {
87 SurfaceDescriptor buffer;
91 union OptionalThebesBuffer { ThebesBuffer; null_t; };
93 struct OpCreateThebesBuffer {
95 OptionalThebesBuffer initialFront;
96 nsIntRegion frontValidRegion;
100 struct OpDestroyThebesFrontBuffer { PLayer layer; };
102 struct OpCreateCanvasBuffer {
107 struct OpDestroyCanvasFrontBuffer { PLayer layer; };
109 struct OpCreateImageBuffer {
114 struct OpDestroyImageFrontBuffer { PLayer layer; };
117 // Change a layer's attributes
118 struct CommonLayerAttributes {
119 nsIntRegion visibleRegion;
120 gfx3DMatrix transform;
121 PRUint32 contentFlags;
125 bool useTileSourceRect;
126 nsIntRect tileSourceRect;
129 struct ThebesLayerAttributes {
130 nsIntRegion validRegion;
134 struct ContainerLayerAttributes{ FrameMetrics metrics; };
135 struct ColorLayerAttributes { gfxRGBA color; };
136 struct CanvasLayerAttributes { GraphicsFilterType filter; };
137 struct ImageLayerAttributes { GraphicsFilterType filter; };
139 union SpecificLayerAttributes {
141 ThebesLayerAttributes;
142 ContainerLayerAttributes;
143 ColorLayerAttributes;
144 CanvasLayerAttributes;
145 ImageLayerAttributes;
148 struct LayerAttributes {
149 CommonLayerAttributes common;
150 SpecificLayerAttributes specific;
153 struct OpSetLayerAttributes {
155 LayerAttributes attrs;
159 // Monkey with the tree structure
160 struct OpSetRoot { PLayer root; };
161 struct OpInsertAfter { PLayer container; PLayer childLayer; PLayer after; };
162 struct OpAppendChild { PLayer container; PLayer childLayer; };
163 struct OpRemoveChild { PLayer container; PLayer childLayer; };
166 // Paint (buffer update)
167 struct OpPaintThebesBuffer {
169 ThebesBuffer newFrontBuffer;
170 nsIntRegion updatedRegion;
173 struct OpPaintCanvas {
176 Shmem newFrontBuffer;
179 struct OpPaintImage {
181 Shmem newFrontBuffer;
185 // A unit of a changeset; a set of these comprise a changeset
188 OpCreateContainerLayer;
192 OpCreateCanvasBuffer;
193 OpCreateThebesBuffer;
195 OpDestroyThebesFrontBuffer;
196 OpDestroyCanvasFrontBuffer;
197 OpDestroyImageFrontBuffer;
199 OpSetLayerAttributes;
212 // Replies to operations
213 struct OpBufferSwap { PLayer layer; SurfaceDescriptor newBackBuffer; };
215 struct OpThebesBufferSwap {
217 ThebesBuffer newBackBuffer;
218 nsIntRegion newValidRegion;
219 float newXResolution;
220 float newYResolution;
221 // If the parent took the child's old back buffer and returned its
222 // old front buffer, |readOnlyFrontBuffer| may (if non-null) contain
223 // the child's old back buffer (parent's new front buffer). This
224 // buffer can be used to read back the newly updated region into the
225 // child's new back buffer. This buffer must be considered
226 // read-only, but sadly that's not enforced.
227 OptionalThebesBuffer readOnlyFrontBuffer;
228 nsIntRegion frontUpdatedRegion;
231 // Unit of a "changeset reply". This is a weird abstraction, probably
232 // only to be used for buffer swapping.
239 sync protocol PLayers {
240 manager PRenderFrame /*or PCompositor or PMedia or PPlugin*/;
246 sync Update(Edit[] cset)
247 returns (EditReply[] reply);
250 returns (LayersBackend backend);
255 } // namespace layers
256 } // namespace mozilla