Fix layer copy

This commit is contained in:
luboslenco
2020-03-19 17:32:30 +01:00
parent cc73048ab2
commit 59321fc574
5 changed files with 44 additions and 2 deletions
+20 -2
View File
@@ -173,8 +173,12 @@ class LayerSlot {
texpaint_mask.g2.begin();
if (createMaskImage != null) texpaint_mask.g2.drawScaledImage(createMaskImage, 0, 0, texpaint_mask.width, texpaint_mask.height);
else texpaint_mask.g2.clear(createMaskColor);
if (createMaskImage != null) {
texpaint_mask.g2.drawScaledImage(createMaskImage, 0, 0, texpaint_mask.width, texpaint_mask.height);
}
else {
texpaint_mask.g2.clear(createMaskColor);
}
texpaint_mask.g2.end();
g.begin();
@@ -249,7 +253,9 @@ class LayerSlot {
l.texpaint_pack.g2.end();
l.texpaint_preview.g2.begin(true, 0x00000000);
l.texpaint_preview.g2.pipeline = Layers.pipeCopy;
l.texpaint_preview.g2.drawScaledImage(texpaint_preview, 0, 0, texpaint_preview.width, texpaint_preview.height);
l.texpaint_preview.g2.pipeline = null;
l.texpaint_preview.g2.end();
if (texpaint_mask != null) {
@@ -261,7 +267,9 @@ class LayerSlot {
l.texpaint_mask.g2.end();
l.texpaint_mask_preview.g2.begin(true, 0x00000000);
l.texpaint_mask_preview.g2.pipeline = Layers.pipeCopy;
l.texpaint_mask_preview.g2.drawScaledImage(texpaint_mask_preview, 0, 0, texpaint_mask_preview.width, texpaint_mask_preview.height);
l.texpaint_mask_preview.g2.pipeline = null;
l.texpaint_mask_preview.g2.end();
}
@@ -299,16 +307,24 @@ class LayerSlot {
this.texpaint_nor = Image.createRenderTarget(res, res, format);
this.texpaint_pack = Image.createRenderTarget(res, res, format);
if (Layers.pipeMerge == null) Layers.makePipe();
this.texpaint.g2.begin(false);
this.texpaint.g2.pipeline = Layers.pipeCopy;
this.texpaint.g2.drawScaledImage(texpaint, 0, 0, res, res);
this.texpaint.g2.pipeline = null;
this.texpaint.g2.end();
this.texpaint_nor.g2.begin(false);
this.texpaint_nor.g2.pipeline = Layers.pipeCopy;
this.texpaint_nor.g2.drawScaledImage(texpaint_nor, 0, 0, res, res);
this.texpaint_nor.g2.pipeline = null;
this.texpaint_nor.g2.end();
this.texpaint_pack.g2.begin(false);
this.texpaint_pack.g2.pipeline = Layers.pipeCopy;
this.texpaint_pack.g2.drawScaledImage(texpaint_pack, 0, 0, res, res);
this.texpaint_pack.g2.pipeline = null;
this.texpaint_pack.g2.end();
iron.App.notifyOnInit(function() { // Out of command list execution
@@ -326,7 +342,9 @@ class LayerSlot {
this.texpaint_mask = Image.createRenderTarget(res, res, TextureFormat.L8);
this.texpaint_mask.g2.begin(false);
this.texpaint_mask.g2.pipeline = Layers.pipeCopy;
this.texpaint_mask.g2.drawScaledImage(texpaint_mask, 0, 0, res, res);
this.texpaint_mask.g2.pipeline = null;
this.texpaint_mask.g2.end();
iron.App.notifyOnInit(function() { // Out of command list execution
+10
View File
@@ -206,20 +206,28 @@ class ImportArm {
Project.layers.push(l);
if (!isGroup) {
if (Layers.pipeMerge == null) Layers.makePipe();
// TODO: create render target from bytes
var texpaint = Image.fromBytes(Lz4.decode(ld.texpaint, ld.res * ld.res * 4 * bytesPerPixel), ld.res, ld.res, format);
l.texpaint.g2.begin(false);
l.texpaint.g2.pipeline = Layers.pipeCopy;
l.texpaint.g2.drawImage(texpaint, 0, 0);
l.texpaint.g2.pipeline = null;
l.texpaint.g2.end();
var texpaint_nor = Image.fromBytes(Lz4.decode(ld.texpaint_nor, ld.res * ld.res * 4 * bytesPerPixel), ld.res, ld.res, format);
l.texpaint_nor.g2.begin(false);
l.texpaint_nor.g2.pipeline = Layers.pipeCopy;
l.texpaint_nor.g2.drawImage(texpaint_nor, 0, 0);
l.texpaint_nor.g2.pipeline = null;
l.texpaint_nor.g2.end();
var texpaint_pack = Image.fromBytes(Lz4.decode(ld.texpaint_pack, ld.res * ld.res * 4 * bytesPerPixel), ld.res, ld.res, format);
l.texpaint_pack.g2.begin(false);
l.texpaint_pack.g2.pipeline = Layers.pipeCopy;
l.texpaint_pack.g2.drawImage(texpaint_pack, 0, 0);
l.texpaint_pack.g2.pipeline = null;
l.texpaint_pack.g2.end();
var texpaint_mask: kha.Image = null;
@@ -227,7 +235,9 @@ class ImportArm {
l.createMask(0, false);
texpaint_mask = Image.fromBytes(Lz4.decode(ld.texpaint_mask, ld.res * ld.res), ld.res, ld.res, TextureFormat.L8);
l.texpaint_mask.g2.begin(false);
l.texpaint_mask.g2.pipeline = Layers.pipeCopy;
l.texpaint_mask.g2.drawImage(texpaint_mask, 0, 0);
l.texpaint_mask.g2.pipeline = null;
l.texpaint_mask.g2.end();
}
+3
View File
@@ -87,8 +87,11 @@ class TabTextures {
UIFiles.show("png", true, function(path: String) {
var target = kha.Image.createRenderTarget(img.width, img.height);
function exportTexture(g: kha.graphics4.Graphics) {
if (Layers.pipeMerge == null) Layers.makePipe();
target.g2.begin(false);
target.g2.pipeline = Layers.pipeCopy;
target.g2.drawImage(img, 0, 0);
target.g2.pipeline = null;
target.g2.end();
var f = UIFiles.filename;
if (f == "") f = tr("untitled");
+8
View File
@@ -777,6 +777,7 @@ class UISidebar {
if (Context.layersPreviewDirty) {
Context.layersPreviewDirty = false;
Context.layerPreviewDirty = false;
if (Layers.pipeMerge == null) Layers.makePipe();
// Update all layer previews
for (l in Project.layers) {
if (l.getChildren() != null) continue;
@@ -784,14 +785,18 @@ class UISidebar {
var source = l.texpaint;
var g2 = target.g2;
g2.begin(true, 0xff000000);
g2.pipeline = Layers.pipeCopy;
g2.drawScaledImage(source, 0, 0, target.width, target.height);
g2.pipeline = null;
g2.end();
if (l.texpaint_mask != null) {
var target = l.texpaint_mask_preview;
var source = l.texpaint_mask;
var g2 = target.g2;
g2.begin(true, 0x00000000);
g2.pipeline = Layers.pipeCopy;
g2.drawScaledImage(source, 0, 0, target.width, target.height);
g2.pipeline = null;
g2.end();
}
}
@@ -799,13 +804,16 @@ class UISidebar {
}
if (Context.layerPreviewDirty && Context.layer.getChildren() == null) {
Context.layerPreviewDirty = false;
if (Layers.pipeMerge == null) Layers.makePipe();
// Update layer preview
var l = Context.layer;
var target = Context.layerIsMask ? l.texpaint_mask_preview : l.texpaint_preview;
var source = Context.layerIsMask ? l.texpaint_mask : l.texpaint;
var g2 = target.g2;
g2.begin(true, 0x00000000);
g2.pipeline = Layers.pipeCopy;
g2.drawScaledImage(source, 0, 0, target.width, target.height);
g2.pipeline = null;
g2.end();
hwnd.redraws = 2;
}
+3
View File
@@ -345,10 +345,13 @@ class RenderUtil {
RenderPathPaint.useLiveLayer(false);
// Scale layer down to to image preview
if (Layers.pipeMerge == null) Layers.makePipe();
var l = RenderPathPaint.liveLayer;
var target = Context.brush.image;
target.g2.begin(true, 0x00000000);
target.g2.pipeline = Layers.pipeCopy;
target.g2.drawScaledImage(l.texpaint, 0, 0, target.width, target.height);
target.g2.pipeline = null;
target.g2.end();
// Scale image preview down to to icon