disable two ClientCertStoreChromeOSTest.* unit_tests on Valgrind bots
[chromium-blink-merge.git] / cc / debug / debug_rect_history.h
blob6bcf43853450a9298b79e8d56e35d74b97d05d5f
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 CC_DEBUG_DEBUG_RECT_HISTORY_H_
6 #define CC_DEBUG_DEBUG_RECT_HISTORY_H_
8 #include <vector>
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/layers/layer_lists.h"
12 #include "ui/gfx/geometry/rect.h"
14 namespace cc {
16 class LayerImpl;
17 class LayerTreeDebugState;
19 // There are currently six types of debug rects:
21 // - Paint rects (update rects): regions of a layer that needed to be
22 // re-uploaded to the texture resource; in most cases implying that they had to
23 // be repainted, too.
25 // - Property-changed rects: enclosing bounds of layers that cause changes to
26 // the screen even if the layer did not change internally. (For example, if the
27 // layer's opacity or position changes.)
29 // - Surface damage rects: the aggregate damage on a target surface that is
30 // caused by all layers and surfaces that contribute to it. This includes (1)
31 // paint rects, (2) property- changed rects, and (3) newly exposed areas.
33 // - Screen space rects: this is the region the contents occupy in screen space.
35 // - Replica screen space rects: this is the region the replica's contents
36 // occupy in screen space.
37 enum DebugRectType {
38 PAINT_RECT_TYPE,
39 PROPERTY_CHANGED_RECT_TYPE,
40 SURFACE_DAMAGE_RECT_TYPE,
41 SCREEN_SPACE_RECT_TYPE,
42 REPLICA_SCREEN_SPACE_RECT_TYPE,
43 TOUCH_EVENT_HANDLER_RECT_TYPE,
44 WHEEL_EVENT_HANDLER_RECT_TYPE,
45 SCROLL_EVENT_HANDLER_RECT_TYPE,
46 NON_FAST_SCROLLABLE_RECT_TYPE,
47 ANIMATION_BOUNDS_RECT_TYPE,
50 struct DebugRect {
51 DebugRect(DebugRectType new_type, const gfx::Rect& new_rect)
52 : type(new_type), rect(new_rect) {}
54 DebugRectType type;
55 gfx::Rect rect;
58 // This class maintains a history of rects of various types that can be used
59 // for debugging purposes. The overhead of collecting rects is performed only if
60 // the appropriate LayerTreeSettings are enabled.
61 class DebugRectHistory {
62 public:
63 static scoped_ptr<DebugRectHistory> Create();
65 ~DebugRectHistory();
67 // Note: Saving debug rects must happen before layers' change tracking is
68 // reset.
69 void SaveDebugRectsForCurrentFrame(
70 LayerImpl* root_layer,
71 LayerImpl* hud_layer,
72 const LayerImplList& render_surface_layer_list,
73 const LayerTreeDebugState& debug_state);
75 const std::vector<DebugRect>& debug_rects() { return debug_rects_; }
77 private:
78 DebugRectHistory();
80 void SavePaintRects(LayerImpl* layer);
81 void SavePropertyChangedRects(const LayerImplList& render_surface_layer_list,
82 LayerImpl* hud_layer);
83 void SaveSurfaceDamageRects(
84 const LayerImplList& render_surface_layer_list);
85 void SaveScreenSpaceRects(
86 const LayerImplList& render_surface_layer_list);
87 void SaveTouchEventHandlerRects(LayerImpl* layer);
88 void SaveTouchEventHandlerRectsCallback(LayerImpl* layer);
89 void SaveWheelEventHandlerRects(LayerImpl* layer);
90 void SaveWheelEventHandlerRectsCallback(LayerImpl* layer);
91 void SaveScrollEventHandlerRects(LayerImpl* layer);
92 void SaveScrollEventHandlerRectsCallback(LayerImpl* layer);
93 void SaveNonFastScrollableRects(LayerImpl* layer);
94 void SaveNonFastScrollableRectsCallback(LayerImpl* layer);
95 void SaveLayerAnimationBoundsRects(
96 const LayerImplList& render_surface_layer_list);
98 std::vector<DebugRect> debug_rects_;
100 DISALLOW_COPY_AND_ASSIGN(DebugRectHistory);
103 } // namespace cc
105 #endif // CC_DEBUG_DEBUG_RECT_HISTORY_H_