This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Update canvaskit backend #12318
Merged
harryterkelsen
merged 6 commits into
flutter:master
from
harryterkelsen:update-canvaskit-backend
Sep 17, 2019
Merged
Update canvaskit backend #12318
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
977a30e
Improve the CanvasKit backend for Flutter Web
harryterkelsen bf09631
Merge branch 'master' into update-canvaskit-backend
harryterkelsen fa62ed0
Add license header to vertices.dart
harryterkelsen 992b679
Remove unused 'encodedPositions'
harryterkelsen 510e382
Delete commented old code. Don't use Skia by default
harryterkelsen ea5cf41
Add `vertices.dart` to licenses file
harryterkelsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,13 +73,35 @@ class SkiaFontCollection { | |
|
|
||
| js.JsObject getFont(String family, double size) { | ||
| if (_registeredTypefaces[family] == null) { | ||
| if (family == 'sans-serif') { | ||
| // If it's the default font, return a default SkFont | ||
| return js.JsObject(canvasKit['SkFont'], <dynamic>[null, size]); | ||
| if (assertionsEnabled) { | ||
| html.window.console.warn('Using unregistered font: $family'); | ||
| } | ||
| throw Exception('Unregistered font: $family'); | ||
| return js.JsObject(canvasKit['SkFont'], <dynamic>[null, size]); | ||
| } | ||
| final js.JsObject skTypeface = _registeredTypefaces[family].values.first; | ||
| //final js.JsObject skTypeface = _registeredTypefaces[family].values.first; | ||
| // We don't attempt to find a Typeface matching the text style. Instead, we | ||
| // try to find the "default" typeface. The default typeface either has no | ||
| // descriptors, or only has a descriptor of font-weight 400 (the default). | ||
| final Map<Map<String, String>, js.JsObject> typefaces = | ||
| _registeredTypefaces[family]; | ||
| js.JsObject skTypeface; | ||
|
|
||
| for (MapEntry<Map<String, String>, js.JsObject> entry | ||
| in typefaces.entries) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| final Map<String, String> descriptors = entry.key; | ||
| if (descriptors.isEmpty || | ||
| (descriptors.length == 1 && descriptors['weight'] == '400')) { | ||
| skTypeface = entry.value; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| // If we couldn't find a suitable default, just use any typeface in the | ||
| // family. | ||
| if (skTypeface == null) { | ||
| skTypeface = typefaces.values.first; | ||
| } | ||
|
|
||
| return js.JsObject(canvasKit['SkFont'], <dynamic>[skTypeface, size]); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ part of engine; | |
|
|
||
| /// EXPERIMENTAL: Enable the Skia-based rendering backend. | ||
| const bool experimentalUseSkia = | ||
| bool.fromEnvironment('FLUTTER_WEB_USE_SKIA', defaultValue: false); | ||
| bool.fromEnvironment('FLUTTER_WEB_USE_SKIA', defaultValue: true); | ||
|
||
|
|
||
| /// The URL to use when downloading the CanvasKit script and associated wasm. | ||
| const String canvasKitBaseUrl = 'https://unpkg.com/[email protected]/bin/'; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops