1aea903381
Added changes for public.bzl
This is a reland of commit 4a375fe213
Original change's description:
> Move SkSubRun to src/text
>
> Change-Id: I5c1040b8236dc792de20495a3fea3c0be6e31c20
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549847
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>
Change-Id: I86e342a416a3c97bf972c496b93b37e35cd09c19
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550496
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
/*
|
|
* Copyright 2018 The Android Open Source Project
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "src/text/GlyphRun.h"
|
|
|
|
#include "include/core/SkTextBlob.h"
|
|
#include "tests/Test.h"
|
|
|
|
#include <algorithm>
|
|
#include <memory>
|
|
|
|
|
|
#if 0 // should we revitalize this by consing up a device for drawTextBlob() ?
|
|
DEF_TEST(GlyphRunBlob, reporter) {
|
|
constexpr uint16_t count = 5;
|
|
constexpr int runCount = 2;
|
|
|
|
auto tf = SkTypeface::MakeFromName("monospace", SkFontStyle());
|
|
|
|
SkFont font;
|
|
font.setTypeface(tf);
|
|
font.setHinting(SkFontHinting::kNormal);
|
|
font.setSize(1u);
|
|
|
|
SkTextBlobBuilder blobBuilder;
|
|
for (int runNum = 0; runNum < runCount; runNum++) {
|
|
const auto& runBuffer = blobBuilder.allocRunPosH(font, count, runNum);
|
|
SkASSERT(runBuffer.utf8text == nullptr);
|
|
SkASSERT(runBuffer.clusters == nullptr);
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
runBuffer.glyphs[i] = static_cast<SkGlyphID>(i + runNum * count);
|
|
runBuffer.pos[i] = SkIntToScalar(i + runNum * count);
|
|
}
|
|
}
|
|
|
|
auto blob = blobBuilder.make();
|
|
|
|
sktext::GlyphRunBuilder runBuilder;
|
|
SkPaint legacy_paint;
|
|
font.LEGACY_applyToPaint(&legacy_paint);
|
|
runBuilder.drawTextBlob(legacy_paint, *blob, SkPoint::Make(0, 0));
|
|
|
|
auto runList = runBuilder.useGlyphRunList();
|
|
|
|
REPORTER_ASSERT(reporter, runList.size() == runCount);
|
|
int runIndex = 0;
|
|
for (auto& run : runList) {
|
|
REPORTER_ASSERT(reporter, run.runSize() == count);
|
|
|
|
int index = 0;
|
|
for (auto p : run.positions()) {
|
|
if (p.x() != runIndex * count + index) {
|
|
ERRORF(reporter, "x: %g != k: %d", p.x(), runIndex * count + index);
|
|
break;
|
|
}
|
|
index += 1;
|
|
}
|
|
|
|
runIndex += 1;
|
|
}
|
|
}
|
|
#endif
|