1c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org/*
2c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org * Copyright 2013 Google Inc.
3c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org *
4c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be
5c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org * found in the LICENSE file.
6c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org */
7c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
8c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org/**
9c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org * Pathologically simple drawing tests, designed to generate consistent
10c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org * output images across platforms for gm/tests/run.sh
11c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org */
12c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
13c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org#include "gm.h"
14c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org#include "SkCanvas.h"
15c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org#include "SkPaint.h"
16c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
17c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.orgclass SelfTestGM : public skiagm::GM {
18c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.orgpublic:
191c4029296f518a84ef90095243ba210163a1e1f9mtklein    SelfTestGM(const char name[], SkColor color) :
201c4029296f518a84ef90095243ba210163a1e1f9mtklein        fName(name), fColor(color) {}
21c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    const static int kWidth = 300;
22c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    const static int kHeight = 200;
23c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
24c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.orgprotected:
25c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    SkString onShortName() {
26c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org        return fName;
27c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    }
28c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
29f539318f0d3dba743ec1886d5d9df0fb1be628a1tfarina    SkISize onISize() { return SkISize::Make(kWidth, kHeight); }
30c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
31c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    virtual void onDraw(SkCanvas* canvas) {
32c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org        SkPaint paint;
33c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org        paint.setStyle(SkPaint::kFill_Style);
34c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org        paint.setColor(fColor);
35c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org        canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeight), paint);
36c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    }
37c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
38c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.orgprivate:
39c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    const SkString fName;
40c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org    const SkColor fColor;
41c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org};
42c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
43c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org//////////////////////////////////////////////////////////////////////////////
44c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
45b9ba1eadc839fb346a5bcf5f7a38b775e1069586epoger@google.com// We use translucent colors to make sure we are properly handling cases like
46b9ba1eadc839fb346a5bcf5f7a38b775e1069586epoger@google.com// those which caused https://code.google.com/p/skia/issues/detail?id=1079
47b9ba1eadc839fb346a5bcf5f7a38b775e1069586epoger@google.com// ('gm generating spurious pixel_error messages as of r7258')
48b9ba1eadc839fb346a5bcf5f7a38b775e1069586epoger@google.comstatic SkColor kTranslucentGreen = 0x7700EE00;
49b9ba1eadc839fb346a5bcf5f7a38b775e1069586epoger@google.comstatic SkColor kTranslucentBlue  = 0x770000DD;
50b9ba1eadc839fb346a5bcf5f7a38b775e1069586epoger@google.com
51c8263e704135436f71a585801966294d6deadeebepoger@google.comstatic skiagm::GM* F1(void*) {
521c4029296f518a84ef90095243ba210163a1e1f9mtklein    return new SelfTestGM("selftest1", kTranslucentGreen);
53c8263e704135436f71a585801966294d6deadeebepoger@google.com}
54c8263e704135436f71a585801966294d6deadeebepoger@google.comstatic skiagm::GM* F2(void*) {
551c4029296f518a84ef90095243ba210163a1e1f9mtklein    return new SelfTestGM("selftest2", kTranslucentBlue);
56c8263e704135436f71a585801966294d6deadeebepoger@google.com}
57c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.org
58c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.orgstatic skiagm::GMRegistry gR1(F1);
59c61c3c310185f6ffaefce194a079159423945191commit-bot@chromium.orgstatic skiagm::GMRegistry gR2(F2);
60