Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
surface.cc File Reference
#include "flutter/skwasm/surface.h"
#include <algorithm>
#include <emscripten/wasm_worker.h>
#include "flutter/display_list/display_list.h"
#include "flutter/display_list/image/dl_image.h"
#include "flutter/skwasm/live_objects.h"
#include "flutter/skwasm/skwasm_support.h"
#include "third_party/skia/include/core/SkColorSpace.h"

Go to the source code of this file.

Functions

SKWASM_EXPORT Skwasm::Surfacesurface_create ()
 
SKWASM_EXPORT uint32_t surface_setCanvas (Skwasm::Surface *surface, SkwasmObject canvas)
 
SKWASM_EXPORT void surface_receiveCanvasOnWorker (Skwasm::Surface *surface, SkwasmObject canvas, uint32_t callback_id)
 
SKWASM_EXPORT void surface_onInitialized (Skwasm::Surface *surface, uint32_t callback_id)
 
SKWASM_EXPORT uint32_t surface_setSize (Skwasm::Surface *surface, int width, int height)
 
SKWASM_EXPORT void surface_resizeOnWorker (Skwasm::Surface *surface, int width, int height, uint32_t callback_id)
 
SKWASM_EXPORT void surface_onResizeComplete (Skwasm::Surface *surface, uint32_t callback_id)
 
SKWASM_EXPORT unsigned long surface_getThreadId (Skwasm::Surface *surface)
 
SKWASM_EXPORT EMSCRIPTEN_WEBGL_CONTEXT_HANDLE surface_getGlContext (Skwasm::Surface *surface)
 
SKWASM_EXPORT uint32_t surface_triggerContextLoss (Skwasm::Surface *surface)
 
SKWASM_EXPORT void surface_triggerContextLossOnWorker (Skwasm::Surface *surface, uint32_t callback_id)
 
SKWASM_EXPORT void surface_onContextLossTriggered (Skwasm::Surface *surface, uint32_t callback_id)
 
SKWASM_EXPORT void surface_reportContextLost (Skwasm::Surface *surface, uint32_t callback_id)
 
SKWASM_EXPORT void surface_setCallbackHandler (Skwasm::Surface *surface, Skwasm::Surface::CallbackHandler *callback_handler)
 
SKWASM_EXPORT void surface_destroy (Skwasm::Surface *surface)
 
SKWASM_EXPORT void surface_dispose (Skwasm::Surface *surface)
 
SKWASM_EXPORT void surface_setResourceCacheLimitBytes (Skwasm::Surface *surface, int bytes)
 
SKWASM_EXPORT uint32_t surface_renderPictures (Skwasm::Surface *surface, flutter::DisplayList **pictures, int count)
 
SKWASM_EXPORT void surface_renderPicturesOnWorker (Skwasm::Surface *surface, sk_sp< flutter::DisplayList > *pictures, int picture_count, uint32_t callback_id, double raster_start)
 
SKWASM_EXPORT uint32_t surface_rasterizeImage (Skwasm::Surface *surface, flutter::DlImage *image, Skwasm::ImageByteFormat format)
 
SKWASM_EXPORT void surface_rasterizeImageOnWorker (Skwasm::Surface *surface, flutter::DlImage *image, Skwasm::ImageByteFormat format, uint32_t callback_id)
 
SKWASM_EXPORT void surface_onRenderComplete (Skwasm::Surface *surface, uint32_t callback_id, SkwasmObject image_bitmap)
 
SKWASM_EXPORT void surface_onRasterizeComplete (Skwasm::Surface *surface, SkData *data, uint32_t callback_id)
 
SKWASM_EXPORT void surface_onContextLost (Skwasm::Surface *surface)
 
SKWASM_EXPORT bool skwasm_isMultiThreaded ()
 

Function Documentation

◆ skwasm_isMultiThreaded()

SKWASM_EXPORT bool skwasm_isMultiThreaded ( )

Definition at line 466 of file surface.cc.

466 {
467 return !skwasm_isSingleThreaded();
468}
bool skwasm_isSingleThreaded()

References skwasm_isSingleThreaded().

◆ surface_create()

SKWASM_EXPORT Skwasm::Surface * surface_create ( )

Definition at line 325 of file surface.cc.

325 {
327 return new Skwasm::Surface();
328}
uint32_t live_surface_count

References Skwasm::live_surface_count.

◆ surface_destroy()

SKWASM_EXPORT void surface_destroy ( Skwasm::Surface surface)

Definition at line 399 of file surface.cc.

399 {
401 // Dispatch to the worker
402 skwasm_dispatchDisposeSurface(surface->GetThreadId(), surface);
403}
VkSurfaceKHR surface
Definition main.cc:65
void skwasm_dispatchDisposeSurface(unsigned long thread_id, Skwasm::Surface *surface)

References Skwasm::live_surface_count, skwasm_dispatchDisposeSurface(), and surface.

◆ surface_dispose()

SKWASM_EXPORT void surface_dispose ( Skwasm::Surface surface)

Definition at line 405 of file surface.cc.

405 {
406 // This should be called directly only on the worker
407 surface->Dispose();
408}

References surface.

◆ surface_getGlContext()

SKWASM_EXPORT EMSCRIPTEN_WEBGL_CONTEXT_HANDLE surface_getGlContext ( Skwasm::Surface surface)

Definition at line 370 of file surface.cc.

370 {
371 return surface->GetGlContext();
372}

References surface.

◆ surface_getThreadId()

SKWASM_EXPORT unsigned long surface_getThreadId ( Skwasm::Surface surface)

Definition at line 365 of file surface.cc.

365 {
366 return surface->GetThreadId();
367}

References surface.

◆ surface_onContextLossTriggered()

SKWASM_EXPORT void surface_onContextLossTriggered ( Skwasm::Surface surface,
uint32_t  callback_id 
)

Definition at line 383 of file surface.cc.

384 {
385 surface->OnContextLossTriggered(callback_id);
386}

References surface.

◆ surface_onContextLost()

SKWASM_EXPORT void surface_onContextLost ( Skwasm::Surface surface)

Definition at line 462 of file surface.cc.

462 {
463 surface->OnContextLost();
464}

References surface.

◆ surface_onInitialized()

SKWASM_EXPORT void surface_onInitialized ( Skwasm::Surface surface,
uint32_t  callback_id 
)

Definition at line 342 of file surface.cc.

343 {
344 surface->OnInitialized(callback_id);
345}

References surface.

◆ surface_onRasterizeComplete()

SKWASM_EXPORT void surface_onRasterizeComplete ( Skwasm::Surface surface,
SkData *  data,
uint32_t  callback_id 
)

Definition at line 456 of file surface.cc.

458 {
459 surface->OnRasterizeComplete(callback_id, data);
460}
std::shared_ptr< const fml::Mapping > data

References data, and surface.

◆ surface_onRenderComplete()

SKWASM_EXPORT void surface_onRenderComplete ( Skwasm::Surface surface,
uint32_t  callback_id,
SkwasmObject  image_bitmap 
)

Definition at line 450 of file surface.cc.

452 {
453 surface->OnRenderComplete(callback_id, image_bitmap);
454}

References surface.

◆ surface_onResizeComplete()

SKWASM_EXPORT void surface_onResizeComplete ( Skwasm::Surface surface,
uint32_t  callback_id 
)

Definition at line 360 of file surface.cc.

361 {
362 surface->OnResizeComplete(callback_id);
363}

References surface.

◆ surface_rasterizeImage()

SKWASM_EXPORT uint32_t surface_rasterizeImage ( Skwasm::Surface surface,
flutter::DlImage image,
Skwasm::ImageByteFormat  format 
)

Definition at line 434 of file surface.cc.

436 {
437 return surface->RasterizeImage(image, format);
438}
FlutterVulkanImage * image

References format, image, and surface.

◆ surface_rasterizeImageOnWorker()

SKWASM_EXPORT void surface_rasterizeImageOnWorker ( Skwasm::Surface surface,
flutter::DlImage image,
Skwasm::ImageByteFormat  format,
uint32_t  callback_id 
)

Definition at line 440 of file surface.cc.

444 {
445 surface->RasterizeImageOnWorker(image, format, callback_id);
446}

References format, image, and surface.

◆ surface_receiveCanvasOnWorker()

SKWASM_EXPORT void surface_receiveCanvasOnWorker ( Skwasm::Surface surface,
SkwasmObject  canvas,
uint32_t  callback_id 
)

Definition at line 336 of file surface.cc.

338 {
339 surface->ReceiveCanvasOnWorker(canvas, callback_id);
340}

References surface.

◆ surface_renderPictures()

SKWASM_EXPORT uint32_t surface_renderPictures ( Skwasm::Surface surface,
flutter::DisplayList **  pictures,
int  count 
)

Definition at line 415 of file surface.cc.

417 {
418 return surface->RenderPictures(pictures, count);
419}

References surface.

◆ surface_renderPicturesOnWorker()

SKWASM_EXPORT void surface_renderPicturesOnWorker ( Skwasm::Surface surface,
sk_sp< flutter::DisplayList > *  pictures,
int  picture_count,
uint32_t  callback_id,
double  raster_start 
)

Definition at line 421 of file surface.cc.

426 {
427 // This will release the pictures when they leave scope.
428 std::unique_ptr<sk_sp<flutter::DisplayList>[]> pictures_pointer =
429 std::unique_ptr<sk_sp<flutter::DisplayList>[]>(pictures);
430 surface->RenderPicturesOnWorker(pictures, picture_count, callback_id,
431 raster_start);
432}

References surface.

◆ surface_reportContextLost()

SKWASM_EXPORT void surface_reportContextLost ( Skwasm::Surface surface,
uint32_t  callback_id 
)

Definition at line 388 of file surface.cc.

389 {
390 surface->ReportContextLost(callback_id);
391}

References surface.

◆ surface_resizeOnWorker()

SKWASM_EXPORT void surface_resizeOnWorker ( Skwasm::Surface surface,
int  width,
int  height,
uint32_t  callback_id 
)

Definition at line 353 of file surface.cc.

356 {
357 surface->ResizeOnWorker(width, height, callback_id);
358}
int32_t height
int32_t width

References height, surface, and width.

◆ surface_setCallbackHandler()

SKWASM_EXPORT void surface_setCallbackHandler ( Skwasm::Surface surface,
Skwasm::Surface::CallbackHandler callback_handler 
)

Definition at line 393 of file surface.cc.

395 {
396 surface->SetCallbackHandler(callback_handler);
397}
CallbackHandler callback_handler

References callback_handler, and surface.

◆ surface_setCanvas()

SKWASM_EXPORT uint32_t surface_setCanvas ( Skwasm::Surface surface,
SkwasmObject  canvas 
)

Definition at line 330 of file surface.cc.

331 {
332 // Dispatch to the worker so the canvas can be transferred to the worker.
333 return surface->SetCanvas(canvas);
334}

References surface.

◆ surface_setResourceCacheLimitBytes()

SKWASM_EXPORT void surface_setResourceCacheLimitBytes ( Skwasm::Surface surface,
int  bytes 
)

Definition at line 410 of file surface.cc.

411 {
412 surface->SetResourceCacheLimit(bytes);
413}

References surface.

◆ surface_setSize()

SKWASM_EXPORT uint32_t surface_setSize ( Skwasm::Surface surface,
int  width,
int  height 
)

Definition at line 347 of file surface.cc.

349 {
350 return surface->SetSize(width, height);
351}

References height, surface, and width.

◆ surface_triggerContextLoss()

SKWASM_EXPORT uint32_t surface_triggerContextLoss ( Skwasm::Surface surface)

Definition at line 374 of file surface.cc.

374 {
375 return surface->TriggerContextLoss();
376}

References surface.

◆ surface_triggerContextLossOnWorker()

SKWASM_EXPORT void surface_triggerContextLossOnWorker ( Skwasm::Surface surface,
uint32_t  callback_id 
)

Definition at line 378 of file surface.cc.

379 {
380 surface->TriggerContextLossOnWorker(callback_id);
381}

References surface.