Skip to content

Commit

Permalink
Merge pull request #2329 from adroitwhiz/remove-updatedrawableproperties
Browse files Browse the repository at this point in the history
Remove remaining updateDrawableProperties calls
  • Loading branch information
fsih authored Sep 24, 2020
2 parents 9329f93 + 267395b commit 7eabcb8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
36 changes: 16 additions & 20 deletions src/blocks/scratch3_looks.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,21 @@ class Scratch3LooksBlocks {
bubbleState.onSpriteRight = true;
this._renderBubble(target);
} else {
this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, {
position: [
bubbleState.onSpriteRight ? (
Math.max(
stageBounds.left, // Bubble should not extend past left edge of stage
Math.min(stageBounds.right - bubbleWidth, targetBounds.right)
)
) : (
Math.min(
stageBounds.right - bubbleWidth, // Bubble should not extend past right edge of stage
Math.max(stageBounds.left, targetBounds.left - bubbleWidth)
)
),
// Bubble should not extend past the top of the stage
Math.min(stageBounds.top, targetBounds.bottom + bubbleHeight)
]
});
this.runtime.renderer.updateDrawablePosition(bubbleState.drawableId, [
bubbleState.onSpriteRight ? (
Math.max(
stageBounds.left, // Bubble should not extend past left edge of stage
Math.min(stageBounds.right - bubbleWidth, targetBounds.right)
)
) : (
Math.min(
stageBounds.right - bubbleWidth, // Bubble should not extend past right edge of stage
Math.max(stageBounds.left, targetBounds.left - bubbleWidth)
)
),
// Bubble should not extend past the top of the stage
Math.min(stageBounds.top, targetBounds.bottom + bubbleHeight)
]);
this.runtime.requestRedraw();
}
}
Expand Down Expand Up @@ -235,9 +233,7 @@ class Scratch3LooksBlocks {
target.addListener(RenderedTarget.EVENT_TARGET_VISUAL_CHANGE, this._onTargetChanged);
bubbleState.drawableId = this.runtime.renderer.createDrawable(StageLayering.SPRITE_LAYER);
bubbleState.skinId = this.runtime.renderer.createTextSkin(type, text, bubbleState.onSpriteRight, [0, 0]);
this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, {
skinId: bubbleState.skinId
});
this.runtime.renderer.updateDrawableSkinId(bubbleState.drawableId, bubbleState.skinId);
}

this._positionBubble(target);
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/scratch3_pen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Scratch3PenBlocks {
if (this._penSkinId < 0 && this.runtime.renderer) {
this._penSkinId = this.runtime.renderer.createPenSkin();
this._penDrawableId = this.runtime.renderer.createDrawable(StageLayering.PEN_LAYER);
this.runtime.renderer.updateDrawableProperties(this._penDrawableId, {skinId: this._penSkinId});
this.runtime.renderer.updateDrawableSkinId(this._penDrawableId, this._penSkinId);
}
return this._penSkinId;
}
Expand Down
20 changes: 9 additions & 11 deletions src/io/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,18 @@ class Video {
this._ghost = ghost;
// Confirm that the default value has been changed to a valid id for the drawable
if (this._drawable !== -1) {
this.runtime.renderer.updateDrawableProperties(this._drawable, {
ghost: this._forceTransparentPreview ? 100 : ghost
});
this.runtime.renderer.updateDrawableEffect(
this._drawable,
'ghost',
this._forceTransparentPreview ? 100 : ghost
);
}
}

_disablePreview () {
if (this._skinId !== -1) {
this.runtime.renderer.updateBitmapSkin(this._skinId, new ImageData(...Video.DIMENSIONS), 1);
this.runtime.renderer.updateDrawableProperties(this._drawable, {visible: false});
this.runtime.renderer.updateDrawableVisible(this._drawable, false);
}
this._renderPreviewFrame = null;
}
Expand All @@ -149,17 +151,13 @@ class Video {
if (this._skinId === -1 && this._drawable === -1) {
this._skinId = renderer.createBitmapSkin(new ImageData(...Video.DIMENSIONS), 1);
this._drawable = renderer.createDrawable(StageLayering.VIDEO_LAYER);
renderer.updateDrawableProperties(this._drawable, {
skinId: this._skinId
});
renderer.updateDrawableSkinId(this._drawable, this._skinId);
}

// if we haven't already created and started a preview frame render loop, do so
if (!this._renderPreviewFrame) {
renderer.updateDrawableProperties(this._drawable, {
ghost: this._forceTransparentPreview ? 100 : this._ghost,
visible: true
});
renderer.updateDrawableEffect(this._drawable, 'ghost', this._forceTransparentPreview ? 100 : this._ghost);
renderer.updateDrawableVisible(this._drawable, true);

this._renderPreviewFrame = () => {
clearTimeout(this._renderPreviewTimeout);
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/fake-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ FakeRenderer.prototype.updateDrawableVisible = function (d, visible) { // eslint
FakeRenderer.prototype.updateDrawableEffect = function (d, effectName, value) { // eslint-disable-line no-unused-vars
};

FakeRenderer.prototype.updateDrawableProperties = function (d, p) { // eslint-disable-line no-unused-vars
throw new Error('updateDrawableProperties is deprecated');
};

FakeRenderer.prototype.getCurrentSkinSize = function (d) { // eslint-disable-line no-unused-vars
return [0, 0];
};
Expand Down

0 comments on commit 7eabcb8

Please sign in to comment.