skia2/bench/WritePixelsBench.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

76 lines
2.0 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 "SkCanvas.h"
#include "SkString.h"
class WritePixelsBench : public Benchmark {
public:
WritePixelsBench(SkColorType ct, SkAlphaType at)
: fColorType(ct)
, fAlphaType(at)
, fName("writepix")
{
switch (ct) {
case kRGBA_8888_SkColorType:
fName.append("_RGBA");
break;
case kBGRA_8888_SkColorType:
fName.append("_BGRA");
break;
default:
SkASSERT(0);
break;
}
switch (at) {
case kPremul_SkAlphaType:
fName.append("_PM");
break;
case kUnpremul_SkAlphaType:
fName.append("_UPM");
break;
default:
SkASSERT(0);
break;
}
}
protected:
const char* onGetName() SK_OVERRIDE {
return fName.c_str();
}
void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkISize size = canvas->getDeviceSize();
canvas->clear(0xFFFF0000);
SkBitmap bmp;
bmp.allocN32Pixels(size.width(), size.height());
canvas->readPixels(&bmp, 0, 0);
SkImageInfo info = SkImageInfo::Make(bmp.width(), bmp.height(), fColorType, fAlphaType);
for (int loop = 0; loop < loops; ++loop) {
canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0);
}
}
private:
SkColorType fColorType;
SkAlphaType fAlphaType;
SkString fName;
typedef Benchmark INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kPremul_SkAlphaType)); )
DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kUnpremul_SkAlphaType)); )