start to build with no paint-text fields

Bug: skia:
Change-Id: Ie425fb73d70d45c05108ecca6ce8a89e8eafc02a
Reviewed-on: https://skia-review.googlesource.com/c/181161
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-01-03 23:29:38 -05:00 committed by Skia Commit-Bot
parent fb93e61813
commit a6d1c0a13a
4 changed files with 13 additions and 9 deletions

View File

@ -8,9 +8,11 @@
#include "Benchmark.h"
#include "SkBlendModePriv.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkString.h"
#include "SkTextBlob.h"
// Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
class XfermodeBench : public Benchmark {
@ -34,12 +36,13 @@ protected:
paint.setColor(random.nextU());
if (fAA) {
// Draw text to exercise AA code paths.
paint.setAntiAlias(true);
paint.setTextSize(random.nextRangeScalar(12, 96));
SkFont font;
font.setSize(random.nextRangeScalar(12, 96));
SkScalar x = random.nextRangeScalar(0, (SkScalar)size.fWidth),
y = random.nextRangeScalar(0, (SkScalar)size.fHeight);
auto blob = SkTextBlob::MakeFromText(text, len, font, kUTF8_SkTextEncoding);
for (int j = 0; j < 1000; ++j) {
canvas->drawText(text, len, x, y, paint);
canvas->drawTextBlob(blob, x, y, paint);
}
} else {
// Draw rects to exercise non-AA code paths.

View File

@ -9,6 +9,7 @@
#include "GrContext.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
@ -79,9 +80,10 @@ void HelloWorld::onPaint(SkCanvas* canvas) {
}
// Draw a message with a nice black paint
paint.setSubpixelText(true);
SkFont font;
font.setSubpixel(true);
font.setSize(20);
paint.setColor(SK_ColorBLACK);
paint.setTextSize(20);
canvas->save();
static const char message[] = "Hello World";
@ -95,7 +97,7 @@ void HelloWorld::onPaint(SkCanvas* canvas) {
canvas->rotate(fRotationAngle);
// Draw the text
canvas->drawText(message, strlen(message), 0, 0, paint);
canvas->drawSimpleText(message, strlen(message), kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->restore();
}

View File

@ -111,6 +111,7 @@ static void init_surface(Fuzz* fuzz, sk_sp<SkSurface>* s) {
static void fuzz_drawText(Fuzz* fuzz, sk_sp<SkTypeface> typeface) {
SkFont font(typeface);
SkPaint p;
init_paint(fuzz, &p);
sk_sp<SkSurface> surface;
@ -125,10 +126,9 @@ static void fuzz_drawText(Fuzz* fuzz, sk_sp<SkTypeface> typeface) {
SkPoint pts[kPtsLen];
for (uint8_t i = 0; i < kPtsLen; ++i) {
pts[i].set(x, y);
x += p.getTextSize();
x += font.getSize();
}
SkFont font(typeface);
bool b;
fuzz->next(&b);
font.setForceAutoHinting(b);

View File

@ -28,7 +28,6 @@ public:
static void DrawString(SkCanvas* canvas, const char text[], SkScalar x, SkScalar y,
const SkFont& font, const SkPaint& paint, Align align = kLeft_Align) {
SkASSERT(paint.getTextEncoding() == kUTF8_SkTextEncoding);
Draw(canvas, text, strlen(text), kUTF8_SkTextEncoding, x, y, font, paint, align);
}