20 pthread_create(&fThread,
nullptr, pthread_main,
this);
32 pthread_join(fThread,
nullptr);
35int SurfaceThread::message_callback(
int ,
int ,
void*
data) {
38 surfaceThread->readMessage(&
message);
52 SkDebugf(
"surface destroyed, shutting down thread");
53 surfaceThread->fRunning =
false;
54 if(
auto* windowSurface =
reinterpret_cast<Surface*
>(*
message.fWindowSurface)){
55 windowSurface->release(
nullptr);
62 if(
auto* windowSurface =
reinterpret_cast<Surface*
>(*
message.fWindowSurface)){
63 windowSurface->getCanvas()->drawPicture(
picture);
64 windowSurface->flushAndSubmit();
76void* SurfaceThread::pthread_main(
void* arg) {
79 ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
80 ALooper_addFd(looper, surfaceThread->fPipe[0], 1, ALOOPER_EVENT_INPUT,
81 surfaceThread->message_callback, surfaceThread);
83 while (surfaceThread->fRunning) {
85 while (ident == ALOOPER_POLL_CALLBACK) {
86 ident = ALooper_pollOnce(0,
nullptr,
nullptr,
nullptr);
90 SkDebugf(
"Unhandled ALooper_pollOnce ident=%d !", ident);
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool read(SkStream *stream, void *buffer, size_t amount)
void postMessage(const Message &message) const
void readMessage(Message *message) const
const EmbeddedViewParams * params
sk_sp< const SkPicture > picture
std::unique_ptr< WindowContext > MakeGLForAndroid(ANativeWindow *window, const DisplayParams ¶ms)
void write(SkWStream *wStream, const T &text)
std::shared_ptr< const fml::Mapping > data