SkImageGenerator::Result onGetScanlines(void* dst, int count, size_t rowBytes) override { // Set the jump location for libjpeg errors if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) { return fCodec->fDecoderMgr->returnFailure("setjmp", SkImageGenerator::kInvalidInput); } // Read rows one at a time for (int y = 0; y < count; y++) { // Read row of the image uint32_t rowsDecoded = jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &fSrcRow, 1); if (rowsDecoded != 1) { SkSwizzler::Fill(dst, this->dstInfo(), rowBytes, count - y, SK_ColorBLACK, NULL); return SkImageGenerator::kIncompleteInput; } // Convert to RGB if necessary if (JCS_CMYK == fCodec->fDecoderMgr->dinfo()->out_color_space) { convert_CMYK_to_RGB(fSrcRow, dstInfo().width()); } // Swizzle to output destination fCodec->fSwizzler->setDstRow(dst); fCodec->fSwizzler->next(fSrcRow); dst = SkTAddOffset<void>(dst, rowBytes); } return SkImageGenerator::kSuccess; }
bool copyDir(const QString &srcPath, const QString &dstPath) { bool result = true; bool test = true; LOG_FREE(Info, "copyDir", "copyDir '" << toString(srcPath) << "' to '" << toString(dstPath) << "'"); // ensure directory exists QFileInfo dstInfo(dstPath); QString fileName = dstInfo.fileName(); if (!dstInfo.exists() || !dstInfo.isDir()){ QDir parentDstDir(QFileInfo(dstPath).path()); LOG_FREE(Info, "copyDir", "Creating directory named = '" << toString(fileName) << "' in parentDstDir = '" << toString(parentDstDir.path()) << "'"); if (!parentDstDir.mkpath(fileName)){ LOG_FREE(Error, "copyDir", "Failed to create directory = '" << toString(fileName) << "' in parentDstDir = '" << toString(parentDstDir.path()) << "'"); return false; } } QDir srcDir(srcPath); // remove all files in dst as well as any directories in dst that are not in src test = synchDirStructures(srcPath, dstPath); if (!test){ LOG_FREE(Error, "copyDir", "Failed to synch destination '" << toString(dstPath) << "' with source '" << toString(srcPath) << "'"); result = false; } // copy all files in src to dst for (const QFileInfo &srcItemInfo : srcDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { QString srcItemPath = srcPath + "/" + srcItemInfo.fileName(); QString dstItemPath = dstPath + "/" + srcItemInfo.fileName(); QFileInfo dstItemInfo = QFileInfo(dstItemPath); if (srcItemInfo.isDir()) { test = copyDir(srcItemPath, dstItemPath); if (!test){ LOG_FREE(Error, "copyDir", "Failed to copy directory '" << toString(srcItemPath) << "' to '" << toString(dstItemPath) << "'"); result = false; // DLM: do we really want to give up here? //return false; } } else if (srcItemInfo.isFile()) { test = QFile::copy(srcItemPath, dstItemPath); if (!test){ LOG_FREE(Error, "copyDir", "Failed to copy file '" << toString(srcItemPath) << "' to '" << toString(dstItemPath) << "'"); result = false; // DLM: do we really want to give up here? //return false; } } } return result; }