Chromium Code Reviews| 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 { |
| + public: |
| + using SkPictureRecorder::SkPictureRecorder; |
| + using SkPictureRecorder::RecordFlags; |
| + using SkPictureRecorder::FinishFlags; |
| + |
| + ALWAYS_INLINE PaintCanvas* beginRecording(const SkRect& bounds, |
| + SkBBHFactory* bbhFactory = nullptr, |
|
danakj
2017/03/02 19:44:40
why not chromium-style parameter names?
enne (OOO)
2017/03/02 23:59:43
Just following SkPictureRecorder example. Changed
|
| + 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); |
| + return sk_ref_sp(static_cast<PaintRecord*>(p.get())); |
| + } |
| + |
| + 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_; |
|
danakj
2017/03/02 19:44:40
you could use Optional to avoid the private constr
|
| +}; |
| + |
| +} // namespace cc |
| #endif // CC_PAINT_PAINT_RECORDER_H_ |