paint_record.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2017 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. #include "cc/paint/paint_record.h"
  5. #include "cc/paint/paint_op_buffer.h"
  6. #include "third_party/skia/include/core/SkPictureRecorder.h"
  7. namespace cc {
  8. sk_sp<SkPicture> ToSkPicture(
  9. sk_sp<PaintRecord> record,
  10. const SkRect& bounds,
  11. ImageProvider* image_provider,
  12. PlaybackParams::CustomDataRasterCallback callback) {
  13. SkPictureRecorder recorder;
  14. SkCanvas* canvas = recorder.beginRecording(bounds);
  15. PlaybackParams params(image_provider);
  16. params.custom_callback = callback;
  17. record->Playback(canvas, params);
  18. return recorder.finishRecordingAsPicture();
  19. }
  20. sk_sp<const SkPicture> ToSkPicture(
  21. sk_sp<const PaintRecord> record,
  22. const SkRect& bounds,
  23. ImageProvider* image_provider,
  24. PlaybackParams::CustomDataRasterCallback callback) {
  25. SkPictureRecorder recorder;
  26. SkCanvas* canvas = recorder.beginRecording(bounds);
  27. PlaybackParams params(image_provider);
  28. params.custom_callback = callback;
  29. record->Playback(canvas, params);
  30. return recorder.finishRecordingAsPicture();
  31. }
  32. } // namespace cc