void cThumbnailWidget::AssignParameters(const cParameterContainer &_params, const cFractalContainer &_fractal) { *params = _params; *fractal = _fractal; params->Set("image_width", tWidth * oversample); params->Set("image_height", tHeight * oversample); cSettings tempSettings(cSettings::formatCondensedText); tempSettings.CreateText(params, fractal); oldHash = hash; hash = tempSettings.GetHashCode(); if(hash != oldHash) { stopRequest = true; while (image->IsUsed()) { //just wait and pray } emit settingsChanged(); isRendered = false; hasParameters = true; QString thumbnailFileName = systemData.thumbnailDir + hash + QString(".png"); if (QFileInfo::exists(thumbnailFileName) && !disableThumbnailCache) { stopRequest = true; isRendered = true; while (image->IsUsed()) { //just wait and pray } QPixmap pixmap; pixmap.load(thumbnailFileName); pixmap = pixmap.scaled(tWidth, tHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); QImage qimage = pixmap.toImage(); qimage = qimage.convertToFormat(QImage::Format_RGB888); sRGB8 *bitmap; bitmap = (sRGB8*) (qimage.bits()); int bwidth = qimage.width(); int bheight = qimage.height(); sRGB8 *previewPointer = (sRGB8*) image->GetPreviewPrimaryPtr(); sRGB8 *preview2Pointer = (sRGB8*) image->GetPreviewPtr(); memcpy(previewPointer, bitmap, sizeof(sRGB8) * bwidth * bheight); memcpy(preview2Pointer, bitmap, sizeof(sRGB8) * bwidth * bheight); emit thumbnailRendered(); } else { if(!disableTimer) { //render thumbnail after random time. It forces rendering of widgets when they are not visible. It makes rendering of widgets when they are idle. timer->start(Random(100000) * 10 + 1); } } } }
void cThumbnailWidget::AssignParameters( const cParameterContainer &_params, const cFractalContainer &_fractal) { if (image) { if (!params) params = new cParameterContainer; if (!fractal) fractal = new cFractalContainer; *params = _params; *fractal = _fractal; params->Set("image_width", tWidth * oversample); params->Set("image_height", tHeight * oversample); params->Set("stereo_mode", int(cStereo::stereoRedCyan)); params->Set("DOF_max_noise", params->Get<double>("DOF_max_noise") * 10.0); params->Set("DOF_min_samples", 5); double distance = cInterface::GetDistanceForPoint(params->Get<CVector3>("camera"), params, fractal); if (distance < 1e-5) { params->Set("opencl_mode", 0); } cSettings tempSettings(cSettings::formatCondensedText); tempSettings.CreateText(params, fractal); oldHash = hash; hash = tempSettings.GetHashCode(); if (hash != oldHash) { stopRequest = true; while (image->IsUsed()) { // just wait and pray } emit settingsChanged(); isRendered = false; hasParameters = true; QString thumbnailFileName = GetThumbnailFileName(); if (QFileInfo::exists(thumbnailFileName) && !disableThumbnailCache) { stopRequest = true; isRendered = true; while (image->IsUsed()) { // just wait and pray } QPixmap pixmap; pixmap.load(thumbnailFileName); pixmap = pixmap.scaled(tWidth, tHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); QImage qImage = pixmap.toImage(); qImage = qImage.convertToFormat(QImage::Format_RGB888); sRGB8 *previewPointer = reinterpret_cast<sRGB8 *>(image->GetPreviewPrimaryPtr()); sRGB8 *preview2Pointer = reinterpret_cast<sRGB8 *>(image->GetPreviewPtr()); int bWidth = qImage.width(); int bHeight = qImage.height(); if (!qImage.isNull()) { for (int y = 0; y < bHeight; y++) { sRGB8 *line = reinterpret_cast<sRGB8 *>(qImage.scanLine(y)); for (int x = 0; x < bWidth; x++) { sRGB8 pixel(static_cast<unsigned short>(line[x].R), static_cast<unsigned short>(line[x].G), static_cast<unsigned short>(line[x].B)); previewPointer[x + y * bWidth] = pixel; preview2Pointer[x + y * bWidth] = pixel; } } } delete params; params = nullptr; delete fractal; fractal = nullptr; emit thumbnailRendered(); } else { if (!disableTimer) { // render thumbnail after random time. It forces rendering of widgets when they are not // visible. It makes rendering of widgets when they are idle. timer->start(Random(1000000) * 10 + 60000); } } } } else { qCritical() << "Image not yet allocated!"; } }