static void test_peephole() { SkRandom rand; SkPictureRecorder recorder; for (int j = 0; j < 100; j++) { SkRandom rand2(rand); // remember the seed SkCanvas* canvas = recorder.beginRecording(100, 100); for (int i = 0; i < 1000; ++i) { rand_op(canvas, rand); } sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); rand = rand2; } { SkCanvas* canvas = recorder.beginRecording(100, 100); SkRect rect = SkRect::MakeWH(50, 50); for (int i = 0; i < 100; ++i) { canvas->save(); } while (canvas->getSaveCount() > 1) { canvas->clipRect(rect); canvas->restore(); } sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); } }
// Ensure that serializing an empty picture does not assert. Likewise only runs in debug mode. static void test_serializing_empty_picture() { SkPictureRecorder recorder; recorder.beginRecording(0, 0); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); SkDynamicMemoryWStream stream; picture->serialize(&stream); }
/* Hit a few SkPicture::Analysis cases not handled elsewhere. */ static void test_analysis(skiatest::Reporter* reporter) { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(100, 100); { canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ()); } SkAutoTUnref<SkPicture> picture(recorder.endRecording()); REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps()); canvas = recorder.beginRecording(100, 100); { SkPaint paint; // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shader // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here. SkBitmap bitmap; bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2)); bitmap.eraseColor(SK_ColorBLUE); *(bitmap.getAddr32(0, 0)) = SK_ColorGREEN; SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); paint.setShader(shader)->unref(); REPORTER_ASSERT(reporter, shader->asABitmap(NULL, NULL, NULL) == SkShader::kDefault_BitmapType); canvas->drawRect(SkRect::MakeWH(10, 10), paint); } picture.reset(recorder.endRecording()); REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps()); }
/* Hit a few SkPicture::Analysis cases not handled elsewhere. */ static void test_analysis(skiatest::Reporter* reporter) { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(100, 100); { canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ()); } sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps()); canvas = recorder.beginRecording(100, 100); { SkPaint paint; // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shader // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here. SkBitmap bitmap; bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2)); bitmap.eraseColor(SK_ColorBLUE); *(bitmap.getAddr32(0, 0)) = SK_ColorGREEN; paint.setShader(SkShader::MakeBitmapShader(bitmap, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)); REPORTER_ASSERT(reporter, paint.getShader()->isABitmap()); canvas->drawRect(SkRect::MakeWH(10, 10), paint); } REPORTER_ASSERT(reporter, recorder.finishRecordingAsPicture()->willPlayBackBitmaps()); }
//--------------------------------------------------------------------------- // Packet "C8" void File_Dirac::Intra_Non_Reference_Picture_Low() { Element_Name("Intra Non Reference Picture (low-delay)"); //Parsing picture(); }
//--------------------------------------------------------------------------- // Packet "0A" void File_Dirac::Inter_Non_Reference_Picture_2() { Element_Name("Inter Non Reference Picture (2 pictures)"); //Parsing picture(); }
//--------------------------------------------------------------------------- // Packet "48" void File_Dirac::Intra_Non_Reference_Picture_No() { Element_Name("Intra Non Reference Picture (no arithmetic coding)"); //Parsing picture(); }
int main(void) { USART_Init(103); DDRD=0xff; DDRE=0xff; GLCD_Init128(); picture(&sportronix[0]); _delay_ms(2500); clrlcd(); sei(); lcdputs2(46,2,ar3); //score lcdputs2(5,6,ar4); lcdputs2(110,6,ar4); //FOUL lcdputs2(58,6,ar6); lcdnumdata(25,3,AS); lcdnumdata(85,3,BS); lcdnumdata(55,7,QT); lcdnumdata(5,7,AF); lcdnumdata(110,7,BF); while(1) { } }
/*! \brief paint method. In this method each Plotter is grabbed from its own QCustomPlot Widget to a Pixmap and then drawed with the QPainter primitive drawPixmap */ void QtYARPScope::paint(QPainter *painter) { if(!loader){ return; } int rows = loader->portscope_rows; int cols = loader->portscope_columns; int w = painter->device()->width(); int h = painter->device()->height(); for (int i=0; i<plotManager->getPlotters()->count();i++) { painter->beginNativePainting(); // Workaround to flush the painter auto* plotter = (Plotter*)plotManager->getPlotters()->at(i); int hSpan = plotter->hspan; int vSpan = plotter->vspan; int plotterWidth = (w/cols) * hSpan; int plotterHeight = (h/rows) * vSpan; QPixmap picture(QSize(plotter->customPlot.width() * plotter->customPlot.devicePixelRatio(), plotter->customPlot.height() * plotter->customPlot.devicePixelRatio())); QCPPainter qcpPainter( &picture ); plotter->customPlot.toPainter( &qcpPainter ); QRectF r = QRectF(plotter->gridx * plotterWidth/hSpan, plotter->gridy * plotterHeight/vSpan, picture.rect().width(),picture.rect().height()); plotter->setPaintGeometry(r); painter->drawPixmap(r,picture,QRectF(0,0,plotterWidth,plotterHeight) ); painter->endNativePainting(); } }
/* <ButtonPic x="250px" y="50px" width="120px" height="110px" action="localGame" picture="menu/i_play.png" text="Play" /> */ bool ButtonPic::LoadXMLConfiguration(void) { if (NULL == profile || NULL == widgetNode) { //TODO error ... xml attributs not initialized ! return false; } XmlReader * xmlFile = profile->GetXMLDocument(); ParseXMLGeometry(); ParseXMLMisc(); ParseXMLBorder(); ParseXMLBackground(); std::string picture("menu/pic_not_found.png"); if (!xmlFile->ReadStringAttr(widgetNode, "picture", picture)) { //TODO error return false; } picture = profile->relative_path + picture; Surface surface(picture.c_str()); m_img_normal = surface; std::string labelText("No Text"); xmlFile->ReadStringAttr(widgetNode, "text", labelText); txt_label = new Text(_(labelText.c_str()), dark_gray_color, Font::FONT_SMALL, Font::FONT_BOLD, false); //txt_label->SetMaxWidth(size.x); return true; }
// Verify that associated bitmap cache entries are purged on SkImage destruction. DEF_TEST(BitmapCache_discarded_image, reporter) { // Cache entries associated with SkImages fall into two categories: // // 1) generated image bitmaps (managed by the image cacherator) // 2) scaled/resampled bitmaps (cached when HQ filters are used) // // To exercise the first cache type, we use generated/picture-backed SkImages. // To exercise the latter, we draw scaled bitmap images using HQ filters. const SkMatrix xforms[] = { SkMatrix::MakeScale(1, 1), SkMatrix::MakeScale(1.7f, 0.5f), }; for (size_t i = 0; i < SK_ARRAY_COUNT(xforms); ++i) { test_discarded_image(reporter, xforms[i], []() { SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10)); surface->getCanvas()->clear(SK_ColorCYAN); return surface->newImageSnapshot(); }); test_discarded_image(reporter, xforms[i], []() { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clear(SK_ColorCYAN); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); return SkImage::NewFromPicture(picture, SkISize::Make(10, 10), nullptr, nullptr); }); } }
void loadWidgets(tgui::Gui& gui, tgui::Gui& gui2, sf::RenderWindow& window) { tgui::Picture::Ptr picture(gui2); picture->load("images/xubuntu_bg_aluminium.jpg"); picture->setCallbackId(3); //would be nice to get below to work, but OpenGL covers it //picture->bindCallbackEx(onBackClick, tgui::Picture::LeftMouseClicked); tgui::Label::Ptr instructions1(gui); instructions1->setText("Use up and down arrow keys"); instructions1->setPosition(0, 0); tgui::Label::Ptr instructions2(gui); instructions2->setText("to control speed of spin"); instructions2->setPosition(0, 32); // Create check box for pausing tgui::Checkbox::Ptr checkbox(gui); checkbox->load("widgets/Black.conf"); checkbox->setPosition(window.getSize().x - 128, 30); checkbox->setText("Paused"); checkbox->setSize(32, 32); checkbox->setCallbackId(1); checkbox->bindCallbackEx(pauseCallback, tgui::Checkbox::LeftMouseClicked); // Create the quit button tgui::Button::Ptr quit(gui); quit->load("widgets/Black.conf"); quit->setSize(128, 30); quit->setPosition(window.getSize().x - 128, 0); quit->setText("Quit"); quit->setCallbackId(2); quit->bindCallbackEx(quitCallback, tgui::Button::LeftMouseClicked); }
YamiStatus VaapiPostProcessScaler::process(const SharedPtr<VideoFrame>& src, const SharedPtr<VideoFrame>& dest) { if (!m_context) { ERROR("NO context for scaler"); return YAMI_FAIL; } if (!src || !dest) { return YAMI_INVALID_PARAM; } copyVideoFrameMeta(src, dest); SurfacePtr surface(new VaapiSurface(m_display,(VASurfaceID)dest->surface)); VaapiVppPicture picture(m_context, surface); VAProcPipelineParameterBuffer* vppParam; if (!picture.editVppParam(vppParam)) return YAMI_OUT_MEMORY; VARectangle srcCrop, destCrop; if (fillRect(srcCrop, src->crop)) vppParam->surface_region = &srcCrop; vppParam->surface = (VASurfaceID)src->surface; vppParam->surface_color_standard = fourccToColorStandard(src->fourcc); if (fillRect(destCrop, dest->crop)) vppParam->output_region = &destCrop; vppParam->output_background_color = 0xff000000; vppParam->output_color_standard = fourccToColorStandard(dest->fourcc); return picture.process() ? YAMI_SUCCESS : YAMI_FAIL; }
boost::shared_ptr<pathprovider> pathprovider::instance(C_ItemPtr &item) { map<C_ItemPtr, boost::shared_ptr<pathprovider> >::iterator it = _map.find(item); if (it == _map.end()) { I_MapItem *subject = NULL; C_DrawingStrategyPtr(item)->get_Subject(&subject); C_LinkPtr link(subject); C_ItemPtr item(subject); C_PicturePtr picture(subject); if (subject) { subject->Release(); } if (link && item) { _map[item] = boost::shared_ptr<pathprovider>(new subjectpath(item)); } else if (picture && item) { _map[item] = boost::shared_ptr<pathprovider>(new subjectpath(item)); } else { _map[item] = boost::shared_ptr<pathprovider>(new nullpath); } it = _map.find(item); } return it->second; }
static bool run_single_benchmark(const SkString& inputPath, sk_tools::PictureBenchmark& benchmark) { SkFILEStream inputStream; inputStream.setPath(inputPath.c_str()); if (!inputStream.isValid()) { SkString err; err.printf("Could not open file %s\n", inputPath.c_str()); gLogger.logError(err); return false; } bool success = false; SkPicture picture(&inputStream, &success, &SkImageDecoder::DecodeStream); if (!success) { SkString err; err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); gLogger.logError(err); return false; } SkString filename; sk_tools::get_basename(&filename, inputPath); SkString result; result.printf("running bench [%i %i] %s ", picture.width(), picture.height(), filename.c_str()); gLogger.logProgress(result); benchmark.run(&picture); return true; }
Encode_Status VaapiEncoderH264::reorder(const SurfacePtr& surface, uint64_t timeStamp, bool forceKeyFrame) { if (!surface) return ENCODE_INVALID_PARAMS; PicturePtr picture(new VaapiEncPictureH264(m_context, surface, timeStamp)); bool isIdr = (m_frameIndex == 0 ||m_frameIndex >= keyFramePeriod() || forceKeyFrame); if (isIdr) { setIdrFrame (picture); m_reorderFrameList.push_back(picture); m_curFrameNum++; m_reorderState = VAAPI_ENC_REORD_DUMP_FRAMES; } else if (m_frameIndex % intraPeriod() == 0) { setIFrame (picture); m_reorderFrameList.push_front(picture); m_curFrameNum++; m_reorderState = VAAPI_ENC_REORD_DUMP_FRAMES; }else if (m_frameIndex % (m_numBFrames + 1) != 0) { setBFrame (picture); m_reorderFrameList.push_back(picture); } else { setPFrame (picture); m_reorderFrameList.push_front(picture); m_curFrameNum++; m_reorderState = VAAPI_ENC_REORD_DUMP_FRAMES; } picture->m_poc = ((m_frameIndex * 2) % m_maxPicOrderCnt); m_frameIndex++; return ENCODE_SUCCESS; }
int handle(Request* request, MHD_Connection* connection, const char* url, const char* method, const char* upload_data, size_t* upload_data_size) override { if (!request->fPicture.get()) { return MHD_NO; } // TODO move to a function // Playback into picture recorder SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(kImageWidth, kImageHeight); request->fDebugCanvas->draw(canvas); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); SkDynamicMemoryWStream outStream; SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerializer()); picture->serialize(&outStream, serializer); SkAutoTUnref<SkData> data(outStream.copyToData()); // TODO fancier name handling return SendData(connection, data, "application/octet-stream", true, "attachment; filename=something.skp;"); }
//--------------------------------------------------------------------------- // Packet "0C" void File_Dirac::Intra_Reference_Picture() { Element_Name("Intra Reference Picture"); //Parsing picture(); }
void qmlPlotPaintedItem::paint(QPainter* painter) { QPixmap picture(boundingRect().size().toSize()); QCPPainter qcpPainter(&picture); m_CustomPlot.toPainter(&qcpPainter); painter->drawPixmap(QPoint(), picture); }
//--------------------------------------------------------------------------- // Packet "0D" void File_Dirac::Inter_Reference_Picture_1() { Element_Name("Inter Reference Picture (1 picture)"); //Parsing picture(); }
bool TheoraState::Init() { if (!mActive) return false; int64_t n = mInfo.aspect_numerator; int64_t d = mInfo.aspect_denominator; mPixelAspectRatio = (n == 0 || d == 0) ? 1.0f : static_cast<float>(n) / static_cast<float>(d); // Ensure the frame and picture regions aren't larger than our prescribed // maximum, or zero sized. nsIntSize frame(mInfo.frame_width, mInfo.frame_height); nsIntRect picture(mInfo.pic_x, mInfo.pic_y, mInfo.pic_width, mInfo.pic_height); if (!VideoInfo::ValidateVideoRegion(frame, picture, frame)) { return mActive = false; } mCtx = th_decode_alloc(&mInfo, mSetup); if (mCtx == nullptr) { return mActive = false; } return true; }
//--------------------------------------------------------------------------- // Packet "CC" void File_Dirac::Reference_Picture_Low() { Element_Name("Reference Picture (low-delay)"); //Parsing picture(); }
static SkImage* create_picture_image() { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clear(SK_ColorCYAN); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); return SkImage::NewFromPicture(picture, SkISize::Make(10, 10), nullptr, nullptr); };
// Ensure that serializing an empty picture does not assert. Likewise only runs in debug mode. static void test_serializing_empty_picture() { SkPictureRecorder recorder; recorder.beginRecording(0, 0); sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); SkDynamicMemoryWStream stream; picture->serialize(&stream); }
// Test that image encoding failures do not break picture serialization/deserialization. DEF_TEST(Image_Serialize_Encoding_Failure, reporter) { SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100)); surface->getCanvas()->clear(SK_ColorGREEN); SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); REPORTER_ASSERT(reporter, image); SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(100, 100); canvas->drawImage(image, 0, 0); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); REPORTER_ASSERT(reporter, picture); REPORTER_ASSERT(reporter, picture->approximateOpCount() > 0); MockSerializer emptySerializer([]() -> SkData* { return SkData::NewEmpty(); }); MockSerializer nullSerializer([]() -> SkData* { return nullptr; }); MockSerializer* serializers[] = { &emptySerializer, &nullSerializer }; for (size_t i = 0; i < SK_ARRAY_COUNT(serializers); ++i) { SkDynamicMemoryWStream wstream; REPORTER_ASSERT(reporter, !serializers[i]->didEncode()); picture->serialize(&wstream, serializers[i]); REPORTER_ASSERT(reporter, serializers[i]->didEncode()); SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rstream)); REPORTER_ASSERT(reporter, deserialized); REPORTER_ASSERT(reporter, deserialized->approximateOpCount() > 0); } }
static void serialize_and_compare_typeface(sk_sp<SkTypeface> typeface, const char* text, skiatest::Reporter* reporter) { // Create a paint with the typeface. SkPaint paint; paint.setColor(SK_ColorGRAY); paint.setTextSize(SkIntToScalar(30)); paint.setTypeface(std::move(typeface)); // Paint some text. SkPictureRecorder recorder; SkIRect canvasRect = SkIRect::MakeWH(kBitmapSize, kBitmapSize); SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(canvasRect.width()), SkIntToScalar(canvasRect.height()), nullptr, 0); canvas->drawColor(SK_ColorWHITE); canvas->drawText(text, 2, 24, 32, paint); sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); // Serlialize picture and create its clone from stream. SkDynamicMemoryWStream stream; picture->serialize(&stream); std::unique_ptr<SkStream> inputStream(stream.detachAsStream()); sk_sp<SkPicture> loadedPicture(SkPicture::MakeFromStream(inputStream.get())); // Draw both original and clone picture and compare bitmaps -- they should be identical. SkBitmap origBitmap = draw_picture(*picture); SkBitmap destBitmap = draw_picture(*loadedPicture); compare_bitmaps(reporter, origBitmap, destBitmap); }
int main(int argc, char** argv) { SkCommandLineFlags::SetUsage( "Usage: get_images_from_skps -s <dir of skps> -o <dir for output images>\n"); SkCommandLineFlags::Parse(argc, argv); const char* inputs = FLAGS_skps[0]; gOutputDir = FLAGS_out[0]; if (!sk_isdir(inputs) || !sk_isdir(gOutputDir)) { SkCommandLineFlags::PrintUsage(); return 1; } SkOSFile::Iter iter(inputs, "skp"); for (SkString file; iter.next(&file); ) { SkAutoTDelete<SkStream> stream = SkStream::NewFromFile(SkOSPath::Join(inputs, file.c_str()).c_str()); SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(stream)); SkDynamicMemoryWStream scratch; Sniffer sniff; picture->serialize(&scratch, &sniff); } SkDebugf("%d known, %d unknown\n", gKnown, gUnknown); return 0; }
/** Reads an skp file, renders it to pdf and writes the output to a pdf file * @param inputPath The skp file to be read. * @param outputDir Output dir. * @param renderer The object responsible to render the skp object into pdf. */ static bool render_pdf(const SkString& inputPath, const SkString& outputDir, sk_tools::PdfRenderer& renderer) { SkString inputFilename; sk_tools::get_basename(&inputFilename, inputPath); SkFILEStream inputStream; inputStream.setPath(inputPath.c_str()); if (!inputStream.isValid()) { SkDebugf("Could not open file %s\n", inputPath.c_str()); return false; } bool success = false; SkAutoTUnref<SkPicture> picture(SkNEW_ARGS(SkPicture, (&inputStream, &success))); if (!success) { SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str()); return false; } SkDebugf("exporting... [%i %i] %s\n", picture->width(), picture->height(), inputPath.c_str()); renderer.init(picture); renderer.render(); success = write_output(outputDir, inputFilename, renderer); renderer.end(); return success; }
int main(int argc, char** argv) { SkCommandLineFlags::SetUsage( "Usage: get_images_from_skps -s <dir of skps> -o <dir for output images> --testDecode " "-j <output JSON path>\n"); SkCommandLineFlags::Parse(argc, argv); const char* inputs = FLAGS_skps[0]; gOutputDir = FLAGS_out[0]; if (!sk_isdir(inputs) || !sk_isdir(gOutputDir)) { SkCommandLineFlags::PrintUsage(); return 1; } SkOSFile::Iter iter(inputs, "skp"); for (SkString file; iter.next(&file); ) { SkAutoTDelete<SkStream> stream = SkStream::NewFromFile(SkOSPath::Join(inputs, file.c_str()).c_str()); sk_sp<SkPicture> picture(SkPicture::MakeFromStream(stream)); SkDynamicMemoryWStream scratch; Sniffer sniff(file.c_str()); picture->serialize(&scratch, &sniff); } int totalUnknowns = 0; /** JSON results are written out in the following format: { "failures": { "skp1": 12, "skp4": 2, ... }, "totalFailures": 32, "totalSuccesses": 21, } */ Json::Value fRoot; for(auto it = gSkpToUnknownCount.cbegin(); it != gSkpToUnknownCount.cend(); ++it) { SkDebugf("%s %d\n", it->first.c_str(), it->second); totalUnknowns += it->second; fRoot["failures"][it->first.c_str()] = it->second; } SkDebugf("%d known, %d unknown\n", gKnown, totalUnknowns); fRoot["totalFailures"] = totalUnknowns; fRoot["totalSuccesses"] = gKnown; if (totalUnknowns > 0) { if (!FLAGS_failuresJsonPath.isEmpty()) { SkDebugf("Writing failures to %s\n", FLAGS_failuresJsonPath[0]); SkFILEWStream stream(FLAGS_failuresJsonPath[0]); stream.writeText(Json::StyledWriter().write(fRoot).c_str()); stream.flush(); } return -1; } return 0; }
// Ensure that deleting an empty SkPicture does not assert. Asserts only fire // in debug mode, so only run in debug mode. static void test_deleting_empty_picture() { SkPictureRecorder recorder; // Creates an SkPictureRecord recorder.beginRecording(0, 0); // Turns that into an SkPicture sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); // Ceates a new SkPictureRecord recorder.beginRecording(0, 0); }