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

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: 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
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 }
16
17 namespace gfx {
18 class Canvas;
19 class Rect;
20 }
21
22 class SkCanvas;
23
24 namespace ui {
25
26 // A class to hide the complexity behind setting up a recording into an
27 // SkPicture. This is meant to be short-lived within the scope of recording
28 // taking place, the SkPicture should be removed from the PaintRecorder once
29 // recording is complete and can be cached.
30 class COMPOSITOR_EXPORT PaintRecorder {
31 public:
32 // The |recording_bounds| are in the space of the ui::Layer that the
33 // recording is being done in.
34 PaintRecorder(const gfx::Rect& recording_bounds, float device_scale_factor);
35 ~PaintRecorder();
36
37 // Gets the SkCanvas for the recording. Any operations done on this canvas
38 // will be saved in the resulting SkPicture.
39 SkCanvas* skcanvas() { return skcanvas_.get(); }
40
41 // Gets a gfx::Canvas wrapping the SkCanvas for convenience methods.
42 gfx::Canvas* canvas() { return canvas_.get(); }
43
44 // Ends recording and removes the SkPicture from the object. Any use of the
45 // canvas after calling this would be lost or undefined.
46 skia::RefPtr<SkPicture> TakePicture();
47
48 // A helper method for TakePicture(), when caching the SkPicture is not
49 // required, that inserts it directly into a DisplayItemList.
50 void TakeDisplayItem(cc::DisplayItemList* list);
51
52 private:
53 float device_scale_factor_;
54 SkPictureRecorder recorder_;
55 skia::RefPtr<SkCanvas> skcanvas_;
56 scoped_ptr<gfx::Canvas> canvas_;
57
58 DISALLOW_COPY_AND_ASSIGN(PaintRecorder);
59 };
60
61 } // namespace ui
62
63 #endif // UI_COMPOSITOR_PAINT_RECORDER_H_
OLDNEW
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/compositor/paint_recorder.cc » ('j') | ui/views/view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698