blob: 812d47512f872b8f398be2fd52890c7e3a147d05 [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:
19 SelfTestGM(const char name[], SkColor color) : fName(name), fColor(color) {}
20 const static int kWidth = 300;
21 const static int kHeight = 200;
22
23protected:
24 SkString onShortName() {
25 return fName;
26 }
27
28 SkISize onISize() { return skiagm::make_isize(kWidth, kHeight); }
29
30 virtual void onDraw(SkCanvas* canvas) {
31 SkPaint paint;
32 paint.setStyle(SkPaint::kFill_Style);
33 paint.setColor(fColor);
34 canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeight), paint);
35 }
36
37private:
38 const SkString fName;
39 const SkColor fColor;
40};
41
42//////////////////////////////////////////////////////////////////////////////
43
epoger@google.comb9ba1ea2013-03-02 19:56:18 +000044// We use translucent colors to make sure we are properly handling cases like
45// those which caused https://code.google.com/p/skia/issues/detail?id=1079
46// ('gm generating spurious pixel_error messages as of r7258')
47static SkColor kTranslucentGreen = 0x7700EE00;
48static SkColor kTranslucentBlue = 0x770000DD;
49
50static skiagm::GM* F1(void*) { return new SelfTestGM("selftest1", kTranslucentGreen); }
51static skiagm::GM* F2(void*) { return new SelfTestGM("selftest2", kTranslucentBlue); }
commit-bot@chromium.orgc61c3c32013-03-01 15:32:34 +000052
53static skiagm::GMRegistry gR1(F1);
54static skiagm::GMRegistry gR2(F2);