| 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_CACHE_H_ | 5 #ifndef UI_COMPOSITOR_PAINT_CACHE_H_ |
| 6 #define UI_COMPOSITOR_PAINT_CACHE_H_ | 6 #define UI_COMPOSITOR_PAINT_CACHE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/optional.h" |
| 9 #include "cc/playback/drawing_display_item.h" | 10 #include "cc/playback/drawing_display_item.h" |
| 10 #include "ui/compositor/compositor_export.h" | 11 #include "ui/compositor/compositor_export.h" |
| 11 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 12 | 13 |
| 13 namespace ui { | 14 namespace ui { |
| 14 class PaintContext; | 15 class PaintContext; |
| 15 class PaintRecorder; | 16 class PaintRecorder; |
| 16 | 17 |
| 17 // A class that holds the output of a PaintRecorder to be reused when the | 18 // A class that holds the output of a PaintRecorder to be reused when the |
| 18 // object that created the PaintRecorder has not been changed/invalidated. | 19 // object that created the PaintRecorder has not been changed/invalidated. |
| 19 class COMPOSITOR_EXPORT PaintCache { | 20 class COMPOSITOR_EXPORT PaintCache { |
| 20 public: | 21 public: |
| 21 PaintCache(); | 22 PaintCache(); |
| 22 ~PaintCache(); | 23 ~PaintCache(); |
| 23 | 24 |
| 24 // Returns true if the PaintCache was able to insert a previously-saved | 25 // Returns true if the PaintCache was able to insert a previously-saved |
| 25 // painting output into the PaintContext. If it returns false, the caller | 26 // painting output into the PaintContext. If it returns false, the caller |
| 26 // needs to do the work of painting, which can be stored into the PaintCache | 27 // needs to do the work of painting, which can be stored into the PaintCache |
| 27 // to be used next time. | 28 // to be used next time. |
| 28 bool UseCache(const PaintContext& context, const gfx::Size& size_in_context); | 29 bool UseCache(const PaintContext& context, const gfx::Size& size_in_context); |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 // Only PaintRecorder can modify these. | 32 // Only PaintRecorder can modify these. |
| 32 friend PaintRecorder; | 33 friend PaintRecorder; |
| 33 | 34 |
| 34 void SetCache(const cc::DrawingDisplayItem& item); | 35 void SetCache(const cc::DrawingDisplayItem& item); |
| 35 | 36 |
| 36 bool has_cache_; | 37 base::Optional<cc::DrawingDisplayItem> display_item_; |
| 37 cc::DrawingDisplayItem display_item_; | |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(PaintCache); | 39 DISALLOW_COPY_AND_ASSIGN(PaintCache); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 } // namespace ui | 42 } // namespace ui |
| 43 | 43 |
| 44 #endif // UI_COMPOSITOR_PAINT_CACHE_H_ | 44 #endif // UI_COMPOSITOR_PAINT_CACHE_H_ |
| OLD | NEW |