1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CCDebugRectHistory_h
6 #define CCDebugRectHistory_h
8 #if USE(ACCELERATED_COMPOSITING)
10 #include "FloatRect.h"
12 #include <wtf/Noncopyable.h>
13 #include <wtf/PassOwnPtr.h>
14 #include <wtf/Vector.h>
19 struct CCLayerTreeSettings
;
21 // There are currently six types of debug rects:
23 // - Paint rects (update rects): regions of a layer that needed to be re-uploaded to the
24 // texture resource; in most cases implying that they had to be repainted, too.
26 // - Property-changed rects: enclosing bounds of layers that cause changes to the screen
27 // even if the layer did not change internally. (For example, if the layer's opacity or
30 // - Surface damage rects: the aggregate damage on a target surface that is caused by all
31 // layers and surfaces that contribute to it. This includes (1) paint rects, (2) property-
32 // changed rects, and (3) newly exposed areas.
34 // - Screen space rects: this is the region the contents occupy in screen space.
36 // - Replica screen space rects: this is the region the replica's contents occupy in screen space.
38 // - Occluding rects: these are the regions that contribute to the occluded region.
40 enum DebugRectType
{ PaintRectType
, PropertyChangedRectType
, SurfaceDamageRectType
, ScreenSpaceRectType
, ReplicaScreenSpaceRectType
, OccludingRectType
};
43 CCDebugRect(DebugRectType newType
, FloatRect newRect
)
51 // This class maintains a history of rects of various types that can be used
52 // for debugging purposes. The overhead of collecting rects is performed only if
53 // the appropriate CCLayerTreeSettings are enabled.
54 class CCDebugRectHistory
{
55 WTF_MAKE_NONCOPYABLE(CCDebugRectHistory
);
57 static PassOwnPtr
<CCDebugRectHistory
> create()
59 return adoptPtr(new CCDebugRectHistory());
62 // Note: Saving debug rects must happen before layers' change tracking is reset.
63 void saveDebugRectsForCurrentFrame(CCLayerImpl
* rootLayer
, const Vector
<CCLayerImpl
*>& renderSurfaceLayerList
, const Vector
<IntRect
>& occludingScreenSpaceRects
, const CCLayerTreeSettings
&);
65 const Vector
<CCDebugRect
>& debugRects() { return m_debugRects
; }
70 void savePaintRects(CCLayerImpl
*);
71 void savePropertyChangedRects(const Vector
<CCLayerImpl
*>& renderSurfaceLayerList
);
72 void saveSurfaceDamageRects(const Vector
<CCLayerImpl
* >& renderSurfaceLayerList
);
73 void saveScreenSpaceRects(const Vector
<CCLayerImpl
* >& renderSurfaceLayerList
);
74 void saveOccludingRects(const Vector
<IntRect
>& occludingScreenSpaceRects
);
76 Vector
<CCDebugRect
> m_debugRects
;
81 #endif // USE(ACCELERATED_COMPOSITING)