OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_COMPOSITOR_CANVAS_PAINTER_H_ |
| 6 #define UI_COMPOSITOR_CANVAS_PAINTER_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "ui/compositor/compositor_export.h" |
| 10 #include "ui/compositor/paint_context.h" |
| 11 #include "ui/gfx/geometry/rect.h" |
| 12 |
| 13 namespace cc { |
| 14 class DisplayItemList; |
| 15 } |
| 16 |
| 17 namespace gfx { |
| 18 class Canvas; |
| 19 } |
| 20 |
| 21 namespace ui { |
| 22 |
| 23 // This class provides a simple helper for painting directly to a bitmap |
| 24 // backed canvas (for painting use-cases other than compositing). After |
| 25 // constructing an instance of a CanvasPainter, the context() can be used |
| 26 // to do painting using the normal composited paint paths. When |
| 27 // the painter is destroyed, any painting done with the context() will be |
| 28 // rastered into the canvas. |
| 29 class COMPOSITOR_EXPORT CanvasPainter { |
| 30 public: |
| 31 CanvasPainter(gfx::Canvas* canvas, float raster_scale_factor); |
| 32 ~CanvasPainter(); |
| 33 |
| 34 const PaintContext& context() const { return context_; } |
| 35 |
| 36 private: |
| 37 gfx::Canvas* const canvas_; |
| 38 const float raster_scale_factor_; |
| 39 const gfx::Rect rect_; |
| 40 scoped_refptr<cc::DisplayItemList> list_; |
| 41 PaintContext context_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(CanvasPainter); |
| 44 }; |
| 45 |
| 46 } // namespace ui |
| 47 |
| 48 #endif // UI_COMPOSITOR_CANVAS_PAINTER_H_ |
OLD | NEW |