Index: cc/paint/paint_recorder.h |
diff --git a/cc/paint/paint_recorder.h b/cc/paint/paint_recorder.h |
index be866fddf1df1d48cd9286ff9b55f3ab766db6f3..5b1003ef13fa3dd2822f8ba0877ee80d5549cdc9 100644 |
--- a/cc/paint/paint_recorder.h |
+++ b/cc/paint/paint_recorder.h |
@@ -5,10 +5,57 @@ |
#ifndef CC_PAINT_PAINT_RECORDER_H_ |
#define CC_PAINT_PAINT_RECORDER_H_ |
+#include "base/compiler_specific.h" |
+#include "base/memory/ptr_util.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 PaintRecorder : private SkPictureRecorder { |
vmpstr
2017/03/02 21:52:42
I'm a bit hesitant about private inheritance... Wh
enne (OOO)
2017/03/02 23:59:44
Sure, changed to composition here. I think PaintR
|
+ public: |
+ using SkPictureRecorder::SkPictureRecorder; |
+ using SkPictureRecorder::RecordFlags; |
+ using SkPictureRecorder::FinishFlags; |
+ |
+ ALWAYS_INLINE PaintCanvas* beginRecording(const SkRect& bounds, |
+ SkBBHFactory* bbhFactory = nullptr, |
+ uint32_t recordFlags = 0) { |
+ canvas_.SetInternalSkCanvas( |
+ SkPictureRecorder::beginRecording(bounds, bbhFactory, recordFlags)); |
+ return getRecordingCanvas(); |
+ } |
+ |
+ ALWAYS_INLINE PaintCanvas* beginRecording(SkScalar width, |
+ SkScalar height, |
+ SkBBHFactory* bbhFactory = nullptr, |
+ uint32_t recordFlags = 0) { |
+ canvas_.SetInternalSkCanvas(SkPictureRecorder::beginRecording( |
+ width, height, bbhFactory, recordFlags)); |
+ return getRecordingCanvas(); |
+ } |
+ |
+ ALWAYS_INLINE PaintCanvas* getRecordingCanvas() { return &canvas_; } |
+ |
+ ALWAYS_INLINE sk_sp<PaintRecord> finishRecordingAsPicture( |
+ uint32_t endFlags = 0) { |
+ sk_sp<SkPicture> p = SkPictureRecorder::finishRecordingAsPicture(endFlags); |
vmpstr
2017/03/02 21:52:42
p = picture?
|
+ return sk_ref_sp(static_cast<PaintRecord*>(p.get())); |
vmpstr
2017/03/02 21:52:42
That's kind of an awkward pattern... Does static_c
enne (OOO)
2017/03/02 23:59:44
Yeah, it doesn't work, sorry.
|
+ } |
+ |
+ ALWAYS_INLINE sk_sp<PaintRecord> finishRecordingAsPictureWithCull( |
+ const SkRect& cullRect, |
+ uint32_t endFlags = 0) { |
+ sk_sp<SkPicture> p = |
+ SkPictureRecorder::finishRecordingAsPictureWithCull(cullRect, endFlags); |
+ return sk_ref_sp(static_cast<PaintRecord*>(p.get())); |
+ } |
+ |
+ private: |
+ PaintCanvas canvas_; |
+}; |
+ |
+} // namespace cc |
#endif // CC_PAINT_PAINT_RECORDER_H_ |