Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: ppapi/cpp/paint_aggregator.h

Issue 7553026: New C++ Docs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 PPAPI_CPP_PAINT_AGGREGATOR_H_ 5 #ifndef PPAPI_CPP_PAINT_AGGREGATOR_H_
6 #define PPAPI_CPP_PAINT_AGGREGATOR_H_ 6 #define PPAPI_CPP_PAINT_AGGREGATOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ppapi/cpp/point.h" 11 #include "ppapi/cpp/point.h"
12 #include "ppapi/cpp/rect.h" 12 #include "ppapi/cpp/rect.h"
13 13
14 /// @file
15 /// This file defines the API to aggregate multiple invalidation and scroll
16 /// commands to produce a scroll and repaint sequence.
14 namespace pp { 17 namespace pp {
15 18
16 // This class is responsible for aggregating multiple invalidation and scroll 19 /// This class is responsible for aggregating multiple invalidation and scroll
17 // commands to produce a scroll and repaint sequence. You can use this manually 20 /// commands to produce a scroll and repaint sequence. You can use this manually
18 // to track your updates, but most applications will use the PaintManager to 21 /// to track your updates, but most applications will use the PaintManager to
19 // additionally handle the necessary callbacks on top of the PaintAggregator 22 /// additionally handle the necessary callbacks on top of the PaintAggregator
20 // functionality. 23 /// functionality.
21 // 24 ///
22 // See http://code.google.com/p/ppapi/wiki/2DPaintingModel 25 /// See http://code.google.com/p/ppapi/wiki/2DPaintingModel
23 class PaintAggregator { 26 class PaintAggregator {
24 public: 27 public:
25 struct PaintUpdate { 28 struct PaintUpdate {
29 /// Default constructor for creating an is_null() <code>PaintUpdate</code>
30 /// object.
26 PaintUpdate(); 31 PaintUpdate();
32
33 /// Destructor.
27 ~PaintUpdate(); 34 ~PaintUpdate();
28 35
29 // True if there is a scroll applied. This indicates that the scroll delta 36 /// True if there is a scroll applied. This indicates that the scroll delta
30 // and scroll_rect are nonzero (just as a convenience). 37 /// and scroll_rect are nonzero (just as a convenience).
31 bool has_scroll; 38 bool has_scroll;
32 39
33 // The amount to scroll by. Either the X or Y may be nonzero to indicate a 40 /// The amount to scroll by. Either the X or Y may be nonzero to indicate a
34 // scroll in that direction, but there will never be a scroll in both 41 /// scroll in that direction, but there will never be a scroll in both
35 // directions at the same time (this will be converted to a paint of the 42 /// directions at the same time (this will be converted to a paint of the
36 // region instead). 43 /// region instead).
37 // 44 ///
38 // If there is no scroll, this will be (0, 0). 45 /// If there is no scroll, this will be (0, 0).
39 Point scroll_delta; 46 Point scroll_delta;
40 47
41 // The rectangle that should be scrolled by the scroll_delta. If there is no 48 /// The rectangle that should be scrolled by the scroll_delta. If there is
42 // scroll, this will be (0, 0, 0, 0). We only track one scroll command at 49 /// no scroll, this will be (0, 0, 0, 0). We only track one scroll command
43 // once. If there are multiple ones, they will be converted to invalidates. 50 /// at once. If there are multiple ones, they will be converted to
51 /// invalidates.
44 Rect scroll_rect; 52 Rect scroll_rect;
45 53
46 // A list of all the individual dirty rectangles. This is an aggregated list 54 /// A list of all the individual dirty rectangles. This is an aggregated
47 // of all invalidate calls. Different rectangles may be unified to produce a 55 /// list of all invalidate calls. Different rectangles may be unified to
48 // minimal list with no overlap that is more efficient to paint. This list 56 /// produce a minimal list with no overlap that is more efficient to paint.
49 // also contains the region exposed by any scroll command. 57 /// This list also contains the region exposed by any scroll command.
50 std::vector<Rect> paint_rects; 58 std::vector<Rect> paint_rects;
51 59
52 // The union of all paint_rects. 60 /// The union of all paint_rects.
53 Rect paint_bounds; 61 Rect paint_bounds;
54 }; 62 };
55 63
64 /// Default constructor.
56 PaintAggregator(); 65 PaintAggregator();
57 66
58 // Setters for the configuration settings. See the corresponding variables 67 /// Setter function setting the max ratio of paint rect area to scroll rect
59 // below for what these mean. 68 /// area that we will tolerate before downgrading the scroll into a repaint.
69 ///
70 /// If the combined area of paint rects contained within the scroll
71 /// rect grows too large, then we might as well just treat
72 /// the scroll rect as a paint rect.
73 ///
74 /// @param[in] area The max ratio of paint rect area to scroll rect area that
75 /// we will tolerate before downgrading the scroll into a repaint.
60 void set_max_redundant_paint_to_scroll_area(float area) { 76 void set_max_redundant_paint_to_scroll_area(float area) {
61 max_redundant_paint_to_scroll_area_ = area; 77 max_redundant_paint_to_scroll_area_ = area;
62 } 78 }
79
80 /// Setter function for setting the maximum number of paint rects. If we
81 /// exceed this limit, then we'll start combining paint rects (see
82 /// CombinePaintRects). This limiting can be important since there is
83 /// typically some overhead in deciding what to paint. If your module is fast
84 /// at doing these computations, raise this threshold, if your module is
85 /// slow, lower it (probably requires some tuning to find the right value).
86 ///
87 /// @param[in] max_rects The maximum number of paint rects.
63 void set_max_paint_rects(size_t max_rects) { 88 void set_max_paint_rects(size_t max_rects) {
64 max_paint_rects_ = max_rects; 89 max_paint_rects_ = max_rects;
65 } 90 }
66 91
67 // There is a PendingUpdate if InvalidateRect or ScrollRect were called and 92 /// This function determines if there is a pending update. There is a
68 // ClearPendingUpdate was not called. 93 /// PendingUpdate if InvalidateRect or ScrollRect were called and
94 /// ClearPendingUpdate was not called.
95 ///
96 /// @return True if there is a pending update, otherwise false.
69 bool HasPendingUpdate() const; 97 bool HasPendingUpdate() const;
98
99 /// This function clears a pending update.
70 void ClearPendingUpdate(); 100 void ClearPendingUpdate();
71 101
102 /// This function gets a pending update.
103 ///
104 /// @return A PaintUpdate containing the pending update.
72 PaintUpdate GetPendingUpdate() const; 105 PaintUpdate GetPendingUpdate() const;
73 106
74 // The given rect should be repainted. 107 /// This function invalidates the rect so it will be repainted.
108 ///
109 /// @param[in] rect A rect to be repainted.
75 void InvalidateRect(const Rect& rect); 110 void InvalidateRect(const Rect& rect);
76 111
77 // The given rect should be scrolled by the given amounts. 112 /// This function invalidate the rect so it can be scrolled.
dmichael (off chromium) 2011/08/04 16:33:38 Maybe instead: This function adds a pending scroll
dmichael (off chromium) 2011/08/09 19:24:36 Can you fix this comment? At the very leasy, inval
jond 2011/08/09 19:54:16 Done.
jond 2011/08/09 19:54:16 Done.
113 ///
114 /// @param[in] clip_rect The rect to scroll.
115 /// @param[in] amount A Point amount to scroll <code>rect</code>.
78 void ScrollRect(const Rect& clip_rect, const Point& amount); 116 void ScrollRect(const Rect& clip_rect, const Point& amount);
79 117
80 private: 118 private:
81 // This structure is an internal version of PaintUpdate. It's different in 119 // This structure is an internal version of PaintUpdate. It's different in
82 // two respects: 120 // two respects:
83 // 121 //
84 // - The scroll damange (area exposed by the scroll operation, if any) is 122 // - The scroll damange (area exposed by the scroll operation, if any) is
85 // maintained separately from the dirty rects generated by calling 123 // maintained separately from the dirty rects generated by calling
86 // InvalidateRect. We need to know this distinction for some operations. 124 // InvalidateRect. We need to know this distinction for some operations.
87 // 125 //
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // important since there is typically some overhead in deciding what to 164 // important since there is typically some overhead in deciding what to
127 // paint. If your plugin is fast at doing these computations, raise this 165 // paint. If your plugin is fast at doing these computations, raise this
128 // threshold, if your plugin is slow, lower it (probably requires some 166 // threshold, if your plugin is slow, lower it (probably requires some
129 // tuning to find the right value). 167 // tuning to find the right value).
130 size_t max_paint_rects_; 168 size_t max_paint_rects_;
131 }; 169 };
132 170
133 } // namespace pp 171 } // namespace pp
134 172
135 #endif // PPAPI_CPP_PAINT_AGGREGATOR_H_ 173 #endif // PPAPI_CPP_PAINT_AGGREGATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698