KisLayerSP KisCloneLayer::reincarnateAsPaintLayer() const { KisPaintDeviceSP newOriginal = new KisPaintDevice(*original()); KisPaintLayerSP newLayer = new KisPaintLayer(image(), name(), opacity(), newOriginal); newLayer->setX(newLayer->x() + x()); newLayer->setY(newLayer->y() + y()); newLayer->setCompositeOp(compositeOpId()); newLayer->mergeNodeProperties(nodeProperties()); return newLayer; }
void KisTransparencyMaskTest::testMoveParentLayer() { KisImageSP image; KisPaintLayerSP layer; KisPaintDeviceSP dev; KisTransparencyMaskSP mask; initImage(image, layer, dev, mask); mask->initSelection(layer); mask->selection()->pixelSelection()->invert(); mask->select(QRect(50, 50, 100, 100)); KisFullRefreshWalker walker(image->bounds()); KisAsyncMerger merger; walker.collectRects(layer, image->bounds()); merger.startMerge(walker); // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_before.png"); QRect initialRect(0,0,200,100); QCOMPARE(layer->exactBounds(), initialRect); QCOMPARE(image->projection()->exactBounds(), QRect(50,50,100,50)); layer->setX(100); layer->setY(100); dbgKrita << "Sel. rect before:" << mask->selection()->selectedExactRect(); mask->setX(100); mask->setY(100); dbgKrita << "Sel. rect after:" << mask->selection()->selectedExactRect(); QRect finalRect(100,100,200,100); QCOMPARE(layer->exactBounds(), finalRect); walker.collectRects(layer, initialRect | finalRect); merger.startMerge(walker); // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_after.png"); QCOMPARE(image->projection()->exactBounds(), QRect(150,150,100,50)); }