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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/compositor/paint_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/paint_recorder.h
diff --git a/ui/compositor/paint_recorder.h b/ui/compositor/paint_recorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..ce6c97d441f6137ba3ac8ec6c08f22a266316738
--- /dev/null
+++ b/ui/compositor/paint_recorder.h
@@ -0,0 +1,64 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_COMPOSITOR_PAINT_RECORDER_H_
+#define UI_COMPOSITOR_PAINT_RECORDER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "skia/ext/refptr.h"
+#include "third_party/skia/include/core/SkPictureRecorder.h"
+#include "ui/compositor/compositor_export.h"
+
+namespace cc {
+class DisplayItemList;
+class DrawingDisplayItem;
+}
+
+namespace gfx {
+class Canvas;
+class Rect;
+}
+
+class SkCanvas;
+
+namespace ui {
+
+// A class to hide the complexity behind setting up a recording into an
+// SkPicture. This is meant to be short-lived within the scope of recording
+// taking place, the SkPicture should be removed from the PaintRecorder once
+// recording is complete and can be cached.
+class COMPOSITOR_EXPORT PaintRecorder {
+ public:
+ // The |recording_bounds| are in the space of the ui::Layer that the
+ // recording is being done in.
+ PaintRecorder(const gfx::Rect& recording_bounds, float device_scale_factor);
+ ~PaintRecorder();
+
+ // Gets the SkCanvas for the recording. Any operations done on this canvas
+ // will be saved in the resulting SkPicture.
+ SkCanvas* skcanvas() { return skcanvas_.get(); }
+
+ // Gets a gfx::Canvas wrapping the SkCanvas for convenience methods.
+ gfx::Canvas* canvas() { return canvas_.get(); }
+
+ // Ends recording and returns the DisplayItem from the object. Any use of the
+ // canvas after calling this would be lost or undefined.
+ scoped_ptr<cc::DrawingDisplayItem> TakeDisplayItem();
+
+ // A helper method for TakeDisplayItem(), when caching the SkPicture is not
+ // required, that inserts it directly into a DisplayItemList.
+ void AppendDisplayItem(cc::DisplayItemList* list);
+
+ private:
+ float device_scale_factor_;
+ SkPictureRecorder recorder_;
+ skia::RefPtr<SkCanvas> skcanvas_;
+ scoped_ptr<gfx::Canvas> canvas_;
+
+ DISALLOW_COPY_AND_ASSIGN(PaintRecorder);
+};
+
+} // namespace ui
+
+#endif // UI_COMPOSITOR_PAINT_RECORDER_H_
« 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