Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove calls to updateDrawableSkinIdRotationCenter #2314

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/import/load-costume.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,17 @@ const loadBitmap_ = function (costume, runtime, _rotationCenter) {
return fetched;
})
.then(({canvas, mergeCanvas, rotationCenter}) => {
// createBitmapSkin does the right thing if costume.bitmapResolution or rotationCenter are undefined...
costume.skinId = runtime.renderer.createBitmapSkin(canvas, costume.bitmapResolution, rotationCenter);
// createBitmapSkin does the right thing if costume.bitmapResolution is undefined...
// TODO: is rotationCenter ever undefined?
adroitwhiz marked this conversation as resolved.
Show resolved Hide resolved
let center;
if (rotationCenter) {
center = [
rotationCenter[0] / 2,
rotationCenter[1] / 2
adroitwhiz marked this conversation as resolved.
Show resolved Hide resolved
];
}

costume.skinId = runtime.renderer.createBitmapSkin(canvas, costume.bitmapResolution, center);
canvasPool.release(mergeCanvas);
const renderSize = runtime.renderer.getSkinSize(costume.skinId);
costume.size = [renderSize[0] * 2, renderSize[1] * 2]; // Actual size, since all bitmaps are resolution 2
Expand Down
20 changes: 2 additions & 18 deletions src/sprites/rendered-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,19 +458,7 @@ class RenderedTarget extends Target {
);
if (this.renderer) {
const costume = this.getCostumes()[this.currentCostume];
if (
typeof costume.rotationCenterX !== 'undefined' &&
typeof costume.rotationCenterY !== 'undefined'
) {
const scale = costume.bitmapResolution || 2;
const rotationCenter = [
costume.rotationCenterX / scale,
costume.rotationCenterY / scale
];
this.renderer.updateDrawableSkinIdRotationCenter(this.drawableID, costume.skinId, rotationCenter);
} else {
this.renderer.updateDrawableSkinId(this.drawableID, costume.skinId);
}
this.renderer.updateDrawableSkinId(this.drawableID, costume.skinId);

if (this.visible) {
this.emit(RenderedTarget.EVENT_TARGET_VISUAL_CHANGE, this);
Expand Down Expand Up @@ -709,11 +697,7 @@ class RenderedTarget extends Target {
this.renderer.updateDrawableVisible(this.drawableID, this.visible);

const costume = this.getCostumes()[this.currentCostume];
const bitmapResolution = costume.bitmapResolution || 2;
this.renderer.updateDrawableSkinIdRotationCenter(this.drawableID, costume.skinId, [
costume.rotationCenterX / bitmapResolution,
costume.rotationCenterY / bitmapResolution
]);
this.renderer.updateDrawableSkinId(this.drawableID, costume.skinId);

for (const effectName in this.effects) {
if (!this.effects.hasOwnProperty(effectName)) continue;
Expand Down
3 changes: 0 additions & 3 deletions test/fixtures/fake-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ FakeRenderer.prototype.getFencedPositionOfDrawable = function (d, p) { // eslint
FakeRenderer.prototype.updateDrawableSkinId = function (d, skinId) { // eslint-disable-line no-unused-vars
};

FakeRenderer.prototype.updateDrawableSkinIdRotationCenter =
function (d, skinId, rotationCenter) {}; // eslint-disable-line no-unused-vars

FakeRenderer.prototype.updateDrawablePosition = function (d, position) { // eslint-disable-line no-unused-vars
this.x = position[0];
this.y = position[1];
Expand Down