| 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_RECORDER_H_ | 5 #ifndef UI_COMPOSITOR_PAINT_RECORDER_H_ |
| 6 #define UI_COMPOSITOR_PAINT_RECORDER_H_ | 6 #define UI_COMPOSITOR_PAINT_RECORDER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/paint/record_paint_canvas.h" | 11 #include "cc/paint/record_paint_canvas.h" |
| 12 #include "ui/compositor/compositor_export.h" | 12 #include "ui/compositor/compositor_export.h" |
| 13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 class Canvas; | 17 class Canvas; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace ui { | 20 namespace ui { |
| 21 class PaintCache; | 21 class PaintCache; |
| 22 class PaintContext; | 22 class PaintContext; |
| 23 class PaintInfo; |
| 23 | 24 |
| 24 // A class to hide the complexity behind setting up a recording into a | 25 // A class to hide the complexity behind setting up a recording into a |
| 25 // DisplayItem. This is meant to be short-lived within the scope of recording | 26 // DisplayItem. This is meant to be short-lived within the scope of recording |
| 26 // taking place, the DisplayItem should be removed from the PaintRecorder once | 27 // taking place, the DisplayItem should be removed from the PaintRecorder once |
| 27 // recording is complete and can be cached. | 28 // recording is complete and can be cached. |
| 28 class COMPOSITOR_EXPORT PaintRecorder { | 29 class COMPOSITOR_EXPORT PaintRecorder { |
| 29 public: | 30 public: |
| 30 // The |cache| is owned by the caller and must be kept alive while | 31 // The |cache| is owned by the caller and must be kept alive while |
| 31 // PaintRecorder is in use. Canvas is bounded by |recording_size|. | 32 // PaintRecorder is in use. Canvas is bounded by |recording_size|. |
| 32 PaintRecorder(const PaintContext& context, | 33 // TODO(malaykeshav): |recording_size| is now redundant and can be removed |
| 33 const gfx::Size& recording_size, | 34 // since context already has size information. |
| 34 PaintCache* cache); | 35 PaintRecorder(const PaintInfo& info, PaintCache* cache); |
| 35 PaintRecorder(const PaintContext& context, const gfx::Size& recording_size); | 36 PaintRecorder(const PaintContext& context, const gfx::Size& recording_size); |
| 36 ~PaintRecorder(); | 37 ~PaintRecorder(); |
| 37 | 38 |
| 38 // Gets a gfx::Canvas for painting into. | 39 // Gets a gfx::Canvas for painting into. |
| 39 gfx::Canvas* canvas() { return &canvas_; } | 40 gfx::Canvas* canvas() { return &canvas_; } |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 const PaintContext& context_; | 43 const PaintContext& context_; |
| 43 cc::RecordPaintCanvas record_canvas_; | 44 cc::RecordPaintCanvas record_canvas_; |
| 44 gfx::Canvas canvas_; | 45 gfx::Canvas canvas_; |
| 45 PaintCache* cache_; | 46 PaintCache* cache_; |
| 46 gfx::Size recording_size_; | 47 gfx::Size recording_size_; |
| 48 bool is_pixel_canvas_; |
| 47 | 49 |
| 48 DISALLOW_COPY_AND_ASSIGN(PaintRecorder); | 50 DISALLOW_COPY_AND_ASSIGN(PaintRecorder); |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 } // namespace ui | 53 } // namespace ui |
| 52 | 54 |
| 53 #endif // UI_COMPOSITOR_PAINT_RECORDER_H_ | 55 #endif // UI_COMPOSITOR_PAINT_RECORDER_H_ |
| OLD | NEW |