CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / gfx / layers / ReadbackProcessor.h
blob0f8bffb582e5c90a97949216501ebb7de8bf8610
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Corporation code.
17 * The Initial Developer of the Original Code is Mozilla Foundation.
18 * Portions created by the Initial Developer are Copyright (C) 2011
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Robert O'Callahan <robert@ocallahan.org>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef GFX_READBACKPROCESSOR_H
39 #define GFX_READBACKPROCESSOR_H
41 #include "ReadbackLayer.h"
42 #include "ThebesLayerBuffer.h"
44 namespace mozilla {
45 namespace layers {
47 class ReadbackProcessor {
48 public:
49 /**
50 * Called by the container before processing any child layers. Call this
51 * if any child layer might have changed in any way (other than content-only
52 * changes to layers other than ColorLayers and ThebesLayers).
54 * This method recomputes the relationship between ReadbackLayers and
55 * sibling layers, and dispatches changes to ReadbackLayers. Except that
56 * if a ThebesLayer needs its contents sent to some ReadbackLayer, we'll
57 * just record that internally and later the ThebesLayer should call
58 * GetThebesLayerUpdates when it paints, to find out which rectangle needs
59 * to be sent, and the ReadbackLayer it needs to be sent to.
61 void BuildUpdates(ContainerLayer* aContainer);
63 struct Update {
64 /**
65 * The layer a ThebesLayer should send its contents to.
67 ReadbackLayer* mLayer;
68 /**
69 * The rectangle of content that it should send, in the ThebesLayer's
70 * coordinate system. This rectangle is guaranteed to be in the ThebesLayer's
71 * visible region. Translate it to mLayer's coordinate system
72 * by adding mLayer->GetBackgroundLayerOffset().
74 nsIntRect mUpdateRect;
75 /**
76 * The sequence counter value to use when calling DoUpdate
78 PRUint64 mSequenceCounter;
80 /**
81 * Appends any ReadbackLayers that need to be updated, and the rects that
82 * need to be updated, to aUpdates. Only need to call this for ThebesLayers
83 * that have been marked UsedForReadback().
84 * Each Update's mLayer's mBackgroundLayer will have been set to aLayer.
85 * If a ThebesLayer doesn't call GetThebesLayerUpdates, then all the
86 * ReadbackLayers that needed data from that ThebesLayer will be marked
87 * as having unknown backgrounds.
88 * @param aUpdateRegion if non-null, this region is set to the union
89 * of the mUpdateRects.
91 void GetThebesLayerUpdates(ThebesLayer* aLayer,
92 nsTArray<Update>* aUpdates,
93 nsIntRegion* aUpdateRegion = nsnull);
95 ~ReadbackProcessor();
97 protected:
98 void BuildUpdatesForLayer(ReadbackLayer* aLayer);
100 nsTArray<Update> mAllUpdates;
105 #endif /* GFX_READBACKPROCESSOR_H */