commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2014 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | // This test only works with the GPU backend. |
| 10 | |
| 11 | #include "gm.h" |
| 12 | |
| 13 | #if SK_SUPPORT_GPU |
| 14 | |
| 15 | #include "GrContext.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 16 | #include "GrDefaultGeoProcFactory.h" |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame^] | 17 | #include "GrDrawContextPriv.h" |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 18 | #include "GrPathUtils.h" |
| 19 | #include "GrTest.h" |
| 20 | #include "SkColorPriv.h" |
| 21 | #include "SkDevice.h" |
| 22 | #include "SkGeometry.h" |
| 23 | #include "SkTLList.h" |
| 24 | |
joshualitt | 2771b56 | 2015-08-07 12:46:26 -0700 | [diff] [blame] | 25 | #include "batches/GrTestBatch.h" |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 26 | #include "batches/GrVertexBatch.h" |
joshualitt | 2771b56 | 2015-08-07 12:46:26 -0700 | [diff] [blame] | 27 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 28 | #include "effects/GrConvexPolyEffect.h" |
| 29 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 30 | namespace skiagm { |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 31 | |
| 32 | class ConvexPolyTestBatch : public GrTestBatch { |
| 33 | public: |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 34 | DEFINE_BATCH_CLASS_ID |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 35 | struct Geometry : public GrTestBatch::Geometry { |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 36 | SkRect fRect; |
| 37 | SkRect fBounds; // This will be == fRect, except fBounds must be sorted, whereas fRect can |
| 38 | // be inverted |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 39 | }; |
| 40 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 41 | const char* name() const override { return "ConvexPolyTestBatch"; } |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 42 | |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 43 | static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 44 | return new ConvexPolyTestBatch(gp, geo); |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | private: |
| 48 | ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo) |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 49 | : INHERITED(ClassID(), gp, geo.fBounds) |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 50 | , fGeometry(geo) { |
joshualitt | 144c3c8 | 2015-11-30 12:30:13 -0800 | [diff] [blame] | 51 | // Make sure any artifacts around the exterior of path are visible by using overly |
| 52 | // conservative bounding geometry. |
| 53 | fGeometry.fBounds.outset(5.f, 5.f); |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 54 | fGeometry.fRect.outset(5.f, 5.f); |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 55 | } |
| 56 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 57 | Geometry* geoData(int index) override { |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 58 | SkASSERT(0 == index); |
| 59 | return &fGeometry; |
| 60 | } |
| 61 | |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame] | 62 | const Geometry* geoData(int index) const override { |
| 63 | SkASSERT(0 == index); |
| 64 | return &fGeometry; |
| 65 | } |
| 66 | |
joshualitt | 144c3c8 | 2015-11-30 12:30:13 -0800 | [diff] [blame] | 67 | void generateGeometry(Target* target) const override { |
bsalomon | ed0bcad | 2015-05-04 10:36:42 -0700 | [diff] [blame] | 68 | size_t vertexStride = this->geometryProcessor()->getVertexStride(); |
bsalomon | b5238a7 | 2015-05-05 07:49:49 -0700 | [diff] [blame] | 69 | SkASSERT(vertexStride == sizeof(SkPoint)); |
| 70 | QuadHelper helper; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 71 | SkPoint* verts = reinterpret_cast<SkPoint*>(helper.init(target, vertexStride, 1)); |
bsalomon | b5238a7 | 2015-05-05 07:49:49 -0700 | [diff] [blame] | 72 | if (!verts) { |
joshualitt | 4b31de8 | 2015-03-05 14:33:41 -0800 | [diff] [blame] | 73 | return; |
| 74 | } |
| 75 | |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 76 | fGeometry.fRect.toQuad(verts); |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 77 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 78 | helper.recordDraw(target); |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | Geometry fGeometry; |
| 82 | |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 83 | typedef GrTestBatch INHERITED; |
| 84 | }; |
| 85 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 86 | /** |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 87 | * This GM directly exercises a GrProcessor that draws convex polygons. |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 88 | */ |
| 89 | class ConvexPolyEffect : public GM { |
| 90 | public: |
| 91 | ConvexPolyEffect() { |
| 92 | this->setBGColor(0xFFFFFFFF); |
| 93 | } |
| 94 | |
| 95 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 96 | SkString onShortName() override { |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 97 | return SkString("convex_poly_effect"); |
| 98 | } |
| 99 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 100 | SkISize onISize() override { |
tfarina | f539318 | 2014-06-09 23:59:03 -0700 | [diff] [blame] | 101 | return SkISize::Make(720, 800); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 102 | } |
| 103 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 104 | void onOnceBeforeDraw() override { |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 105 | SkPath tri; |
| 106 | tri.moveTo(5.f, 5.f); |
| 107 | tri.lineTo(100.f, 20.f); |
| 108 | tri.lineTo(15.f, 100.f); |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 109 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 110 | fPaths.addToTail(tri); |
| 111 | fPaths.addToTail(SkPath())->reverseAddPath(tri); |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 112 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 113 | tri.close(); |
| 114 | fPaths.addToTail(tri); |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 115 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 116 | SkPath ngon; |
| 117 | static const SkScalar kRadius = 50.f; |
| 118 | const SkPoint center = { kRadius, kRadius }; |
| 119 | for (int i = 0; i < GrConvexPolyEffect::kMaxEdges; ++i) { |
| 120 | SkScalar angle = 2 * SK_ScalarPI * i / GrConvexPolyEffect::kMaxEdges; |
| 121 | SkPoint point; |
| 122 | point.fY = SkScalarSinCos(angle, &point.fX); |
| 123 | point.scale(kRadius); |
| 124 | point = center + point; |
| 125 | if (0 == i) { |
| 126 | ngon.moveTo(point); |
| 127 | } else { |
| 128 | ngon.lineTo(point); |
| 129 | } |
| 130 | } |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 131 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 132 | fPaths.addToTail(ngon); |
| 133 | SkMatrix scaleM; |
| 134 | scaleM.setScale(1.1f, 0.4f); |
| 135 | ngon.transform(scaleM); |
| 136 | fPaths.addToTail(ngon); |
skia.committer@gmail.com | f0b0cda | 2014-02-09 03:02:01 +0000 | [diff] [blame] | 137 | |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 138 | // integer edges |
| 139 | fRects.addToTail(SkRect::MakeLTRB(5.f, 1.f, 30.f, 25.f)); |
| 140 | // half-integer edges |
| 141 | fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 24.5f)); |
| 142 | // vertically/horizontally thin rects that cover pixel centers |
| 143 | fRects.addToTail(SkRect::MakeLTRB(5.25f, 0.5f, 5.75f, 24.5f)); |
| 144 | fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 0.75f)); |
| 145 | // vertically/horizontally thin rects that don't cover pixel centers |
| 146 | fRects.addToTail(SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f)); |
| 147 | fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); |
| 148 | // small in x and y |
| 149 | fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); |
| 150 | // inverted in x and y |
| 151 | fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 152 | } |
| 153 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 154 | void onDraw(SkCanvas* canvas) override { |
joshualitt | df0c557 | 2015-08-03 11:35:28 -0700 | [diff] [blame] | 155 | using namespace GrDefaultGeoProcFactory; |
reed@google.com | 9c135db | 2014-03-12 18:28:35 +0000 | [diff] [blame] | 156 | GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 157 | if (nullptr == rt) { |
halcanary | 2a24338 | 2015-09-09 08:16:41 -0700 | [diff] [blame] | 158 | skiagm::GM::DrawGpuOnlyMessage(canvas); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 159 | return; |
| 160 | } |
| 161 | GrContext* context = rt->getContext(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 162 | if (nullptr == context) { |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 163 | return; |
| 164 | } |
| 165 | |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 166 | SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); |
| 167 | if (!drawContext) { |
| 168 | return; |
| 169 | } |
| 170 | |
joshualitt | df0c557 | 2015-08-03 11:35:28 -0700 | [diff] [blame] | 171 | Color color(0xff000000); |
| 172 | Coverage coverage(Coverage::kSolid_Type); |
| 173 | LocalCoords localCoords(LocalCoords::kUnused_Type); |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 174 | SkAutoTUnref<const GrGeometryProcessor> gp( |
joshualitt | df0c557 | 2015-08-03 11:35:28 -0700 | [diff] [blame] | 175 | GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I())); |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 176 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 177 | SkScalar y = 0; |
bsalomon | f045d60 | 2015-11-18 19:01:12 -0800 | [diff] [blame] | 178 | for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 179 | iter.get(); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 180 | iter.next()) { |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 181 | const SkPath* path = iter.get(); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 182 | SkScalar x = 0; |
| 183 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 184 | for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { |
robertphillips | 1d24b8d | 2015-03-26 19:57:08 -0700 | [diff] [blame] | 185 | const SkMatrix m = SkMatrix::MakeTrans(x, y); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 186 | SkPath p; |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 187 | path->transform(m, &p); |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 188 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 189 | GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; |
| 190 | SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, p)); |
| 191 | if (!fp) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 192 | continue; |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 193 | } |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 194 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 195 | GrPipelineBuilder pipelineBuilder; |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 196 | pipelineBuilder.setXPFactory( |
| 197 | GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref(); |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 198 | pipelineBuilder.addCoverageFragmentProcessor(fp); |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 199 | pipelineBuilder.setRenderTarget(rt); |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 200 | |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 201 | ConvexPolyTestBatch::Geometry geometry; |
joshualitt | df0c557 | 2015-08-03 11:35:28 -0700 | [diff] [blame] | 202 | geometry.fColor = color.fColor; |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 203 | geometry.fRect = p.getBounds(); |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 204 | geometry.fBounds = p.getBounds(); |
joshualitt | 50408ad | 2014-11-03 12:31:14 -0800 | [diff] [blame] | 205 | |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 206 | SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp, geometry)); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 207 | |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame^] | 208 | drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch); |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 209 | |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 210 | x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 211 | } |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 212 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 213 | // Draw AA and non AA paths using normal API for reference. |
| 214 | canvas->save(); |
| 215 | canvas->translate(x, y); |
| 216 | SkPaint paint; |
| 217 | canvas->drawPath(*path, paint); |
| 218 | canvas->translate(path->getBounds().width() + 10.f, 0); |
| 219 | paint.setAntiAlias(true); |
| 220 | canvas->drawPath(*path, paint); |
| 221 | canvas->restore(); |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 222 | |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 223 | y += SkScalarCeilToScalar(path->getBounds().height() + 20.f); |
| 224 | } |
| 225 | |
bsalomon | f045d60 | 2015-11-18 19:01:12 -0800 | [diff] [blame] | 226 | for (RectList::Iter iter(fRects, RectList::Iter::kHead_IterStart); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 227 | iter.get(); |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 228 | iter.next()) { |
| 229 | |
| 230 | SkScalar x = 0; |
| 231 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 232 | for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 233 | SkRect rect = *iter.get(); |
| 234 | rect.offset(x, y); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 235 | GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; |
| 236 | SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, rect)); |
| 237 | if (!fp) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 238 | continue; |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 239 | } |
| 240 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 241 | GrPipelineBuilder pipelineBuilder; |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 242 | pipelineBuilder.setXPFactory( |
| 243 | GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref(); |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 244 | pipelineBuilder.addCoverageFragmentProcessor(fp); |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 245 | pipelineBuilder.setRenderTarget(rt); |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 246 | |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 247 | ConvexPolyTestBatch::Geometry geometry; |
joshualitt | df0c557 | 2015-08-03 11:35:28 -0700 | [diff] [blame] | 248 | geometry.fColor = color.fColor; |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 249 | geometry.fRect = rect; |
joshualitt | 95964c6 | 2015-02-11 13:45:50 -0800 | [diff] [blame] | 250 | geometry.fBounds = rect; |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 251 | geometry.fBounds.sort(); |
joshualitt | 50408ad | 2014-11-03 12:31:14 -0800 | [diff] [blame] | 252 | |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 253 | SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp, geometry)); |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 254 | |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame^] | 255 | drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch); |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 256 | |
| 257 | x += SkScalarCeilToScalar(rect.width() + 10.f); |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 258 | } |
| 259 | |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 260 | // Draw rect without and with AA using normal API for reference |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 261 | canvas->save(); |
| 262 | canvas->translate(x, y); |
| 263 | SkPaint paint; |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 264 | canvas->drawRect(*iter.get(), paint); |
| 265 | x += SkScalarCeilToScalar(iter.get()->width() + 10.f); |
commit-bot@chromium.org | f053980 | 2014-02-08 19:31:05 +0000 | [diff] [blame] | 266 | paint.setAntiAlias(true); |
| 267 | canvas->drawRect(*iter.get(), paint); |
| 268 | canvas->restore(); |
| 269 | |
commit-bot@chromium.org | d85f32c | 2014-02-28 14:43:26 +0000 | [diff] [blame] | 270 | y += SkScalarCeilToScalar(iter.get()->height() + 20.f); |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
| 274 | private: |
bsalomon | f045d60 | 2015-11-18 19:01:12 -0800 | [diff] [blame] | 275 | typedef SkTLList<SkPath, 1> PathList; |
| 276 | typedef SkTLList<SkRect, 1> RectList; |
| 277 | PathList fPaths; |
| 278 | RectList fRects; |
skia.committer@gmail.com | f0b0cda | 2014-02-09 03:02:01 +0000 | [diff] [blame] | 279 | |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 280 | typedef GM INHERITED; |
| 281 | }; |
| 282 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 283 | DEF_GM(return new ConvexPolyEffect;) |
commit-bot@chromium.org | c3fe549 | 2014-01-30 18:15:51 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | #endif |