| 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 #include "ui/gfx/geometry/rect.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 class DisplayItem; | 13 class DisplayItem; |
| 14 class DisplayItemList; | 14 class DisplayItemList; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 class Path; | 18 class Path; |
| 19 class Size; | |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace ui { | 21 namespace ui { |
| 23 class PaintContext; | 22 class PaintContext; |
| 24 | 23 |
| 25 // A class to provide scoped clips of painting to a DisplayItemList. The clip | 24 // A class to provide scoped clips of painting to a DisplayItemList. The clip |
| 26 // provided will be applied to any DisplayItems added to the DisplayItemList | 25 // provided will be applied to any DisplayItems added to the DisplayItemList |
| 27 // while this object is alive. In other words, any nested recorders will be | 26 // while this object is alive. In other words, any nested recorders will be |
| 28 // clipped. | 27 // clipped. |
| 29 class COMPOSITOR_EXPORT ClipRecorder { | 28 class COMPOSITOR_EXPORT ClipRecorder { |
| 30 public: | 29 public: |
| 31 explicit ClipRecorder(const PaintContext& context); | 30 explicit ClipRecorder(const PaintContext& context); |
| 32 ~ClipRecorder(); | 31 ~ClipRecorder(); |
| 33 | 32 |
| 34 void ClipRect(const gfx::Rect& clip_rect); | 33 void ClipRect(const gfx::Rect& clip_rect); |
| 35 void ClipPath(const gfx::Path& clip_path); | 34 void ClipPath(const gfx::Path& clip_path); |
| 36 void ClipPathWithAntiAliasing(const gfx::Path& clip_path); | 35 void ClipPathWithAntiAliasing(const gfx::Path& clip_path); |
| 37 | 36 |
| 38 private: | 37 private: |
| 39 enum Closer { | 38 enum Closer { |
| 40 CLIP_RECT, | 39 CLIP_RECT, |
| 41 CLIP_PATH, | 40 CLIP_PATH, |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 void RecordCloser(const gfx::Rect& bounds_in_layer, Closer); | 43 void RecordCloser(Closer); |
| 45 | 44 |
| 46 const PaintContext& context_; | 45 const PaintContext& context_; |
| 47 // If someone needs to do more than this many operations with a single | 46 // If someone needs to do more than this many operations with a single |
| 48 // ClipRecorder then we'll increase this. | 47 // ClipRecorder then we'll increase this. |
| 49 enum : int { kMaxOpCount = 4 }; | 48 enum : int { kMaxOpCount = 4 }; |
| 50 Closer closers_[kMaxOpCount]; | 49 Closer closers_[kMaxOpCount]; |
| 51 gfx::Rect bounds_in_layer_[kMaxOpCount]; | |
| 52 int num_closers_; | 50 int num_closers_; |
| 53 | 51 |
| 54 DISALLOW_COPY_AND_ASSIGN(ClipRecorder); | 52 DISALLOW_COPY_AND_ASSIGN(ClipRecorder); |
| 55 }; | 53 }; |
| 56 | 54 |
| 57 } // namespace ui | 55 } // namespace ui |
| 58 | 56 |
| 59 #endif // UI_COMPOSITOR_CLIP_RECORDER_H_ | 57 #endif // UI_COMPOSITOR_CLIP_RECORDER_H_ |
| OLD | NEW |