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
4 : *
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/
9 : *
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.
14 : *
15 : * The Original Code is Mozilla Corporation code.
16 : *
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.
20 : *
21 : * Contributor(s):
22 : * Robert O'Callahan <robert@ocallahan.org>
23 : *
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.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef GFX_READBACKPROCESSOR_H
39 : #define GFX_READBACKPROCESSOR_H
40 :
41 : #include "ReadbackLayer.h"
42 : #include "ThebesLayerBuffer.h"
43 : #include "nsTArray.h"
44 :
45 : namespace mozilla {
46 : namespace layers {
47 :
48 0 : class ReadbackProcessor {
49 : public:
50 : /**
51 : * Called by the container before processing any child layers. Call this
52 : * if any child layer might have changed in any way (other than content-only
53 : * changes to layers other than ColorLayers and ThebesLayers).
54 : *
55 : * This method recomputes the relationship between ReadbackLayers and
56 : * sibling layers, and dispatches changes to ReadbackLayers. Except that
57 : * if a ThebesLayer needs its contents sent to some ReadbackLayer, we'll
58 : * just record that internally and later the ThebesLayer should call
59 : * GetThebesLayerUpdates when it paints, to find out which rectangle needs
60 : * to be sent, and the ReadbackLayer it needs to be sent to.
61 : */
62 : void BuildUpdates(ContainerLayer* aContainer);
63 :
64 0 : struct Update {
65 : /**
66 : * The layer a ThebesLayer should send its contents to.
67 : */
68 : ReadbackLayer* mLayer;
69 : /**
70 : * The rectangle of content that it should send, in the ThebesLayer's
71 : * coordinate system. This rectangle is guaranteed to be in the ThebesLayer's
72 : * visible region. Translate it to mLayer's coordinate system
73 : * by adding mLayer->GetBackgroundLayerOffset().
74 : */
75 : nsIntRect mUpdateRect;
76 : /**
77 : * The sequence counter value to use when calling DoUpdate
78 : */
79 : PRUint64 mSequenceCounter;
80 : };
81 : /**
82 : * Appends any ReadbackLayers that need to be updated, and the rects that
83 : * need to be updated, to aUpdates. Only need to call this for ThebesLayers
84 : * that have been marked UsedForReadback().
85 : * Each Update's mLayer's mBackgroundLayer will have been set to aLayer.
86 : * If a ThebesLayer doesn't call GetThebesLayerUpdates, then all the
87 : * ReadbackLayers that needed data from that ThebesLayer will be marked
88 : * as having unknown backgrounds.
89 : * @param aUpdateRegion if non-null, this region is set to the union
90 : * of the mUpdateRects.
91 : */
92 : void GetThebesLayerUpdates(ThebesLayer* aLayer,
93 : nsTArray<Update>* aUpdates,
94 : nsIntRegion* aUpdateRegion = nsnull);
95 :
96 : ~ReadbackProcessor();
97 :
98 : protected:
99 : void BuildUpdatesForLayer(ReadbackLayer* aLayer);
100 :
101 : nsTArray<Update> mAllUpdates;
102 : };
103 :
104 : }
105 : }
106 : #endif /* GFX_READBACKPROCESSOR_H */
|