• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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.
4 
5 #ifndef UI_VIEWS_CULL_SET_H_
6 #define UI_VIEWS_CULL_SET_H_
7 
8 #include "base/containers/hash_tables.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/views/views_export.h"
12 
13 namespace views {
14 
15 class View;
16 
17 // A CullSet defines a set of View pointers which have been possibly culled
18 // from painting or other bounds-checking operations. It wraps a set of
19 // pointers to views, or NULL if no such set is available.
20 class VIEWS_EXPORT CullSet {
21  public:
22   // Default constructor builds a CullSet that will always return true for
23   // ShouldPaint().
24   CullSet();
25   ~CullSet();
26 
27   // Wraps a set of pointers to Views, as might be provided by
28   // gfx::RTree::Query(), that intersect the damage rect and therefore need
29   // to be painted. CullSet takes ownership of the provided pointer.
30   CullSet(scoped_ptr<base::hash_set<intptr_t> > cull_set);
31 
32   // Returns true if |view| needs to be painted.
33   bool ShouldPaint(const View* view) const;
34 
35  private:
36   friend class BoundsTreeTestView;
37 
38   // The set of Views that collided with the query rectangle provided to the
39   // RTree data structure, or NULL if one is not available.
40   scoped_ptr<base::hash_set<intptr_t> > cull_set_;
41 
42   DISALLOW_COPY_AND_ASSIGN(CullSet);
43 };
44 
45 }  // namespace views
46 
47 #endif  // UI_VIEWS_CULL_SET_H_
48