114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com/* 214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com * Copyright 2013 Google Inc. 314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com * 414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com * Use of this source code is governed by a BSD-style license that can be 514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com * found in the LICENSE file. 614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com */ 714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com#include "gm.h" 9b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com#include "SkBlurDrawLooper.h" 10b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com#include "SkBlurMask.h" 1114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com#include "SkBlurMaskFilter.h" 1214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com#include "SkGradientShader.h" 13b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com#include "SkMatrix.h" 14b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com#include "SkTArray.h" 1514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 1614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.comnamespace skiagm { 1714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 1814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.comclass RectsGM : public GM { 1914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.compublic: 2014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com RectsGM() { 2114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com this->setBGColor(0xFF000000); 2214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com this->makePaints(); 2314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com this->makeMatrices(); 2414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com this->makeRects(); 2514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 2614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 2714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.comprotected: 28a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org virtual uint32_t onGetFlags() const SK_OVERRIDE { 29a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org return kSkipTiled_Flag; 30a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org } 31a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org 3214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com virtual SkString onShortName() SK_OVERRIDE { 3314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com return SkString("rects"); 3414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 3514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 3614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com virtual SkISize onISize() SK_OVERRIDE { 37f539318f0d3dba743ec1886d5d9df0fb1be628a1tfarina return SkISize::Make(1200, 900); 3814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 3914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 4014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com void makePaints() { 4114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 4214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // no AA 4314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 4414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 4514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 4614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 4714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 4814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 4914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // AA 5014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 5114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 5214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setAntiAlias(true); 5314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 5414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 5514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 5614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 57a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org // AA with translucent 58a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org SkPaint p; 59a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setColor(SK_ColorWHITE); 60a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setAntiAlias(true); 61a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setAlpha(0x66); 62a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org fPaints.push_back(p); 63a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org } 64a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org 65a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org { 6614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // AA with mask filter 6714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 6814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 6914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setAntiAlias(true); 70b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com SkMaskFilter* mf = SkBlurMaskFilter::Create( 71e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org kNormal_SkBlurStyle, 72b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), 7314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkBlurMaskFilter::kHighQuality_BlurFlag); 7414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setMaskFilter(mf)->unref(); 7514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 7614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 7714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 7814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 7914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // AA with radial shader 8014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 8114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 8214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setAntiAlias(true); 8314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPoint center = SkPoint::Make(SkIntToScalar(-5), SkIntToScalar(30)); 8414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN }; 8514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 }; 8614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkShader* s = SkGradientShader::CreateRadial(center, 8714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkIntToScalar(20), 8814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com colors, 8914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com pos, 9014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SK_ARRAY_COUNT(colors), 9114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkShader::kClamp_TileMode); 9214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setShader(s)->unref(); 9314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 9414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 9514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 9614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 9714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // AA with blur 9814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 9914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 10014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setAntiAlias(true); 10114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkBlurDrawLooper* shadowLooper = 10273cb15351f33459e0c861a96135c634dec77ef9dcommit-bot@chromium.org SkBlurDrawLooper::Create(SK_ColorWHITE, 10373cb15351f33459e0c861a96135c634dec77ef9dcommit-bot@chromium.org SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), 10473cb15351f33459e0c861a96135c634dec77ef9dcommit-bot@chromium.org SkIntToScalar(5), SkIntToScalar(10), 10573cb15351f33459e0c861a96135c634dec77ef9dcommit-bot@chromium.org SkBlurDrawLooper::kIgnoreTransform_BlurFlag | 10673cb15351f33459e0c861a96135c634dec77ef9dcommit-bot@chromium.org SkBlurDrawLooper::kOverrideColor_BlurFlag | 10773cb15351f33459e0c861a96135c634dec77ef9dcommit-bot@chromium.org SkBlurDrawLooper::kHighQuality_BlurFlag); 10814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkAutoUnref aurL0(shadowLooper); 10914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setLooper(shadowLooper); 11014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 11114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 11214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 11314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 11414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // AA with stroke style 11514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 11614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 11714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setAntiAlias(true); 11814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setStyle(SkPaint::kStroke_Style); 11914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setStrokeWidth(SkIntToScalar(3)); 12014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 12114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 12214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 12314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 124a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org // AA with bevel-stroke style 125a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org SkPaint p; 126a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setColor(SK_ColorWHITE); 127a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setAntiAlias(true); 128a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStyle(SkPaint::kStroke_Style); 129a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStrokeJoin(SkPaint::kBevel_Join); 130a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStrokeWidth(SkIntToScalar(3)); 131a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org fPaints.push_back(p); 132a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org } 133a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org 134a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org { 135a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org // AA with round-stroke style 136a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org SkPaint p; 137a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setColor(SK_ColorWHITE); 138a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setAntiAlias(true); 139a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStyle(SkPaint::kStroke_Style); 140a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStrokeJoin(SkPaint::kRound_Join); 141a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStrokeWidth(SkIntToScalar(3)); 142a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org fPaints.push_back(p); 143a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org } 144a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org 145a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org { 14614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // AA with stroke style, width = 0 14714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 14814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 14914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setAntiAlias(true); 15014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setStyle(SkPaint::kStroke_Style); 15114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 15214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 15314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 15414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 155a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org // AA with stroke style, width wider than rect width and/or height 156a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org SkPaint p; 157a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setColor(SK_ColorWHITE); 158a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setAntiAlias(true); 159a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStyle(SkPaint::kStroke_Style); 160a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org p.setStrokeWidth(SkIntToScalar(40)); 161a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org fPaints.push_back(p); 162a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org } 163a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org 164a0fd1b340736587aa082d6c5613546477b47b013commit-bot@chromium.org { 16514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // AA with stroke and fill style 16614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint p; 16714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setColor(SK_ColorWHITE); 16814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setAntiAlias(true); 16914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setStyle(SkPaint::kStrokeAndFill_Style); 17014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com p.setStrokeWidth(SkIntToScalar(2)); 17114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fPaints.push_back(p); 17214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 17314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 17414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 17514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com void makeMatrices() { 17614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 17714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // 1x1.5 scale 17814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkMatrix m; 17956a2e0de631a647aa04e98ec123f3544273f26careed@google.com m.setScale(1, 1.5f); 18014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fMatrices.push_back(m); 18114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 18214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 18314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 18414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // 1.5x1.5 scale 18514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkMatrix m; 18656a2e0de631a647aa04e98ec123f3544273f26careed@google.com m.setScale(1.5f, 1.5f); 18714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fMatrices.push_back(m); 18814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 18914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 19014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 19114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // 1x1.5 skew 19214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkMatrix m; 19356a2e0de631a647aa04e98ec123f3544273f26careed@google.com m.setSkew(1, 1.5f); 19414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fMatrices.push_back(m); 19514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 19614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 19714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 19814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // 1.5x1.5 skew 19914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkMatrix m; 20056a2e0de631a647aa04e98ec123f3544273f26careed@google.com m.setSkew(1.5f, 1.5f); 20114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fMatrices.push_back(m); 20214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 20314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 20414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 20514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // 30 degree rotation 20614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkMatrix m; 20714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com m.setRotate(SkIntToScalar(30)); 20814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fMatrices.push_back(m); 20914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 2106f5abddf898dc2c2497394fe9a0b82e1f872b0d5robertphillips@google.com 2116f5abddf898dc2c2497394fe9a0b82e1f872b0d5robertphillips@google.com { 2126f5abddf898dc2c2497394fe9a0b82e1f872b0d5robertphillips@google.com // 90 degree rotation 2136f5abddf898dc2c2497394fe9a0b82e1f872b0d5robertphillips@google.com SkMatrix m; 2146f5abddf898dc2c2497394fe9a0b82e1f872b0d5robertphillips@google.com m.setRotate(SkIntToScalar(90)); 2156f5abddf898dc2c2497394fe9a0b82e1f872b0d5robertphillips@google.com fMatrices.push_back(m); 2166f5abddf898dc2c2497394fe9a0b82e1f872b0d5robertphillips@google.com } 21714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 21814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 21914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com void makeRects() { 22014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 22114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // small square 22214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkRect r = SkRect::MakeLTRB(0, 0, 30, 30); 22314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fRects.push_back(r); 22414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 22514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 22614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 22714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // thin vertical 22814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkRect r = SkRect::MakeLTRB(0, 0, 2, 40); 22914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fRects.push_back(r); 23014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 23114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 23214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 23314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // thin horizontal 23414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkRect r = SkRect::MakeLTRB(0, 0, 40, 2); 23514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fRects.push_back(r); 23614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 23714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 23814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 23914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // very thin 24014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkRect r = SkRect::MakeLTRB(0, 0, 0.25f, 10); 24114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fRects.push_back(r); 24214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 24314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 24414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com { 24514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // zaftig 24614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkRect r = SkRect::MakeLTRB(0, 0, 60, 60); 24714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com fRects.push_back(r); 24814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 24914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 25014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 25114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com // position the current test on the canvas 25214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com static void position(SkCanvas* canvas, int testCount) { 25314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->translate(SK_Scalar1 * 100 * (testCount % 10) + SK_Scalar1 / 4, 25414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SK_Scalar1 * 100 * (testCount / 10) + 3 * SK_Scalar1 / 4); 25514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 25614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 25714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 2580a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com SkAutoCommentBlock acb(canvas, "onDraw"); 2590a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 26014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); 26114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 26214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com int testCount = 0; 26314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 2640a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com canvas->addComment("Test", "Various Paints"); 2650a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 26614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com for (int i = 0; i < fPaints.count(); ++i) { 26714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com for (int j = 0; j < fRects.count(); ++j, ++testCount) { 26814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->save(); 26914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com this->position(canvas, testCount); 27014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->drawRect(fRects[j], fPaints[i]); 27114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->restore(); 27214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 27314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 27414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 2750a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com canvas->addComment("Test", "Matrices"); 2760a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 27714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkPaint paint; 27814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com paint.setColor(SK_ColorWHITE); 27914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com paint.setAntiAlias(true); 28014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 28114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com for (int i = 0; i < fMatrices.count(); ++i) { 28214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com for (int j = 0; j < fRects.count(); ++j, ++testCount) { 28314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->save(); 28414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com this->position(canvas, testCount); 28514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->concat(fMatrices[i]); 28614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->drawRect(fRects[j], paint); 28714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com canvas->restore(); 28814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 28914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 29014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com } 29114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 29214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.comprivate: 29314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkTArray<SkPaint> fPaints; 29414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkTArray<SkMatrix> fMatrices; 29514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com SkTArray<SkRect> fRects; 29614c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 29714c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com typedef GM INHERITED; 29814c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com}; 29914c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 30014c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com////////////////////////////////////////////////////////////////////////////// 30114c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 30214c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.comstatic GM* MyFactory(void*) { return new RectsGM; } 30314c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.comstatic GMRegistry reg(MyFactory); 30414c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com 30514c3fc60b2779b5048df0b3a2569a462a298357crobertphillips@google.com} 306