diff --git a/src/drawdance/libengine/dpengine/draw_context.c b/src/drawdance/libengine/dpengine/draw_context.c index 3c59ce6d89..30e918152d 100644 --- a/src/drawdance/libengine/dpengine/draw_context.c +++ b/src/drawdance/libengine/dpengine/draw_context.c @@ -69,12 +69,14 @@ DP_DrawContext *DP_draw_context_new(void) DP_DrawContext *dc = DP_malloc_simd(sizeof(*dc)); dc->pool_size = 0; dc->pool = NULL; + DP_warn("Allocate draw context %p", (void *)dc); return dc; } void DP_draw_context_free(DP_DrawContext *dc) { if (dc) { + DP_warn("Free draw context %p", (void *)dc); DP_free(dc->pool); DP_free_simd(dc); } @@ -203,8 +205,12 @@ unsigned char *DP_draw_context_raster_pool_resize(DP_DrawContext *dc, { DP_ASSERT(dc); DP_ASSERT(new_size > dc->pool_size); - DP_ASSERT(new_size < DP_DRAW_CONTEXT_RASTER_POOL_MAX_SIZE); + DP_ASSERT(new_size <= DP_DRAW_CONTEXT_RASTER_POOL_MAX_SIZE); DP_ASSERT(dc->pool); + DP_warn("Raster pool resize form %zu to %zu (min %zu/max %zu)", + dc->pool_size, new_size, + (size_t)DP_DRAW_CONTEXT_RASTER_POOL_MIN_SIZE, + (size_t)DP_DRAW_CONTEXT_RASTER_POOL_MAX_SIZE); DP_free(dc->pool); void *new_raster_pool = DP_malloc(new_size); dc->pool = new_raster_pool; diff --git a/src/drawdance/libengine/dpengine/paint_engine.c b/src/drawdance/libengine/dpengine/paint_engine.c index 8368d2c170..8089f92f42 100644 --- a/src/drawdance/libengine/dpengine/paint_engine.c +++ b/src/drawdance/libengine/dpengine/paint_engine.c @@ -2364,6 +2364,7 @@ void DP_paint_engine_preview_transform( DP_canvas_state_height(cs), offset_x, offset_y); } else { + DP_warn("Invalid transform preview dimensions %dx%d", width, height); dispose_pixels(user); DP_paint_engine_preview_clear(pe, DP_PREVIEW_TRANSFORM); } diff --git a/src/drawdance/libengine/dpengine/preview.c b/src/drawdance/libengine/dpengine/preview.c index 4dbf3f8acf..3304e75e5a 100644 --- a/src/drawdance/libengine/dpengine/preview.c +++ b/src/drawdance/libengine/dpengine/preview.c @@ -304,6 +304,7 @@ static bool preview_transform_prepare_image(DP_PreviewTransform *pvtf, pvtf->pixels.dispose = NULL; if (img) { + DP_warn("Transformed on layer %d", pvtf->target_layer_id); pvtf->img = img; return true; } diff --git a/src/libclient/canvas/canvasmodel.cpp b/src/libclient/canvas/canvasmodel.cpp index 0a4b1af770..ee28788c22 100644 --- a/src/libclient/canvas/canvasmodel.cpp +++ b/src/libclient/canvas/canvasmodel.cpp @@ -356,7 +356,9 @@ void CanvasModel::setSelection(Selection *selection) QImage CanvasModel::selectionToImage(int layerId) const { + qInfo("selectionToImage(%d)", layerId); if(m_selection && !m_selection->pasteImage().isNull()) { + qInfo("selectionToImage: paste image already exists"); return m_selection->transformedPasteImage(); } @@ -370,10 +372,13 @@ QImage CanvasModel::selectionToImage(int layerId) const return QImage{}; } + qInfo("selectionToImage: x%d y%d w%d h%d", rect.x(), rect.y(), rect.width(), rect.height()); QImage img; if(layerId == 0) { + qInfo("selectionToImage: with background to image"); img = canvasState.toFlatImage(true, true, &rect); } else if(layerId == -1) { + qInfo("selectionToImage: without background to image"); img = canvasState.toFlatImage(false, true, &rect); } else { drawdance::LayerContent layerContent = canvasState.searchLayerContent(layerId); @@ -383,10 +388,12 @@ QImage CanvasModel::selectionToImage(int layerId) const img.fill(0); return img; } + qInfo("selectionToImage: layer %d to image", layerId); img = layerContent.toImage(rect); } if(m_selection && !m_selection->isAxisAlignedRectangle()) { + qInfo("selectionToImage: mask outside pixels"); // Mask out pixels outside the selection QPainter mp(&img); mp.setCompositionMode(QPainter::CompositionMode_DestinationIn); diff --git a/src/libclient/drawdance/global.cpp b/src/libclient/drawdance/global.cpp index b6992935ab..3a478a71dd 100644 --- a/src/libclient/drawdance/global.cpp +++ b/src/libclient/drawdance/global.cpp @@ -131,7 +131,7 @@ DrawContext DrawContextPool::acquireContext() DP_DrawContext *dc; if(m_available.isEmpty()) { dc = DP_draw_context_new(); - m_contexts.append(dc); + // m_contexts.append(dc); } else { dc = m_available.pop(); } @@ -141,8 +141,9 @@ DrawContext DrawContextPool::acquireContext() void DrawContextPool::releaseContext(DP_DrawContext *dc) { Q_ASSERT(dc); - QMutexLocker locker{&m_mutex}; - m_available.push(dc); + // QMutexLocker locker{&m_mutex}; + // m_available.push(dc); + DP_draw_context_free(dc); } DrawContextPoolStatistics DrawContextPool::instanceStatistics() diff --git a/src/libclient/tools/selection.cpp b/src/libclient/tools/selection.cpp index 585bd05bf8..607bbabad0 100644 --- a/src/libclient/tools/selection.cpp +++ b/src/libclient/tools/selection.cpp @@ -162,9 +162,16 @@ void SelectionTool::startMove() // Copy layer content into move preview buffer. int layerId = m_owner.activeLayer(); - const QImage img = model->selectionToImage(layerId); - sel->setMoveImage(img, maskBounds, model->size(), layerId); + QImage img = model->selectionToImage(layerId); + if(img.isNull()) { + qWarning("startMove: selected image is null"); + return; + } else { + img = QImage{img.size(), QImage::Format_ARGB32_Premultiplied}; + img.fill(Qt::red); + } + sel->setMoveImage(img, maskBounds, model->size(), layerId); // The actual canvas pixels aren't touch yet, so we create a temporary sublayer // to erase the selected region. model->paintEngine()->previewCut(layerId, maskBounds, eraseMask); diff --git a/src/libclient/tools/toolcontroller.cpp b/src/libclient/tools/toolcontroller.cpp index 3de989dded..c23bbc0f30 100644 --- a/src/libclient/tools/toolcontroller.cpp +++ b/src/libclient/tools/toolcontroller.cpp @@ -236,17 +236,20 @@ void ToolController::onSelectionChange(canvas::Selection *sel) void ToolController::updateSelectionPreview() { if(!m_model) { + qInfo("updateSelectionPreview: no model set"); return; } canvas::PaintEngine *paintEngine = m_model->paintEngine(); canvas::Selection *sel = m_model->selection(); if(sel && sel->hasPasteImage()) { + qInfo("updateSelectionPreview: preview transform"); QPoint point = sel->shape().boundingRect().topLeft().toPoint(); paintEngine->previewTransform( m_activeLayer, point.x(), point.y(), sel->pasteImage(), sel->destinationQuad(), m_selectInterpolation); } else { + qInfo("updateSelectionPreview: clear preview transform"); paintEngine->clearTransformPreview(); } }