Revert "use SkShaper instead of SkTextBox"
This reverts commit 59dad91117
.
Reason for revert: Possibly breaks Build-Win-Clang-arm64-Release-Android
Original change's description:
> use SkShaper instead of SkTextBox
>
> Change-Id: I63fae79007938cb89c122799b8984a88e91ac1e7
> Reviewed-on: https://skia-review.googlesource.com/102863
> Commit-Queue: Hal Canary <halcanary@google.com>
> Reviewed-by: Hal Canary <halcanary@google.com>
> Reviewed-by: Ben Wagner <bungeman@google.com>
TBR=halcanary@google.com,bungeman@google.com,fmalita@chromium.org,reed@google.com
Change-Id: Id865d9e9cce03b4166f818c2bad659bdecc4f447
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/105941
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
This commit is contained in:
parent
18c46b553a
commit
efcacfa8a8
21
BUILD.gn
21
BUILD.gn
@ -1499,7 +1499,6 @@ if (skia_enable_tools) {
|
||||
":experimental_svg_model",
|
||||
":flags",
|
||||
":gm",
|
||||
":skshaper",
|
||||
":tool_utils",
|
||||
":views",
|
||||
":xml",
|
||||
@ -1610,21 +1609,15 @@ if (skia_enable_tools) {
|
||||
}
|
||||
}
|
||||
|
||||
test_lib("skshaper") {
|
||||
public_include_dirs = [ "tools/shape" ]
|
||||
deps = [
|
||||
":skia",
|
||||
]
|
||||
# TODO(halcanary): Build ICU on iOS.
|
||||
if (is_ios || target_cpu == "wasm") {
|
||||
sources = [
|
||||
"tools/shape/SkShaper_primitive.cpp",
|
||||
]
|
||||
} else {
|
||||
# TODO(halcanary): Build ICU on iOS.
|
||||
if (!is_ios && target_cpu != "wasm") {
|
||||
test_app("sktexttopdf-hb") {
|
||||
sources = [
|
||||
"tools/shape/SkShaper_harfbuzz.cpp",
|
||||
"tools/shape/using_skia_and_harfbuzz.cpp",
|
||||
]
|
||||
deps += [
|
||||
deps = [
|
||||
":skia",
|
||||
"//third_party/harfbuzz",
|
||||
"//third_party/icu",
|
||||
]
|
||||
@ -1632,11 +1625,11 @@ if (skia_enable_tools) {
|
||||
}
|
||||
test_app("sktexttopdf") {
|
||||
sources = [
|
||||
"tools/shape/SkShaper_primitive.cpp",
|
||||
"tools/shape/using_skia_and_harfbuzz.cpp",
|
||||
]
|
||||
deps = [
|
||||
":skia",
|
||||
":skshaper",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -5,26 +5,24 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
|
||||
#include "SkView.h"
|
||||
#include "SkBlurMaskFilter.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkColorShader.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkOSFile.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRandom.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkShaper.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkTime.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
#include "SkTextBox.h"
|
||||
#include "SkOSFile.h"
|
||||
#include "SkStream.h"
|
||||
|
||||
extern void skia_set_text_gamma(float blackGamma, float whiteGamma);
|
||||
|
||||
@ -59,7 +57,7 @@ public:
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "TextBox");
|
||||
return true;
|
||||
@ -72,28 +70,27 @@ protected:
|
||||
|
||||
canvas->clipRect(SkRect::MakeWH(w, h));
|
||||
canvas->drawColor(bg);
|
||||
|
||||
SkShaper shaper(nullptr);
|
||||
|
||||
SkScalar margin = 20;
|
||||
SkTextBox tbox;
|
||||
tbox.setMode(SkTextBox::kLineBreak_Mode);
|
||||
tbox.setBox(margin, margin,
|
||||
w - margin, h - margin);
|
||||
tbox.setSpacing(SkIntToScalar(3)/3, 0);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setLCDRenderText(true);
|
||||
paint.setColor(fg);
|
||||
tbox.setText(gText, strlen(gText), paint);
|
||||
|
||||
for (int i = 9; i < 24; i += 2) {
|
||||
SkTextBlobBuilder builder;
|
||||
paint.setTextSize(SkIntToScalar(i));
|
||||
SkPoint end = shaper.shape(&builder, paint, gText, strlen(gText), true,
|
||||
{ margin, margin }, w - margin);
|
||||
canvas->drawTextBlob(builder.make(), 0, 0, paint);
|
||||
|
||||
canvas->translate(0, end.y());
|
||||
tbox.draw(canvas);
|
||||
canvas->translate(0, tbox.getTextHeight() + paint.getFontSpacing());
|
||||
}
|
||||
}
|
||||
|
||||
void onDrawContent(SkCanvas* canvas) override {
|
||||
virtual void onDrawContent(SkCanvas* canvas) {
|
||||
SkScalar width = this->width() / 3;
|
||||
drawTest(canvas, width, this->height(), SK_ColorBLACK, SK_ColorWHITE);
|
||||
canvas->translate(width, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user