| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 UI_COMPOSITOR_CLIP_RECORDER_H_ | 5 #ifndef UI_COMPOSITOR_CLIP_RECORDER_H_ |
| 6 #define UI_COMPOSITOR_CLIP_RECORDER_H_ | 6 #define UI_COMPOSITOR_CLIP_RECORDER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/compositor/compositor_export.h" | 9 #include "ui/compositor/compositor_export.h" |
| 10 #include "ui/gfx/geometry/rect.h" |
| 10 | 11 |
| 11 namespace cc { | 12 namespace cc { |
| 12 class DisplayItem; | 13 class DisplayItem; |
| 13 class DisplayItemList; | 14 class DisplayItemList; |
| 14 } | 15 } |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 class Path; | 18 class Path; |
| 18 class Rect; | 19 class Size; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace ui { | 22 namespace ui { |
| 22 class PaintContext; | 23 class PaintContext; |
| 23 | 24 |
| 24 // A class to provide scoped clips of painting to a DisplayItemList. The clip | 25 // A class to provide scoped clips of painting to a DisplayItemList. The clip |
| 25 // provided will be applied to any DisplayItems added to the DisplayItemList | 26 // provided will be applied to any DisplayItems added to the DisplayItemList |
| 26 // while this object is alive. In other words, any nested PaintRecorders or | 27 // while this object is alive. In other words, any nested PaintRecorders or |
| 27 // other ClipRecorders will be clipped. | 28 // other ClipRecorders will be clipped. |
| 28 class COMPOSITOR_EXPORT ClipRecorder { | 29 class COMPOSITOR_EXPORT ClipRecorder { |
| 29 public: | 30 public: |
| 30 explicit ClipRecorder(const PaintContext& context); | 31 // |size_in_layer| is the size in layer space dimensions surrounding |
| 32 // everything that's visible. |
| 33 ClipRecorder(const PaintContext& context, const gfx::Size& size_in_layer); |
| 31 ~ClipRecorder(); | 34 ~ClipRecorder(); |
| 32 | 35 |
| 33 void ClipRect(const gfx::Rect& clip_rect); | 36 void ClipRect(const gfx::Rect& clip_rect); |
| 34 void ClipPath(const gfx::Path& clip_path); | 37 void ClipPath(const gfx::Path& clip_path); |
| 35 void ClipPathWithAntiAliasing(const gfx::Path& clip_path); | 38 void ClipPathWithAntiAliasing(const gfx::Path& clip_path); |
| 36 | 39 |
| 37 private: | 40 private: |
| 38 enum Closer { | 41 enum Closer { |
| 39 CLIP_RECT, | 42 CLIP_RECT, |
| 40 CLIP_PATH, | 43 CLIP_PATH, |
| 41 }; | 44 }; |
| 42 const PaintContext& context_; | 45 const PaintContext& context_; |
| 46 const gfx::Rect bounds_in_layer_; |
| 43 // If someone needs to do more than this many operations with a single | 47 // If someone needs to do more than this many operations with a single |
| 44 // ClipRecorder then increase the size of the closers_ array. | 48 // ClipRecorder then increase the size of the closers_ array. |
| 45 Closer closers_[4]; | 49 Closer closers_[4]; |
| 46 size_t num_closers_; | 50 size_t num_closers_; |
| 47 | 51 |
| 48 DISALLOW_COPY_AND_ASSIGN(ClipRecorder); | 52 DISALLOW_COPY_AND_ASSIGN(ClipRecorder); |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 } // namespace ui | 55 } // namespace ui |
| 52 | 56 |
| 53 #endif // UI_COMPOSITOR_CLIP_RECORDER_H_ | 57 #endif // UI_COMPOSITOR_CLIP_RECORDER_H_ |
| OLD | NEW |