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.
5 #ifndef UI_COMPOSITOR_CANVAS_PAINTER_H_
6 #define UI_COMPOSITOR_CANVAS_PAINTER_H_
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"
14 class DisplayItemList
;
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
{
31 CanvasPainter(gfx::Canvas
* canvas
, float raster_scale_factor
);
34 const PaintContext
& context() const { return context_
; }
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_
;
43 DISALLOW_COPY_AND_ASSIGN(CanvasPainter
);
48 #endif // UI_COMPOSITOR_CANVAS_PAINTER_H_