Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: ui/compositor/canvas_painter.h

Issue 2694023003: Make CanvasPainter raster directly to an SkBitmap (Closed)
Patch Set: tapted review Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/compositor/canvas_painter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
30 const gfx::Size& paint_size,
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 const float raster_scale_;
41 const SkColor clear_color_;
41 scoped_refptr<cc::DisplayItemList> list_; 42 scoped_refptr<cc::DisplayItemList> list_;
42 PaintContext context_; 43 PaintContext context_;
43 44
44 DISALLOW_COPY_AND_ASSIGN(CanvasPainter); 45 DISALLOW_COPY_AND_ASSIGN(CanvasPainter);
45 }; 46 };
46 47
47 } // namespace ui 48 } // namespace ui
48 49
49 #endif // UI_COMPOSITOR_CANVAS_PAINTER_H_ 50 #endif // UI_COMPOSITOR_CANVAS_PAINTER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/canvas_painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698