This commit is contained in:
Anton Lavrenov
2019-10-07 14:22:52 -05:00
parent cfd40b2083
commit 201a292a89
11 changed files with 21 additions and 157 deletions

View File

@@ -384,73 +384,6 @@ suite('Layer', function() {
assert.equal(layer.shouldDrawHit(), true);
});
// ======================================================
// skip, because we don't use this caching. It is slow.
test.skip('hit graph caching', function() {
var stage = addStage();
var layer = new Konva.Layer();
var originGetImageData = layer.getHitCanvas().getContext().getImageData;
var count = 0;
layer.getHitCanvas().getContext().getImageData = function() {
count += 1;
return originGetImageData.apply(this, arguments);
};
stage.add(layer);
var circle = new Konva.Circle({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2,
radius: 70,
fill: 'red',
stroke: 'black',
strokeWidth: 4
});
layer.add(circle);
layer.draw();
assert.equal(count, 0, 'draw should not touch getImageData');
var top = stage.content.getBoundingClientRect().top;
stage._mousemove({
clientX: stage.getWidth() / 2,
clientY: stage.getHeight() / 2 + top
});
// while mouse event we need hit canvas info
assert.equal(count, 1, 'getImageData should be called once');
stage._mousemove({
clientX: stage.getWidth() / 2,
clientY: stage.getHeight() / 2 + top + 2
});
assert.equal(
count,
1,
'getImageData should not be called, because data is cached'
);
var group = new Konva.Group();
group.cache({
width: 1,
height: 1
});
layer.add(group);
group.draw();
stage._mousemove({
clientX: stage.getWidth() / 2,
clientY: stage.getHeight() / 2 + top + 2
});
// after drawing group hit cache should be cleared
assert.equal(
count,
2,
'while creating new cache getImageData should be called'
);
});
test('get/set layer size', function() {
var stage = addStage();
var layer = new Konva.Layer();