Skip to content

Commit

Permalink
trace compatible with autofill and painterly
Browse files Browse the repository at this point in the history
  • Loading branch information
dipsywong98 committed Feb 28, 2019
1 parent afd1358 commit 1aeb571
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
3 changes: 3 additions & 0 deletions ImpressionistDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,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 +266,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
28 changes: 9 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,11 +218,9 @@ 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();
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 1aeb571

Please sign in to comment.