37static SkPMColor convert_yuva_to_rgba(
const float mtx[20], uint8_t yuva[4]) {
59 int shift =
static_cast<int>(channel) * 8;
60 return static_cast<uint8_t
>((pixel >> shift) & 0xff);
70 , fPixmaps(
std::move(pixmaps)) {}
76 const Options&)
override {
78 fFlattened.allocPixels(
info);
86 SkMatrix om = fPixmaps.yuvaInfo().originMatrix();
88 float normX = 1.f/
info.width();
89 float normY = 1.f/
info.height();
94 for (
int y = 0;
y <
info.height(); ++
y) {
95 for (
int x = 0;
x <
info.width(); ++
x) {
102 uint8_t yuva[4] = {0, 0, 0, 255};
104 for (
auto c : {SkYUVAInfo::YUVAChannels::kY,
105 SkYUVAInfo::YUVAChannels::kU,
106 SkYUVAInfo::YUVAChannels::kV}) {
107 const auto& pmap = fPixmaps.plane(yuvaLocations[c].fPlane);
108 yuva[c] = look_up(xy1, pmap, yuvaLocations[c].fChannel);
112 const auto& pmap = fPixmaps.plane(aPlane);
113 yuva[3] = look_up(xy1, pmap, aChan);
117 *fFlattened.getAddr32(
x,
y) = convert_yuva_to_rgba(mtx, yuva);
122 return fFlattened.readPixels(
info, pixels, rowBytes, 0, 0);
127 *
info = fPixmaps.pixmapsInfo();
128 return info->isValid();
137 fPixmaps.plane(
i).readPixels(pixmaps.
plane(
i));
167 std::array<sk_sp<SkImage>, 4> planes;
168 for (
int i = 0;
i < n; ++
i) {
185 std::copy_n(rgbToYUV + 5*
i, 5,
m + 15);
197 return {planes,
info};
204 if (
image->reset(std::move(
data), mipmapped, std::move(cs))) {
215 if (
image->reset(std::move(pixmaps), mipmapped, std::move(cs))) {
223 if (this->ensureYUVImage(rContext,
type)) {
224 size_t idx =
static_cast<size_t>(
type);
226 return fYUVImage[idx];
232#if defined(SK_GRAPHITE)
234 if (this->ensureYUVImage(recorder,
type)) {
235 size_t idx =
static_cast<size_t>(
type);
237 return fYUVImage[idx];
245 fMipmapped = mipmapped;
260 if (!codec->getYUVAPlanes(fPixmaps)) {
264 fColorSpace = std::move(cs);
276 fMipmapped = mipmapped;
278 fPixmaps = std::move(pixmaps);
282 fColorSpace = std::move(cs);
288 size_t idx =
static_cast<size_t>(
type);
290 if (fYUVImage[idx] && fYUVImage[idx]->isValid(rContext)) {
296 if (!rContext || rContext->
abandoned()) {
307 auto generator = std::make_unique<Generator>(fPixmaps, fColorSpace);
312 if (!rContext || rContext->
abandoned()) {
319 mbets[
i] = sk_gpu_test::ManagedBackendTexture::MakeFromPixmap(
326 textures[
i] = mbets[
i]->texture();
334 if (!yuvaTextures.isValid()) {
337 void* planeRelContext =
338 sk_gpu_test::ManagedBackendTexture::MakeYUVAReleaseContext(mbets);
343 sk_gpu_test::ManagedBackendTexture::ReleaseProc,
351 return fYUVImage[idx] !=
nullptr;
354#if defined(SK_GRAPHITE)
360 size_t idx =
static_cast<size_t>(
type);
362 if (fYUVImage[idx] &&
as_IB(fYUVImage[idx])->isGraphiteBacked()) {
380 auto generator = std::make_unique<Generator>(fPixmaps, fColorSpace);
393 mbets[
i] = sk_gpu_test::ManagedGraphiteTexture::MakeFromPixmap(
400 textures[
i] = mbets[
i]->texture();
405 YUVABackendTextures yuvaTextures(recorder,
408 if (!yuvaTextures.isValid()) {
411 void* imageRelContext =
412 sk_gpu_test::ManagedGraphiteTexture::MakeYUVAReleaseContext(mbets);
417 sk_gpu_test::ManagedGraphiteTexture::ImageReleaseProc,
431 genMipmaps = GenerateMipmapsFromBase::kYes;
435 const auto& plane = fPixmaps.
plane(
i);
438 mbet = ManagedGraphiteTexture::MakeUnInit(recorder,
450 levels.push_back(plane);
451 for (
int l = 0; l < levelCnt; ++l) {
454 level.alloc(plane.info().makeDimensions(dims));
456 levels.push_back(
level);
457 levelStorage.push_back(std::move(
level));
465 mbet = ManagedGraphiteTexture::MakeFromPixmap(recorder,
480 ManagedGraphiteTexture::ImageReleaseProc,
481 mbet->releaseContext());
492 return fYUVImage[idx] !=
nullptr;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
constexpr SkColor SK_ColorRED
@ kTopLeft_SkEncodedOrigin
static bool SkEncodedOriginSwapsWidthHeight(SkEncodedOrigin origin)
static SkImage_Base * as_IB(SkImage *image)
void swap(sk_sp< T > &a, sk_sp< T > &b)
#define SkScalarRoundToInt(x)
#define SkScalarFloorToInt(x)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
void SkColorMatrix_RGB2YUV(SkYUVColorSpace cs, float m[20])
void SkColorMatrix_YUV2RGB(SkYUVColorSpace cs, float m[20])
virtual GrDirectContext * asDirectContext()
bool abandoned() override
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
static std::unique_ptr< SkImageGenerator > MakeFromEncodedCodec(sk_sp< SkData >, std::optional< SkAlphaType >=std::nullopt)
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
const SkImageInfo & getInfo() const
virtual bool onGetYUVAPlanes(const SkYUVAPixmaps &)
virtual bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes &, SkYUVAPixmapInfo *) const
virtual bool onGetPixels(const SkImageInfo &, void *, size_t, const Options &)
SkPoint mapPoint(SkPoint pt) const
bool invert(SkMatrix *inverse) const
static SkISize ComputeLevelSize(int baseWidth, int baseHeight, int level)
static int ComputeLevelCount(int baseWidth, int baseHeight)
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes) const
SkColorType colorType() const
const SkImageInfo & info() const
SkISize dimensions() const
sk_sp< SkImage > makeImageSnapshot()
@ kY_U_V_A
Plane 0: Y, Plane 1: U, Plane 2: V, Plane 3: A.
@ kY_U_V
Plane 0: Y, Plane 1: U, Plane 2: V.
static constexpr int kMaxPlanes
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
static int PlaneDimensions(SkISize imageDimensions, PlaneConfig, Subsampling, SkEncodedOrigin, SkISize planeDimensions[kMaxPlanes])
static constexpr SupportedDataTypes All()
const SkYUVAInfo & yuvaInfo() const
const SkPixmap & plane(int i) const
static SkYUVAPixmaps Allocate(const SkYUVAPixmapInfo &yuvaPixmapInfo)
static SkYUVAPixmaps MakeCopy(const SkYUVAPixmaps &src)
sk_sp< SkImage > refImage(GrRecordingContext *rContext, Type)
static std::unique_ptr< LazyYUVImage > Make(sk_sp< SkData > data, skgpu::Mipmapped=skgpu::Mipmapped::kNo, sk_sp< SkColorSpace >=nullptr)
bool updateBackendTexture(const BackendTexture &, const SkPixmap srcData[], int numLevels)
SK_API sk_sp< SkImage > TextureFromYUVAPixmaps(GrRecordingContext *context, const SkYUVAPixmaps &pixmaps, skgpu::Mipmapped buildMips, bool limitToMaxTextureSize, sk_sp< SkColorSpace > imageColorSpace)
SK_API sk_sp< SkImage > WrapTexture(skgpu::graphite::Recorder *, const skgpu::graphite::BackendTexture &, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, skgpu::Origin origin, GenerateMipmapsFromBase generateMipmapsFromBase, TextureReleaseProc=nullptr, ReleaseContext=nullptr, std::string_view label={})
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
SK_API sk_sp< SkImage > TextureFromYUVATextures(GrRecordingContext *context, const GrYUVABackendTextures &yuvaTextures, sk_sp< SkColorSpace > imageColorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkImage > TextureFromYUVAImages(skgpu::graphite::Recorder *recorder, const SkYUVAInfo &yuvaInfo, SkSpan< const sk_sp< SkImage > > images, sk_sp< SkColorSpace > imageColorSpace)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
sk_sp< const SkImage > image
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
std::function< UnitlessTime(int)> Generator
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
std::tuple< std::array< sk_sp< SkImage >, SkYUVAInfo::kMaxPlanes >, SkYUVAInfo > MakeYUVAPlanesAsA8(SkImage *src, SkYUVColorSpace cs, SkYUVAInfo::Subsampling ss, GrRecordingContext *rContext)
SkSamplingOptions(SkFilterMode::kLinear))
SkImageInfo makeWH(int newWidth, int newHeight) const
SkImageInfo makeColorType(SkColorType newColorType) const
static SkImageInfo MakeA8(int width, int height)
constexpr float y() const
constexpr float x() const
static SkRect Make(const SkISize &size)
static bool AreValidLocations(const SkYUVAInfo::YUVALocations &locations, int *numPlanes=nullptr)
std::shared_ptr< const fml::Mapping > data