예제 #1
0
void QuiltTask::draw() {
    SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get()));

    SkBitmap full;
    SetupBitmap(fReference.colorType(), fGM.get(), &full);
    SkCanvas fullCanvas(full);

    SkBitmap tile;
    tile.allocPixels(SkImageInfo::Make(FLAGS_quiltTile, FLAGS_quiltTile,
                                       fReference.colorType(), kPremul_SkAlphaType));
    SkCanvas tileCanvas(tile);

    for (int y = 0; y < tiles_needed(full.height(), tile.height()); y++) {
        for (int x = 0; x < tiles_needed(full.width(), tile.width()); x++) {
            SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/);

            const SkScalar xOffset = SkIntToScalar(x * tile.width()),
                           yOffset = SkIntToScalar(y * tile.height());
            SkMatrix matrix = tileCanvas.getTotalMatrix();
            matrix.postTranslate(-xOffset, -yOffset);
            tileCanvas.setMatrix(matrix);

            recorded->draw(&tileCanvas);
            tileCanvas.flush();
            fullCanvas.drawBitmap(tile, xOffset, yOffset, NULL);
        }
    }

    if (!BitmapsEqual(full, fReference)) {
        this->fail();
        this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full)));
    }
}
예제 #2
0
void ReplayTask::draw() {
    const uint32_t flags = fUseRTree ? SkPicture::kOptimizeForClippedPlayback_RecordingFlag : 0;
    SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), flags));

    SkBitmap bitmap;
    SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
    DrawPicture(recorded, &bitmap);
    if (!BitmapsEqual(bitmap, fReference)) {
        this->fail();
        this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
    }
}
예제 #3
0
파일: gpuveto.cpp 프로젝트: Arternis/skia
int tool_main(int argc, char** argv) {
#if SK_SUPPORT_GPU
    SkCommandLineFlags::SetUsage("Reports on an skp file's suitability for GPU rasterization");
    SkCommandLineFlags::Parse(argc, argv);

    if (FLAGS_readFile.count() != 1) {
        if (!FLAGS_quiet) {
            SkDebugf("Missing input file\n");
        }
        return kError;
    }

    SkFILEStream inputStream(FLAGS_readFile[0]);
    if (!inputStream.isValid()) {
        if (!FLAGS_quiet) {
            SkDebugf("Couldn't open file\n");
        }
        return kError;
    }

    SkPicture::InstallPixelRefProc proc = &sk_tools::LazyDecodeBitmap;

    SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
    if (NULL == picture.get()) {
        if (!FLAGS_quiet) {
            SkDebugf("Could not read the SkPicture\n");
        }
        return kError;
    }

    // The SkPicture tracking information is only generated during recording
    // an isn't serialized. Replay the picture to regenerated the tracking data.
    SkPictureRecorder recorder;
    picture->playback(recorder.beginRecording(picture->cullRect().width(), 
                                              picture->cullRect().height(), 
                                              NULL, 0));
    SkAutoTUnref<SkPicture> recorded(recorder.endRecording());

    if (recorded->suitableForGpuRasterization(NULL)) {
        SkDebugf("suitable\n");
    } else {
        SkDebugf("unsuitable\n");
    }

    return kSuccess;
#else
    SkDebugf("gpuveto is only useful when GPU rendering is enabled\n");
    return kError;
#endif
}
예제 #4
0
int main(int argc, char** argv) {
#if SK_SUPPORT_GPU
    SkCommandLineFlags::SetUsage("Reports on an skp file's suitability for GPU rasterization");
    SkCommandLineFlags::Parse(argc, argv);

    if (FLAGS_readFile.count() != 1) {
        if (!FLAGS_quiet) {
            SkDebugf("Missing input file\n");
        }
        return kError;
    }

    SkFILEStream inputStream(FLAGS_readFile[0]);
    if (!inputStream.isValid()) {
        if (!FLAGS_quiet) {
            SkDebugf("Couldn't open file\n");
        }
        return kError;
    }

    sk_sp<SkPicture> picture(SkPicture::MakeFromStream(&inputStream));
    if (nullptr == picture) {
        if (!FLAGS_quiet) {
            SkDebugf("Could not read the SkPicture\n");
        }
        return kError;
    }

    // The SkPicture tracking information is only generated during recording
    // an isn't serialized. Replay the picture to regenerated the tracking data.
    SkPictureRecorder recorder;
    picture->playback(recorder.beginRecording(picture->cullRect().width(),
                                              picture->cullRect().height(),
                                              nullptr, 0));
    sk_sp<SkPicture> recorded(recorder.finishRecordingAsPicture());

    if (SkPictureGpuAnalyzer(recorded).suitableForGpuRasterization(nullptr)) {
        SkDebugf("suitable\n");
    } else {
        SkDebugf("unsuitable\n");
    }

    return kSuccess;
#else
    SkDebugf("gpuveto is only useful when GPU rendering is enabled\n");
    return kError;
#endif
}
예제 #5
0
void TileGridTask::draw() {
    const SkTileGridPicture::TileGridInfo info = {
        fTileSize,
        SkISize::Make(0,0),   // Overlap between adjacent tiles.
        SkIPoint::Make(0,0),  // Offset.
    };
    const SkISize size = fGM->getISize();
    SkTileGridPicture recorded(size.width(), size.height(), info);
    RecordPicture(fGM.get(), &recorded, SkPicture::kUsePathBoundsForClip_RecordingFlag);

    SkBitmap full;
    SetupBitmap(fReference.colorType(), fGM.get(), &full);
    SkCanvas fullCanvas(full);

    SkBitmap tile;
    tile.allocPixels(SkImageInfo::Make(fTileSize.width(), fTileSize.height(),
                                       fReference.colorType(), kPremul_SkAlphaType));
    SkCanvas tileCanvas(tile);

    SkPaint paint;
    paint.setXfermodeMode(SkXfermode::kSrc_Mode);

    for (int y = 0; y < tiles_needed(full.height(), tile.height()); y++) {
        for (int x = 0; x < tiles_needed(full.width(), tile.width()); x++) {
            SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/);

            const SkScalar xOffset = SkIntToScalar(x * tile.width()),
                           yOffset = SkIntToScalar(y * tile.height());
            SkMatrix matrix = tileCanvas.getTotalMatrix();
            matrix.postTranslate(-xOffset, -yOffset);
            tileCanvas.setMatrix(matrix);

            recorded.draw(&tileCanvas);
            tileCanvas.flush();
            fullCanvas.drawBitmap(tile, xOffset, yOffset, &paint);
        }
    }

    if (!BitmapsEqual(full, fReference)) {
        this->fail();
        this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full)));
    }
}
예제 #6
0
void FRecord::record()
{
	FStateInput inputState(0);

	if(getFlag(RECORD_FLASH_R) == true)
	{	
		inputState[FLASH_CHANNEL_R] = flashIntensityR;
		(*dmx)->setSystemState(inputState);
	}

	if(getFlag(RECORD_FLASH_G) == true)
	{	
		inputState[FLASH_CHANNEL_G] = flashIntensityG;
		(*dmx)->setSystemState(inputState);
	}

	if(getFlag(RECORD_FLASH_B) == true)
	{	
		inputState[FLASH_CHANNEL_B] = flashIntensityB;
		(*dmx)->setSystemState(inputState);
	}
	msleep(1000);

	nSamples++;

	if(*camera == NULL)
		return;

	//cimg_library::CImg<unsigned char>* image;
	FImage<unsigned char> image;
	(*camera)->grab(&image());

	image.traceEdges();

	unsigned char color[] = {255,0,0};

	image.paintEdges(color);

	QApplication::beep();

	//image.speckImage()->display("title");

	dateTime = QDateTime::currentDateTime();
	int year = dateTime.date().year();
	int month = dateTime.date().month();
	int day = dateTime.date().day();
	int hour = dateTime.time().hour();
	int min = dateTime.time().minute();
	int sec = dateTime.time().second();
	int msec = dateTime.time().msec();

	FStateSens sensState;
	(*camera)->getSensorState(&sensState);

	FStateSysLed ledState;
	(*dmx)->getSystemState(&ledState);

	FStateSysRgb rgbState;
	(*camera)->getSystemState(&rgbState);

	FStateLab labState;
	//(*color)->rgb2lab(rgbState[F_STATE_SYS_RGB_R](), rgbState[F_STATE_SYS_RGB_G](), rgbState[F_STATE_SYS_RGB_B]());
	//(*color)->getSensorState(labState);
	
	image.blobs();
	
	if(getFlag(RECORD_IMAGES_ON) == true)
	{
		char saveString[255];
		sprintf(saveString, "%s\\%s_%d%02d%02d_%02d%02d%02d.bmp",mImagePath, mBaseName, year, month, day, hour, min, sec);

		image()->save(saveString);
	}

	if(getFlag(RECORD_CSV_ON) == true)
	{
		char saveString[255];
		sprintf(saveString, "%s\\%s_%d%02d%02d.csv", mCsvPath, mBaseName, year, month, day);
		
		QFile file(saveString);
		bool bHeaderWrite = false;
		bHeaderWrite = !file.exists();

		if(bHeaderWrite == true)
		{
			if(file.open(QIODevice::WriteOnly | QIODevice::Text))
			{
				std::string lineBuffer;
				lineBuffer.empty();

				writeTimeStampHeader(file);

				std::string label;
				label.empty();
				char separator = ';';

				sensState.labelString(label,separator);
				ledState.labelString(label,separator);
				rgbState.labelString(label,separator);
				refState.labelString(label,separator);
				labState.labelString(label,separator);

				file.write(label.c_str());
				file.write("\n");
				file.close();
			}

		}

		if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
		{
			std::string lineBuffer;
			lineBuffer.empty();

			writeTimeStamp(dateTime, file);

			std::string values;
			values.empty();
			char separator = ';';

			sensState.valueString(values,separator);
			ledState.valueString(values,separator);
			rgbState.valueString(values,separator);
			refState.valueString(values,separator);
			labState.valueString(values,separator);

			file.write(values.c_str());
			file.write("\n");
			file.close();
		}
	}

	//delete image;
	emit recorded(nSamples);

	msleep(1000);

	if(getFlag(RECORD_FLASH_R) == true)
	{
		inputState[FLASH_CHANNEL_R] = 0;
		(*dmx)->setSystemState(inputState);	
	}
	if(getFlag(RECORD_FLASH_G) == true)
	{
		inputState[FLASH_CHANNEL_G] = 0;
		(*dmx)->setSystemState(inputState);	
	}
	if(getFlag(RECORD_FLASH_B) == true)
	{
		inputState[FLASH_CHANNEL_B] = 0;
		(*dmx)->setSystemState(inputState);	
	}
}
예제 #7
0
void SoundRecorderArts::slotEmitSignal()
{
	emit recorded( sound() );
}