skia2/bench/CoverageBench.cpp
mtklein 72c9faab45 Fix up all the easy virtual ... SK_OVERRIDE cases.
This fixes every case where virtual and SK_OVERRIDE were on the same line,
which should be the bulk of cases.  We'll have to manually clean up the rest
over time unless I level up in regexes.

for f in (find . -type f); perl -p -i -e 's/virtual (.*)SK_OVERRIDE/\1SK_OVERRIDE/g' $f; end

BUG=skia:

Review URL: https://codereview.chromium.org/806653007
2015-01-09 10:06:40 -08:00

71 lines
1.8 KiB
C++

/*
* Copyright 2013 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 "SkDraw.h"
#include "SkMatrix.h"
#include "SkPath.h"
#include "SkRasterClip.h"
class DrawPathBench : public Benchmark {
SkPaint fPaint;
SkString fName;
SkPath fPath;
SkRasterClip fRC;
SkBitmap fBitmap;
SkMatrix fIdentity;
SkDraw fDraw;
bool fDrawCoverage;
public:
DrawPathBench(bool drawCoverage) : fDrawCoverage(drawCoverage) {
fPaint.setAntiAlias(true);
fName.printf("draw_coverage_%s", drawCoverage ? "true" : "false");
fPath.moveTo(0, 0);
fPath.quadTo(500, 0, 500, 500);
fPath.quadTo(250, 0, 0, 500);
fBitmap.allocPixels(SkImageInfo::MakeA8(500, 500));
fIdentity.setIdentity();
fRC.setRect(fPath.getBounds().round());
fDraw.fBitmap = &fBitmap;
fDraw.fMatrix = &fIdentity;
fDraw.fClip = &fRC.bwRgn();
fDraw.fRC = &fRC;
}
protected:
const char* onGetName() SK_OVERRIDE {
return fName.c_str();
}
void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
if (fDrawCoverage) {
for (int i = 0; i < loops; ++i) {
fDraw.drawPathCoverage(fPath, fPaint);
}
} else {
for (int i = 0; i < loops; ++i) {
fDraw.drawPath(fPath, fPaint);
}
}
}
private:
typedef Benchmark INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
DEF_BENCH( return new DrawPathBench(false) )
DEF_BENCH( return new DrawPathBench(true) )