57#include <initializer_list>
188 int numBitmaps)
const;
199 int numBitmaps)
const {
200 SkYUVAInfo info(dimensions, fPlaneConfig, fSubsampling, yuvColorSpace, fOrigin);
202 int n =
info.numPlanes();
203 if (numBitmaps < n) {
206 for (
int i = 0;
i < n; ++
i) {
273 startDeg = fmodf(startDeg, 360.0f);
276 endDeg = fmodf(endDeg, 360.0f);
278 if (endDeg < startDeg) {
283 if (!takeLongWayRound) {
284 sweepDeg = sweepDeg - 360;
287 path->arcTo(r, startDeg, sweepDeg,
false);
298 int numDivisions = 2 * numLobes;
299 SkScalar fullLobeDegrees = 360.0f / numLobes;
300 SkScalar outDegrees = ratio * fullLobeDegrees / (ratio + 1.0f);
301 SkScalar innerDegrees = fullLobeDegrees / (ratio + 1.0f);
309 o.
fX + innerRadius, o.
fY + innerRadius));
312 p.moveTo(o.
fX + innerRadius * curV.
fX, o.
fY + innerRadius * curV.
fY);
314 for (
int i = 0;
i < numDivisions; ++
i) {
321 o.
fY + outerRadius * curV.
fY);
323 o.
fY + outerRadius * nextV.
fY);
326 add_arc(&
p, top, curV, nextTop, nextV, circles,
true);
331 o.
fY + innerRadius * curV.
fY);
333 o.
fY + innerRadius * nextV.
fY);
336 add_arc(&
p, bot, curV, nextBot, nextV,
nullptr,
false);
374 paint.setAntiAlias(
false);
380 for (
int i = 0;
i < circles.
size(); ++
i) {
388 paint.setAlpha(opaque ? 0xFF : 0x40);
391 canvas->drawOval(r,
paint);
452 for (
int y = 0;
y < orientedBM.
height(); ++
y) {
453 for (
int x = 0;
x < orientedBM.
width(); ++
x) {
466 dst->fR = yuva[0] / 255.0f;
467 dst->fG = yuva[1] / 255.0f;
468 dst->fB = yuva[2] / 255.0f;
469 dst->fA = yuva[3] / 255.0f;
475 for (
int y = 0;
y < orientedBM.
height()/2; ++
y) {
476 for (
int x = 0;
x < orientedBM.
width()/2; ++
x) {
477 uint32_t yAccum = 0, uAccum = 0, vAccum = 0, aAccum = 0;
504 dst->fR = yAccum / (4.0f * 255.0f);
505 dst->fG = uAccum / (4.0f * 255.0f);
506 dst->fB = vAccum / (4.0f * 255.0f);
507 dst->fA = aAccum / (4.0f * 255.0f);
526 for (
int y = 0;
y < fullY.
height()/2; ++
y) {
527 for (
int x = 0;
x < fullY.
width()/2; ++
x) {
532 *
result.getAddr16(
x,
y) = (v8 << 8) | u8;
534 *
result.getAddr16(
x,
y) = (u8 << 8) | v8;
551 for (
int y = 0;
y <
src.height(); ++
y) {
552 for (
int x = 0;
x <
src.width(); ++
x) {
553 const float* srcPixel = (
const float*)
src.getAddr(
x,
y);
554 uint16_t* dstPixel = (uint16_t*)
result.getAddr(
x,
y);
575 [] (uint16_t* dstPixel,
const float* srcPixel) {
576 dstPixel[0] = flt_2_uint16(srcPixel[1]);
577 dstPixel[1] = flt_2_uint16(srcPixel[0]);
578 dstPixel[2] = flt_2_uint16(srcPixel[2]);
579 dstPixel[3] = flt_2_uint16(srcPixel[3]);
604 resultBMs[nextLayer++] = yuvaFull;
625 *yuvaFull.
getAddr32(
x,
y) = (
A << 30) | (
V << 20) | (
Y << 10) | (
U << 0);
629 resultBMs[nextLayer++] = yuvaFull;
636 (uint16_t* dstPixel,
const float* srcPixel) {
637 uint16_t val16 = flt_2_uint16(srcPixel[0]);
638 dstPixel[0] = tenBitsPP ? (val16 & 0xFFC0)
643 (uint16_t* dstPixel,
const float* srcPixel) {
644 uint16_t u16 = flt_2_uint16(srcPixel[1]);
645 uint16_t v16 = flt_2_uint16(srcPixel[2]);
646 dstPixel[0] = tenBitsPP ? (u16 & 0xFFC0) : u16;
647 dstPixel[1] = tenBitsPP ? (v16 & 0xFFC0) : v16;
652 (uint16_t* dstPixel,
const float* srcPixel) {
653 uint16_t val16 = flt_2_uint16(srcPixel[3]);
654 dstPixel[0] = tenBitsPP ? (val16 & 0xFFC0)
662 [] (uint16_t* dstPixel,
const float* srcPixel) {
663 dstPixel[0] = SkFloatToHalf(srcPixel[0]);
666 [] (uint16_t* dstPixel,
const float* srcPixel) {
667 dstPixel[0] = SkFloatToHalf(srcPixel[1]);
668 dstPixel[1] = SkFloatToHalf(srcPixel[2]);
672 [] (uint16_t* dstPixel,
const float* srcPixel) {
673 dstPixel[0] = SkFloatToHalf(srcPixel[3]);
682 resultBMs[nextLayer++] = planes.
fYFull;
683 resultBMs[nextLayer++] = uvQuarter;
690 resultBMs[nextLayer++] = planes.
fYFull;
691 resultBMs[nextLayer++] = vuQuarter;
695 resultBMs[nextLayer++] = planes.
fYFull;
696 resultBMs[nextLayer++] = planes.
fUQuarter;
697 resultBMs[nextLayer++] = planes.
fVQuarter;
700 resultBMs[nextLayer++] = planes.
fYFull;
701 resultBMs[nextLayer++] = planes.
fVQuarter;
702 resultBMs[nextLayer++] = planes.
fUQuarter;
707 resultBMs[nextLayer++] = planes.
fAFull;
713 static const char* kYUVColorSpaceNames[] = {
"JPEG",
"601",
"709F",
"709L",
714 "2020_8F",
"2020_8L",
"2020_10L",
"2020_12F",
715 "FCCL",
"SMPTE240L",
"YDZDXL",
"GBRL",
716 "YCGCO_8F",
"YCGCO_8L",
"YCGCO_10F",
"YCGCO_12F",
717 "YCGCO_12L",
"Identity"};
727 colLabel.
printf(
"%s", kYUVColorSpaceNames[yuvColorSpace]);
733 colLabel.
printf(
"%s", opaque ?
"Opaque" :
"Transparent");
742 static const char* kYUVFormatNames[] = {
743 "P016",
"P010",
"P016F",
"Y416",
"AYUV",
"Y410",
"NV12",
"NV21",
"I420",
"YV12"
754 rowLabel.
printf(
"%s", kYUVFormatNames[yuvFormat]);
762 static const float kJPEGConversionMatrix[20] = {
763 1.0f, 0.0f, 1.402f, 0.0f, -180.0f/255,
764 1.0f, -0.344136f, -0.714136f, 0.0f, 136.0f/255,
765 1.0f, 1.772f, 0.0f, 0.0f, -227.6f/255,
766 0.0f, 0.0f, 0.0f, 1.0f, 0.0f
795 : fUseTargetColorSpace(useTargetColorSpace)
796 , fUseSubset(useSubset)
797 , fUseCubicSampling(useCubicSampling)
805 if (fUseTargetColorSpace) {
811 if (fUseCubicSampling) {
814 switch (fImageType) {
816 name +=
"_frompixmaps";
824 name +=
"_fromimages";
842 float innerRadius = 20.0f;
858 if (fUseTargetColorSpace) {
865 for (
bool opaque : {
false,
true }) {
887#if defined(SK_GRAPHITE)
889 fImages[opaque][cs][
format] = lazyYUV->refImage(recorder, fImageType);
893 fImages[opaque][cs][
format] = lazyYUV->refImage(dContext, fImageType);
896 origin = (origin + 1) % 8;
916 if (dContext && dContext->abandoned()) {
928 *errorMsg =
"Failed to create YUV images";
936 for (
int i = 0;
i < 2; ++
i) {
939 fImages[
i][j][k] =
nullptr;
947#if defined(SK_GRAPHITE)
980 for (
int opaque : { 0, 1 }) {
985 canvas->
drawImageRect(fOriginalBMs[opaque].asImage(), srcRect, dstRect,
991 if (fUseTargetColorSpace && fImages[opaque][cs][
format]) {
996#if defined(SK_GRAPHITE)
999 recorder, fTargetColorSpace, {});
1004 direct, fTargetColorSpace);
1007 &
paint, constraint);
1023 bool fUseTargetColorSpace;
1025 bool fUseCubicSampling;
1029 using INHERITED =
GM;
1058#
if defined(SK_GRAPHITE)
1068 this->setBGColor(0xFFCCCCCC);
1084 float innerRadius = 20.0f;
1090 fOriginalBMs[0] =
make_bitmap(kN32_SkColorType,
path, circles,
false,
false);
1097 fOriginalBMs[1] =
make_bitmap(kN32_SkColorType,
path, circles,
true,
false);
1104 for (
bool opaque : {
false,
true }) {
1117 auto yuvaPixmaps = planarConfig.
makeYUVAPixmaps(fOriginalBMs[opaque].dimensions(),
1127 fImages[opaque][
i++] =
1143 if (!dContext || dContext->abandoned()) {
1144 *errorMsg =
"DirectContext required to create YUV images";
1148 this->createBitmaps();
1149 if (!this->createImages(dContext)) {
1150 *errorMsg =
"Failed to create YUV images";
1158 fImages[0][0] = fImages[0][1] = fImages[1][0] = fImages[1][1] =
nullptr;
1162 SkASSERT(fImages[0][0] && fImages[0][1] && fImages[1][0] && fImages[1][1]);
1166 *msg =
"YUV ColorSpace image creation requires a direct context.";
1171 for (
int tagged : { 0, 1 }) {
1172 for (
int opaque : { 0, 1 }) {
1175 auto raster = fOriginalBMs[opaque].asImage()->makeColorSpace(
1176 nullptr, fTargetColorSpace);
1180 if (fImages[opaque][tagged]) {
1181 auto yuv = fImages[opaque][tagged]->makeColorSpace(dContext, fTargetColorSpace);
1193 auto nonTexture = yuv->makeNonTextureImage();
1217DEF_GM(
return new YUVMakeColorSpaceGM();)
1279 for (
int i = 0;
i <
info.numPlanes(); ++
i) {
1280 planes[
i]->peekPixels(&pixmaps[
i]);
1297 for (
int i = 0;
i <
info.numPlanes(); ++
i) {
1299 y += planes[
i]->height();
1304 using INHERITED =
GM;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
static const uint64_t kGreen
static const uint64_t kBlue
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kA16_float_SkColorType
pixel with a half float for alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
@ kR16G16_float_SkColorType
pixel with a half float for red and green
#define SkColorGetR(color)
#define SkColorGetG(color)
constexpr SkColor SK_ColorTRANSPARENT
constexpr SkColor SK_ColorRED
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkColorGetA(color)
#define SkColorGetB(color)
@ kTopLeft_SkEncodedOrigin
static bool SkEncodedOriginSwapsWidthHeight(SkEncodedOrigin origin)
static SkMatrix SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, int h)
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
@ kRec709_Full_SkYUVColorSpace
describes HDTV range
@ kYCgCo_10bit_Full_SkYUVColorSpace
@ kYCgCo_12bit_Full_SkYUVColorSpace
@ kYCgCo_12bit_Limited_SkYUVColorSpace
@ kGBR_Limited_SkYUVColorSpace
@ kBT2020_8bit_Limited_SkYUVColorSpace
@ kBT2020_SkYUVColorSpace
@ kYCgCo_8bit_Limited_SkYUVColorSpace
@ kRec601_SkYUVColorSpace
@ kFCC_Limited_SkYUVColorSpace
@ kYCgCo_8bit_Full_SkYUVColorSpace
describes YCgCo matrix
@ kBT2020_8bit_Full_SkYUVColorSpace
describes UHDTV range, non-constant-luminance
@ kRec601_Limited_SkYUVColorSpace
describes SDTV range
@ kRec709_Limited_SkYUVColorSpace
@ kSMPTE240_Limited_SkYUVColorSpace
@ kBT2020_12bit_Full_SkYUVColorSpace
@ kRec709_SkYUVColorSpace
@ kIdentity_SkYUVColorSpace
maps Y->R, U->G, V->B
@ kBT2020_10bit_Limited_SkYUVColorSpace
@ kYDZDX_Limited_SkYUVColorSpace
@ kJPEG_Full_SkYUVColorSpace
describes full range
static SkV4 v4(SkV3 v, SkScalar w)
#define INHERITED(method,...)
#define SkScalarATan2(y, x)
#define SkScalarRoundToInt(x)
#define SkScalarCeilToInt(x)
#define SkRadiansToDegrees(radians)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
void SkColorMatrix_RGB2YUV(SkYUVColorSpace cs, float m[20])
static SkScalar center(float pos0, float pos1)
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
void allocPixels(const SkImageInfo &info, size_t rowBytes)
sk_sp< SkImage > asImage() const
SkColor getColor(int x, int y) const
uint8_t * getAddr8(int x, int y) const
const SkPixmap & pixmap() const
void * getAddr(int x, int y) const
const SkImageInfo & info() const
uint32_t * getAddr32(int x, int y) const
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void concat(const SkMatrix &matrix)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
static std::unique_ptr< SkCanvas > MakeRasterDirect(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
void setScale(float rScale, float gScale, float bScale, float aScale=1.0f)
static bool Equals(const SkColorSpace *, const SkColorSpace *)
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkColorSpace > makeColorSpin() const
static constexpr SkFontStyle Bold()
@ kAlias
no transparent pixels on glyph edges
virtual sk_sp< SkImage > makeColorSpace(GrDirectContext *direct, sk_sp< SkColorSpace > target) const =0
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
void mapVector(SkScalar dx, SkScalar dy, SkVector *result) const
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
void push_back(const T &v)
static void DrawString(SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
@ 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.
@ kY_V_U_A
Plane 0: Y, Plane 1: V, Plane 2: U, Plane 3: A.
@ kY_VU
Plane 0: Y, Plane 1: VU.
@ kY_UV
Plane 0: Y, Plane 1: UV.
@ kY_VU_A
Plane 0: Y, Plane 1: VU, Plane 2: A.
@ kY_V_U
Plane 0: Y, Plane 1: V, Plane 2: U.
@ kY_UV_A
Plane 0: Y, Plane 1: UV, Plane 2: A.
static constexpr int kMaxPlanes
@ k420
1 set of UV values for each 2x2 block of Y values.
@ k444
No subsampling. UV values for each Y.
static constexpr int NumPlanes(PlaneConfig)
static SkYUVAPixmaps FromExternalPixmaps(const SkYUVAInfo &, const SkPixmap[kMaxPlanes])
SkYUVAPixmaps makeYUVAPixmaps(SkISize dimensions, SkYUVColorSpace yuvColorSpace, const SkBitmap bitmaps[], int numBitmaps) const
YUVAPlanarConfig(YUVFormat format, bool opaque, SkEncodedOrigin origin)
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
void onOnceBeforeDraw() override
SkString getName() const override
static std::unique_ptr< LazyYUVImage > Make(sk_sp< SkData > data, skgpu::Mipmapped=skgpu::Mipmapped::kNo, sk_sp< SkColorSpace >=nullptr)
GM(SkColor backgroundColor=SK_ColorWHITE)
void onGpuTeardown() override
SkISize getISize() override
DrawResult onDraw(SkCanvas *canvas, SkString *msg) override
SkString getName() const override
DrawResult onGpuSetup(SkCanvas *canvas, SkString *errorMsg, GraphiteTestContext *) override
bool createImages(GrDirectContext *context)
static Editor::Movement convert(skui::Key key)
uint32_t uint32_t * format
Dart_NativeFunction function
T __attribute__((ext_vector_type(N))) V
constexpr SkColor4f kMagenta
constexpr SkColor4f kCyan
constexpr SkColor4f kYellow
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 > SubsetTextureFrom(GrDirectContext *context, const SkImage *img, const SkIRect &subset)
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
SkSamplingOptions sampling
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library name
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
font
Font Metadata and Metrics.
std::tuple< std::array< sk_sp< SkImage >, SkYUVAInfo::kMaxPlanes >, SkYUVAInfo > MakeYUVAPlanesAsA8(SkImage *src, SkYUVColorSpace cs, SkYUVAInfo::Subsampling ss, GrRecordingContext *rContext)
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
SkSamplingOptions(SkFilterMode::kLinear))
DEF_GM(return new WackyYUVFormatsGM(false, false, false, WackyYUVFormatsGM::Type::kFromGenerator);) DEF_GM(return new WackyYUVFormatsGM(false
static constexpr SkCubicResampler Mitchell()
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static constexpr SkISize Make(int32_t w, int32_t h)
SkImageInfo makeWH(int newWidth, int newHeight) const
SkISize dimensions() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkImageInfo MakeA8(int width, int height)
static constexpr SkPoint Make(float x, float y)
float cross(const SkVector &vec) const
static SkRect Make(const SkISize &size)
void offsetTo(float newX, float newY)
SkScalar fBottom
larger y-axis bounds
void inset(float dx, float dy)
SkScalar fLeft
smaller x-axis bounds
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkScalar fRight
larger x-axis bounds
void offset(float dx, float dy)
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
SkScalar fTop
smaller y-axis bounds