blob: 332a0cd27503849d3eb88ede816d81a53076568c [file] [log] [blame]
commit-bot@chromium.orgc61c3c32013-03-01 15:32:34 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8/**
9 * Pathologically simple drawing tests, designed to generate consistent
10 * output images across platforms for gm/tests/run.sh
11 */
12
13#include "gm.h"
14#include "SkCanvas.h"
15#include "SkPaint.h"
16
17class SelfTestGM : public skiagm::GM {
18public:
mtklein1c402922015-01-23 11:07:07 -080019 SelfTestGM(const char name[], SkColor color) :
20 fName(name), fColor(color) {}
commit-bot@chromium.orgc61c3c32013-03-01 15:32:34 +000021 const static int kWidth = 300;
22 const static int kHeight = 200;
23
24protected:
25 SkString onShortName() {
26 return fName;
27 }
28
tfarinaf5393182014-06-09 23:59:03 -070029 SkISize onISize() { return SkISize::Make(kWidth, kHeight); }
commit-bot@chromium.orgc61c3c32013-03-01 15:32:34 +000030
31 virtual void onDraw(SkCanvas* canvas) {
32 SkPaint paint;
33 paint.setStyle(SkPaint::kFill_Style);
34 paint.setColor(fColor);
35 canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeight), paint);
36 }
37
38private:
39 const SkString fName;
40 const SkColor fColor;
41};
42
43//////////////////////////////////////////////////////////////////////////////
44
epoger@google.comb9ba1ea2013-03-02 19:56:18 +000045// We use translucent colors to make sure we are properly handling cases like
46// those which caused https://code.google.com/p/skia/issues/detail?id=1079
47// ('gm generating spurious pixel_error messages as of r7258')
48static SkColor kTranslucentGreen = 0x7700EE00;
49static SkColor kTranslucentBlue = 0x770000DD;
50
epoger@google.comc8263e72013-04-10 12:17:34 +000051static skiagm::GM* F1(void*) {
mtklein1c402922015-01-23 11:07:07 -080052 return new SelfTestGM("selftest1", kTranslucentGreen);
epoger@google.comc8263e72013-04-10 12:17:34 +000053}
54static skiagm::GM* F2(void*) {
mtklein1c402922015-01-23 11:07:07 -080055 return new SelfTestGM("selftest2", kTranslucentBlue);
epoger@google.comc8263e72013-04-10 12:17:34 +000056}
commit-bot@chromium.orgc61c3c32013-03-01 15:32:34 +000057
58static skiagm::GMRegistry gR1(F1);
59static skiagm::GMRegistry gR2(F2);