34 unsigned char* pixels;
35 atlas.GetTexDataAsAlpha8(&pixels, &
w, &
h);
43 atlas.TexID = &fontPaint;
49 ImGuiIO& io = ImGui::GetIO();
76 ImGui::DestroyContext();
80 ImGui::GetStyle().ScaleAllSizes(scaleFactor);
82 ImFontAtlas&
atlas = *ImGui::GetIO().Fonts;
85 cfg.SizePixels = 13 * scaleFactor;
86 atlas.AddFontDefault(&cfg);
90#if defined(SK_BUILD_FOR_UNIX)
91static const char* get_clipboard_text(
void*
user_data) {
93 return w->getClipboardText();
96static void set_clipboard_text(
void*
user_data,
const char*
text) {
98 w->setClipboardText(
text);
105#if defined(SK_BUILD_FOR_UNIX)
106 ImGuiIO& io = ImGui::GetIO();
107 io.ClipboardUserData = fWindow;
108 io.GetClipboardTextFn = get_clipboard_text;
109 io.SetClipboardTextFn = set_clipboard_text;
114 ImGuiIO& io = ImGui::GetIO();
115 io.MousePos.x =
static_cast<float>(
x);
116 io.MousePos.y =
static_cast<float>(
y);
118 io.MouseDown[0] =
true;
120 io.MouseDown[0] =
false;
122 return io.WantCaptureMouse;
126 ImGuiIO& io = ImGui::GetIO();
127 io.MouseWheel +=
delta;
128 return io.WantCaptureMouse;
132 intptr_t funcIndex = fSkiaWidgetFuncs.
size();
139 ImGuiIO& io = ImGui::GetIO();
141 static double previousTime = 0.0;
143 io.DeltaTime =
static_cast<float>(currentTime - previousTime);
144 previousTime = currentTime;
146 io.DisplaySize.x =
static_cast<float>(fWindow->
width());
147 io.DisplaySize.y =
static_cast<float>(fWindow->
height());
163 const ImDrawData* drawData = ImGui::GetDrawData();
168 auto canvas =
surface->getCanvas();
170 for (
int i = 0;
i < drawData->CmdListsCount; ++
i) {
171 const ImDrawList* drawList = drawData->CmdLists[
i];
175 for (
int j = 0; j < drawList->VtxBuffer.size(); ++j) {
176 const ImDrawVert& vert = drawList->VtxBuffer[j];
179 color.push_back(vert.col);
187 for (
int j = 0; j < drawList->CmdBuffer.size(); ++j) {
188 const ImDrawCmd* drawCmd = &drawList->CmdBuffer[j];
193 if (drawCmd->UserCallback) {
194 drawCmd->UserCallback(drawList, drawCmd);
196 intptr_t idIndex = (intptr_t)drawCmd->TextureId;
197 if (idIndex < fSkiaWidgetFuncs.
size()) {
202 ImDrawIdx rectIndex = drawList->IdxBuffer[indexOffset];
205 canvas->translate(tl.
fX, tl.
fY);
206 fSkiaWidgetFuncs[idIndex](canvas);
212 drawCmd->ClipRect.z, drawCmd->ClipRect.w));
214 drawList->VtxBuffer.size(),
217 drawList->IdxBuffer.begin() + indexOffset);
220 indexOffset += drawCmd->ElemCount;
225 fSkiaWidgetFuncs.
clear();
229 ImGuiIO& io = ImGui::GetIO();
231 return io.WantCaptureKeyboard;
235 ImGuiIO& io = ImGui::GetIO();
236 if (io.WantTextInput) {
237 if (c > 0 && c < 0x10000) {
238 io.AddInputCharacter(c);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static void build_ImFontAtlas(ImFontAtlas &atlas, SkPaint &fontPaint)
constexpr SkColor SK_ColorWHITE
SK_API void SkSwapRB(uint32_t *dest, const uint32_t *src, int count)
bool onMouse(int x, int y, skui::InputState state, skui::ModifierKey modifiers) override
void onAttach(sk_app::Window *window) override
void onPaint(SkSurface *) override
void onPrePaint() override
bool onMouseWheel(float delta, int x, int y, skui::ModifierKey modifiers) override
std::function< void(SkCanvas *)> SkiaWidgetFunc
void setScaleFactor(float scaleFactor)
bool onKey(skui::Key key, skui::InputState state, skui::ModifierKey modifiers) override
void skiaWidget(const ImVec2 &size, SkiaWidgetFunc func)
bool onChar(SkUnichar c, skui::ModifierKey modifiers) override
static SkMatrix Scale(SkScalar sx, SkScalar sy)
void setColor(SkColor color)
void setShader(sk_sp< SkShader > shader)
void push_back(const T &v)
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
sk_sp< const SkImage > atlas
static EGLResult< EGLContext > CreateContext(EGLDisplay display, EGLConfig config, EGLContext share=EGL_NO_CONTEXT)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SkSamplingOptions(SkFilterMode::kLinear))
@ kHome
the home key - added to match android
static SkImageInfo MakeA8(int width, int height)
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)