OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkColorSpace_Base.h" | 9 #include "SkColorSpace_Base.h" |
10 #include "SkColorSpaceXform.h" | 10 #include "SkColorSpaceXform.h" |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 new SkFastXform<SkColorSpace::kNonStandard_GammaNamed>(s
rcSpace, srcToDst, | 483 new SkFastXform<SkColorSpace::kNonStandard_GammaNamed>(s
rcSpace, srcToDst, |
484 d
stSpace)); | 484 d
stSpace)); |
485 } | 485 } |
486 } | 486 } |
487 | 487 |
488 return std::unique_ptr<SkColorSpaceXform>(new SkDefaultXform(srcSpace, srcTo
Dst, dstSpace)); | 488 return std::unique_ptr<SkColorSpaceXform>(new SkDefaultXform(srcSpace, srcTo
Dst, dstSpace)); |
489 } | 489 } |
490 | 490 |
491 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 491 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
492 | 492 |
493 // TODO (msarett): | |
494 // Once SkFastXform supports translation, delete this function and use asRowMajo
rf(). | |
495 static void build_src_to_dst(float srcToDstArray[12], const SkMatrix44& srcToDst
Matrix) { | |
496 // Build the following row major matrix: | |
497 // rX gX bX 0 | |
498 // rY gY bY 0 | |
499 // rZ gZ bZ 0 | |
500 srcToDstArray[0] = srcToDstMatrix.getFloat(0, 0); | |
501 srcToDstArray[1] = srcToDstMatrix.getFloat(0, 1); | |
502 srcToDstArray[2] = srcToDstMatrix.getFloat(0, 2); | |
503 srcToDstArray[3] = 0.0f; | |
504 srcToDstArray[4] = srcToDstMatrix.getFloat(1, 0); | |
505 srcToDstArray[5] = srcToDstMatrix.getFloat(1, 1); | |
506 srcToDstArray[6] = srcToDstMatrix.getFloat(1, 2); | |
507 srcToDstArray[7] = 0.0f; | |
508 srcToDstArray[8] = srcToDstMatrix.getFloat(2, 0); | |
509 srcToDstArray[9] = srcToDstMatrix.getFloat(2, 1); | |
510 srcToDstArray[10] = srcToDstMatrix.getFloat(2, 2); | |
511 srcToDstArray[11] = 0.0f; | |
512 } | |
513 | |
514 template <SkColorSpace::GammaNamed Dst> | 493 template <SkColorSpace::GammaNamed Dst> |
515 SkFastXform<Dst>::SkFastXform(const sk_sp<SkColorSpace>& srcSpace, const SkMatri
x44& srcToDst, | 494 SkFastXform<Dst>::SkFastXform(const sk_sp<SkColorSpace>& srcSpace, const SkMatri
x44& srcToDst, |
516 const sk_sp<SkColorSpace>& dstSpace) | 495 const sk_sp<SkColorSpace>& dstSpace) |
517 { | 496 { |
518 build_src_to_dst(fSrcToDst, srcToDst); | 497 srcToDst.asRowMajorf(fSrcToDst); |
519 build_gamma_tables(fSrcGammaTables, fSrcGammaTableStorage, 256, srcSpace, kT
oLinear); | 498 build_gamma_tables(fSrcGammaTables, fSrcGammaTableStorage, 256, srcSpace, kT
oLinear); |
520 build_gamma_tables(fDstGammaTables, fDstGammaTableStorage, SkDefaultXform::k
DstGammaTableSize, | 499 build_gamma_tables(fDstGammaTables, fDstGammaTableStorage, SkDefaultXform::k
DstGammaTableSize, |
521 dstSpace, kFromLinear); | 500 dstSpace, kFromLinear); |
522 } | 501 } |
523 | 502 |
524 template <> | 503 template <> |
525 void SkFastXform<SkColorSpace::kSRGB_GammaNamed> | 504 void SkFastXform<SkColorSpace::kSRGB_GammaNamed> |
526 ::applyTo8888(SkPMColor* dst, const RGBA32* src, int len) const | 505 ::applyTo8888(SkPMColor* dst, const RGBA32* src, int len) const |
527 { | 506 { |
528 SkOpts::color_xform_RGB1_to_srgb(dst, src, len, fSrcGammaTables, fSrcToDst); | 507 SkOpts::color_xform_RGB1_to_srgb(dst, src, len, fSrcGammaTables, fSrcToDst); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 const int n000 = 0; | 587 const int n000 = 0; |
609 const int n001 = 3 * colorLUT->fGridPoints[1] * colorLUT->fGridPoints[2]; | 588 const int n001 = 3 * colorLUT->fGridPoints[1] * colorLUT->fGridPoints[2]; |
610 const int n010 = 3 * colorLUT->fGridPoints[2]; | 589 const int n010 = 3 * colorLUT->fGridPoints[2]; |
611 const int n011 = n001 + n010; | 590 const int n011 = n001 + n010; |
612 const int n100 = 3; | 591 const int n100 = 3; |
613 const int n101 = n100 + n001; | 592 const int n101 = n100 + n001; |
614 const int n110 = n100 + n010; | 593 const int n110 = n100 + n010; |
615 const int n111 = n110 + n001; | 594 const int n111 = n110 + n001; |
616 | 595 |
617 // Base ptr into the table. | 596 // Base ptr into the table. |
618 float* ptr = &colorLUT->fTable[ix*n001 + iy*n010 + iz*n100]; | 597 const float* ptr = &(colorLUT->table()[ix*n001 + iy*n010 + iz*n100]); |
619 | 598 |
620 // The code below performs a tetrahedral interpolation for each of the three | 599 // The code below performs a tetrahedral interpolation for each of the three |
621 // dst components. Once the tetrahedron containing the interpolation point
is | 600 // dst components. Once the tetrahedron containing the interpolation point
is |
622 // identified, the interpolation is a weighted sum of grid values at the | 601 // identified, the interpolation is a weighted sum of grid values at the |
623 // vertices of the tetrahedron. The claim is that tetrahedral interpolation | 602 // vertices of the tetrahedron. The claim is that tetrahedral interpolation |
624 // provides a more accurate color conversion. | 603 // provides a more accurate color conversion. |
625 // blogs.mathworks.com/steve/2006/11/24/tetrahedral-interpolation-for-colors
pace-conversion/ | 604 // blogs.mathworks.com/steve/2006/11/24/tetrahedral-interpolation-for-colors
pace-conversion/ |
626 // | 605 // |
627 // I have one test image, and visually I can't tell the difference between | 606 // I have one test image, and visually I can't tell the difference between |
628 // tetrahedral and trilinear interpolation. In terms of computation, the | 607 // tetrahedral and trilinear interpolation. In terms of computation, the |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 dst++; | 701 dst++; |
723 src++; | 702 src++; |
724 } | 703 } |
725 } | 704 } |
726 | 705 |
727 void SkDefaultXform::applyToF16(RGBAF16* dst, const RGBA32* src, int len) const
{ | 706 void SkDefaultXform::applyToF16(RGBAF16* dst, const RGBA32* src, int len) const
{ |
728 // FIXME (msarett): | 707 // FIXME (msarett): |
729 // Planning to delete SkDefaultXform. Not going to bother to implement this
. | 708 // Planning to delete SkDefaultXform. Not going to bother to implement this
. |
730 memset(dst, 0, len * sizeof(RGBAF16)); | 709 memset(dst, 0, len * sizeof(RGBAF16)); |
731 } | 710 } |
OLD | NEW |