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

Unified Diff: cc/paint/paint_recorder.h

Issue 2690583002: Make cc/paint have concrete types (Closed)
Patch Set: Add missing file 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 side-by-side diff with in-line comments
Download patch
Index: cc/paint/paint_recorder.h
diff --git a/cc/paint/paint_recorder.h b/cc/paint/paint_recorder.h
index be866fddf1df1d48cd9286ff9b55f3ab766db6f3..00096038c57079e7a5b4e062fb6fc62867b4f367 100644
--- a/cc/paint/paint_recorder.h
+++ b/cc/paint/paint_recorder.h
@@ -5,10 +5,62 @@
#ifndef CC_PAINT_PAINT_RECORDER_H_
#define CC_PAINT_PAINT_RECORDER_H_
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "base/memory/ptr_util.h"
+#include "base/optional.h"
+#include "cc/paint/paint_canvas.h"
+#include "cc/paint/paint_record.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
namespace cc {
-using PaintRecorder = SkPictureRecorder;
-}
+
+class CC_PAINT_EXPORT PaintRecorder {
+ public:
+ PaintRecorder();
+ ~PaintRecorder();
+
+ ALWAYS_INLINE PaintCanvas* beginRecording(const SkRect& bounds) {
+ uint32_t record_flags = 0;
+ canvas_.emplace(recorder_.beginRecording(bounds, nullptr, record_flags));
+ return getRecordingCanvas();
+ }
+
+ ALWAYS_INLINE PaintCanvas* beginRecording(
+ SkScalar width,
+ SkScalar height,
+ SkBBHFactory* rtree_factory = nullptr) {
+ uint32_t record_flags = 0;
+ canvas_.emplace(
+ recorder_.beginRecording(width, height, rtree_factory, record_flags));
+ return getRecordingCanvas();
+ }
+
+ ALWAYS_INLINE PaintCanvas* getRecordingCanvas() {
+ return canvas_.has_value() ? &canvas_.value() : nullptr;
+ }
+
+ ALWAYS_INLINE sk_sp<PaintRecord> finishRecordingAsPicture(
+ uint32_t endFlags = 0) {
danakj 2017/03/03 18:33:19 end_flags
+ sk_sp<SkPicture> picture = recorder_.finishRecordingAsPicture(endFlags);
+ return sk_ref_sp(static_cast<PaintRecord*>(picture.get()));
+ }
+
+ ALWAYS_INLINE sk_sp<PaintRecord> finishRecordingAsPictureWithCull(
+ const SkRect& cullRect,
danakj 2017/03/03 18:33:19 cull_rect
+ uint32_t endFlags = 0) {
danakj 2017/03/03 18:33:19 end_flags
+ sk_sp<SkPicture> picture =
+ recorder_.finishRecordingAsPictureWithCull(cullRect, endFlags);
+ return sk_ref_sp(static_cast<PaintRecord*>(picture.get()));
+ }
+
+ private:
+ SkPictureRecorder recorder_;
+ base::Optional<PaintCanvas> canvas_;
+
+ DISALLOW_COPY_AND_ASSIGN(PaintRecorder);
+};
+
+} // namespace cc
#endif // CC_PAINT_PAINT_RECORDER_H_

Powered by Google App Engine
This is Rietveld 408576698