paysages : Preview improvements.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@316 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
3c2137ded1
commit
0242fc547a
3 changed files with 24 additions and 16 deletions
4
TODO
4
TODO
|
@ -10,11 +10,11 @@ Technology Preview 2 :
|
||||||
- Add a noise filler (and maybe noise intervals ?).
|
- Add a noise filler (and maybe noise intervals ?).
|
||||||
- Improve curve editor.
|
- Improve curve editor.
|
||||||
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
||||||
- There should not have to be more preview threads than cpu cores.
|
|
||||||
- Pause previews drawing of main window when a dialog is opened.
|
- Pause previews drawing of main window when a dialog is opened.
|
||||||
- Interrupt preview chunk renderings that will be discarded at commit, or that are no more visible.
|
- Interrupt preview chunk renderings that will be discarded at commit, or that are no more visible.
|
||||||
- Can't overwrite picture files (ILError).
|
- Can't overwrite picture files (ILError).
|
||||||
- Fix "RGB parameters out of range" on preview while moving render size fast in render tab.
|
- Fix "RGB parameters out of range" (and segfault) on preview while moving render params fast in render tab.
|
||||||
|
- When there are two previews in the same view, balance rendering between the two.
|
||||||
|
|
||||||
Technology Preview 3 :
|
Technology Preview 3 :
|
||||||
- Restore render progress.
|
- Restore render progress.
|
||||||
|
|
|
@ -331,9 +331,9 @@ QImage BasePreview::startChunkTransaction(int x, int y, int w, int h, int* revis
|
||||||
|
|
||||||
void BasePreview::commitChunkTransaction(QImage* chunk, int x, int y, int w, int h, int revision)
|
void BasePreview::commitChunkTransaction(QImage* chunk, int x, int y, int w, int h, int revision)
|
||||||
{
|
{
|
||||||
|
lock_drawing->lock();
|
||||||
if (revision == _revision)
|
if (revision == _revision)
|
||||||
{
|
{
|
||||||
lock_drawing->lock();
|
|
||||||
for (int ix = 0; ix < w; ix++)
|
for (int ix = 0; ix < w; ix++)
|
||||||
{
|
{
|
||||||
for (int iy = 0; iy < h; iy++)
|
for (int iy = 0; iy < h; iy++)
|
||||||
|
@ -341,9 +341,9 @@ void BasePreview::commitChunkTransaction(QImage* chunk, int x, int y, int w, int
|
||||||
pixbuf->setPixel(x + ix, y + iy, chunk->pixel(ix, iy));
|
pixbuf->setPixel(x + ix, y + iy, chunk->pixel(ix, iy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lock_drawing->unlock();
|
|
||||||
emit contentChange();
|
emit contentChange();
|
||||||
}
|
}
|
||||||
|
lock_drawing->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor BasePreview::getPixelColor(int x, int y)
|
QColor BasePreview::getPixelColor(int x, int y)
|
||||||
|
@ -356,14 +356,7 @@ void BasePreview::handleRedraw()
|
||||||
lock_drawing->lock();
|
lock_drawing->lock();
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
|
invalidatePixbuf(128);
|
||||||
QImage part = pixbuf->copy();
|
|
||||||
pixbuf->fill(0x00000000);
|
|
||||||
QPainter painter(pixbuf);
|
|
||||||
painter.setOpacity(0.99);
|
|
||||||
painter.drawImage(0, 0, part);
|
|
||||||
|
|
||||||
updateChunks();
|
|
||||||
|
|
||||||
lock_drawing->unlock();
|
lock_drawing->unlock();
|
||||||
}
|
}
|
||||||
|
@ -426,6 +419,22 @@ void BasePreview::updateChunks()
|
||||||
_revision++;
|
_revision++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasePreview::invalidatePixbuf(int value)
|
||||||
|
{
|
||||||
|
for (int ix = 0; ix < _width; ix++)
|
||||||
|
{
|
||||||
|
for (int iy = 0; iy < _height; iy++)
|
||||||
|
{
|
||||||
|
QRgb col = pixbuf->pixel(ix, iy);
|
||||||
|
if (qAlpha(col) == 255)
|
||||||
|
{
|
||||||
|
pixbuf->setPixel(ix, iy, qRgba(qRed(col), qGreen(col), qBlue(col), value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateChunks();
|
||||||
|
}
|
||||||
|
|
||||||
void BasePreview::mousePressEvent(QMouseEvent* event)
|
void BasePreview::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
|
@ -590,9 +599,8 @@ void BasePreview::wheelEvent(QWheelEvent* event)
|
||||||
QImage part = pixbuf->copy((width - new_width) / 2, (height - new_height) / 2, new_width, new_height).scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
QImage part = pixbuf->copy((width - new_width) / 2, (height - new_height) / 2, new_width, new_height).scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
QPainter painter(pixbuf);
|
QPainter painter(pixbuf);
|
||||||
pixbuf->fill(0x00000000);
|
pixbuf->fill(0x00000000);
|
||||||
painter.setOpacity(0.99);
|
|
||||||
painter.drawImage(0, 0, part);
|
painter.drawImage(0, 0, part);
|
||||||
updateChunks();
|
invalidatePixbuf(254);
|
||||||
lock_drawing->unlock();
|
lock_drawing->unlock();
|
||||||
|
|
||||||
emit contentChange();
|
emit contentChange();
|
||||||
|
@ -603,9 +611,8 @@ void BasePreview::wheelEvent(QWheelEvent* event)
|
||||||
QImage part = pixbuf->scaled((int) floor(((double) width) * old_scaling / scaling), (int) floor(((double) height) * old_scaling / scaling), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
QImage part = pixbuf->scaled((int) floor(((double) width) * old_scaling / scaling), (int) floor(((double) height) * old_scaling / scaling), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
QPainter painter(pixbuf);
|
QPainter painter(pixbuf);
|
||||||
pixbuf->fill(0x00000000);
|
pixbuf->fill(0x00000000);
|
||||||
painter.setOpacity(0.99);
|
|
||||||
painter.drawImage((width - part.width()) / 2, (height - part.height()) / 2, part);
|
painter.drawImage((width - part.width()) / 2, (height - part.height()) / 2, part);
|
||||||
updateChunks();
|
invalidatePixbuf(254);
|
||||||
lock_drawing->unlock();
|
lock_drawing->unlock();
|
||||||
|
|
||||||
emit contentChange();
|
emit contentChange();
|
||||||
|
|
|
@ -39,6 +39,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void updateScaling();
|
void updateScaling();
|
||||||
void updateChunks();
|
void updateChunks();
|
||||||
|
void invalidatePixbuf(int value);
|
||||||
|
|
||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event);
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event);
|
||||||
|
|
Loading…
Reference in a new issue