| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_DEBUG_RECT_HISTORY_H_ | 5 #ifndef CC_DEBUG_RECT_HISTORY_H_ |
| 6 #define CC_DEBUG_RECT_HISTORY_H_ | 6 #define CC_DEBUG_RECT_HISTORY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| 11 #include "ui/gfx/rect_f.h" | 11 #include "ui/gfx/rect_f.h" |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class LayerImpl; | 16 class LayerImpl; |
| 17 class LayerTreeDebugState; | 17 class LayerTreeDebugState; |
| 18 | 18 |
| 19 // There are currently six types of debug rects: | 19 // There are currently six types of debug rects: |
| 20 // | 20 // |
| 21 // - Paint rects (update rects): regions of a layer that needed to be re-uploade
d to the | 21 // - Paint rects (update rects): regions of a layer that needed to be |
| 22 // texture resource; in most cases implying that they had to be repainted, too
. | 22 // re-uploaded to the texture resource; in most cases implying that they had to |
| 23 // be repainted, too. |
| 23 // | 24 // |
| 24 // - Property-changed rects: enclosing bounds of layers that cause changes to th
e screen | 25 // - Property-changed rects: enclosing bounds of layers that cause changes to |
| 25 // even if the layer did not change internally. (For example, if the layer's o
pacity or | 26 // the screen even if the layer did not change internally. (For example, if the |
| 26 // position changes.) | 27 // layer's opacity or position changes.) |
| 27 // | 28 // |
| 28 // - Surface damage rects: the aggregate damage on a target surface that is caus
ed by all | 29 // - Surface damage rects: the aggregate damage on a target surface that is |
| 29 // layers and surfaces that contribute to it. This includes (1) paint rects, (
2) property- | 30 // caused by all layers and surfaces that contribute to it. This includes (1) |
| 30 // changed rects, and (3) newly exposed areas. | 31 // paint rects, (2) property- changed rects, and (3) newly exposed areas. |
| 31 // | 32 // |
| 32 // - Screen space rects: this is the region the contents occupy in screen space. | 33 // - Screen space rects: this is the region the contents occupy in screen space. |
| 33 // | 34 // |
| 34 // - Replica screen space rects: this is the region the replica's contents occup
y in screen space. | 35 // - Replica screen space rects: this is the region the replica's contents |
| 36 // occupy in screen space. |
| 35 // | 37 // |
| 36 // - Occluding rects: these are the regions that contribute to the occluded regi
on. | 38 // - Occluding rects: these are the regions that contribute to the occluded |
| 39 // region. |
| 37 // | 40 // |
| 38 // - Non-Occluding rects: these are the regions of composited layers that do not | 41 // - Non-Occluding rects: these are the regions of composited layers that do not |
| 39 // contribute to the occluded region. | 42 // contribute to the occluded region. |
| 40 // | 43 // |
| 41 enum DebugRectType { PaintRectType, PropertyChangedRectType, SurfaceDamageRectTy
pe, ScreenSpaceRectType, ReplicaScreenSpaceRectType, OccludingRectType, NonOcclu
dingRectType }; | 44 enum DebugRectType { |
| 45 PAINT_RECT_TYPE, |
| 46 PROPERTY_CHANGED_RECT_TYPE, |
| 47 SURFACE_DAMAGE_RECT_TYPE, |
| 48 SCREEN_SPACE_RECT_TYPE, |
| 49 REPLICA_SCREEN_SPACE_RECT_TYPE, |
| 50 OCCLUDING_RECT_TYPE, |
| 51 NONOCCLUDING_RECT_TYPE, |
| 52 }; |
| 42 | 53 |
| 43 struct DebugRect { | 54 struct DebugRect { |
| 44 DebugRect(DebugRectType newType, gfx::RectF newRect) | 55 DebugRect(DebugRectType new_type, gfx::RectF new_rect) |
| 45 : type(newType) | 56 : type(new_type), rect(new_rect) {} |
| 46 , rect(newRect) { } | |
| 47 | 57 |
| 48 DebugRectType type; | 58 DebugRectType type; |
| 49 gfx::RectF rect; | 59 gfx::RectF rect; |
| 50 }; | 60 }; |
| 51 | 61 |
| 52 // This class maintains a history of rects of various types that can be used | 62 // 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 | 63 // for debugging purposes. The overhead of collecting rects is performed only if |
| 54 // the appropriate LayerTreeSettings are enabled. | 64 // the appropriate LayerTreeSettings are enabled. |
| 55 class DebugRectHistory { | 65 class DebugRectHistory { |
| 56 public: | 66 public: |
| 57 static scoped_ptr<DebugRectHistory> create(); | 67 static scoped_ptr<DebugRectHistory> Create(); |
| 58 | 68 |
| 59 ~DebugRectHistory(); | 69 ~DebugRectHistory(); |
| 60 | 70 |
| 61 // Note: Saving debug rects must happen before layers' change tracking is re
set. | 71 // Note: Saving debug rects must happen before layers' change tracking is |
| 62 void saveDebugRectsForCurrentFrame(LayerImpl* rootLayer, const std::vector<L
ayerImpl*>& renderSurfaceLayerList, const std::vector<gfx::Rect>& occludingScree
nSpaceRects, const std::vector<gfx::Rect>& nonOccludingScreenSpaceRects, const L
ayerTreeDebugState& debugState); | 72 // reset. |
| 73 void SaveDebugRectsForCurrentFrame( |
| 74 LayerImpl* root_layer, |
| 75 const std::vector<LayerImpl*>& render_surface_layer_list, |
| 76 const std::vector<gfx::Rect>& occluding_screen_space_rects, |
| 77 const std::vector<gfx::Rect>& non_occluding_screen_space_rects, |
| 78 const LayerTreeDebugState& debug_state); |
| 63 | 79 |
| 64 const std::vector<DebugRect>& debugRects() { return m_debugRects; } | 80 const std::vector<DebugRect>& debug_rects() { return debug_rects_; } |
| 65 | 81 |
| 66 private: | 82 private: |
| 67 DebugRectHistory(); | 83 DebugRectHistory(); |
| 68 | 84 |
| 69 void savePaintRects(LayerImpl*); | 85 void SavePaintRects(LayerImpl* layer); |
| 70 void savePropertyChangedRects(const std::vector<LayerImpl*>& renderSurfaceLa
yerList); | 86 void SavePropertyChangedRects( |
| 71 void saveSurfaceDamageRects(const std::vector<LayerImpl* >& renderSurfaceLay
erList); | 87 const std::vector<LayerImpl*>& render_surface_layer_list); |
| 72 void saveScreenSpaceRects(const std::vector<LayerImpl* >& renderSurfaceLayer
List); | 88 void SaveSurfaceDamageRects( |
| 73 void saveOccludingRects(const std::vector<gfx::Rect>& occludingScreenSpaceRe
cts); | 89 const std::vector<LayerImpl*>& render_surface_layer_list); |
| 74 void saveNonOccludingRects(const std::vector<gfx::Rect>& nonOccludingScreenS
paceRects); | 90 void SaveScreenSpaceRects( |
| 91 const std::vector<LayerImpl*>& render_surface_layer_list); |
| 92 void SaveOccludingRects( |
| 93 const std::vector<gfx::Rect>& occluding_screen_space_rects); |
| 94 void SaveNonOccludingRects( |
| 95 const std::vector<gfx::Rect>& non_occluding_screen_space_rects); |
| 75 | 96 |
| 76 std::vector<DebugRect> m_debugRects; | 97 std::vector<DebugRect> debug_rects_; |
| 77 | 98 |
| 78 DISALLOW_COPY_AND_ASSIGN(DebugRectHistory); | 99 DISALLOW_COPY_AND_ASSIGN(DebugRectHistory); |
| 79 }; | 100 }; |
| 80 | 101 |
| 81 } // namespace cc | 102 } // namespace cc |
| 82 | 103 |
| 83 #endif // CC_DEBUG_RECT_HISTORY_H_ | 104 #endif // CC_DEBUG_RECT_HISTORY_H_ |
| OLD | NEW |