Flutter Engine
The Flutter Engine
Functions
ImGuiLayer.cpp File Reference
#include "tools/viewer/ImGuiLayer.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkShader.h"
#include "include/core/SkSurface.h"
#include "include/core/SkSwizzle.h"
#include "include/core/SkVertices.h"
#include "include/private/base/SkTDArray.h"
#include "src/base/SkTime.h"
#include "tools/skui/InputState.h"
#include "tools/skui/Key.h"
#include <cstdint>

Go to the source code of this file.

Functions

static void build_ImFontAtlas (ImFontAtlas &atlas, SkPaint &fontPaint)
 

Function Documentation

◆ build_ImFontAtlas()

static void build_ImFontAtlas ( ImFontAtlas &  atlas,
SkPaint fontPaint 
)
static

Definition at line 32 of file ImGuiLayer.cpp.

32 {
33 int w, h;
34 unsigned char* pixels;
35 atlas.GetTexDataAsAlpha8(&pixels, &w, &h);
37 SkPixmap pmap(info, pixels, info.minRowBytes());
38 SkMatrix localMatrix = SkMatrix::Scale(1.0f / w, 1.0f / h);
39 auto fontImage = SkImages::RasterFromPixmap(pmap, nullptr, nullptr);
40 auto fontShader = fontImage->makeShader(SkSamplingOptions(SkFilterMode::kLinear), localMatrix);
41 fontPaint.setShader(fontShader);
42 fontPaint.setColor(SK_ColorWHITE);
43 atlas.TexID = &fontPaint;
44}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setShader(sk_sp< SkShader > shader)
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
SkSamplingOptions(SkFilterMode::kLinear))
SkScalar w
SkScalar h
static SkImageInfo MakeA8(int width, int height)