335 {
337 if (
src.dimensions().isEmpty() ||
dst.dimensions().isEmpty()) {
338 return false;
339 }
341 return false;
342 }
343 if (!
src.hasPixels() || !
dst.hasPixels()) {
344 return false;
345 }
346 if (
dst.dimensions() !=
src.dimensions()) {
347 return false;
348 }
350
351
352
355 return false;
356 }
357 auto* tRow =
reinterpret_cast<const char*
>(temp.
addr());
358 auto* dRow =
reinterpret_cast<char*
>(
dst.addr());
359 for (
int y = 0;
y <
dst.height(); ++
y, tRow += temp.
rowBytes(), dRow +=
dst.rowBytes()) {
360 for (
int x = 0;
x <
dst.width(); ++
x) {
361 auto t = tRow +
x*
sizeof(uint32_t);
364 }
365 }
366 return true;
368
369
371 auto* sRow =
reinterpret_cast<const char*
>(
src.addr());
372 auto* tRow =
reinterpret_cast<char*
>(temp.
addr());
373 for (
int y = 0;
y <
src.height(); ++
y, sRow +=
src.rowBytes(), tRow += temp.
rowBytes()) {
374 for (
int x = 0;
x <
src.width(); ++
x) {
376 auto t = tRow +
x*
sizeof(uint32_t);
378 t[3] = static_cast<char>(0xFF);
379 }
380 }
382 }
383
384 size_t srcBpp =
src.info().bpp();
385 size_t dstBpp =
dst.info().bpp();
386
387
390
395 bool alphaOrCSConversion =
397
398 if (
src.colorType() ==
dst.colorType() && !alphaOrCSConversion) {
399 size_t tightRB = dstBpp *
dst.width();
400 if (flipY) {
401 auto s =
static_cast<const char*
>(
src.addr());
402 auto d = SkTAddOffset<char>(
dst.addr(),
dst.rowBytes()*(
dst.height() - 1));
403 for (
int y = 0;
y <
dst.height(); ++
y,
d -=
dst.rowBytes(),
s +=
src.rowBytes()) {
404 memcpy(
d,
s, tightRB);
405 }
406 } else {
408 src.addr(),
src.rowBytes(),
409 tightRB,
src.height());
410 }
411 return true;
412 }
413
415 bool srcIsNormalized;
416 bool srcIsSRGB;
419 &srcIsNormalized,
420 &srcIsSRGB);
421
424 bool dstIsNormalized;
425 bool dstIsSRGB;
428 &lumMode,
429 &dstIsNormalized,
430 &dstIsSRGB);
431
434 if (alphaOrCSConversion) {
435 steps.
init(
src.colorSpace(),
src.alphaType(),
dst.colorSpace(),
dst.alphaType());
436 } else {
438 }
439 int cnt = 1;
442 srcCtx{
const_cast<void*
>(
src.addr()),
SkToInt(
src.rowBytes()/srcBpp)},
444
445 if (flipY) {
446
447
448
449
450
451 srcCtx.pixels =
static_cast<char*
>(srcCtx.pixels) +
src.rowBytes()*(
height - 1);
453 }
454
455 bool hasConversion = alphaOrCSConversion || lumMode !=
LumMode::kNone;
456
457 if (srcIsSRGB && dstIsSRGB && !hasConversion) {
458
459 srcIsSRGB = dstIsSRGB = false;
460 }
461
462 hasConversion = hasConversion || srcIsSRGB || dstIsSRGB;
463
466 if (hasConversion) {
467 loadSwizzle.apply(&pipeline);
468 if (srcIsSRGB) {
470 }
471 if (alphaOrCSConversion) {
472 steps->apply(&pipeline);
473 }
474 switch (lumMode) {
476 break;
478 pipeline.
append(SkRasterPipelineOp::bt709_luminance_or_luma_to_rgb);
479 break;
481 pipeline.
append(SkRasterPipelineOp::bt709_luminance_or_luma_to_alpha);
482
483
484
485
487 break;
488 }
489 if (dstIsSRGB) {
491 }
492 storeSwizzle.apply(&pipeline);
493 } else {
494 loadStoreSwizzle.
apply(&pipeline);
495 }
497 auto pipelineFn = pipeline.
compile();
498 for (
int i = 0;
i < cnt; ++
i) {
500 srcCtx.pixels =
static_cast<char*
>(srcCtx.pixels) -
src.rowBytes();
501 dstCtx.pixels =
static_cast<char*
>(dstCtx.pixels) +
dst.rowBytes();
502 }
503
504 return true;
505}
bool GrConvertPixels(const GrPixmap &dst, const GrCPixmap &src, bool flipY)
static skgpu::Swizzle get_load_and_src_swizzle(GrColorType ct, SkRasterPipelineOp *load, bool *isNormalized, bool *isSRGB)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static void SkRectMemcpy(void *dst, size_t dstRB, const void *src, size_t srcRB, size_t trimRowBytes, int rowCount)
void swap(sk_sp< T > &a, sk_sp< T > &b)
static uint32_t premul(uint32_t color)
static GrPixmap Allocate(const GrImageInfo &info)
static bool Equals(const SkColorSpace *, const SkColorSpace *)
std::function< void(size_t, size_t, size_t, size_t)> compile() const
T * init(Args &&... args)
static constexpr Swizzle Concat(const Swizzle &a, const Swizzle &b)
const skcms_TransferFunction * skcms_sRGB_TransferFunction()