Skip to content

Commit

Permalink
m91-1a01201b77 Resize SVGs without ViewBox (11144)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Jun 4, 2021
1 parent 5e4c4cc commit bf2313d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
default: 'false'

env:
version: m91-b99622c05a-2
version: m91-1a01201b77

jobs:
macos:
Expand Down
20 changes: 18 additions & 2 deletions patches/11144_SkSVGDOM.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
diff --git a/modules/svg/src/SkSVGDOM.cpp b/modules/svg/src/SkSVGDOM.cpp
index 5f16e3ee43..2ec63ec8ca 100644
index 7915654963..509c52548d 100644
--- a/modules/svg/src/SkSVGDOM.cpp
+++ b/modules/svg/src/SkSVGDOM.cpp
@@ -473,6 +473,10 @@ const SkSize& SkSVGDOM::containerSize() const {
@@ -426,6 +426,15 @@ SkSVGDOM::SkSVGDOM(sk_sp<SkSVGSVG> root, sk_sp<SkFontMgr> fmgr,
, fContainerSize(fRoot->intrinsicSize(SkSVGLengthContext(SkSize::Make(0, 0))))
{
SkASSERT(fResourceProvider);
+ if (!fRoot->getViewBox().isValid()
+ && fRoot->getWidth().unit() != SkSVGLength::Unit::kPercentage
+ && fRoot->getHeight().unit() != SkSVGLength::Unit::kPercentage)
+ {
+ SkSVGLengthContext lctx(SkSize::Make(0, 0));
+ SkScalar width = lctx.resolve(fRoot->getWidth(), SkSVGLengthContext::LengthType::kHorizontal);
+ SkScalar height = lctx.resolve(fRoot->getHeight(), SkSVGLengthContext::LengthType::kVertical);
+ fRoot->setViewBox(SkRect::MakeWH(width, height));
+ }
}

void SkSVGDOM::render(SkCanvas* canvas) const {
@@ -444,6 +453,10 @@ const SkSize& SkSVGDOM::containerSize() const {
void SkSVGDOM::setContainerSize(const SkSize& containerSize) {
// TODO: inval
fContainerSize = containerSize;
Expand Down

0 comments on commit bf2313d

Please sign in to comment.