|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef GFX_READBACKPROCESSOR_H |
|
7 #define GFX_READBACKPROCESSOR_H |
|
8 |
|
9 #include <stdint.h> // for uint64_t |
|
10 #include "nsRect.h" // for nsIntRect |
|
11 #include "nsTArray.h" // for nsTArray |
|
12 |
|
13 class nsIntRegion; |
|
14 |
|
15 namespace mozilla { |
|
16 namespace layers { |
|
17 |
|
18 class ContainerLayer; |
|
19 class ReadbackLayer; |
|
20 class ThebesLayer; |
|
21 |
|
22 class ReadbackProcessor { |
|
23 public: |
|
24 /** |
|
25 * Called by the container before processing any child layers. Call this |
|
26 * if any child layer might have changed in any way (other than content-only |
|
27 * changes to layers other than ColorLayers and ThebesLayers). |
|
28 * |
|
29 * This method recomputes the relationship between ReadbackLayers and |
|
30 * sibling layers, and dispatches changes to ReadbackLayers. Except that |
|
31 * if a ThebesLayer needs its contents sent to some ReadbackLayer, we'll |
|
32 * just record that internally and later the ThebesLayer should call |
|
33 * GetThebesLayerUpdates when it paints, to find out which rectangle needs |
|
34 * to be sent, and the ReadbackLayer it needs to be sent to. |
|
35 */ |
|
36 void BuildUpdates(ContainerLayer* aContainer); |
|
37 |
|
38 struct Update { |
|
39 /** |
|
40 * The layer a ThebesLayer should send its contents to. |
|
41 */ |
|
42 ReadbackLayer* mLayer; |
|
43 /** |
|
44 * The rectangle of content that it should send, in the ThebesLayer's |
|
45 * coordinate system. This rectangle is guaranteed to be in the ThebesLayer's |
|
46 * visible region. Translate it to mLayer's coordinate system |
|
47 * by adding mLayer->GetBackgroundLayerOffset(). |
|
48 */ |
|
49 nsIntRect mUpdateRect; |
|
50 /** |
|
51 * The sequence counter value to use when calling DoUpdate |
|
52 */ |
|
53 uint64_t mSequenceCounter; |
|
54 }; |
|
55 /** |
|
56 * Appends any ReadbackLayers that need to be updated, and the rects that |
|
57 * need to be updated, to aUpdates. Only need to call this for ThebesLayers |
|
58 * that have been marked UsedForReadback(). |
|
59 * Each Update's mLayer's mBackgroundLayer will have been set to aLayer. |
|
60 * If a ThebesLayer doesn't call GetThebesLayerUpdates, then all the |
|
61 * ReadbackLayers that needed data from that ThebesLayer will be marked |
|
62 * as having unknown backgrounds. |
|
63 * @param aUpdateRegion if non-null, this region is set to the union |
|
64 * of the mUpdateRects. |
|
65 */ |
|
66 void GetThebesLayerUpdates(ThebesLayer* aLayer, |
|
67 nsTArray<Update>* aUpdates, |
|
68 nsIntRegion* aUpdateRegion = nullptr); |
|
69 |
|
70 ~ReadbackProcessor(); |
|
71 |
|
72 protected: |
|
73 void BuildUpdatesForLayer(ReadbackLayer* aLayer); |
|
74 |
|
75 nsTArray<Update> mAllUpdates; |
|
76 }; |
|
77 |
|
78 } |
|
79 } |
|
80 #endif /* GFX_READBACKPROCESSOR_H */ |