Debian Codegraph @

src/capture/SkCapture.h

raw
1 /*
2 * Copyright 2025 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkCapture_DEFINED
9 #define SkCapture_DEFINED
10
11 #include "include/core/SkAlphaType.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/core/SkSerialProcs.h"
14 #include "include/private/base/SkTArray.h"
15
16 #include <optional>
17
18 class SkData;
19 class SkImage;
20 class SkPicture;
21
22 class SkCanvas;
23 class SkCaptureCanvas;
24
25 // TODO(b/412351769): Make this class public.
26 class SkCapture : public SkRefCnt {
27 public:
28 struct Metadata {
29 uint32_t version;
30 uint32_t numPictures;
31 };
32
33 static sk_sp<SkCapture> MakeFromData(sk_sp<const SkData>);
34 // TODO: instead of a make from pictures factory, the CaptureManager might just need hooks into
35 // the to build it over time. Move the SkPictures (fPictures) here and just maintain that in one
36 // place.
37 static sk_sp<SkCapture> MakeFromPictures(skia_private::TArray<sk_sp<SkPicture>>);
38 sk_sp<SkData> serializeCapture();
39
40 // TODO: Pictures being grabbed by index is not intuitive and leave the capture disorganized.
41 // This should be deleted once SkPictures are organized by Surface and grouped by Recording.
42 sk_sp<SkPicture> getPicture(int i) const;
43 Metadata getMetadata() const;
44
45 private:
46 // TODO: add more awareness of the image meta data to a SkCaptureContext object
47 static SkSerialReturnType serializeImageProc(SkImage* img, void* ctx);
48 static sk_sp<SkImage> deserializeImageProc(sk_sp<SkData>,
49 std::optional<SkAlphaType>, void* ctx);
50
51 Metadata fMetadata;
52 //TODO(b/412351769): Replace pictures with SkCapturePicture structs that also include
53 // picture metadata
54 skia_private::TArray<sk_sp<SkPicture>> fPictures;
55
56 static const uint32_t kVersion = 0; // Until this version is 1 or greater, active development
57 // will make this unstable.
58 };
59
60 #endif //SkCapture_DEFINED