R=robertphillips@google.com

Review URL: https://codereview.chromium.org/21592002

git-svn-id: http://skia.googlecode.com/svn/trunk@10510 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2013-08-02 14:39:25 +00:00
Родитель fde1e7ccb4
Коммит aade2e1e19
2 изменённых файлов: 67 добавлений и 0 удалений

66
bench/FSRectBench.cpp Normal file
Просмотреть файл

@ -0,0 +1,66 @@
/*
* 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 "SkBenchmark.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRandom.h"
/**
* Draws full screen opaque rectangles. It is designed to test any optimizations in the GPU backend
* to turn such draws into clears.
*/
class FSRectBench : public SkBenchmark {
public:
FSRectBench(void* param)
: INHERITED(param)
, fInit(false) {
}
protected:
virtual const char* onGetName() SK_OVERRIDE { return "fullscreen_rects"; }
virtual void onPreDraw() SK_OVERRIDE {
if (!fInit) {
SkMWCRandom rand;
static const SkScalar kMinOffset = 0;
static const SkScalar kMaxOffset = 100 * SK_Scalar1;
static const SkScalar kOffsetRange = kMaxOffset - kMinOffset;
for (int i = 0; i < N; ++i) {
fRects[i].fLeft = -kMinOffset - SkScalarMul(rand.nextUScalar1(), kOffsetRange);
fRects[i].fTop = -kMinOffset - SkScalarMul(rand.nextUScalar1(), kOffsetRange);
fRects[i].fRight = W + kMinOffset + SkScalarMul(rand.nextUScalar1(), kOffsetRange);
fRects[i].fBottom = H + kMinOffset + SkScalarMul(rand.nextUScalar1(), kOffsetRange);
fColors[i] = rand.nextU() | 0xFF000000;
}
fInit = true;
}
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
for (int i = 0; i < N; ++i) {
paint.setColor(fColors[i]);
canvas->drawRect(fRects[i], paint);
}
}
private:
enum {
W = 640,
H = 480,
N = SkBENCHLOOP(300)
};
SkRect fRects[N];
SkColor fColors[N];
bool fInit;
typedef SkBenchmark INHERITED;
};
DEF_BENCH( return SkNEW_ARGS(FSRectBench, (p)); )

Просмотреть файл

@ -25,6 +25,7 @@
'../bench/DisplacementBench.cpp',
'../bench/FontCacheBench.cpp',
'../bench/FontScalerBench.cpp',
'../bench/FSRectBench.cpp',
'../bench/GameBench.cpp',
'../bench/GradientBench.cpp',
'../bench/GrMemoryPoolBench.cpp',