| 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_PAINT_CONTEXT_H_ | 5 #ifndef UI_COMPOSITOR_PAINT_CONTEXT_H_ |
| 6 #define UI_COMPOSITOR_PAINT_CONTEXT_H_ | 6 #define UI_COMPOSITOR_PAINT_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/compositor/compositor_export.h" | 10 #include "ui/compositor/compositor_export.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Clone a PaintContext with an additional |offset|. | 49 // Clone a PaintContext with an additional |offset|. |
| 50 PaintContext CloneWithPaintOffset(const gfx::Vector2d& offset) const { | 50 PaintContext CloneWithPaintOffset(const gfx::Vector2d& offset) const { |
| 51 return PaintContext(*this, offset); | 51 return PaintContext(*this, offset); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Clone a PaintContext that has no consideration for invalidation. | 54 // Clone a PaintContext that has no consideration for invalidation. |
| 55 PaintContext CloneWithoutInvalidation() const { | 55 PaintContext CloneWithoutInvalidation() const { |
| 56 return PaintContext(canvas_); | 56 return PaintContext(canvas_); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // When true, IsRectInvalidated() can be called, otherwise its result would be | 59 // When true, IsRectInvalid() can be called, otherwise its result would be |
| 60 // invalid. | 60 // invalid. |
| 61 bool CanCheckInvalidated() const { return !invalidation_.IsEmpty(); } | 61 bool CanCheckInvalid() const { return !invalidation_.IsEmpty(); } |
| 62 |
| 63 // When true, if a thing is not invalidated it does not need to paint itself. |
| 64 // When false, everything should provide an output when painting regardless of |
| 65 // being invalidated in order to remain visible. |
| 66 bool ShouldEarlyOutOfPaintingWhenValid() const { return !!canvas_; } |
| 62 | 67 |
| 63 // When true, the |bounds| touches an invalidated area, so should be | 68 // When true, the |bounds| touches an invalidated area, so should be |
| 64 // re-painted. When false, re-painting can be skipped. Bounds should be in | 69 // re-painted. When false, re-painting can be skipped. Bounds should be in |
| 65 // the local space with offsets up to the painting root in the PaintContext. | 70 // the local space with offsets up to the painting root in the PaintContext. |
| 66 bool IsRectInvalidated(const gfx::Rect& bounds) const { | 71 bool IsRectInvalid(const gfx::Rect& bounds) const { |
| 67 DCHECK(CanCheckInvalidated()); | 72 DCHECK(CanCheckInvalid()); |
| 68 return invalidation_.Intersects(bounds + offset_); | 73 return invalidation_.Intersects(bounds + offset_); |
| 69 } | 74 } |
| 70 | 75 |
| 71 #if DCHECK_IS_ON() | 76 #if DCHECK_IS_ON() |
| 72 void Visited(void* visited) const { | 77 void Visited(void* visited) const { |
| 73 if (!root_visited_) | 78 if (!root_visited_) |
| 74 root_visited_ = visited; | 79 root_visited_ = visited; |
| 75 } | 80 } |
| 76 void* RootVisited() const { return root_visited_; } | 81 void* RootVisited() const { return root_visited_; } |
| 77 const gfx::Vector2d& PaintOffset() const { return offset_; } | 82 const gfx::Vector2d& PaintOffset() const { return offset_; } |
| 78 #endif | 83 #endif |
| 79 | 84 |
| 80 const gfx::Rect& InvalidationForTesting() const { return invalidation_; } | 85 const gfx::Rect& InvalidationForTesting() const { return invalidation_; } |
| 81 | 86 |
| 82 private: | 87 private: |
| 83 // The Recorder classes need access to the internal canvas and friends, but we | 88 // The Recorder classes need access to the internal canvas and friends, but we |
| 84 // don't want to expose them on this class so that people must go through the | 89 // don't want to expose them on this class so that people must go through the |
| 85 // recorders to access them. | 90 // recorders to access them. |
| 86 friend class ClipTransformRecorder; | 91 friend class ClipTransformRecorder; |
| 87 friend class CompositingRecorder; | 92 friend class CompositingRecorder; |
| 88 friend class PaintRecorder; | 93 friend class PaintRecorder; |
| 94 // The Cache class also needs to access the DisplayItemList to append its |
| 95 // cache contents. |
| 96 friend class PaintCache; |
| 89 | 97 |
| 90 PaintContext& operator=(const PaintContext& other) = delete; | 98 PaintContext& operator=(const PaintContext& other) = delete; |
| 91 | 99 |
| 92 // Clone a PaintContext with an additional |offset|. | 100 // Clone a PaintContext with an additional |offset|. |
| 93 PaintContext(const PaintContext& other, const gfx::Vector2d& offset); | 101 PaintContext(const PaintContext& other, const gfx::Vector2d& offset); |
| 94 | 102 |
| 95 gfx::Canvas* canvas_; | 103 gfx::Canvas* canvas_; |
| 96 cc::DisplayItemList* list_; | 104 cc::DisplayItemList* list_; |
| 97 scoped_ptr<SkPictureRecorder> recorder_; | 105 scoped_ptr<SkPictureRecorder> recorder_; |
| 98 // The device scale of the frame being painted. Used to determine which bitmap | 106 // The device scale of the frame being painted. Used to determine which bitmap |
| (...skipping 15 matching lines...) Expand all Loading... |
| 114 mutable void* root_visited_; | 122 mutable void* root_visited_; |
| 115 // Used to verify that paint recorders are not nested. True while a paint | 123 // Used to verify that paint recorders are not nested. True while a paint |
| 116 // recorder is active. | 124 // recorder is active. |
| 117 mutable bool inside_paint_recorder_; | 125 mutable bool inside_paint_recorder_; |
| 118 #endif | 126 #endif |
| 119 }; | 127 }; |
| 120 | 128 |
| 121 } // namespace ui | 129 } // namespace ui |
| 122 | 130 |
| 123 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ | 131 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ |
| OLD | NEW |