695 {
700
702 state.fType == SkShaderBase::GradientType::kRadial ||
703 state.fType == SkShaderBase::GradientType::kConical) &&
707
708 enum class ShadingType : int32_t {
709 Function = 1,
710 Axial = 2,
711 Radial = 3,
712 FreeFormGouraudTriangleMesh = 4,
713 LatticeFormGouraudTriangleMesh = 5,
714 CoonsPatchMesh = 6,
715 TensorProductPatchMesh = 7,
716 } shadingType;
717
719 if (doStitchFunctions) {
721
724 extend->reserve(2);
725 extend->appendBool(true);
726 extend->appendBool(true);
727 pdfShader->insertObject("Extend", std::move(extend));
728 }
729
730 std::unique_ptr<SkPDFArray> coords;
731 switch (
state.fType) {
733 shadingType = ShadingType::Axial;
738 } break;
739 case SkShaderBase::GradientType::kRadial: {
740 shadingType = ShadingType::Radial;
743 pt1.
x(), pt1.
y(),
info.fRadius[0]);
744 } break;
745 case SkShaderBase::GradientType::kConical: {
746 shadingType = ShadingType::Radial;
752
754 pt2.
x(), pt2.
y(), r2);
755 break;
756 }
757 case SkShaderBase::GradientType::kSweep:
759 default:
762 }
763 pdfShader->insertObject("Coords", std::move(coords));
764 } else {
765 shadingType = ShadingType::Function;
766
767
768 transformPoints[0] =
info.fPoint[0];
769 transformPoints[1] =
info.fPoint[1];
770 switch (
state.fType) {
772 break;
773 case SkShaderBase::GradientType::kRadial:
774 transformPoints[1] = transformPoints[0];
775 transformPoints[1].
fX +=
info.fRadius[0];
776 break;
777 case SkShaderBase::GradientType::kConical: {
778 transformPoints[1] = transformPoints[0];
780 break;
781 }
782 case SkShaderBase::GradientType::kSweep:
783 transformPoints[1] = transformPoints[0];
785 break;
787 default:
789 }
790
791
792
793
794
797
799
800
801
802
803
804
808 &finalMatrix, &perspectiveInverseOnly)) {
810 }
811 }
812
817 }
818
820 switch (
state.fType) {
823 break;
824 case SkShaderBase::GradientType::kRadial:
826 break;
827 case SkShaderBase::GradientType::kConical: {
828
829
830
833 if (!mapperMatrix.
invert(&inverseMapperMatrix)) {
835 }
840 } break;
841 case SkShaderBase::GradientType::kSweep:
843 break;
844 default:
846 }
847 pdfShader->insertObject(
849
851 std::unique_ptr<SkPDFArray> rangeObject =
SkPDFMakeArray(0, 1, 0, 1, 0, 1);
852 pdfShader->insertRef("Function",
854 std::move(rangeObject), doc));
855 }
856
857 pdfShader->insertInt(
"ShadingType",
SkToS32(shadingType));
858 pdfShader->insertName("ColorSpace", "DeviceRGB");
859
861 pdfFunctionShader.insertInt("PatternType", 2);
863 pdfFunctionShader.insertObject("Shading", std::move(pdfShader));
864 return doc->
emit(pdfFunctionShader);
865}
static void radialCode(const SkShaderBase::GradientInfo &info, const SkMatrix &perspectiveRemover, SkDynamicMemoryWStream *function)
static std::unique_ptr< SkPDFDict > gradientStitchCode(const SkShaderBase::GradientInfo &info)
static void sweepCode(const SkShaderBase::GradientInfo &info, const SkMatrix &perspectiveRemover, SkDynamicMemoryWStream *function)
static void linearCode(const SkShaderBase::GradientInfo &info, const SkMatrix &perspectiveRemover, SkDynamicMemoryWStream *function)
static bool split_perspective(const SkMatrix in, SkMatrix *affine, SkMatrix *perspectiveInverse)
static void twoPointConicalCode(const SkShaderBase::GradientInfo &info, const SkMatrix &perspectiveRemover, SkDynamicMemoryWStream *function)
static SkPDFIndirectReference make_ps_function(std::unique_ptr< SkStreamAsset > psCode, std::unique_ptr< SkPDFArray > domain, std::unique_ptr< SkPDFObject > range, SkPDFDocument *doc)
static void unit_to_points_matrix(const SkPoint pts[2], SkMatrix *matrix)
static void FixUpRadius(const SkPoint &p1, SkScalar &r1, const SkPoint &p2, SkScalar &r2)
constexpr int32_t SkToS32(S x)
std::unique_ptr< SkStreamAsset > detachAsStream()
SkScalar mapRadius(SkScalar radius) const
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
bool invert(SkMatrix *inverse) const
SkMatrix & preConcat(const SkMatrix &other)
SkPDFIndirectReference emit(const SkPDFObject &, SkPDFIndirectReference)
static constexpr skcms_TransferFunction kLinear
std::unique_ptr< SkPDFArray > MatrixToArray(const SkMatrix &matrix)
bool InverseTransformBBox(const SkMatrix &matrix, SkRect *bbox)
constexpr float y() const
constexpr float x() const
constexpr float left() const
constexpr float top() const
constexpr float right() const
void set(const SkIRect &src)
constexpr float bottom() const