2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
14 * Draws full screen opaque rectangles. It is designed to test any optimizations in the GPU backend
15 * to turn such draws into clears.
17 class FSRectBench : public Benchmark {
19 FSRectBench() : fInit(false) { }
22 const char* onGetName() override { return "fullscreen_rects"; }
24 void onDelayedSetup() override {
27 static const SkScalar kMinOffset = 0;
28 static const SkScalar kMaxOffset = 100 * SK_Scalar1;
29 static const SkScalar kOffsetRange = kMaxOffset - kMinOffset;
30 for (int i = 0; i < N; ++i) {
31 fRects[i].fLeft = -kMinOffset - rand.nextUScalar1() * kOffsetRange;
32 fRects[i].fTop = -kMinOffset - rand.nextUScalar1() * kOffsetRange;
33 fRects[i].fRight = W + kMinOffset + rand.nextUScalar1() * kOffsetRange;
34 fRects[i].fBottom = H + kMinOffset + rand.nextUScalar1() * kOffsetRange;
35 fColors[i] = rand.nextU() | 0xFF000000;
41 void onDraw(int loops, SkCanvas* canvas) override {
43 for (int i = 0; i < loops; ++i) {
44 paint.setColor(fColors[i % N]);
45 canvas->drawRect(fRects[i % N], paint);
59 typedef Benchmark INHERITED;
62 DEF_BENCH(return new FSRectBench();)