47#include <initializer_list>
59 Barrier(
int threadCount) : fThreadCount(threadCount) { }
62 while (fThreadCount > 0) { }
66 std::atomic<int> fThreadCount;
71std::tuple<SkZip<const SkPackedGlyphID, const SkPoint>,
90 case GlyphAction::kAccept: {
93 acceptedBuffer[acceptedSize++] = std::make_tuple(packedID, glyphBounds.
leftTop());
96 case GlyphAction::kReject:
97 rejectedBuffer[rejectedSize++] = std::make_tuple(glyphID,
pos);
104 return {acceptedBuffer.
first(acceptedSize),
105 rejectedBuffer.
first(rejectedSize),
106 boundingRect.
rect()};
118 font.setSubpixel(
true);
119 font.setTypeface(typeface);
123 for (
int c =
' '; c <
'z'; c++) {
125 pos[c] = {30.0f * c + 30, 30.0f};
127 constexpr size_t glyphCount =
'z' -
' ';
139 for (
int tries = 0; tries < 100; tries++) {
143 auto perThread = [&](
int threadIndex) {
144 barrier.waitForAll();
147 for (
int i = 0;
i < 100;
i++) {
152 acceptedPackedGlyphIDs.
resize(glyphCount);
153 acceptedPositions.
resize(glyphCount);
154 const auto acceptedBuffer =
SkMakeZip(acceptedPackedGlyphIDs, acceptedPositions);
159 rejectedGlyphIDs.
resize(glyphCount);
160 rejectedPositions.
resize(glyphCount);
161 const auto rejectedBuffer =
SkMakeZip(rejectedGlyphIDs, rejectedPositions);
165 auto [accepted, rejected,
bounds] =
180 glyph->fAdvanceX = 10;
181 glyph->fAdvanceY = 11;
182 glyph->fLeft = -1 - uniquify;
186 glyph->fMaskFormat = SkMask::Format::kA8_Format;
194 return strike->
glyph(packedID);
199 std::vector<SkGlyph> imagesToSend;
200 std::vector<SkGlyph> pathsToSend;
201 std::vector<SkGlyph> drawablesToSend;
206 SkGlyph maskGlyph{maskPackedGlyphID};
209 static constexpr uint8_t
X = 0xff;
210 static constexpr uint8_t O = 0x00;
211 uint8_t imageData[][8] = {
222 maskGlyph.setImage(&alloc, imageData);
223 imagesToSend.emplace_back(maskGlyph);
227 SkGlyph pathGlyph{pathPackedGlyphID};
230 path.addRect(pathGlyph.rect());
231 pathGlyph.setPath(&alloc, &
path,
false);
232 pathsToSend.emplace_back(pathGlyph);
236 SkGlyph drawableGlyph{drawablePackedGlyphID};
238 class TestDrawable final :
public SkDrawable {
256 drawableGlyph.setDrawable(&alloc, drawable);
259 drawablesToSend.emplace_back(drawableGlyph);
264 auto data = writeBuffer.snapshotAsData();
static bool SkIsFinite(T x, Pack... values)
DEF_TEST(SkStrikeMultiThread, Reporter)
static std::tuple< SkZip< const SkPackedGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint >, SkRect > prepare_for_mask_drawing(StrikeForGPU *strike, SkZip< const SkGlyphID, const SkPoint > source, SkZip< SkPackedGlyphID, SkPoint > acceptedBuffer, SkZip< SkGlyphID, SkPoint > rejectedBuffer)
@ kUnknown_SkPixelGeometry
constexpr auto SkMakeZip(Ts &&... ts)
#define REPORTER_ASSERT(r, cond,...)
void drawRect(const SkRect &rect, const SkPaint &paint)
virtual SkRect onGetBounds()=0
virtual void onDraw(SkCanvas *)=0
virtual size_t onApproximateBytesUsed()
static std::unique_ptr< SkExecutor > MakeFIFOThreadPool(int threads=0, bool allowBorrowing=true)
static constexpr SkFontStyle Italic()
@ kAntiAlias
may have transparent pixels on glyph edges
skglyph::GlyphAction actionFor(skglyph::ActionType actionType) const
SkGlyphRect offset(SkScalar x, SkScalar y) const
static void SetGlyph(SkGlyph *glyph)
bool setPathHasBeenCalled() const
SkGlyphID getGlyphID() const
bool setDrawableHasBeenCalled() const
bool setImageHasBeenCalled() const
const SkPath * path() const
SkDrawable * drawable() const
const void * image() const
static const SkMatrix & I()
static SkStrikeSpec MakeMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
static SkStrikeSpec MakeWithNoDevice(const SkFont &font, const SkPaint *paint=nullptr)
std::unique_ptr< SkScalerContext > createScalerContext() const
sk_sp< SkStrike > findOrCreateStrike() const
static SkGlyph * GetGlyph(SkStrike *strike, SkPackedGlyphID packedID)
static void FlattenGlyphsByType(SkWriteBuffer &buffer, SkSpan< SkGlyph > images, SkSpan< SkGlyph > paths, SkSpan< SkGlyph > drawables)
bool mergeFromBuffer(SkReadBuffer &buffer) SK_EXCLUDES(fStrikeLock)
SkGlyph * glyph(SkGlyphDigest) SK_REQUIRES(fStrikeLock)
void batch(int N, std::function< void(int)> fn)
constexpr SkZip first(size_t n) const
void resize(size_t count)
virtual SkGlyphDigest digestFor(skglyph::ActionType, SkPackedGlyphID)=0
static constexpr uint64_t kThreadCount
Optional< SkRect > bounds
sk_sp< SkBlender > blender SkRect rect
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
font
Font Metadata and Metrics.
SkGlyphRect rect_union(SkGlyphRect, SkGlyphRect)
constexpr float y() const
constexpr float x() const
std::shared_ptr< const fml::Mapping > data