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 "base/basictypes.h"
11 #include "FloatRect.h"
13 #include <wtf/PassOwnPtr.h>
14 #include <wtf/Vector.h>
20 struct CCLayerTreeSettings
;
22 // There are currently six types of debug rects:
24 // - Paint rects (update rects): regions of a layer that needed to be re-uploaded to the
25 // texture resource; in most cases implying that they had to be repainted, too.
27 // - Property-changed rects: enclosing bounds of layers that cause changes to the screen
28 // even if the layer did not change internally. (For example, if the layer's opacity or
31 // - Surface damage rects: the aggregate damage on a target surface that is caused by all
32 // layers and surfaces that contribute to it. This includes (1) paint rects, (2) property-
33 // changed rects, and (3) newly exposed areas.
35 // - Screen space rects: this is the region the contents occupy in screen space.
37 // - Replica screen space rects: this is the region the replica's contents occupy in screen space.
39 // - Occluding rects: these are the regions that contribute to the occluded region.
41 enum DebugRectType
{ PaintRectType
, PropertyChangedRectType
, SurfaceDamageRectType
, ScreenSpaceRectType
, ReplicaScreenSpaceRectType
, OccludingRectType
};
44 CCDebugRect(DebugRectType newType
, FloatRect newRect
)
52 // This class maintains a history of rects of various types that can be used
53 // for debugging purposes. The overhead of collecting rects is performed only if
54 // the appropriate CCLayerTreeSettings are enabled.
55 class CCDebugRectHistory
{
57 static PassOwnPtr
<CCDebugRectHistory
> create()
59 return adoptPtr(new CCDebugRectHistory());
62 ~CCDebugRectHistory();
64 // Note: Saving debug rects must happen before layers' change tracking is reset.
65 void saveDebugRectsForCurrentFrame(CCLayerImpl
* rootLayer
, const std::vector
<CCLayerImpl
*>& renderSurfaceLayerList
, const Vector
<IntRect
>& occludingScreenSpaceRects
, const CCLayerTreeSettings
&);
67 const Vector
<CCDebugRect
>& debugRects() { return m_debugRects
; }
72 void savePaintRects(CCLayerImpl
*);
73 void savePropertyChangedRects(const std::vector
<CCLayerImpl
*>& renderSurfaceLayerList
);
74 void saveSurfaceDamageRects(const std::vector
<CCLayerImpl
* >& renderSurfaceLayerList
);
75 void saveScreenSpaceRects(const std::vector
<CCLayerImpl
* >& renderSurfaceLayerList
);
76 void saveOccludingRects(const Vector
<IntRect
>& occludingScreenSpaceRects
);
78 Vector
<CCDebugRect
> m_debugRects
;
80 DISALLOW_COPY_AND_ASSIGN(CCDebugRectHistory
);
85 #endif // USE(ACCELERATED_COMPOSITING)