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);
44 auto winctx = skwindow::MakeGLForAndroid(
message.fNativeWindow,
params);
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) {
84 const int ident = ALooper_pollAll(0,
nullptr,
nullptr,
nullptr);
87 SkDebugf(
"Unhandled ALooper_pollAll 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
void write(SkWStream *wStream, const T &text)