mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -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);
|
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
|
* 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)
|
* bitmaps to scratch 3 bitmaps. (Scratch 3 bitmaps are all bitmap resolution 2)
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
const StringUtil = require('../util/string-util');
|
const StringUtil = require('../util/string-util');
|
||||||
const log = require('../util/log');
|
const log = require('../util/log');
|
||||||
|
const {loadSvgString, serializeSvgToString} = require('scratch-svg-renderer');
|
||||||
|
|
||||||
const loadVector_ = function (costume, runtime, rotationCenter, optVersion) {
|
const loadVector_ = function (costume, runtime, rotationCenter, optVersion) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let svgString = costume.asset.decodeText();
|
let svgString = costume.asset.decodeText();
|
||||||
// SVG Renderer load fixes "quirks" associated with Scratch 2 projects
|
// scratch-svg-renderer fixes syntax that causes loading issues,
|
||||||
if (optVersion && optVersion === 2 && !runtime.v2SvgAdapter) {
|
// and if optVersion is 2, fixes "quirks" associated with Scratch 2 SVGs,
|
||||||
log.error('No V2 SVG adapter present; SVGs may not render correctly.');
|
const svgText = serializeSvgToString(loadSvgString(svgString, optVersion === 2/* fromVersion2 */));
|
||||||
} else if (optVersion && optVersion === 2 && runtime.v2SvgAdapter) {
|
|
||||||
runtime.v2SvgAdapter.loadString(svgString, true /* fromVersion2 */);
|
// If the string changed, put back into storage
|
||||||
svgString = runtime.v2SvgAdapter.toString();
|
if (svgString !== svgText) {
|
||||||
// Put back into storage
|
|
||||||
const storage = runtime.storage;
|
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.assetId = costume.asset.assetId;
|
||||||
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
|
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// createSVGSkin does the right thing if rotationCenter isn't provided, so it's okay if it's
|
// createSVGSkin does the right thing if rotationCenter isn't provided, so it's okay if it's
|
||||||
// undefined here
|
// undefined here
|
||||||
costume.skinId = runtime.renderer.createSVGSkin(svgString, rotationCenter);
|
costume.skinId = runtime.renderer.createSVGSkin(svgString, rotationCenter);
|
||||||
|
|
|
@ -1087,14 +1087,6 @@ class VirtualMachine extends EventEmitter {
|
||||||
return this.runtime && this.runtime.renderer;
|
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
|
* 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)
|
* bitmaps to scratch 3 bitmaps. (Scratch 3 bitmaps are all bitmap resolution 2)
|
||||||
|
|
Loading…
Reference in a new issue