1/* 2 * Copyright 2015 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#include "gm.h" 9#include "SkCanvas.h" 10#include "SkPath.h" 11#include "SkTArray.h" 12 13namespace skiagm { 14 15// this GM tests hairlines which fill nearly the entire render target 16class StLouisArchGM : public GM { 17protected: 18 SkString onShortName() override { 19 return SkString("stlouisarch"); 20 } 21 22 SkISize onISize() override { return SkISize::Make((int)kWidth, (int)kHeight); } 23 24 void onOnceBeforeDraw() override { 25 { 26 SkPath* bigQuad = &fPaths.push_back(); 27 bigQuad->moveTo(0, 0); 28 bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0); 29 } 30 31 { 32 SkPath* degenBigQuad = &fPaths.push_back(); 33 SkScalar yPos = kHeight / 2 + 10; 34 degenBigQuad->moveTo(0, yPos); 35 degenBigQuad->quadTo(0, yPos, kWidth, yPos); 36 } 37 38 39 { 40 SkPath* bigCubic = &fPaths.push_back(); 41 bigCubic->moveTo(0, 0); 42 bigCubic->cubicTo(0, kHeight, 43 kWidth, kHeight, 44 kWidth, 0); 45 } 46 47 { 48 SkPath* degenBigCubic = &fPaths.push_back(); 49 SkScalar yPos = kHeight / 2; 50 degenBigCubic->moveTo(0, yPos); 51 degenBigCubic->cubicTo(0, yPos, 52 0, yPos, 53 kWidth, yPos); 54 } 55 56 { 57 SkPath* bigConic = &fPaths.push_back(); 58 bigConic->moveTo(0, 0); 59 bigConic->conicTo(kWidth/2, kHeight, kWidth, 0, .5); 60 } 61 62 { 63 SkPath* degenBigConic = &fPaths.push_back(); 64 SkScalar yPos = kHeight / 2 - 10; 65 degenBigConic->moveTo(0, yPos); 66 degenBigConic->conicTo(0, yPos, kWidth, yPos, .5); 67 } 68 } 69 70 void onDraw(SkCanvas* canvas) override { 71 canvas->save(); 72 canvas->scale(1, -1); 73 canvas->translate(0, -kHeight); 74 for (int p = 0; p < fPaths.count(); ++p) { 75 SkPaint paint; 76 paint.setARGB(0xff, 0, 0, 0); 77 paint.setAntiAlias(true); 78 paint.setStyle(SkPaint::kStroke_Style); 79 paint.setStrokeWidth(0); 80 canvas->drawPath(fPaths[p], paint); 81 } 82 canvas->restore(); 83 } 84 85 const SkScalar kWidth = 256; 86 const SkScalar kHeight = 256; 87 88private: 89 SkTArray<SkPath> fPaths; 90 typedef GM INHERITED; 91}; 92 93////////////////////////////////////////////////////////////////////////////// 94 95static GM* MyFactory(void*) { return new StLouisArchGM; } 96static GMRegistry reg(MyFactory); 97 98} 99