Flutter Engine
The Flutter Engine
Functions
SlugTest.cpp File Reference
#include "include/core/SkFont.h"
#include "include/core/SkFontStyle.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTextBlob.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/chromium/Slug.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"
#include <cstdint>
#include <cstring>

Go to the source code of this file.

Functions

 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (Slug_empty, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( Slug_empty  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 33 of file SlugTest.cpp.

36 {
37 auto dContext = ctxInfo.directContext();
40 auto canvas = surface->getCanvas();
41
42 static const char* kText = " ";
43 auto typeface = ToolUtils::CreatePortableTypeface("serif", SkFontStyle());
44 SkFont font(typeface);
45 size_t txtLen = strlen(kText);
46 int glyphCount = font.countText(kText, txtLen, SkTextEncoding::kUTF8);
47
49 glyphs.append(glyphCount);
50 font.textToGlyphs(kText, txtLen, SkTextEncoding::kUTF8, glyphs.begin(), glyphCount);
51
53
54 font.setSubpixel(true);
56 font.setTypeface(typeface);
57 font.setSize(16);
58
59 const SkTextBlobBuilder::RunBuffer& buf = builder.allocRun(font, glyphs.size(), 0, 0);
60 memcpy(buf.glyphs, glyphs.begin(), glyphs.size() * sizeof(uint16_t));
61 auto blob = builder.make();
62
63 SkPaint p;
64 p.setAntiAlias(true);
65 sk_sp<sktext::gpu::Slug> slug = sktext::gpu::Slug::ConvertBlob(canvas, *blob, {10, 10}, p);
66 REPORTER_ASSERT(reporter, slug == nullptr);
67}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
reporter
Definition: FontMgrTest.cpp:39
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
Definition: SkFont.h:35
@ kAntiAlias
may have transparent pixels on glyph edges
static sk_sp< Slug > ConvertBlob(SkCanvas *canvas, const SkTextBlob &blob, SkPoint origin, const SkPaint &paint)
Definition: Slug.cpp:20
VkSurfaceKHR surface
Definition: main.cc:49
constexpr char kText[]
Definition: glyph_pos.cpp:28
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)
font
Font Metadata and Metrics.
static SkImageInfo MakeN32Premul(int width, int height)
SkGlyphID * glyphs
storage for glyph indexes in run
Definition: SkTextBlob.h:329