Chromium Code Reviews| 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_CANVAS_PAINTER_H_ | 5 #ifndef UI_COMPOSITOR_CANVAS_PAINTER_H_ |
| 6 #define UI_COMPOSITOR_CANVAS_PAINTER_H_ | 6 #define UI_COMPOSITOR_CANVAS_PAINTER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "ui/compositor/compositor_export.h" | 10 #include "ui/compositor/compositor_export.h" |
| 11 #include "ui/compositor/paint_context.h" | 11 #include "ui/compositor/paint_context.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 class DisplayItemList; | 15 class DisplayItemList; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace gfx { | |
| 19 class Canvas; | |
| 20 } | |
| 21 | |
| 22 namespace ui { | 18 namespace ui { |
| 23 | 19 |
| 24 // This class provides a simple helper for painting directly to a bitmap | 20 // This class provides a simple helper for rasterizing from a PaintContext |
| 25 // backed canvas (for painting use-cases other than compositing). After | 21 // interface directly into a bitmap. After constructing an instance of a |
| 26 // constructing an instance of a CanvasPainter, the context() can be used | 22 // CanvasPainter, the context() can be used to do painting using the normal |
| 27 // to do painting using the normal composited paint paths. When | 23 // composited paint paths. When the painter is destroyed, any painting done |
| 28 // the painter is destroyed, any painting done with the context() will be | 24 // with the context() will be rastered into the provided output bitmap. |
| 29 // rastered into the canvas. | 25 // |
| 26 // TODO(enne): rename this class to be PaintContextRasterizer or some such. | |
| 30 class COMPOSITOR_EXPORT CanvasPainter { | 27 class COMPOSITOR_EXPORT CanvasPainter { |
| 31 public: | 28 public: |
| 32 CanvasPainter(gfx::Canvas* canvas, float raster_scale_factor); | 29 CanvasPainter(SkBitmap* output, |
|
danakj
2017/02/14 21:37:26
In blink at least this type of thing should be an
| |
| 30 gfx::Size paint_size, | |
|
danakj
2017/02/14 21:37:26
const&
| |
| 31 float raster_scale, | |
| 32 SkColor clear_color); | |
| 33 ~CanvasPainter(); | 33 ~CanvasPainter(); |
| 34 | 34 |
| 35 const PaintContext& context() const { return context_; } | 35 const PaintContext& context() const { return context_; } |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 gfx::Canvas* const canvas_; | 38 SkBitmap* const output_; |
| 39 const float raster_scale_factor_; | 39 const gfx::Size paint_size_; |
| 40 const gfx::Rect rect_; | 40 SkColor clear_color_; |
|
danakj
2017/02/14 21:37:26
const?
| |
| 41 scoped_refptr<cc::DisplayItemList> list_; | 41 scoped_refptr<cc::DisplayItemList> list_; |
| 42 PaintContext context_; | 42 PaintContext context_; |
| 43 | 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(CanvasPainter); | 44 DISALLOW_COPY_AND_ASSIGN(CanvasPainter); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 } // namespace ui | 47 } // namespace ui |
| 48 | 48 |
| 49 #endif // UI_COMPOSITOR_CANVAS_PAINTER_H_ | 49 #endif // UI_COMPOSITOR_CANVAS_PAINTER_H_ |
| OLD | NEW |