| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/cpp/point.h" | 10 #include "ppapi/cpp/point.h" |
| 11 #include "ppapi/cpp/rect.h" | 11 #include "ppapi/cpp/rect.h" |
| 12 | 12 |
| 13 namespace pp { | 13 namespace pp { |
| 14 | 14 |
| 15 // This class is responsible for aggregating multiple invalidation and scroll | 15 // This class is responsible for aggregating multiple invalidation and scroll |
| 16 // commands to produce a scroll and repaint sequence. You can use this manually | 16 // commands to produce a scroll and repaint sequence. You can use this manually |
| 17 // to track your updates, but most applications will use the PaintManager to | 17 // to track your updates, but most applications will use the PaintManager to |
| 18 // additionally handle the necessary callbacks on top of the PaintAggregator | 18 // additionally handle the necessary callbacks on top of the PaintAggregator |
| 19 // functionality. | 19 // functionality. |
| 20 // | 20 // |
| 21 // See http://code.google.com/p/ppapi/wiki/2DPaintingModel | 21 // See http://code.google.com/p/ppapi/wiki/2DPaintingModel |
| 22 class PaintAggregator { | 22 class PaintAggregator { |
| 23 public: | 23 public: |
| 24 struct PaintUpdate { | 24 struct PaintUpdate { |
| 25 PaintUpdate(); |
| 26 ~PaintUpdate(); |
| 27 |
| 25 // True if there is a scroll applied. This indicates that the scroll delta | 28 // True if there is a scroll applied. This indicates that the scroll delta |
| 26 // and scroll_rect are nonzero (just as a convenience). | 29 // and scroll_rect are nonzero (just as a convenience). |
| 27 bool has_scroll; | 30 bool has_scroll; |
| 28 | 31 |
| 29 // The amount to scroll by. Either the X or Y may be nonzero to indicate a | 32 // The amount to scroll by. Either the X or Y may be nonzero to indicate a |
| 30 // scroll in that direction, but there will never be a scroll in both | 33 // scroll in that direction, but there will never be a scroll in both |
| 31 // directions at the same time (this will be converted to a paint of the | 34 // directions at the same time (this will be converted to a paint of the |
| 32 // region instead). | 35 // region instead). |
| 33 // | 36 // |
| 34 // If there is no scroll, this will be (0, 0). | 37 // If there is no scroll, this will be (0, 0). |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // | 82 // |
| 80 // - The scroll damange (area exposed by the scroll operation, if any) is | 83 // - The scroll damange (area exposed by the scroll operation, if any) is |
| 81 // maintained separately from the dirty rects generated by calling | 84 // maintained separately from the dirty rects generated by calling |
| 82 // InvalidateRect. We need to know this distinction for some operations. | 85 // InvalidateRect. We need to know this distinction for some operations. |
| 83 // | 86 // |
| 84 // - The paint bounds union is computed on the fly so we don't have to keep | 87 // - The paint bounds union is computed on the fly so we don't have to keep |
| 85 // a rectangle up-to-date as we do different operations. | 88 // a rectangle up-to-date as we do different operations. |
| 86 class InternalPaintUpdate { | 89 class InternalPaintUpdate { |
| 87 public: | 90 public: |
| 88 InternalPaintUpdate(); | 91 InternalPaintUpdate(); |
| 92 ~InternalPaintUpdate(); |
| 89 | 93 |
| 90 // Computes the rect damaged by scrolling within |scroll_rect| by | 94 // Computes the rect damaged by scrolling within |scroll_rect| by |
| 91 // |scroll_delta|. This rect must be repainted. It is not included in | 95 // |scroll_delta|. This rect must be repainted. It is not included in |
| 92 // paint_rects or in the rect returned by GetPaintBounds. | 96 // paint_rects or in the rect returned by GetPaintBounds. |
| 93 Rect GetScrollDamage() const; | 97 Rect GetScrollDamage() const; |
| 94 | 98 |
| 95 // Returns the smallest rect containing all paint rects, not including the | 99 // Returns the smallest rect containing all paint rects, not including the |
| 96 // scroll damage rect. | 100 // scroll damage rect. |
| 97 Rect GetPaintBounds() const; | 101 Rect GetPaintBounds() const; |
| 98 | 102 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 121 // important since there is typically some overhead in deciding what to | 125 // important since there is typically some overhead in deciding what to |
| 122 // paint. If your plugin is fast at doing these computations, raise this | 126 // paint. If your plugin is fast at doing these computations, raise this |
| 123 // threshold, if your plugin is slow, lower it (probably requires some | 127 // threshold, if your plugin is slow, lower it (probably requires some |
| 124 // tuning to find the right value). | 128 // tuning to find the right value). |
| 125 size_t max_paint_rects_; | 129 size_t max_paint_rects_; |
| 126 }; | 130 }; |
| 127 | 131 |
| 128 } // namespace pp | 132 } // namespace pp |
| 129 | 133 |
| 130 #endif // PPAPI_CPP_PAINT_AGGREGATOR_H_ | 134 #endif // PPAPI_CPP_PAINT_AGGREGATOR_H_ |
| OLD | NEW |