mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Remove v2SvgAdapter
This commit is contained in:
parent
e1f74678ad
commit
627e62a339
3 changed files with 9 additions and 24 deletions
|
@ -1557,14 +1557,6 @@ class Runtime extends EventEmitter {
|
|||
this.renderer.setLayerGroupOrdering(StageLayering.LAYER_GROUPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the svg adapter, which converts scratch 2 svgs to scratch 3 svgs
|
||||
* @param {!SvgRenderer} svgAdapter The adapter to attach
|
||||
*/
|
||||
attachV2SVGAdapter (svgAdapter) {
|
||||
this.v2SvgAdapter = svgAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bitmap adapter for the VM/runtime, which converts scratch 2
|
||||
* bitmaps to scratch 3 bitmaps. (Scratch 3 bitmaps are all bitmap resolution 2)
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
const StringUtil = require('../util/string-util');
|
||||
const log = require('../util/log');
|
||||
const {loadSvgString, serializeSvgToString} = require('scratch-svg-renderer');
|
||||
|
||||
const loadVector_ = function (costume, runtime, rotationCenter, optVersion) {
|
||||
return new Promise(resolve => {
|
||||
let svgString = costume.asset.decodeText();
|
||||
// SVG Renderer load fixes "quirks" associated with Scratch 2 projects
|
||||
if (optVersion && optVersion === 2 && !runtime.v2SvgAdapter) {
|
||||
log.error('No V2 SVG adapter present; SVGs may not render correctly.');
|
||||
} else if (optVersion && optVersion === 2 && runtime.v2SvgAdapter) {
|
||||
runtime.v2SvgAdapter.loadString(svgString, true /* fromVersion2 */);
|
||||
svgString = runtime.v2SvgAdapter.toString();
|
||||
// Put back into storage
|
||||
// scratch-svg-renderer fixes syntax that causes loading issues,
|
||||
// and if optVersion is 2, fixes "quirks" associated with Scratch 2 SVGs,
|
||||
const svgText = serializeSvgToString(loadSvgString(svgString, optVersion === 2/* fromVersion2 */));
|
||||
|
||||
// If the string changed, put back into storage
|
||||
if (svgString !== svgText) {
|
||||
const storage = runtime.storage;
|
||||
costume.asset.encodeTextData(svgString, storage.DataFormat.SVG, true);
|
||||
costume.asset.encodeTextData(svgText, storage.DataFormat.SVG, true);
|
||||
costume.assetId = costume.asset.assetId;
|
||||
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
|
||||
}
|
||||
|
||||
// createSVGSkin does the right thing if rotationCenter isn't provided, so it's okay if it's
|
||||
// undefined here
|
||||
costume.skinId = runtime.renderer.createSVGSkin(svgString, rotationCenter);
|
||||
|
|
|
@ -1087,14 +1087,6 @@ class VirtualMachine extends EventEmitter {
|
|||
return this.runtime && this.runtime.renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the svg adapter for the VM/runtime, which converts scratch 2 svgs to scratch 3 svgs
|
||||
* @param {!SvgRenderer} svgAdapter The adapter to attach
|
||||
*/
|
||||
attachV2SVGAdapter (svgAdapter) {
|
||||
this.runtime.attachV2SVGAdapter(svgAdapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bitmap adapter for the VM/runtime, which converts scratch 2
|
||||
* bitmaps to scratch 3 bitmaps. (Scratch 3 bitmaps are all bitmap resolution 2)
|
||||
|
|
Loading…
Reference in a new issue