6c0f5d91e2
Reason for revert: for (int i = 0; i < loops; i++) { 54 canvas->drawPoints(SkCanvas::kLines_PointMode, PTS, fPts, paint); 68 canvas->drawLine(fStartPts[i].x(), fStartPts[i].y(), fEndPts[i].x(), fEndPts[i].y(), pai nt); This change means we index arbitrarily far into fStartPts (if loops gets big enough). Original issue's description: > Modify LineBench for drawing > > Currently we only have benchmark for lines that contains randomly generated > points. This CL modifies the benchmark which adds cases of drawing straight > lines. Also, this CL changes the call from drawPoints() to drawLines() > which measures the performance of line drawing. > > BUG=skia:5243 > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1936153002 > > Committed: https://skia.googlesource.com/skia/+/6b27a5e7292d9a18e376f0c229ec62f7b801305a TBR=bsalomon@chromium.org,robertphillips@chromium.org,robertphillips@google.com,xidachen@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:5243 Review-Url: https://codereview.chromium.org/1952063005
67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "Benchmark.h"
|
|
#include "SkBitmap.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkColorPriv.h"
|
|
#include "SkPaint.h"
|
|
#include "SkRandom.h"
|
|
#include "SkShader.h"
|
|
#include "SkString.h"
|
|
#include "SkTArray.h"
|
|
|
|
|
|
class LineBench : public Benchmark {
|
|
SkScalar fStrokeWidth;
|
|
bool fDoAA;
|
|
SkString fName;
|
|
enum {
|
|
PTS = 500,
|
|
};
|
|
SkPoint fPts[PTS];
|
|
|
|
public:
|
|
LineBench(SkScalar width, bool doAA) {
|
|
fStrokeWidth = width;
|
|
fDoAA = doAA;
|
|
fName.printf("lines_%g_%s", width, doAA ? "AA" : "BW");
|
|
|
|
SkRandom rand;
|
|
for (int i = 0; i < PTS; ++i) {
|
|
fPts[i].set(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
|
|
}
|
|
}
|
|
|
|
protected:
|
|
const char* onGetName() override {
|
|
return fName.c_str();
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
SkPaint paint;
|
|
this->setupPaint(&paint);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
paint.setAntiAlias(fDoAA);
|
|
paint.setStrokeWidth(fStrokeWidth);
|
|
|
|
for (int i = 0; i < loops; i++) {
|
|
canvas->drawPoints(SkCanvas::kLines_PointMode, PTS, fPts, paint);
|
|
}
|
|
}
|
|
|
|
private:
|
|
typedef Benchmark INHERITED;
|
|
};
|
|
|
|
DEF_BENCH(return new LineBench(0, false);)
|
|
DEF_BENCH(return new LineBench(SK_Scalar1, false);)
|
|
DEF_BENCH(return new LineBench(0, true);)
|
|
DEF_BENCH(return new LineBench(SK_Scalar1/2, true);)
|
|
DEF_BENCH(return new LineBench(SK_Scalar1, true);)
|