Lines Matching +full:- +full:r

2  * Copyright (c) 2020 - 2024 the ThorVG project. All rights reserved.
60 shape->bounds(&x, &y, &w, &h, false); in _boundingBox()
62 if (auto strokeW = shape->strokeWidth()) { in _boundingBox()
65 w -= strokeW; in _boundingBox()
66 h -= strokeW; in _boundingBox()
76 text->bounds(&x, &y, &w, &h, false); in _boundingBox()
83 gradTransf->e13 = gradTransf->e13 * mBBox->e11 + mBBox->e13; in _transformMultiply()
84 gradTransf->e12 *= mBBox->e11; in _transformMultiply()
85 gradTransf->e11 *= mBBox->e11; in _transformMultiply()
87 gradTransf->e23 = gradTransf->e23 * mBBox->e22 + mBBox->e23; in _transformMultiply()
88 gradTransf->e22 *= mBBox->e22; in _transformMultiply()
89 gradTransf->e21 *= mBBox->e22; in _transformMultiply()
99 bool isTransform = (g->transform ? true : false); in _applyLinearGradientProperty()
101 if (isTransform) finalTransform = *g->transform; in _applyLinearGradientProperty()
103 if (g->userSpace) { in _applyLinearGradientProperty()
104 g->linear->x1 = g->linear->x1 * vBox.w; in _applyLinearGradientProperty()
105 g->linear->y1 = g->linear->y1 * vBox.h; in _applyLinearGradientProperty()
106 g->linear->x2 = g->linear->x2 * vBox.w; in _applyLinearGradientProperty()
107 g->linear->y2 = g->linear->y2 * vBox.h; in _applyLinearGradientProperty()
117 if (isTransform) fillGrad->transform(finalTransform); in _applyLinearGradientProperty()
119 fillGrad->linear(g->linear->x1, g->linear->y1, g->linear->x2, g->linear->y2); in _applyLinearGradientProperty()
120 fillGrad->spread(g->spread); in _applyLinearGradientProperty()
123 stopCount = g->stops.count; in _applyLinearGradientProperty()
128 for (uint32_t i = 0; i < g->stops.count; ++i) { in _applyLinearGradientProperty()
129 auto colorStop = &g->stops[i]; in _applyLinearGradientProperty()
131 stops[i].r = colorStop->r; in _applyLinearGradientProperty()
132 stops[i].g = colorStop->g; in _applyLinearGradientProperty()
133 stops[i].b = colorStop->b; in _applyLinearGradientProperty()
134 stops[i].a = static_cast<uint8_t>((colorStop->a * opacity) / 255); in _applyLinearGradientProperty()
135 stops[i].offset = colorStop->offset; in _applyLinearGradientProperty()
136 … //check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes in _applyLinearGradientProperty()
137 if (colorStop->offset < prevOffset) stops[i].offset = prevOffset; in _applyLinearGradientProperty()
138 else if (colorStop->offset > 1) stops[i].offset = 1; in _applyLinearGradientProperty()
141 fillGrad->colorStops(stops, stopCount); in _applyLinearGradientProperty()
154 bool isTransform = (g->transform ? true : false); in _applyRadialGradientProperty()
156 if (isTransform) finalTransform = *g->transform; in _applyRadialGradientProperty()
158 if (g->userSpace) { in _applyRadialGradientProperty()
160 //https://www.w3.org/TR/2015/WD-SVG2-20150915/coords.html in _applyRadialGradientProperty()
161 g->radial->cx = g->radial->cx * vBox.w; in _applyRadialGradientProperty()
162 g->radial->cy = g->radial->cy * vBox.h; in _applyRadialGradientProperty()
163 g->radial->r = g->radial->r * sqrtf(powf(vBox.w, 2.0f) + powf(vBox.h, 2.0f)) / sqrtf(2.0f); in _applyRadialGradientProperty()
164 g->radial->fx = g->radial->fx * vBox.w; in _applyRadialGradientProperty()
165 g->radial->fy = g->radial->fy * vBox.h; in _applyRadialGradientProperty()
166 … g->radial->fr = g->radial->fr * sqrtf(powf(vBox.w, 2.0f) + powf(vBox.h, 2.0f)) / sqrtf(2.0f); in _applyRadialGradientProperty()
176 if (isTransform) fillGrad->transform(finalTransform); in _applyRadialGradientProperty()
178 …P(fillGrad)->radial(g->radial->cx, g->radial->cy, g->radial->r, g->radial->fx, g->radial->fy, g->r… in _applyRadialGradientProperty()
179 fillGrad->spread(g->spread); in _applyRadialGradientProperty()
182 stopCount = g->stops.count; in _applyRadialGradientProperty()
187 for (uint32_t i = 0; i < g->stops.count; ++i) { in _applyRadialGradientProperty()
188 auto colorStop = &g->stops[i]; in _applyRadialGradientProperty()
190 stops[i].r = colorStop->r; in _applyRadialGradientProperty()
191 stops[i].g = colorStop->g; in _applyRadialGradientProperty()
192 stops[i].b = colorStop->b; in _applyRadialGradientProperty()
193 stops[i].a = static_cast<uint8_t>((colorStop->a * opacity) / 255); in _applyRadialGradientProperty()
194 stops[i].offset = colorStop->offset; in _applyRadialGradientProperty()
195 … //check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes in _applyRadialGradientProperty()
196 if (colorStop->offset < prevOffset) stops[i].offset = prevOffset; in _applyRadialGradientProperty()
197 else if (colorStop->offset > 1) stops[i].offset = 1; in _applyRadialGradientProperty()
200 fillGrad->colorStops(stops, stopCount); in _applyRadialGradientProperty()
210 if (node->child.count != 1) return false; in _appendClipUseNode()
211 auto child = *(node->child.data); in _appendClipUseNode()
214 if (node->transform) finalTransform = *node->transform; in _appendClipUseNode()
215 if (node->node.use.x != 0.0f || node->node.use.y != 0.0f) { in _appendClipUseNode()
216 Matrix m = {1, 0, node->node.use.x, 0, 1, node->node.use.y, 0, 0, 1}; in _appendClipUseNode()
219 if (child->transform) finalTransform = *child->transform * finalTransform; in _appendClipUseNode()
227 if (node->type == SvgNodeType::Use) { in _appendClipChild()
238 if (node->transform && type != SvgNodeType::Mask) { in _compositionTransform()
239 m = *node->transform; in _compositionTransform()
241 if (compNode->transform) { in _compositionTransform()
242 m *= *compNode->transform; in _compositionTransform()
244 if (!compNode->node.clip.userSpace) { in _compositionTransform()
246 P(paint)->bounds(&x, &y, &w, &h, false, false); in _compositionTransform()
259 if (node->style->clipPath.applying) { in _applyComposition()
262 auto compNode = node->style->clipPath.node; in _applyComposition()
263 if (compNode && compNode->child.count > 0) { in _applyComposition()
264 node->style->clipPath.applying = true; in _applyComposition()
268 auto child = compNode->child.data; in _applyComposition()
271 for (uint32_t i = 0; i < compNode->child.count; ++i, ++child) { in _applyComposition()
272 …if (_appendClipChild(loaderData, *child, comp.get(), vBox, svgPath, compNode->child.count > 1)) va… in _applyComposition()
277 comp->transform(finalTransform); in _applyComposition()
278 paint->clip(std::move(comp)); in _applyComposition()
281 node->style->clipPath.applying = false; in _applyComposition()
288 if (node->style->mask.applying) { in _applyComposition()
291 auto compNode = node->style->mask.node; in _applyComposition()
292 if (compNode && compNode->child.count > 0) { in _applyComposition()
293 node->style->mask.applying = true; in _applyComposition()
297 if (!compNode->node.mask.userSpace) { in _applyComposition()
299 comp->transform(finalTransform); in _applyComposition()
301 if (node->transform) comp->transform(*node->transform); in _applyComposition()
304 if (compNode->node.mask.type == SvgMaskType::Luminance && !isMaskWhite) { in _applyComposition()
305 paint->composite(std::move(comp), CompositeMethod::LumaMask); in _applyComposition()
307 paint->composite(std::move(comp), CompositeMethod::AlphaMask); in _applyComposition()
311 node->style->mask.applying = false; in _applyComposition()
319 SvgStyleProperty* style = node->style; in _applyProperty()
322 if (node->transform && !clip) vg->transform(*node->transform); in _applyProperty()
323 if (node->type == SvgNodeType::Doc || !node->style->display) return; in _applyProperty()
326 if (style->fill.paint.none) { in _applyProperty()
328 } else if (style->fill.paint.gradient) { in _applyProperty()
330 if (!style->fill.paint.gradient->userSpace) bBox = _boundingBox(vg); in _applyProperty()
332 if (style->fill.paint.gradient->type == SvgGradientType::Linear) { in _applyProperty()
333 … auto linear = _applyLinearGradientProperty(style->fill.paint.gradient, bBox, style->fill.opacity); in _applyProperty()
334 vg->fill(std::move(linear)); in _applyProperty()
335 } else if (style->fill.paint.gradient->type == SvgGradientType::Radial) { in _applyProperty()
336 … auto radial = _applyRadialGradientProperty(style->fill.paint.gradient, bBox, style->fill.opacity); in _applyProperty()
337 vg->fill(std::move(radial)); in _applyProperty()
339 } else if (style->fill.paint.url) { in _applyProperty()
342 } else if (style->fill.paint.curColor) { in _applyProperty()
344 vg->fill(style->color.r, style->color.g, style->color.b, style->fill.opacity); in _applyProperty()
347 …vg->fill(style->fill.paint.color.r, style->fill.paint.color.g, style->fill.paint.color.b, style->f… in _applyProperty()
351 vg->fill((tvg::FillRule)style->fill.fillRule); in _applyProperty()
353 vg->order(!style->paintOrder); in _applyProperty()
356 if (style->opacity < 255) vg->opacity(style->opacity); in _applyProperty()
358 if (node->type == SvgNodeType::G || node->type == SvgNodeType::Use) return; in _applyProperty()
361 vg->stroke(style->stroke.width); in _applyProperty()
362 vg->stroke(style->stroke.cap); in _applyProperty()
363 vg->stroke(style->stroke.join); in _applyProperty()
364 vg->strokeMiterlimit(style->stroke.miterlimit); in _applyProperty()
365 if (style->stroke.dash.array.count > 0) { in _applyProperty()
366 …P(vg)->strokeDash(style->stroke.dash.array.data, style->stroke.dash.array.count, style->stroke.das… in _applyProperty()
370 if (style->stroke.paint.none) { in _applyProperty()
371 vg->stroke(0.0f); in _applyProperty()
372 } else if (style->stroke.paint.gradient) { in _applyProperty()
374 if (!style->stroke.paint.gradient->userSpace) bBox = _boundingBox(vg); in _applyProperty()
376 if (style->stroke.paint.gradient->type == SvgGradientType::Linear) { in _applyProperty()
377 …auto linear = _applyLinearGradientProperty(style->stroke.paint.gradient, bBox, style->stroke.opaci… in _applyProperty()
378 vg->stroke(std::move(linear)); in _applyProperty()
379 } else if (style->stroke.paint.gradient->type == SvgGradientType::Radial) { in _applyProperty()
380 …auto radial = _applyRadialGradientProperty(style->stroke.paint.gradient, bBox, style->stroke.opaci… in _applyProperty()
381 vg->stroke(std::move(radial)); in _applyProperty()
383 } else if (style->stroke.paint.url) { in _applyProperty()
386 } else if (style->stroke.paint.curColor) { in _applyProperty()
388 vg->stroke(style->color.r, style->color.g, style->color.b, style->stroke.opacity); in _applyProperty()
391 …vg->stroke(style->stroke.paint.color.r, style->stroke.paint.color.g, style->stroke.paint.color.b, … in _applyProperty()
408 switch (node->type) { in _recognizeShape()
410 if (node->node.path.path) { in _recognizeShape()
411 if (!svgPathToShape(node->node.path.path, shape)) { in _recognizeShape()
419 …shape->appendCircle(node->node.ellipse.cx, node->node.ellipse.cy, node->node.ellipse.rx, node->nod… in _recognizeShape()
423 if (node->node.polygon.pts.count < 2) break; in _recognizeShape()
424 auto pts = node->node.polygon.pts.begin(); in _recognizeShape()
425 shape->moveTo(pts[0], pts[1]); in _recognizeShape()
426 for (pts += 2; pts < node->node.polygon.pts.end(); pts += 2) { in _recognizeShape()
427 shape->lineTo(pts[0], pts[1]); in _recognizeShape()
429 shape->close(); in _recognizeShape()
433 if (node->node.polyline.pts.count < 2) break; in _recognizeShape()
434 auto pts = node->node.polyline.pts.begin(); in _recognizeShape()
435 shape->moveTo(pts[0], pts[1]); in _recognizeShape()
436 for (pts += 2; pts < node->node.polyline.pts.end(); pts += 2) { in _recognizeShape()
437 shape->lineTo(pts[0], pts[1]); in _recognizeShape()
442 …shape->appendCircle(node->node.circle.cx, node->node.circle.cy, node->node.circle.r, node->node.ci… in _recognizeShape()
446 …shape->appendRect(node->node.rect.x, node->node.rect.y, node->node.rect.w, node->node.rect.h, node in _recognizeShape()
450 shape->moveTo(node->node.line.x1, node->node.line.y1); in _recognizeShape()
451 shape->lineTo(node->node.line.x2, node->node.line.y2); in _recognizeShape()
473 …//The 'transform' matrix has higher priority than the node->transform, since it already contains it in _appendClipShape()
474 auto m = transform ? transform : (node->transform ? node->transform : nullptr); in _appendClipShape()
479 currentPtsCnt = shape->pathCoords(&tmp); in _appendClipShape()
486 auto ptsCnt = shape->pathCoords(&pts); in _appendClipShape()
529 if (strncmp(*href, "image/", sizeof("image/") - 1)) return false; //not allowed mime type in _isValidImageMimeTypeAndEncoding()
530 *href += sizeof("image/") - 1; in _isValidImageMimeTypeAndEncoding()
536 if (!strncmp(*href, imageMimeTypes[i].name, imageMimeTypes[i].sz - 1)) { in _isValidImageMimeTypeAndEncoding()
537 *href += imageMimeTypes[i].sz - 1; in _isValidImageMimeTypeAndEncoding()
546 if (!strncmp(*href, "base64,", sizeof("base64,") - 1)) { in _isValidImageMimeTypeAndEncoding()
547 *href += sizeof("base64,") - 1; in _isValidImageMimeTypeAndEncoding()
553 if (!strncmp(*href, "utf8,", sizeof("utf8,") - 1)) { in _isValidImageMimeTypeAndEncoding()
554 *href += sizeof("utf8,") - 1; in _isValidImageMimeTypeAndEncoding()
576 if (!node->node.image.href || !strlen(node->node.image.href)) return nullptr; in _imageBuildHelper()
581 const char* href = node->node.image.href; in _imageBuildHelper()
582 if (!strncmp(href, "data:", sizeof("data:") - 1)) { in _imageBuildHelper()
583 href += sizeof("data:") - 1; in _imageBuildHelper()
590 if (picture->load(decoded, size, mimetype, false) != Result::Success) { in _imageBuildHelper()
597 if (picture->load(decoded, size, mimetype, false) != Result::Success) { in _imageBuildHelper()
605 if (!strncmp(href, "file://", sizeof("file://") - 1)) href += sizeof("file://") - 1; in _imageBuildHelper()
619 if (picture->load(imagePath) != Result::Success) { in _imageBuildHelper()
629 if (picture->size(&w, &h) == Result::Success && w > 0 && h > 0) { in _imageBuildHelper()
630 auto sx = node->node.image.w / w; in _imageBuildHelper()
631 auto sy = node->node.image.h / h; in _imageBuildHelper()
632 m = {sx, 0, node->node.image.x, 0, sy, node->node.image.y, 0, 0, 1}; in _imageBuildHelper()
634 if (node->transform) m = *node->transform * m; in _imageBuildHelper()
635 picture->transform(m); in _imageBuildHelper()
651 return {sx, 0, -tvx, 0, sy, -tvy, 0, 0, 1}; in _calculateAspectRatioMatrix()
673 tvx -= (width - tvw) * 0.5f; in _calculateAspectRatioMatrix()
677 tvx -= width - tvw; in _calculateAspectRatioMatrix()
681 tvy -= (height - tvh) * 0.5f; in _calculateAspectRatioMatrix()
685 tvx -= (width - tvw) * 0.5f; in _calculateAspectRatioMatrix()
686 tvy -= (height - tvh) * 0.5f; in _calculateAspectRatioMatrix()
690 tvx -= width - tvw; in _calculateAspectRatioMatrix()
691 tvy -= (height - tvh) * 0.5f; in _calculateAspectRatioMatrix()
695 tvy -= height - tvh; in _calculateAspectRatioMatrix()
699 tvx -= (width - tvw) * 0.5f; in _calculateAspectRatioMatrix()
700 tvy -= height - tvh; in _calculateAspectRatioMatrix()
704 tvx -= width - tvw; in _calculateAspectRatioMatrix()
705 tvy -= height - tvh; in _calculateAspectRatioMatrix()
713 return {sx, 0, -tvx, 0, sy, -tvy, 0, 0, 1}; in _calculateAspectRatioMatrix()
723 if (node->transform) mUseTransform = *node->transform; in _useBuildHelper()
724 if (node->node.use.x != 0.0f || node->node.use.y != 0.0f) { in _useBuildHelper()
725 Matrix mTranslate = {1, 0, node->node.use.x, 0, 1, node->node.use.y, 0, 0, 1}; in _useBuildHelper()
729 if (node->node.use.symbol) { in _useBuildHelper()
730 auto symbol = node->node.use.symbol->node.symbol; in _useBuildHelper()
733 if (node->node.use.isWidthSet) width = node->node.use.w; in _useBuildHelper()
735 if (node->node.use.isHeightSet) height = node->node.use.h; in _useBuildHelper()
744 mViewBox = {1, 0, -symbol.vx, 0, 1, -symbol.vy, 0, 0, 1}; in _useBuildHelper()
749 if (node->node.use.symbol->transform) { in _useBuildHelper()
750 mSceneTransform = *node->node.use.symbol->transform * mViewBox; in _useBuildHelper()
753 scene->transform(mSceneTransform); in _useBuildHelper()
755 if (!node->node.use.symbol->node.symbol.overflowVisible) { in _useBuildHelper()
757 viewBoxClip->appendRect(0, 0, width, height, 0, 0); in _useBuildHelper()
761 if (node->node.use.symbol->transform) { in _useBuildHelper()
762 mClipTransform = mUseTransform * *node->node.use.symbol->transform; in _useBuildHelper()
764 viewBoxClip->transform(mClipTransform); in _useBuildHelper()
766 scene->clip(std::move(viewBoxClip)); in _useBuildHelper()
769 scene->transform(mUseTransform); in _useBuildHelper()
779 if (style->fill.paint.none) { in _applyTextFill()
781 } else if (style->fill.paint.gradient) { in _applyTextFill()
783 if (!style->fill.paint.gradient->userSpace) bBox = _boundingBox(text); in _applyTextFill()
785 if (style->fill.paint.gradient->type == SvgGradientType::Linear) { in _applyTextFill()
786 … auto linear = _applyLinearGradientProperty(style->fill.paint.gradient, bBox, style->fill.opacity); in _applyTextFill()
787 text->fill(std::move(linear)); in _applyTextFill()
788 } else if (style->fill.paint.gradient->type == SvgGradientType::Radial) { in _applyTextFill()
789 … auto radial = _applyRadialGradientProperty(style->fill.paint.gradient, bBox, style->fill.opacity); in _applyTextFill()
790 text->fill(std::move(radial)); in _applyTextFill()
792 } else if (style->fill.paint.url) { in _applyTextFill()
795 } else if (style->fill.paint.curColor) { in _applyTextFill()
797 text->fill(style->color.r, style->color.g, style->color.b); in _applyTextFill()
798 text->opacity(style->fill.opacity); in _applyTextFill()
801 text->fill(style->fill.paint.color.r, style->fill.paint.color.g, style->fill.paint.color.b); in _applyTextFill()
802 text->opacity(style->fill.opacity); in _applyTextFill()
809 auto textNode = &node->node.text; in _textBuildHelper()
810 if (!textNode->text) return nullptr; in _textBuildHelper()
814 if (node->transform) textTransform = *node->transform; in _textBuildHelper()
815 translateR(&textTransform, node->node.text.x, node->node.text.y - textNode->fontSize); in _textBuildHelper()
816 text->transform(textTransform); in _textBuildHelper()
819 const float ptPerPx = 0.75f; //1 pt = 1/72; 1 in = 96 px; -> 72/96 = 0.75 in _textBuildHelper()
820 auto fontSizePt = textNode->fontSize * ptPerPx; in _textBuildHelper()
821 if (textNode->fontFamily) text->font(textNode->fontFamily, fontSizePt); in _textBuildHelper()
822 text->text(textNode->text); in _textBuildHelper()
824 _applyTextFill(node->style, text.get(), vBox); in _textBuildHelper()
836 …TVGERR("SVG", "Infinite recursive call - stopped after %d calls! Svg file may be incorrectly forma… in _sceneBuildHelper()
840 if (_isGroupType(node->type) || mask) { in _sceneBuildHelper()
842 … // For a Symbol node, the viewBox transformation has to be applied first - see _useBuildHelper() in _sceneBuildHelper()
843 …if (!mask && node->transform && node->type != SvgNodeType::Symbol) scene->transform(*node->transfo… in _sceneBuildHelper()
845 if (node->style->display && node->style->opacity != 0) { in _sceneBuildHelper()
846 auto child = node->child.data; in _sceneBuildHelper()
847 for (uint32_t i = 0; i < node->child.count; ++i, ++child) { in _sceneBuildHelper()
848 if (_isGroupType((*child)->type)) { in _sceneBuildHelper()
849 if ((*child)->type == SvgNodeType::Use) in _sceneBuildHelper()
850 … scene->push(_useBuildHelper(loaderData, *child, vBox, svgPath, depth + 1, isMaskWhite)); in _sceneBuildHelper()
851 … else if (!((*child)->type == SvgNodeType::Symbol && node->type != SvgNodeType::Use)) in _sceneBuildHelper()
852 … scene->push(_sceneBuildHelper(loaderData, *child, vBox, svgPath, false, depth + 1, isMaskWhite)); in _sceneBuildHelper()
853 } else if ((*child)->type == SvgNodeType::Image) { in _sceneBuildHelper()
856 scene->push(std::move(image)); in _sceneBuildHelper()
859 } else if ((*child)->type == SvgNodeType::Text) { in _sceneBuildHelper()
861 if (text) scene->push(std::move(text)); in _sceneBuildHelper()
862 } else if ((*child)->type != SvgNodeType::Mask) { in _sceneBuildHelper()
866 uint8_t r, g, b; in _sceneBuildHelper() local
867 shape->fillColor(&r, &g, &b); in _sceneBuildHelper()
868 … if (shape->fill() || r < 255 || g < 255 || b < 255 || shape->strokeFill() || in _sceneBuildHelper()
869 … (shape->strokeColor(&r, &g, &b) == Result::Success && (r < 255 || g < 255 || b < 255))) { in _sceneBuildHelper()
873 scene->push(std::move(shape)); in _sceneBuildHelper()
878 scene->opacity(node->style->opacity); in _sceneBuildHelper()
892 scene->bounds(&x, &y, &vBox.w, &vBox.h, false); in _updateInvalidViewSize()
914 if (!loaderData.doc || (loaderData.doc->type != SvgNodeType::Doc)) return nullptr; in svgSceneBuild()
922 docNode->transform(m); in svgSceneBuild()
924 docNode->translate(-vBox.x, -vBox.y); in svgSceneBuild()
928 viewBoxClip->appendRect(0, 0, w, h); in svgSceneBuild()
931 compositeLayer->clip(std::move(viewBoxClip)); in svgSceneBuild()
932 compositeLayer->push(std::move(docNode)); in svgSceneBuild()
935 root->push(std::move(compositeLayer)); in svgSceneBuild()
937 loaderData.doc->node.doc.vx = vBox.x; in svgSceneBuild()
938 loaderData.doc->node.doc.vy = vBox.y; in svgSceneBuild()
939 loaderData.doc->node.doc.vw = vBox.w; in svgSceneBuild()
940 loaderData.doc->node.doc.vh = vBox.h; in svgSceneBuild()
941 loaderData.doc->node.doc.w = w; in svgSceneBuild()
942 loaderData.doc->node.doc.h = h; in svgSceneBuild()