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

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

Issue 1021823002: Introduce ui::PaintRecorder and use it for CursorWindowDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: slimmingui-paintrecorder: rebase Created 5 years, 9 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 | « ui/compositor/compositor.gyp ('k') | ui/compositor/paint_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_PAINT_RECORDER_H_
6 #define UI_COMPOSITOR_PAINT_RECORDER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "skia/ext/refptr.h"
10 #include "third_party/skia/include/core/SkPictureRecorder.h"
11 #include "ui/compositor/compositor_export.h"
12
13 namespace cc {
14 class DisplayItemList;
15 class DrawingDisplayItem;
16 }
17
18 namespace gfx {
19 class Canvas;
20 class Rect;
21 }
22
23 class SkCanvas;
24
25 namespace ui {
26
27 // A class to hide the complexity behind setting up a recording into an
28 // SkPicture. This is meant to be short-lived within the scope of recording
29 // taking place, the SkPicture should be removed from the PaintRecorder once
30 // recording is complete and can be cached.
31 class COMPOSITOR_EXPORT PaintRecorder {
32 public:
33 // The |recording_bounds| are in the space of the ui::Layer that the
34 // recording is being done in.
35 PaintRecorder(const gfx::Rect& recording_bounds, float device_scale_factor);
36 ~PaintRecorder();
37
38 // Gets the SkCanvas for the recording. Any operations done on this canvas
39 // will be saved in the resulting SkPicture.
40 SkCanvas* skcanvas() { return skcanvas_.get(); }
41
42 // Gets a gfx::Canvas wrapping the SkCanvas for convenience methods.
43 gfx::Canvas* canvas() { return canvas_.get(); }
44
45 // Ends recording and returns the DisplayItem from the object. Any use of the
46 // canvas after calling this would be lost or undefined.
47 scoped_ptr<cc::DrawingDisplayItem> TakeDisplayItem();
48
49 // A helper method for TakeDisplayItem(), when caching the SkPicture is not
50 // required, that inserts it directly into a DisplayItemList.
51 void AppendDisplayItem(cc::DisplayItemList* list);
52
53 private:
54 float device_scale_factor_;
55 SkPictureRecorder recorder_;
56 skia::RefPtr<SkCanvas> skcanvas_;
57 scoped_ptr<gfx::Canvas> canvas_;
58
59 DISALLOW_COPY_AND_ASSIGN(PaintRecorder);
60 };
61
62 } // namespace ui
63
64 #endif // UI_COMPOSITOR_PAINT_RECORDER_H_
OLDNEW
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/compositor/paint_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698