64 matrix->preScale(mag, mag);
65 matrix->postTranslate(pts[0].fX, pts[0].fY);
101 multiplier[
i] = kColorScale * (curColor[
i] - prevColor[
i]) / range;
110 dupInput[
i] = dupInput[
i + 1] || multiplier[
i + 1] != 0;
113 if (!dupInput[0] && multiplier[0] == 0) {
114 result->writeText(
"pop ");
120 if (dupInput[
i] && multiplier[
i] != 0) {
121 result->writeText(
"dup ");
124 if (multiplier[
i] == 0) {
128 if (multiplier[
i] != 1) {
130 result->writeText(
" mul ");
132 if (prevColor[
i] != 0) {
134 result->writeText(
" add ");
139 result->writeText(
"exch ");
148 size_t rangeEndIndex = rangeEnds[rangeEnds.
size() - 1];
155 result->writeText(
"dup dup 0 gt exch ");
157 result->writeText(
" le and {\n");
160 result->writeText(
"dup ");
162 result->writeText(
" le {\n");
168 if (rangeEnds.
size() == 1) {
170 size_t rangeBeginIndex = rangeEndIndex - 1;
171 SkScalar rangeBegin =
info.fColorOffsets[rangeBeginIndex];
173 result->writeText(
" sub ");
175 info.fColors[rangeBeginIndex],
info.fColors[rangeEndIndex],
result);
178 size_t loCount = rangeEnds.
size() / 2;
188 result->writeText(
"0} if\n");
192 result->writeText(
"} ifelse\n");
254 result->writeText(
"dup 0 le {pop ");
260 result->writeText(
" 0} if\n");
264 size_t rangeEndsCount = 0;
265 for (
int i = 1;
i <
info.fColorCount; ++
i) {
271 bool constantColorBothSides =
272 eqIgnoringAlpha(
info.fColors[
i-1],
info.fColors[
i]) &&
273 i !=
info.fColorCount-1 &&
274 eqIgnoringAlpha(
info.fColors[
i],
info.fColors[
i+1]);
277 bool degenerateRange =
info.fColorOffsets[
i-1] ==
info.fColorOffsets[
i];
279 if (!degenerateRange && !constantColorBothSides) {
280 rangeEnds[rangeEndsCount] =
i;
289 result->writeText(
"0 gt {");
295 result->writeText(
"} if\n");
303 c0->appendColorComponent(color1[0]);
304 c0->appendColorComponent(color1[1]);
305 c0->appendColorComponent(color1[2]);
306 retval->insertObject(
"C0", std::move(c0));
309 c1->appendColorComponent(color2[0]);
310 c1->appendColorComponent(color2[1]);
311 c1->appendColorComponent(color2[2]);
312 retval->insertObject(
"C1", std::move(c1));
316 retval->insertInt(
"FunctionType", 2);
317 retval->insertScalar(
"N", 1.0f);
326 int colorCount =
info.fColorCount;
327 std::vector<SkColor>
colors(
info.fColors,
info.fColors + colorCount);
328 std::vector<SkScalar> colorOffsets(
info.fColorOffsets,
info.fColorOffsets + colorCount);
331 while (
i < colorCount - 1) {
333 if (colorOffsets[
i - 1] > colorOffsets[
i]) {
334 colorOffsets[
i] = colorOffsets[
i - 1];
338 if ((colorOffsets[
i - 1] == colorOffsets[
i]) && (colorOffsets[
i] == colorOffsets[
i + 1])) {
341 colorOffsets.erase(colorOffsets.begin() +
i);
347 for (
i = 1;
i < colorCount - 1;
i++) {
348 if (colorOffsets[
i - 1] == colorOffsets[
i]) {
349 colorOffsets[
i] += 0.00001f;
353 if (colorOffsets[
i - 1] == colorOffsets[
i]) {
354 colorOffsets[
i - 1] -= 0.00001f;
359 for (
int idx = 0; idx < colorCount; idx++) {
374 retval->insertInt(
"FunctionType", 3);
376 for (
int idx = 1; idx < colorCount; idx++) {
378 bounds->appendScalar(colorOffsets[idx-1]);
382 encode->appendScalar(1.0f);
387 retval->insertObject(
"Encode", std::move(
encode));
388 retval->insertObject(
"Bounds", std::move(
bounds));
389 retval->insertObject(
"Functions", std::move(functions));
397 result->writeText(
"dup truncate sub\n");
398 result->writeText(
"dup 0 le {1 add} if\n");
419 "{1 exch sub} if\n");
451 code->writeText(
" dup ");
453 code->writeText(
" mul "
456 code->writeText(
" mul ");
458 code->writeText(
" add "
532 function->writeText(
" add -2 mul dup dup mul\n");
535 function->writeText(
"4 2 roll dup mul exch dup mul add ");
537 function->writeText(
" sub dup 4 1 roll\n");
545 function->writeText(
"pop pop div neg dup ");
554 function->writeText(
"0 lt {pop false} {true} ifelse\n");
563 function->writeText(
" mul sub dup\n");
570 function->writeText(
"sqrt exch dup 0 lt {exch -1 mul} if");
571 function->writeText(
" add -0.5 mul dup\n");
578 function->writeText(
"3 1 roll div\n");
581 function->writeText(
"2 copy gt {exch} if\n");
591 function->writeText(
" 0 gt {exch pop true}\n");
601 function->writeText(
"0 le {pop false} {true} ifelse\n");
605 function->writeText(
"} {pop pop pop false} ifelse\n");
616 function->writeText(
"} {0 0 0} ifelse }");
623 function->writeText(
"{exch atan 360 div\n");
635 SkScalar subtractRadii = fabs(r1 - r2);
636 if (fabs(
distance - subtractRadii) < 0.002f) {
672 perspectiveInverse->
setAll(one, zero, zero,
674 -p0/p2, -p1/p2, 1/p2);
676 affine->
setAll(sx - p0 * tx / p2, kx - p1 * tx / p2, tx / p2,
677 ky - p0 * ty / p2, sy - p1 * ty / p2, ty / p2,
684 std::unique_ptr<SkPDFArray> domain,
685 std::unique_ptr<SkPDFObject> range,
688 dict->insertInt(
"FunctionType", 4);
689 dict->insertObject(
"Domain", std::move(domain));
690 dict->insertObject(
"Range", std::move(range));
702 state.fType == SkShaderBase::GradientType::kRadial ||
703 state.fType == SkShaderBase::GradientType::kConical) &&
708 enum class ShadingType : int32_t {
712 FreeFormGouraudTriangleMesh = 4,
713 LatticeFormGouraudTriangleMesh = 5,
715 TensorProductPatchMesh = 7,
719 if (doStitchFunctions) {
725 extend->appendBool(
true);
726 extend->appendBool(
true);
727 pdfShader->insertObject(
"Extend", std::move(extend));
730 std::unique_ptr<SkPDFArray> coords;
731 switch (
state.fType) {
733 shadingType = ShadingType::Axial;
739 case SkShaderBase::GradientType::kRadial: {
740 shadingType = ShadingType::Radial;
743 pt1.
x(), pt1.
y(),
info.fRadius[0]);
745 case SkShaderBase::GradientType::kConical: {
746 shadingType = ShadingType::Radial;
754 pt2.
x(), pt2.
y(), r2);
757 case SkShaderBase::GradientType::kSweep:
763 pdfShader->insertObject(
"Coords", std::move(coords));
765 shadingType = ShadingType::Function;
768 transformPoints[0] =
info.fPoint[0];
769 transformPoints[1] =
info.fPoint[1];
770 switch (
state.fType) {
773 case SkShaderBase::GradientType::kRadial:
774 transformPoints[1] = transformPoints[0];
775 transformPoints[1].
fX +=
info.fRadius[0];
777 case SkShaderBase::GradientType::kConical: {
778 transformPoints[1] = transformPoints[0];
782 case SkShaderBase::GradientType::kSweep:
783 transformPoints[1] = transformPoints[0];
808 &finalMatrix, &perspectiveInverseOnly)) {
820 switch (
state.fType) {
824 case SkShaderBase::GradientType::kRadial:
827 case SkShaderBase::GradientType::kConical: {
833 if (!mapperMatrix.
invert(&inverseMapperMatrix)) {
841 case SkShaderBase::GradientType::kSweep:
847 pdfShader->insertObject(
851 std::unique_ptr<SkPDFArray> rangeObject =
SkPDFMakeArray(0, 1, 0, 1, 0, 1);
852 pdfShader->insertRef(
"Function",
854 std::move(rangeObject), doc));
857 pdfShader->insertInt(
"ShadingType",
SkToS32(shadingType));
858 pdfShader->insertName(
"ColorSpace",
"DeviceRGB");
861 pdfFunctionShader.
insertInt(
"PatternType", 2);
863 pdfFunctionShader.
insertObject(
"Shading", std::move(pdfShader));
864 return doc->
emit(pdfFunctionShader);
873 std::vector<SkPDFIndirectReference> patternShaders;
875 patternShaders.push_back(functionShader);
877 std::vector<SkPDFIndirectReference> graphicStates;
879 graphicStates.push_back(gState);
882 std::move(patternShaders),
883 std::vector<SkPDFIndirectReference>(),
884 std::vector<SkPDFIndirectReference>());
900 return content.detachAsStream();
905 for (
int i = 0;
i <
key.fInfo.fColorCount;
i++) {
940 luminosityState.
fHash =
hash(luminosityState);
951 std::move(resources),
979 std::unique_ptr<SkStreamAsset> colorStream =
981 std::unique_ptr<SkPDFDict> alphaFunctionShader =
SkPDFMakeDict();
984 return SkPDFStreamOut(std::move(alphaFunctionShader), std::move(colorStream), doc);
992 {0,
nullptr,
nullptr, {{0, 0}, {0, 0}}, {0, 0},
SkTileMode::kClamp, 0},
1003 key.fInfo.fColors =
key.fColors.get();
1004 key.fInfo.fColorOffsets =
key.fStops.get();
1024 gradientPatternMap.set(std::move(
key), pdfShader);
static SkM44 inv(const SkM44 &m)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SkColorGetR(color)
#define SkColorGetG(color)
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
constexpr SkAlpha SK_AlphaOPAQUE
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkColorGetA(color)
#define SkColorGetB(color)
static void encode(uint8_t output[16], const uint32_t input[4])
static std::unique_ptr< SkPDFDict > get_gradient_resource_dict(SkPDFIndirectReference functionShader, SkPDFIndirectReference gState)
static SkPDFGradientShader::Key clone_key(const SkPDFGradientShader::Key &k)
static SkPDFIndirectReference make_function_shader(SkPDFDocument *doc, const SkPDFGradientShader::Key &state)
static void gradient_function_code(const SkShaderBase::GradientInfo &info, SkDynamicMemoryWStream *result)
static void radialCode(const SkShaderBase::GradientInfo &info, const SkMatrix &perspectiveRemover, SkDynamicMemoryWStream *function)
static void tileModeCode(SkTileMode mode, SkDynamicMemoryWStream *result)
static std::unique_ptr< SkPDFDict > createInterpolationFunction(const ColorTuple &color1, const ColorTuple &color2)
static std::unique_ptr< SkPDFDict > gradientStitchCode(const SkShaderBase::GradientInfo &info)
static void write_gradient_ranges(const SkShaderBase::GradientInfo &info, SkSpan< size_t > rangeEnds, bool top, bool first, SkDynamicMemoryWStream *result)
static void sweepCode(const SkShaderBase::GradientInfo &info, const SkMatrix &perspectiveRemover, SkDynamicMemoryWStream *function)
static SkPDFIndirectReference make_alpha_function_shader(SkPDFDocument *doc, const SkPDFGradientShader::Key &state)
static void linearCode(const SkShaderBase::GradientInfo &info, const SkMatrix &perspectiveRemover, SkDynamicMemoryWStream *function)
static SkPDFIndirectReference create_smask_graphic_state(SkPDFDocument *doc, const SkPDFGradientShader::Key &state)
static void interpolate_color_code(SkScalar range, SkColor beginColor, SkColor endColor, SkDynamicMemoryWStream *result)
static SkPDFIndirectReference find_pdf_shader(SkPDFDocument *doc, SkPDFGradientShader::Key key, bool keyHasAlpha)
static bool split_perspective(const SkMatrix in, SkMatrix *affine, SkMatrix *perspectiveInverse)
static bool gradient_has_alpha(const SkPDFGradientShader::Key &key)
static const int kColorComponents
static void apply_perspective_to_coordinates(const SkMatrix &inversePerspectiveMatrix, SkDynamicMemoryWStream *code)
static uint32_t hash(const SkShaderBase::GradientInfo &v)
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)
uint8_t ColorTuple[kColorComponents]
static void unit_to_points_matrix(const SkPoint pts[2], SkMatrix *matrix)
static std::unique_ptr< SkStreamAsset > create_pattern_fill_content(int gsIndex, int patternIndex, SkRect &bounds)
static void FixUpRadius(const SkPoint &p1, SkScalar &r1, const SkPoint &p2, SkScalar &r2)
static SkPDFGradientShader::Key make_key(const SkShader *shader, const SkMatrix &canvasTransform, const SkIRect &bbox)
std::unique_ptr< SkPDFDict > SkPDFMakeResourceDict(const std::vector< SkPDFIndirectReference > &graphicStateResources, const std::vector< SkPDFIndirectReference > &shaderResources, const std::vector< SkPDFIndirectReference > &xObjectResources, const std::vector< SkPDFIndirectReference > &fontResources)
SkPDFIndirectReference SkPDFStreamOut(std::unique_ptr< SkPDFDict > dict, std::unique_ptr< SkStreamAsset > content, SkPDFDocument *doc, SkPDFSteamCompressionEnabled compress)
static std::unique_ptr< SkPDFDict > SkPDFMakeDict(const char *type=nullptr)
static std::unique_ptr< SkPDFArray > SkPDFMakeArray(Args... args)
#define SkScalarInvert(x)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
SkShaderBase * as_SB(SkShader *shader)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
constexpr int32_t SkToS32(S x)
std::unique_ptr< SkStreamAsset > detachAsStream()
SkScalar mapRadius(SkScalar radius) const
static constexpr int kMScaleX
horizontal scale factor
static constexpr int kMTransY
vertical translation
static constexpr int kMPersp1
input y perspective factor
SkMatrix & setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar persp0, SkScalar persp1, SkScalar persp2)
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
bool invert(SkMatrix *inverse) const
static const SkMatrix & I()
SkMatrix & preConcat(const SkMatrix &other)
static constexpr int kMPersp0
input x perspective factor
static constexpr int kMPersp2
perspective bias
static constexpr int kMTransX
horizontal translation
bool hasPerspective() const
static constexpr int kMSkewY
vertical skew factor
static constexpr int kMScaleY
vertical scale factor
static constexpr int kMSkewX
horizontal skew factor
void insertObject(const char key[], std::unique_ptr< SkPDFObject > &&)
void insertInt(const char key[], int32_t value)
SkPDFIndirectReference emit(const SkPDFObject &, SkPDFIndirectReference)
skia_private::THashMap< SkPDFGradientShader::Key, SkPDFIndirectReference, SkPDFGradientShader::KeyHash > fGradientPatternMap
@ kFill_Style
set to fill geometry
virtual GradientType asGradient(GradientInfo *info=nullptr, SkMatrix *localMatrix=nullptr) const
constexpr SkSpan< T > subspan(size_t offset) const
constexpr bool empty() const
constexpr size_t size() const
Dart_NativeFunction function
union flutter::testing::@2836::KeyboardChange::@76 content
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
static constexpr skcms_TransferFunction kLinear
SkPDFIndirectReference Make(SkPDFDocument *doc, SkShader *shader, const SkMatrix &matrix, const SkIRect &surfaceBBox)
SkPDFIndirectReference GetSMaskGraphicState(SkPDFIndirectReference sMask, bool invert, SkPDFSMaskMode sMaskMode, SkPDFDocument *doc)
void ApplyGraphicState(int objectIndex, SkWStream *content)
void PopulateTilingPatternDict(SkPDFDict *pattern, SkRect &bbox, std::unique_ptr< SkPDFDict > resources, const SkMatrix &matrix)
void AppendColorComponent(uint8_t value, SkWStream *wStream)
std::unique_ptr< SkPDFArray > MatrixToArray(const SkMatrix &matrix)
void AppendRectangle(const SkRect &rect, SkWStream *content)
void PaintPath(SkPaint::Style style, SkPathFillType fill, SkWStream *content)
void AppendScalar(SkScalar value, SkWStream *stream)
SkMatrix GetShaderLocalMatrix(const SkShader *shader)
void ApplyPattern(int objectIndex, SkWStream *content)
bool InverseTransformBBox(const SkMatrix &matrix, SkRect *bbox)
std::unique_ptr< SkPDFArray > RectToArray(const SkRect &rect)
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
PODArray< SkColor > colors
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
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 mode
SkShaderBase::GradientType fType
std::unique_ptr< SkScalar[]> fStops
SkMatrix fShaderTransform
std::unique_ptr< SkColor[]> fColors
SkShaderBase::GradientInfo fInfo
SkMatrix fCanvasTransform
static float Distance(const SkPoint &a, const SkPoint &b)
void scale(float scale, SkPoint *dst) const
constexpr float y() const
constexpr float x() const
static SkRect Make(const SkISize &size)
constexpr float left() const
constexpr float top() const
constexpr float right() const
void set(const SkIRect &src)
constexpr float bottom() const
uint32_t fGradientFlags
see SkGradientShader::Flags
SkPoint fPoint[2]
Type specific, see above.
SkColor * fColors
The colors in the gradient.
int fColorCount
In-out parameter, specifies passed size.
SkScalar fRadius[2]
Type specific, see above.
SkScalar * fColorOffsets
The unit offset for color transitions.