2016-08-18 22:01:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkScalar.h"
|
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/utils/SkRandom.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/ToolUtils.h"
|
2016-08-18 22:01:10 +00:00
|
|
|
|
2019-05-01 21:28:53 +00:00
|
|
|
class AnimTimer;
|
|
|
|
|
2016-08-18 22:01:10 +00:00
|
|
|
class SimpleRectGM : public skiagm::GM {
|
|
|
|
public:
|
|
|
|
SimpleRectGM() {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SkString onShortName() override {
|
|
|
|
SkString name;
|
|
|
|
name.printf("simplerect");
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkISize onISize() override {
|
2016-08-19 02:35:52 +00:00
|
|
|
return SkISize::Make(800, 800);
|
2016-08-18 22:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2016-08-21 22:03:47 +00:00
|
|
|
canvas->translate(1, 1); // want to exercise non-identity ctm performance
|
|
|
|
|
2016-08-18 22:01:10 +00:00
|
|
|
const SkScalar min = -20;
|
|
|
|
const SkScalar max = 800;
|
|
|
|
const SkScalar size = 20;
|
|
|
|
|
|
|
|
SkRandom rand;
|
|
|
|
SkPaint paint;
|
|
|
|
for (int i = 0; i < 10000; i++) {
|
2019-03-20 16:12:10 +00:00
|
|
|
paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
|
2016-08-19 02:35:52 +00:00
|
|
|
SkScalar x = rand.nextRangeScalar(min, max);
|
|
|
|
SkScalar y = rand.nextRangeScalar(min, max);
|
|
|
|
SkScalar w = rand.nextRangeScalar(0, size);
|
|
|
|
SkScalar h = rand.nextRangeScalar(0, size);
|
|
|
|
canvas->drawRect(SkRect::MakeXYWH(x, y, w, h), paint);
|
2016-08-18 22:01:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:55:08 +00:00
|
|
|
bool onAnimate(const AnimTimer& timer) override { return true; }
|
2016-08-18 22:01:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
typedef GM INHERITED;
|
|
|
|
};
|
|
|
|
DEF_GM(return new SimpleRectGM;)
|