paint_preview_recorder_utils.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2019 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. #ifndef COMPONENTS_PAINT_PREVIEW_RENDERER_PAINT_PREVIEW_RECORDER_UTILS_H_
  5. #define COMPONENTS_PAINT_PREVIEW_RENDERER_PAINT_PREVIEW_RECORDER_UTILS_H_
  6. #include "base/files/file.h"
  7. #include "cc/paint/paint_record.h"
  8. #include "components/paint_preview/common/mojom/paint_preview_recorder.mojom-forward.h"
  9. #include "mojo/public/cpp/base/big_buffer.h"
  10. #include "third_party/skia/include/core/SkRefCnt.h"
  11. #include "third_party/skia/include/core/SkStream.h"
  12. #include "ui/gfx/geometry/rect.h"
  13. // These utilities are used by the PaintPreviewRecorderImpl. They are separate
  14. // for testing purposes and to enforce restrictions caused by the lifetime of
  15. // PaintPreviewServiceImpl being tied to it's associated RenderFrame.
  16. namespace paint_preview {
  17. class PaintPreviewTracker;
  18. // Pre processes the PaintOpBuffer prior to conversion to SkPicture.
  19. // 1. Walks |buffer| to extract all the glyphs from its text blobs and links.
  20. // The extracted data is written to `tracker`.
  21. // 2. Tracks geometry changes for frames and saves them to `tracker`.
  22. // 3. Unaccelerates GPU accelerated PaintImages.
  23. void PreProcessPaintOpBuffer(const cc::PaintOpBuffer* buffer,
  24. PaintPreviewTracker* tracker);
  25. // Convert |recording| into an SkPicture, tracking embedded content. Will return
  26. // |nullptr| if the resulting picture failed or zero sized.
  27. sk_sp<const SkPicture> PaintRecordToSkPicture(
  28. sk_sp<const cc::PaintRecord> recording,
  29. PaintPreviewTracker* tracker,
  30. const gfx::Rect& bounds);
  31. // NOTE: |tracker| is effectively const here despite being passed by pointer.
  32. void BuildResponse(PaintPreviewTracker* tracker,
  33. mojom::PaintPreviewCaptureResponse* response);
  34. } // namespace paint_preview
  35. #endif // COMPONENTS_PAINT_PREVIEW_RENDERER_PAINT_PREVIEW_RECORDER_UTILS_H_