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 file,
5
* You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef GFX_LAYER_TREE_INVALIDATION_H
8
#define GFX_LAYER_TREE_INVALIDATION_H
9
10
#include "nsRegion.h" // for nsIntRegion
11
#include "mozilla/UniquePtr.h" // for UniquePtr
12
#include "mozilla/gfx/Point.h"
13
14
namespace mozilla {
15
namespace layers {
16
17
class Layer;
18
class ContainerLayer;
19
20
/**
21
* Callback for ContainerLayer invalidations.
22
*
23
* @param aContainer ContainerLayer being invalidated.
24
* @param aRegion Invalidated region in the ContainerLayer's coordinate
25
* space. If null, then the entire region must be invalidated.
26
*/
27
typedef void (*NotifySubDocInvalidationFunc)(ContainerLayer* aLayer,
28
const nsIntRegion* aRegion);
29
30
/**
31
* A set of cached layer properties (including those of child layers),
32
* used for comparing differences in layer trees.
33
*/
34
struct LayerProperties {
35
protected:
36
LayerProperties() = default;
37
38
LayerProperties(const LayerProperties& a) = delete;
39
LayerProperties& operator=(const LayerProperties& a) = delete;
40
41
public:
42
virtual ~LayerProperties() = default;
43
44
/**
45
* Copies the current layer tree properties into
46
* a new LayerProperties object.
47
*
48
* @param Layer tree to copy, or nullptr if we have no
49
* initial layer tree.
50
*/
51
static UniquePtr<LayerProperties> CloneFrom(Layer* aRoot);
52
53
/**
54
* Clear all invalidation status from this layer tree.
55
*/
56
static void ClearInvalidations(Layer* aRoot);
57
58
/**
59
* Compares a set of existing layer tree properties to the current layer
60
* tree and generates the changed rectangle.
61
*
62
* @param aRoot Root layer of the layer tree to compare against.
63
* @param aOutRegion Outparam that will contain the painted area changed by
64
* the layer tree changes.
65
* @param aCallback If specified, callback to call when ContainerLayers
66
* are invalidated.
67
* @return True on success, false if a calculation overflowed and the entire
68
* layer tree area should be considered invalidated.
69
*/
70
virtual bool ComputeDifferences(Layer* aRoot, nsIntRegion& aOutRegion,
71
NotifySubDocInvalidationFunc aCallback) = 0;
72
73
virtual void MoveBy(const gfx::IntPoint& aOffset) = 0;
74
};
75
76
} // namespace layers
77
} // namespace mozilla
78
79
#endif /* GFX_LAYER_TREE_INVALIDATON_H */