2013-03-01 15:32:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pathologically simple drawing tests, designed to generate consistent
|
|
|
|
* output images across platforms for gm/tests/run.sh
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gm.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkPaint.h"
|
|
|
|
|
|
|
|
class SelfTestGM : public skiagm::GM {
|
|
|
|
public:
|
2015-01-23 19:07:07 +00:00
|
|
|
SelfTestGM(const char name[], SkColor color) :
|
|
|
|
fName(name), fColor(color) {}
|
2013-03-01 15:32:34 +00:00
|
|
|
const static int kWidth = 300;
|
|
|
|
const static int kHeight = 200;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SkString onShortName() {
|
|
|
|
return fName;
|
|
|
|
}
|
|
|
|
|
2014-06-10 06:59:03 +00:00
|
|
|
SkISize onISize() { return SkISize::Make(kWidth, kHeight); }
|
2013-03-01 15:32:34 +00:00
|
|
|
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setStyle(SkPaint::kFill_Style);
|
|
|
|
paint.setColor(fColor);
|
|
|
|
canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeight), paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const SkString fName;
|
|
|
|
const SkColor fColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-03-02 19:56:18 +00:00
|
|
|
// We use translucent colors to make sure we are properly handling cases like
|
|
|
|
// those which caused https://code.google.com/p/skia/issues/detail?id=1079
|
|
|
|
// ('gm generating spurious pixel_error messages as of r7258')
|
|
|
|
static SkColor kTranslucentGreen = 0x7700EE00;
|
|
|
|
static SkColor kTranslucentBlue = 0x770000DD;
|
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
static skiagm::GM* F1(void*) {
|
2015-01-23 19:07:07 +00:00
|
|
|
return new SelfTestGM("selftest1", kTranslucentGreen);
|
2013-04-10 12:17:34 +00:00
|
|
|
}
|
|
|
|
static skiagm::GM* F2(void*) {
|
2015-01-23 19:07:07 +00:00
|
|
|
return new SelfTestGM("selftest2", kTranslucentBlue);
|
2013-04-10 12:17:34 +00:00
|
|
|
}
|
2013-03-01 15:32:34 +00:00
|
|
|
|
|
|
|
static skiagm::GMRegistry gR1(F1);
|
|
|
|
static skiagm::GMRegistry gR2(F2);
|