--- src/opts/SkRasterPipeline_opts.h.orig +++ src/opts/SkRasterPipeline_opts.h @@ -1793,10 +1793,17 @@ *a = cast(wide & (15<< 0)) * (1.0f / (15<< 0)); } SI void from_8888(U32 _8888, F* r, F* g, F* b, F* a) { +#ifdef SK_CPU_BENDIAN + *r = cast((_8888 >> 24) ) * (1/255.0f); + *g = cast((_8888 >> 16) & 0xff) * (1/255.0f); + *b = cast((_8888 >> 8) & 0xff) * (1/255.0f); + *a = cast((_8888 ) & 0xff) * (1/255.0f); +#else *r = cast((_8888 ) & 0xff) * (1/255.0f); *g = cast((_8888 >> 8) & 0xff) * (1/255.0f); *b = cast((_8888 >> 16) & 0xff) * (1/255.0f); *a = cast((_8888 >> 24) ) * (1/255.0f); +#endif } SI void from_88(U16 _88, F* r, F* g) { U32 wide = expand(_88); @@ -2383,10 +2390,17 @@ auto ptr = ptr_at_xy(ctx, dx,dy); U32 dst = load(ptr); +#ifdef SK_CPU_BENDIAN + dr = cast((dst >> 24) ); + dg = cast((dst >> 16) & 0xff); + db = cast((dst >> 8) & 0xff); + da = cast((dst ) & 0xff); +#else dr = cast((dst ) & 0xff); dg = cast((dst >> 8) & 0xff); db = cast((dst >> 16) & 0xff); da = cast((dst >> 24) ); +#endif // {dr,dg,db,da} are in [0,255] // { r, g, b, a} are in [0, 1] (but may be out of gamut) @@ -2397,10 +2411,17 @@ // { r, g, b, a} are now in [0,255] (but may be out of gamut) // to_unorm() clamps back to gamut. Scaling by 1 since we're already 255-based. +#ifdef SK_CPU_BENDIAN + dst = to_unorm(r, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255) << 24 + | to_unorm(g, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255) << 16 + | to_unorm(b, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255) << 8 + | to_unorm(a, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255); +#else dst = to_unorm(r, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255) | to_unorm(g, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255) << 8 | to_unorm(b, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255) << 16 | to_unorm(a, /*scale=*/1, /*bias=*/0.f, /*maxI=*/255) << 24; +#endif store(ptr, dst); } @@ -2953,10 +2974,17 @@ HIGHP_STAGE(store_8888, const SkRasterPipelineContexts::MemoryCtx* ctx) { auto ptr = ptr_at_xy(ctx, dx,dy); +#ifdef SK_CPU_BENDIAN + U32 px = to_unorm(r, 255) << 24 + | to_unorm(g, 255) << 16 + | to_unorm(b, 255) << 8 + | to_unorm(a, 255); +#else U32 px = to_unorm(r, 255) | to_unorm(g, 255) << 8 | to_unorm(b, 255) << 16 | to_unorm(a, 255) << 24; +#endif store(ptr, px); } @@ -6140,11 +6168,18 @@ }; #endif #if !defined(SKRP_CPU_LSX) +#ifdef SK_CPU_BENDIAN + *r = cast_U16(rgba >> 16) >> 8; + *g = cast_U16(rgba >> 16) & 255; + *b = cast_U16(rgba & 65535) >> 8; + *a = cast_U16(rgba & 65535) & 255; +#else *r = cast_U16(rgba & 65535) & 255; *g = cast_U16(rgba & 65535) >> 8; *b = cast_U16(rgba >> 16) & 255; *a = cast_U16(rgba >> 16) >> 8; #endif +#endif } SI void load_8888_(const uint32_t* ptr, U16* r, U16* g, U16* b, U16* a) { @@ -6197,10 +6232,15 @@ }}; vst4_u8((uint8_t*)(ptr), rgba); #else +#ifdef SK_CPU_BENDIAN + store(ptr, cast((r<<8) | g) << 16 + | cast((b<<8) | a) << 0); +#else store(ptr, cast(r | (g<<8)) << 0 | cast(b | (a<<8)) << 16); #endif #endif +#endif } LOWP_STAGE_PP(load_8888, const SkRasterPipelineContexts::MemoryCtx* ctx) {