SkSurfaceCharacterization characterization;
if(!surface->characterize(&characterization)) {
return
}
SkDeferredDisplayListRecorder recorder(characterization);
SkCanvas* subcanvas = recorder.getCanvas();
//some drawings
sk_sp<SkDeferredDisplayList> displayList = recorder.detach();
I'm storing this displayList and reusing it later. But this displayList canvas has beed cleared after a single use. But i need to persist it and use it later for multiple occurrences.
Also is it possible to draw contents in multiple thread using skia in metal?
Regards,
Praveenkumar R
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/5fa7eeaa-30a9-4609-acb1-7d1c1fa9df85n%40googlegroups.com.
this is my use case ----> My drawable viewport size is 1000*1000, So its not drawing the contents in 60fps(frame rate).
here are the few thing i tried to make the frame rate 60fps,
1. I tried creating a multiple DeferredDisplayList for single surface and tries to draw in multiple thread.(Note: Creating is happening in main thread, only the rendering is happening in different threads). But doing this crashes the app. So is there any way that i can achieve this case? here is the code that i tried
///
void ZSSample::drawInMultipleThread(SkCanvas* canvas) {
SkImageInfo firstInfo = SkImageInfo::MakeN32(500, 500, SkAlphaType::kPremul_SkAlphaType);
sk_sp<SkSurface> firstSurface = SkSurface::MakeRenderTarget(canvas->recordingContext(), SkBudgeted::kYes, firstInfo);
SkSurfaceCharacterization firstCharacterization;
if(!firstSurface->characterize(&firstCharacterization)) {
return;
}
SkDeferredDisplayListRecorder firstRecorder(firstCharacterization);
SkCanvas *firstCanvas = firstRecorder.getCanvas();
SkImageInfo secondInfo = SkImageInfo::MakeN32(500, 500, SkAlphaType::kPremul_SkAlphaType);
sk_sp<SkSurface> secondSurface = SkSurface::MakeRenderTarget(canvas->recordingContext(), SkBudgeted::kYes, secondInfo);
SkSurfaceCharacterization secondCharacterization;
if(!secondSurface->characterize(&secondCharacterization)) {
return;
}
SkDeferredDisplayListRecorder secondRecorder(secondCharacterization);
SkCanvas *secondCanvas = secondRecorder.getCanvas();
std::thread firstThread(drawInSurface, firstCanvas);
std::thread secondThread(drawInSurface, secondCanvas);
firstThread.join();
secondThread.join();
sk_sp<SkDeferredDisplayList> firstDisplayList = firstRecorder.detach();
firstSurface->draw(firstDisplayList);
sk_sp<SkDeferredDisplayList> secondDisplayList = secondRecorder.detach();
secondSurface->draw(secondDisplayList);
sk_sp<SkImage> firstImage = firstSurface->makeImageSnapshot();
sk_sp<SkImage> secondImage = secondSurface->makeImageSnapshot();
canvas->drawImage(firstImage, 0, 0);
canvas->drawImage(secondImage, 0, 500);
}
///
2.So i tried creating a multiple surface using MakeRenderTarget and draw the contents in multiple thread, But even in this case my app crashes. Please check the below sample
///
void ZSSample::drawInMultipleThread(SkCanvas* canvas) {
SkImageInfo firstInfo = SkImageInfo::MakeN32(500, 500, SkAlphaType::kPremul_SkAlphaType);
sk_sp<SkSurface> firstSurface = SkSurface::MakeRenderTarget(canvas->recordingContext(), SkBudgeted::kYes, firstInfo);
SkCanvas *firstCanvas = firstSurface->getCanvas();
SkImageInfo secondInfo = SkImageInfo::MakeN32(500, 500, SkAlphaType::kPremul_SkAlphaType);
sk_sp<SkSurface> secondSurface = SkSurface::MakeRenderTarget(canvas->recordingContext(), SkBudgeted::kNo, secondInfo);
SkCanvas* secondCanvas = secondSurface->getCanvas();
std::thread firstThread(drawInSurface, firstCanvas);
std::thread secondThread(drawInSurface, secondCanvas);
firstThread.join();
secondThread.join();
sk_sp<SkImage> image = firstSurface->makeImageSnapshot();
sk_sp<SkImage> image1 = secondSurface->makeImageSnapshot();
canvas->drawImage(image, 0, 0);
canvas->drawImage(image1, 0, 500);
}
///
In both the approaches the app crashes, is there any way that i can achieve the above case.