Revert of Modify LineBench for drawing straight line (patchset #3 id:40001 of https://codereview.chromium.org/1936153002/ )
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
This commit is contained in:
parent
6b27a5e729
commit
6c0f5d91e2
@ -21,33 +21,19 @@ class LineBench : public Benchmark {
|
||||
bool fDoAA;
|
||||
SkString fName;
|
||||
enum {
|
||||
LINES = 500,
|
||||
PTS = 500,
|
||||
};
|
||||
SkPoint fStartPts[LINES];
|
||||
SkPoint fEndPts[LINES];
|
||||
SkPoint fPts[PTS];
|
||||
|
||||
public:
|
||||
enum LineType {
|
||||
SH, // Straight + horizontally
|
||||
SV, // Straight + vertically
|
||||
RAND,
|
||||
};
|
||||
LineBench(SkScalar width, bool doAA, LineType type) {
|
||||
LineBench(SkScalar width, bool doAA) {
|
||||
fStrokeWidth = width;
|
||||
fDoAA = doAA;
|
||||
fName.printf("lines_%g_%s_%s", width, doAA ? "AA" : "BW",
|
||||
type == SH ? "SH" : (type == SV ? "SV" : "RAND"));
|
||||
fName.printf("lines_%g_%s", width, doAA ? "AA" : "BW");
|
||||
|
||||
SkRandom rand;
|
||||
for (int i = 0; i < LINES; ++i) {
|
||||
fStartPts[i].set(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
|
||||
if (type == SH) {
|
||||
fEndPts[i].set(rand.nextUScalar1() * 640, fStartPts[i].y());
|
||||
} else if (type == SV) {
|
||||
fEndPts[i].set(fStartPts[i].x(), rand.nextUScalar1() * 480);
|
||||
} else {
|
||||
fEndPts[i].set(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
|
||||
}
|
||||
for (int i = 0; i < PTS; ++i) {
|
||||
fPts[i].set(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +51,7 @@ protected:
|
||||
paint.setStrokeWidth(fStrokeWidth);
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->drawLine(fStartPts[i].x(), fStartPts[i].y(), fEndPts[i].x(), fEndPts[i].y(), paint);
|
||||
canvas->drawPoints(SkCanvas::kLines_PointMode, PTS, fPts, paint);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,21 +59,8 @@ private:
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
DEF_BENCH(return new LineBench(0, false, LineBench::SH);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1, false, LineBench::SH);)
|
||||
DEF_BENCH(return new LineBench(0, true, LineBench::SH);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1/2, true, LineBench::SH);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1, true, LineBench::SH);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1*10,true, LineBench::SH);)
|
||||
DEF_BENCH(return new LineBench(0, false, LineBench::SV);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1, false, LineBench::SV);)
|
||||
DEF_BENCH(return new LineBench(0, true, LineBench::SV);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1/2, true, LineBench::SV);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1, true, LineBench::SV);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1*10,true, LineBench::SV);)
|
||||
DEF_BENCH(return new LineBench(0, false, LineBench::RAND);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1, false, LineBench::RAND);)
|
||||
DEF_BENCH(return new LineBench(0, true, LineBench::RAND);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1/2, true, LineBench::RAND);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1, true, LineBench::RAND);)
|
||||
DEF_BENCH(return new LineBench(SK_Scalar1*10,true, LineBench::RAND);)
|
||||
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);)
|
||||
|
Loading…
Reference in New Issue
Block a user