Flutter Engine
The Flutter Engine
SkPictureImageGenerator.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
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
9
20#include "include/core/SkSize.h"
21#include "src/base/SkTLazy.h"
23
24#include <memory>
25#include <utility>
26
27namespace SkImageGenerators {
28std::unique_ptr<SkImageGenerator> MakeFromPicture(
29 const SkISize& size,
31 const SkMatrix* matrix,
32 const SkPaint* paint,
33 SkImages::BitDepth bitDepth,
34 sk_sp<SkColorSpace> colorSpace) {
35 return MakeFromPicture(size, picture, matrix, paint, bitDepth, colorSpace, {});
36}
37
38std::unique_ptr<SkImageGenerator> MakeFromPicture(const SkISize& size,
40 const SkMatrix* matrix,
41 const SkPaint* paint,
42 SkImages::BitDepth bitDepth,
43 sk_sp<SkColorSpace> colorSpace,
44 SkSurfaceProps props) {
45 if (!picture || !colorSpace || size.isEmpty()) {
46 return nullptr;
47 }
48
49 SkColorType colorType = kN32_SkColorType;
50 if (SkImages::BitDepth::kF16 == bitDepth) {
52 }
53
55 SkImageInfo::Make(size, colorType, kPremul_SkAlphaType, std::move(colorSpace));
56 return std::unique_ptr<SkImageGenerator>(
57 new SkPictureImageGenerator(info, std::move(picture), matrix, paint, props));
58}
59} // SkImageGenerators
60
61///////////////////////////////////////////////////////////////////////////////////////////////////
62
64 const SkMatrix* matrix, const SkPaint* paint,
65 const SkSurfaceProps& props)
67 , fPicture(std::move(picture))
68 , fProps(props) {
69
70 if (matrix) {
71 fMatrix = *matrix;
72 } else {
73 fMatrix.reset();
74 }
75
76 if (paint) {
77 fPaint.set(*paint);
78 }
79}
80
81bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
82 const Options& opts) {
83 std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, pixels, rowBytes, &fProps);
84 if (!canvas) {
85 return false;
86 }
87 canvas->clear(0);
88 canvas->drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
89 return true;
90}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Definition: SkColorType.h:19
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static std::unique_ptr< SkCanvas > MakeRasterDirect(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr)
Definition: SkCanvas.cpp:2801
SkMatrix & reset()
Definition: SkMatrix.cpp:49
bool onGetPixels(const SkImageInfo &, void *pixels, size_t rowBytes, const Options &) override
SkPictureImageGenerator(const SkImageInfo &, sk_sp< SkPicture >, const SkMatrix *, const SkPaint *, const SkSurfaceProps &)
const T * getMaybeNull() const
Definition: SkTLazy.h:108
T * set(const T &src)
Definition: SkTLazy.h:56
const Paint & paint
Definition: color_source.cc:38
std::unique_ptr< SkImageGenerator > MakeFromPicture(const SkISize &, sk_sp< SkPicture >, const SkMatrix *, const SkPaint *, SkImages::BitDepth, sk_sp< SkColorSpace >, SkSurfaceProps props)
@ kF16
uses 16-bit float per color component
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
Definition: ref_ptr.h:256
Definition: SkSize.h:16
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)