bool PipePictureRenderer::render(SkBitmap** out) { SkASSERT(fCanvas.get() != NULL); SkASSERT(fPicture != NULL); if (NULL == fCanvas.get() || NULL == fPicture) { return false; } PipeController pipeController(fCanvas.get()); SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording(&pipeController); pipeCanvas->drawPicture(fPicture); writer.endRecording(); fCanvas->flush(); if (out) { *out = SkNEW(SkBitmap); setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), SkScalarCeilToInt(fPicture->cullRect().height())); fCanvas->readPixels(*out, 0, 0); } if (fEnableWrites) { return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, fUseChecksumBasedFilenames); } else { return true; } }
DEF_TEST(Pipe, reporter) { SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, 64, 64); SkCanvas canvas(bitmap); PipeController pipeController(&canvas); SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording(&pipeController); testDrawingBadBitmap(pipeCanvas); writer.endRecording(); testDrawingAfterEndRecording(&canvas); }
static void test_pipeTests(skiatest::Reporter*) { SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, 64, 64); SkCanvas canvas(bitmap); PipeController pipeController(&canvas); SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording(&pipeController); testDrawingBadBitmap(pipeCanvas); writer.endRecording(); testDrawingAfterEndRecording(&canvas); }
void PipeTask::draw() { SkBitmap bitmap; SetupBitmap(fReference.config(), fGM.get(), &bitmap); SkCanvas canvas(bitmap); PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory); SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording(&pipeController, fFlags, bitmap.width(), bitmap.height()); pipeCanvas->concat(fGM->getInitialTransform()); fGM->draw(pipeCanvas); writer.endRecording(); if (!BitmapsEqual(bitmap, fReference)) { this->fail(); this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); } }
bool PipePictureRenderer::render(const SkString* path, SkBitmap** out) { SkASSERT(fCanvas.get() != NULL); SkASSERT(fPicture != NULL); if (NULL == fCanvas.get() || NULL == fPicture) { return false; } PipeController pipeController(fCanvas.get()); SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording(&pipeController); pipeCanvas->drawPicture(*fPicture); writer.endRecording(); fCanvas->flush(); if (NULL != path) { return write(fCanvas, path, fJsonSummaryPtr); } if (NULL != out) { *out = SkNEW(SkBitmap); setup_bitmap(*out, fPicture->width(), fPicture->height()); fCanvas->readPixels(*out, 0, 0); } return true; }