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 
5 #ifndef CC_PAINT_SKIA_PAINT_IMAGE_GENERATOR_H_
6 #define CC_PAINT_SKIA_PAINT_IMAGE_GENERATOR_H_
7 
8 #include "cc/paint/paint_export.h"
9 #include "cc/paint/paint_image.h"
10 #include "third_party/skia/include/core/SkImageGenerator.h"
11 
12 namespace cc {
13 class PaintImageGenerator;
14 
15 class CC_PAINT_EXPORT SkiaPaintImageGenerator final : public SkImageGenerator {
16  public:
17   SkiaPaintImageGenerator(sk_sp<PaintImageGenerator> paint_image_generator,
18                           size_t frame_index,
19                           PaintImage::GeneratorClientId client_id);
20   SkiaPaintImageGenerator(const SkiaPaintImageGenerator&) = delete;
21   ~SkiaPaintImageGenerator() override;
22 
23   SkiaPaintImageGenerator& operator=(const SkiaPaintImageGenerator&) = delete;
24 
25   sk_sp<SkData> onRefEncodedData() override;
26   bool onGetPixels(const SkImageInfo&,
27                    void* pixels,
28                    size_t row_bytes,
29                    const Options& options) override;
30 
31   bool onQueryYUVAInfo(
32       const SkYUVAPixmapInfo::SupportedDataTypes& supported_data_types,
33       SkYUVAPixmapInfo* yuva_pixmap_info) const override;
34 
35   bool onGetYUVAPlanes(const SkYUVAPixmaps& planes) override;
36 
37  private:
38   sk_sp<PaintImageGenerator> paint_image_generator_;
39   const size_t frame_index_;
40   const PaintImage::GeneratorClientId client_id_;
41 };
42 
43 }  // namespace cc
44 
45 #endif  // CC_PAINT_SKIA_PAINT_IMAGE_GENERATOR_H_
46