Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
surface.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SKWASM_SURFACE_H_
6#define FLUTTER_SKWASM_SURFACE_H_
7
8#include <cassert>
9
10#include <GLES2/gl2.h>
11#include <GLES2/gl2ext.h>
12#include <emscripten.h>
13#include <emscripten/html5_webgl.h>
14#include <emscripten/threading.h>
15#include <webgl/webgl1.h>
16
21#include "third_party/skia/include/core/SkData.h"
22#include "third_party/skia/include/core/SkRefCnt.h"
23
24namespace flutter {
25class DisplayList;
26}
27
28namespace Skwasm {
29
31 public:
32 TextureSourceWrapper(unsigned long thread_id, SkwasmObject texture_source);
34
36
37 private:
38 unsigned long raster_thread_id_;
39};
40
41class Surface {
42 public:
43 using CallbackHandler = void(uint32_t, void*, SkwasmObject);
44
45 // Main thread only
46 Surface();
47
48 unsigned long GetThreadId() { return thread_; }
49
50 // Main thread only
51 void Dispose();
52 void SetResourceCacheLimit(int bytes);
53 uint32_t RenderPictures(flutter::DisplayList** pictures,
54 int width,
55 int height,
56 int count);
59 void OnRenderComplete(uint32_t callback_id, SkwasmObject image_bitmap);
60 void OnRasterizeComplete(uint32_t callback_id, SkData* data);
61
62 // Any thread
63 std::unique_ptr<TextureSourceWrapper> CreateTextureSourceWrapper(
64 SkwasmObject texture_source);
65
66 // Worker thread
67 void RenderPicturesOnWorker(sk_sp<flutter::DisplayList>* pictures,
68 int width,
69 int height,
70 int picture_count,
71 uint32_t callback_id,
72 double raster_start);
74 ImageByteFormat format,
75 uint32_t callback_id);
76
77 private:
78 void Init();
79 void ResizeSurface(int width, int height);
80 void RecreateSurface();
81
82 CallbackHandler* callback_handler_ = nullptr;
83 uint32_t current_callback_id_ = 0;
84
85 int canvas_width_ = 0;
86 int canvas_height_ = 0;
87
88 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE gl_context_ = 0;
89 std::unique_ptr<RenderContext> render_context_;
90 unsigned long thread_;
91
92 bool is_initialized_ = false;
93};
94} // namespace Skwasm
95
96#endif // FLUTTER_SKWASM_SURFACE_H_
uint32_t RenderPictures(flutter::DisplayList **pictures, int width, int height, int count)
Definition surface.cc:45
unsigned long GetThreadId()
Definition surface.h:48
std::unique_ptr< TextureSourceWrapper > CreateTextureSourceWrapper(SkwasmObject texture_source)
Definition surface.cc:76
void RenderPicturesOnWorker(sk_sp< flutter::DisplayList > *pictures, int width, int height, int picture_count, uint32_t callback_id, double raster_start)
Definition surface.cc:137
void RasterizeImageOnWorker(flutter::DlImage *image, ImageByteFormat format, uint32_t callback_id)
Definition surface.cc:166
void(uint32_t, void *, SkwasmObject) CallbackHandler
Definition surface.h:43
uint32_t RasterizeImage(flutter::DlImage *image, ImageByteFormat format)
Definition surface.cc:65
void OnRenderComplete(uint32_t callback_id, SkwasmObject image_bitmap)
Definition surface.cc:211
void OnRasterizeComplete(uint32_t callback_id, SkData *data)
Definition surface.cc:206
void Dispose()
Definition surface.cc:35
void SetCallbackHandler(CallbackHandler *callback_handler)
Definition surface.cc:83
void SetResourceCacheLimit(int bytes)
Definition surface.cc:40
SkwasmObject GetTextureSource()
Definition surface.cc:228
Represents an image whose allocation is (usually) resident on device memory.
Definition dl_image.h:32
FlutterVulkanImage * image
CallbackHandler callback_handler
__externref_t SkwasmObject
Definition wrappers.h:18
ImageByteFormat
Definition helpers.h:75
flutter::DisplayList DisplayList
int32_t height
int32_t width
std::shared_ptr< const fml::Mapping > data