Add SVG export for BlendImageFilter, PerlinNoise, ColorFilterShader, Luma and AlphaThreshold.#1488
Add SVG export for BlendImageFilter, PerlinNoise, ColorFilterShader, Luma and AlphaThreshold.#1488zfw1234567 wants to merge 67 commits into
Conversation
| float blurrinessY, Color color, | ||
| bool innerShadowOnly) = 0; | ||
|
|
||
| /** |
There was a problem hiding this comment.
新增的回调接口,是需要支持实际的业务支吗?没有的话先不需要加上去,并且风格应该和之前的一样,用纯虚函数。
这个也是为了支持识别filter,如果filter顺序实在不好识别,就额外写一个字段来表示filter。并且额外的字段是业务山使用的时候自己实现的
| svgFragment += " y1='" + FloatToString(info.points[0].y) + "'"; | ||
| svgFragment += " x2='" + FloatToString(info.points[1].x) + "'"; | ||
| svgFragment += " y2='" + FloatToString(info.points[1].y) + "'>"; | ||
| } else { |
There was a problem hiding this comment.
渐变分支只判断 Linear,其余类型一律走 else 当作 radialGradient 输出,存在静默错误:
- Conic:
ConicGradientShader::asGradient写入info.radiuses[0] = -bias*360(角度值),这里却当成 radial 的r使用 → 几何完全错误。 - Diamond:
asGradient写入的是菱形边长,同样被误用为半径。 - None:
info未被填充,输出垃圾值。
且整个过程没有任何告警。建议显式区分 Radial 分支,对 Conic/Diamond/None 调用 reportUnsupportedElement,与既有 addGradientShaderResources 的处理模式保持一致。
| Base64Encode(svgData, svgLength, base64String.data()); | ||
| { | ||
| ElementWriter feImageElement("feImage", writer); | ||
| feImageElement.addAttribute("href", "data:image/svg+xml;base64," + base64String); |
There was a problem hiding this comment.
此处 feImage 使用裸 href,而本文件其余所有出处(如 838、1003、1475、1488 行)以及本项目自身的 SVG 解析器 SVGFeImage.cpp(仅识别 xlink:href)都使用 xlink:href。结果导出的 SVG 无法被 tgfx 自身的导入器回读,破坏往返兼容性。建议统一改为 xlink:href(或同时输出两者以兼容更广的渲染器)。
| return; | ||
| } | ||
| const auto imageShader = static_cast<const ImageShader*>(filter->shader.get()); | ||
| auto data = SVGExportContext::ImageToEncodedData(imageShader->image); |
There was a problem hiding this comment.
这段 image→dataUri 的编码逻辑(ImageToEncodedData → IsJpeg/IsPng → 否则 ImageExportToBitmap → AsDataUri)与 975 行附近的 Image shader 分支几乎完全重复,第三处 1434 行也类似。建议抽取一个 helper(如 EncodeImageToDataUri(image, context))消除重复,降低后续维护成本。
…atching addBlendImageFilter.
…rawImage and drawLayer.
…h callbackColorImageFilter.
…itives matching addBlendImageFilter." This reverts commit 51680c4.
…has tile stitching enabled.
…ign with GPU sRGB pipeline.
…dow, and BlendImageFilterClipToSource.
… BlendImageFilter, ColorFilter shader, PerlinNoise shader, Luma and AlphaThreshold color filters.
… into a single filter element.
…dow detection logic.
…rlinNoise emission with consistent seed type.
…esting logic in drawImage and drawLayer.
…stency with other filter primitives.
…r true and false.
be41e74 to
7ec3823
Compare
…upled container API.
…te duplicate tag list.
…n in compose path.
补全 SVG 导出中此前不支持的 Filter 和 Shader 类型,并重构 filter 生成架构以支持 shader filter 和 colorFilter 的组合场景。
新增 SVG 导出支持:
ImageFilter::Blend 配合不同 shader 类型:
ImageFilter::Compose:
Paint Shader:
ColorFilter:
架构改进:
Bug 修复:
测试: