Skip to content

Commit

Permalink
Merge pull request #23 from dipsywong98/fix/overlay-bug
Browse files Browse the repository at this point in the history
Fix/overlay bug and add tracing function back
  • Loading branch information
dipsywong98 authored Feb 28, 2019
2 parents b03fb39 + 975fe3c commit 0078e39
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
4 changes: 4 additions & 0 deletions ImpressionistDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ void ImpressionistDoc::swapContent()
m_ucPainting = m_ucBitmap;
m_ucBitmap = temp;
m_ucOriginal = temp;
memcpy(m_ucBackup, m_ucPainting, m_nWidth*m_nHeight * 3);
m_pUI->m_origView->refresh();
m_pUI->m_paintView->refresh();
}
Expand Down Expand Up @@ -254,6 +255,7 @@ int ImpressionistDoc::loadImageFromData(unsigned char* dataPtr, const int width,
}
delete[] m_ucPainting;
delete[] m_ucEdge;
delete[] m_ucBackup;
delete[] viewport.dataPtr;

m_ucBitmap = dataPtr;
Expand All @@ -265,9 +267,11 @@ int ImpressionistDoc::loadImageFromData(unsigned char* dataPtr, const int width,
m_ucPainting = new unsigned char[width*height * 3];
m_ucHistory = new unsigned char[width*height * 3];
m_ucEdge = new unsigned char[width*height * 3];
m_ucBackup = new unsigned char[width*height * 3];
memset(m_ucPainting, 0, width*height * 3);
memset(m_ucHistory, 0, width*height * 3);
memset(m_ucEdge, 0, width*height * 3);
memset(m_ucBackup, 0, width*height * 3);

m_pUI->m_mainWindow->resize(m_pUI->m_mainWindow->x(),
m_pUI->m_mainWindow->y(),
Expand Down
34 changes: 15 additions & 19 deletions PaintView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ void PaintView::updateViewport()
});

m_pPaintBitstart = m_pDoc->viewport.dataPtr + 3 * ((m_pDoc->m_nPaintWidth * startrow) + scrollpos.x);

RestoreContent();
m_pPaintBitstart = m_pDoc->m_ucPainting +
3 * ((m_pDoc->m_nPaintWidth * startrow) + scrollpos.x);
}

void PaintView::updatePainting()
Expand Down Expand Up @@ -117,10 +118,10 @@ void PaintView::draw()
drawWidth = min( m_nWindowWidth, m_pDoc->m_nPaintWidth );
drawHeight = min( m_nWindowHeight, m_pDoc->m_nPaintHeight );

// if (uc_backup)
// {
// memcpy(m_pDoc->m_ucPainting, uc_backup, drawWidth*drawHeight * 3);
// }
if (m_pDoc->m_ucBackup)
{
memcpy(m_pDoc->m_ucPainting, m_pDoc->m_ucBackup, drawWidth*drawHeight * 3);
}

startrow = m_pDoc->m_nPaintHeight - (scrollpos.y + drawHeight);
if ( startrow < 0 ) startrow = 0;
Expand All @@ -139,7 +140,7 @@ void PaintView::draw()
if ( m_pDoc->m_ucPainting && !isAnEvent)
{
RestoreContent();
// updateViewport();
updateViewport();
}

bool willSave = false;
Expand Down Expand Up @@ -202,15 +203,6 @@ void PaintView::draw()
painterly();
willPainterly = false;
willSave = true;
} else
{
// for debugging purpose
// Point source(coord.x + m_nStartCol, m_nEndRow - coord.y);
// Point target(coord.x, m_nWindowHeight - coord.y);
// if(source.x>=0 && source.y>=0 && source.x <= m_nWindowWidth-1 && source.y <= m_nWindowHeight)
// {
// m_pDoc->m_pCurrentBrush->BrushMove(source, target);
// }
}


Expand All @@ -226,14 +218,18 @@ void PaintView::draw()
{
SaveCurrentContent();
glFlush();
delete[] uc_backup;
uc_backup = new unsigned char[drawWidth*drawHeight * 3];
memcpy(uc_backup, m_pDoc->m_ucPainting, drawWidth*drawHeight * 3);
// updateViewport();
memcpy(m_pDoc->m_ucBackup, m_pDoc->m_ucPainting, drawWidth*drawHeight * 3);
}
updateViewport();


VideoProcessor::continueWriteStream();
glFlush();
if(m_pDoc->m_ucPainting && m_pDoc->m_ucBackup)
{

memcpy(m_pDoc->m_ucPainting, m_pDoc->m_ucBackup, drawWidth*drawHeight * 3);
}
}

void PaintView::prepareAutoFill()
Expand Down
1 change: 0 additions & 1 deletion PaintView.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class PaintView : public Fl_Gl_Window
std::default_random_engine rng = std::default_random_engine(std::chrono::system_clock::now().time_since_epoch().count());
Point scrollpos{0, 0};
int startrow = 0;
unsigned char *uc_backup = NULL;

void updateViewport();
void updatePainting();
Expand Down

0 comments on commit 0078e39

Please sign in to comment.