Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef GFX_READBACKPROCESSOR_H
8
#define GFX_READBACKPROCESSOR_H
9
10
#include <stdint.h> // for uint64_t
11
#include "nsRect.h" // for mozilla::gfx::IntRect
12
#include "nsRegionFwd.h" // for nsIntRegion
13
#include "nsTArray.h" // for nsTArray
14
15
namespace mozilla {
16
namespace layers {
17
18
class ContainerLayer;
19
class ReadbackLayer;
20
class PaintedLayer;
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 PaintedLayers).
28
*
29
* This method recomputes the relationship between ReadbackLayers and
30
* sibling layers, and dispatches changes to ReadbackLayers. Except that
31
* if a PaintedLayer needs its contents sent to some ReadbackLayer, we'll
32
* just record that internally and later the PaintedLayer should call
33
* GetPaintedLayerUpdates 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 PaintedLayer should send its contents to.
41
*/
42
ReadbackLayer* mLayer;
43
/**
44
* The rectangle of content that it should send, in the PaintedLayer's
45
* coordinate system. This rectangle is guaranteed to be in the
46
* PaintedLayer's visible region. Translate it to mLayer's coordinate system
47
* by adding mLayer->GetBackgroundLayerOffset().
48
*/
49
gfx::IntRect 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 PaintedLayers
58
* that have been marked UsedForReadback().
59
* Each Update's mLayer's mBackgroundLayer will have been set to aLayer.
60
* If a PaintedLayer doesn't call GetPaintedLayerUpdates, then all the
61
* ReadbackLayers that needed data from that PaintedLayer 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 GetPaintedLayerUpdates(PaintedLayer* aLayer, nsTArray<Update>* aUpdates,
67
nsIntRegion* aUpdateRegion = nullptr);
68
69
~ReadbackProcessor();
70
71
protected:
72
void BuildUpdatesForLayer(ReadbackLayer* aLayer);
73
74
nsTArray<Update> mAllUpdates;
75
};
76
77
} // namespace layers
78
} // namespace mozilla
79
80
#endif /* GFX_READBACKPROCESSOR_H */