Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 "SkTypes.h" |
| 9 | |
| 10 | #if SK_SUPPORT_GPU |
| 11 | |
Ben Wagner | 80634eb | 2019-02-07 14:10:42 -0500 | [diff] [blame] | 12 | #include "GrClip.h" |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 13 | #include "GrContextPriv.h" |
Ben Wagner | d4bffed | 2018-08-14 17:51:23 -0400 | [diff] [blame] | 14 | #include "GrMemoryPool.h" |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 15 | #include "GrPathUtils.h" |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 16 | #include "GrRenderTargetContext.h" |
| 17 | #include "GrRenderTargetContextPriv.h" |
| 18 | #include "GrResourceProvider.h" |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 19 | #include "Sample.h" |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 20 | #include "SkCanvas.h" |
Ben Wagner | 80634eb | 2019-02-07 14:10:42 -0500 | [diff] [blame] | 21 | #include "SkMakeUnique.h" |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 22 | #include "SkPaint.h" |
| 23 | #include "SkPath.h" |
Mike Reed | 274218e | 2018-01-08 15:05:02 -0500 | [diff] [blame] | 24 | #include "SkRectPriv.h" |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 25 | #include "ccpr/GrCCCoverageProcessor.h" |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 26 | #include "ccpr/GrCCFillGeometry.h" |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 27 | #include "ccpr/GrCCStroker.h" |
Ben Wagner | 80634eb | 2019-02-07 14:10:42 -0500 | [diff] [blame] | 28 | #include "gl/GrGLGpu.h" |
Brian Salomon | 1471df9 | 2018-06-08 10:49:00 -0400 | [diff] [blame] | 29 | #include "glsl/GrGLSLFragmentProcessor.h" |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 30 | #include "ops/GrDrawOp.h" |
| 31 | |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 32 | using TriPointInstance = GrCCCoverageProcessor::TriPointInstance; |
| 33 | using QuadPointInstance = GrCCCoverageProcessor::QuadPointInstance; |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 34 | using PrimitiveType = GrCCCoverageProcessor::PrimitiveType; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 35 | |
Chris Dalton | a640c49 | 2017-09-11 22:04:03 -0700 | [diff] [blame] | 36 | static constexpr float kDebugBloat = 40; |
| 37 | |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 38 | /** |
| 39 | * This sample visualizes the AA bloat geometry generated by the ccpr geometry shaders. It |
| 40 | * increases the AA bloat by 50x and outputs color instead of coverage (coverage=+1 -> green, |
| 41 | * coverage=0 -> black, coverage=-1 -> red). Use the keys 1-7 to cycle through the different |
| 42 | * geometry processors. |
| 43 | */ |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 44 | class CCPRGeometryView : public Sample { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 45 | public: |
| 46 | CCPRGeometryView() { this->updateGpuData(); } |
| 47 | void onDrawContent(SkCanvas*) override; |
| 48 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 49 | Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override; |
| 50 | bool onClick(Sample::Click*) override; |
| 51 | bool onQuery(Sample::Event* evt) override; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 52 | |
| 53 | private: |
| 54 | class Click; |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 55 | class DrawCoverageCountOp; |
| 56 | class VisualizeCoverageCountFP; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 57 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 58 | void updateAndInval() { this->updateGpuData(); } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 59 | |
| 60 | void updateGpuData(); |
| 61 | |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 62 | PrimitiveType fPrimitiveType = PrimitiveType::kTriangles; |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 63 | SkCubicType fCubicType; |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 64 | SkMatrix fCubicKLM; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 65 | |
| 66 | SkPoint fPoints[4] = { |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 67 | {100.05f, 100.05f}, {400.75f, 100.05f}, {400.75f, 300.95f}, {100.05f, 300.95f}}; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 68 | |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 69 | float fConicWeight = .5; |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 70 | float fStrokeWidth = 40; |
| 71 | bool fDoStroke = false; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 72 | |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 73 | SkTArray<TriPointInstance> fTriPointInstances; |
| 74 | SkTArray<QuadPointInstance> fQuadPointInstances; |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 75 | SkPath fPath; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 76 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 77 | typedef Sample INHERITED; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 78 | }; |
| 79 | |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 80 | class CCPRGeometryView::DrawCoverageCountOp : public GrDrawOp { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 81 | DEFINE_OP_CLASS_ID |
| 82 | |
| 83 | public: |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 84 | DrawCoverageCountOp(CCPRGeometryView* view) : INHERITED(ClassID()), fView(view) { |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 85 | this->setBounds(SkRect::MakeIWH(fView->width(), fView->height()), GrOp::HasAABloat::kNo, |
| 86 | GrOp::IsZeroArea::kNo); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 87 | } |
| 88 | |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 89 | const char* name() const override { |
| 90 | return "[Testing/Sample code] CCPRGeometryView::DrawCoverageCountOp"; |
| 91 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 92 | |
| 93 | private: |
| 94 | FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; } |
Chris Dalton | b8fff0d | 2019-03-05 10:11:58 -0700 | [diff] [blame] | 95 | GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, GrFSAAType) override { |
Chris Dalton | 4b62aed | 2019-01-15 11:53:00 -0700 | [diff] [blame] | 96 | return GrProcessorSet::EmptySetAnalysis(); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 97 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 98 | void onPrepare(GrOpFlushState*) override {} |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 99 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 100 | |
| 101 | CCPRGeometryView* fView; |
| 102 | |
| 103 | typedef GrDrawOp INHERITED; |
| 104 | }; |
| 105 | |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 106 | class CCPRGeometryView::VisualizeCoverageCountFP : public GrFragmentProcessor { |
| 107 | public: |
| 108 | VisualizeCoverageCountFP() : GrFragmentProcessor(kTestFP_ClassID, kNone_OptimizationFlags) {} |
| 109 | |
| 110 | private: |
| 111 | const char* name() const override { |
| 112 | return "[Testing/Sample code] CCPRGeometryView::VisualizeCoverageCountFP"; |
| 113 | } |
| 114 | std::unique_ptr<GrFragmentProcessor> clone() const override { |
| 115 | return skstd::make_unique<VisualizeCoverageCountFP>(); |
| 116 | } |
| 117 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} |
| 118 | bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| 119 | |
| 120 | class Impl : public GrGLSLFragmentProcessor { |
| 121 | void emitCode(EmitArgs& args) override { |
| 122 | GrGLSLFPFragmentBuilder* f = args.fFragBuilder; |
| 123 | f->codeAppendf("half count = %s.a;", args.fInputColor); |
| 124 | f->codeAppendf("%s = half4(clamp(-count, 0, 1), clamp(+count, 0, 1), 0, abs(count));", |
| 125 | args.fOutputColor); |
| 126 | } |
| 127 | }; |
| 128 | |
| 129 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new Impl; } |
| 130 | }; |
| 131 | |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 132 | static void draw_klm_line(int w, int h, SkCanvas* canvas, const SkScalar line[3], SkColor color) { |
| 133 | SkPoint p1, p2; |
| 134 | if (SkScalarAbs(line[1]) > SkScalarAbs(line[0])) { |
| 135 | // Draw from vertical edge to vertical edge. |
| 136 | p1 = {0, -line[2] / line[1]}; |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 137 | p2 = {(SkScalar)w, (-line[2] - w * line[0]) / line[1]}; |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 138 | } else { |
| 139 | // Draw from horizontal edge to horizontal edge. |
| 140 | p1 = {-line[2] / line[0], 0}; |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 141 | p2 = {(-line[2] - h * line[1]) / line[0], (SkScalar)h}; |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | SkPaint linePaint; |
| 145 | linePaint.setColor(color); |
| 146 | linePaint.setAlpha(128); |
| 147 | linePaint.setStyle(SkPaint::kStroke_Style); |
| 148 | linePaint.setStrokeWidth(0); |
| 149 | linePaint.setAntiAlias(true); |
| 150 | canvas->drawLine(p1, p2, linePaint); |
| 151 | } |
| 152 | |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 153 | void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { |
Chris Dalton | 8738cf4 | 2018-03-09 11:57:40 -0700 | [diff] [blame] | 154 | canvas->clear(SK_ColorBLACK); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 155 | |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 156 | if (!fDoStroke) { |
| 157 | SkPaint outlinePaint; |
| 158 | outlinePaint.setColor(0x80ffffff); |
| 159 | outlinePaint.setStyle(SkPaint::kStroke_Style); |
| 160 | outlinePaint.setStrokeWidth(0); |
| 161 | outlinePaint.setAntiAlias(true); |
| 162 | canvas->drawPath(fPath, outlinePaint); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 163 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 164 | |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 165 | #if 0 |
| 166 | SkPaint gridPaint; |
| 167 | gridPaint.setColor(0x10000000); |
| 168 | gridPaint.setStyle(SkPaint::kStroke_Style); |
| 169 | gridPaint.setStrokeWidth(0); |
| 170 | gridPaint.setAntiAlias(true); |
Chris Dalton | a640c49 | 2017-09-11 22:04:03 -0700 | [diff] [blame] | 171 | for (int y = 0; y < this->height(); y += kDebugBloat) { |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 172 | canvas->drawLine(0, y, this->width(), y, gridPaint); |
| 173 | } |
Chris Dalton | a640c49 | 2017-09-11 22:04:03 -0700 | [diff] [blame] | 174 | for (int x = 0; x < this->width(); x += kDebugBloat) { |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 175 | canvas->drawLine(x, 0, x, this->height(), outlinePaint); |
| 176 | } |
| 177 | #endif |
| 178 | |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 179 | SkString caption; |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 180 | if (GrRenderTargetContext* rtc = canvas->internal_private_accessTopLayerRenderTargetContext()) { |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 181 | // Render coverage count. |
| 182 | GrContext* ctx = canvas->getGrContext(); |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 183 | SkASSERT(ctx); |
| 184 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 185 | GrOpMemoryPool* pool = ctx->priv().opMemoryPool(); |
Ben Wagner | d4bffed | 2018-08-14 17:51:23 -0400 | [diff] [blame] | 186 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 187 | const GrBackendFormat format = |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 188 | ctx->priv().caps()->getBackendFormatFromGrColorType(GrColorType::kAlpha_F16, |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 189 | GrSRGBEncoded::kNo); |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 190 | sk_sp<GrRenderTargetContext> ccbuff = |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 191 | ctx->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kApprox, |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 192 | this->width(), this->height(), |
| 193 | kAlpha_half_GrPixelConfig, |
| 194 | nullptr); |
| 195 | SkASSERT(ccbuff); |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 196 | ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT, |
| 197 | GrRenderTargetContext::CanClearFullscreen::kYes); |
Ben Wagner | d4bffed | 2018-08-14 17:51:23 -0400 | [diff] [blame] | 198 | ccbuff->priv().testingOnly_addDrawOp(pool->allocate<DrawCoverageCountOp>(this)); |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 199 | |
| 200 | // Visualize coverage count in main canvas. |
| 201 | GrPaint paint; |
| 202 | paint.addColorFragmentProcessor( |
| 203 | GrSimpleTextureEffect::Make(sk_ref_sp(ccbuff->asTextureProxy()), SkMatrix::I())); |
| 204 | paint.addColorFragmentProcessor( |
| 205 | skstd::make_unique<VisualizeCoverageCountFP>()); |
| 206 | paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver); |
| 207 | rtc->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), |
| 208 | SkRect::MakeIWH(this->width(), this->height())); |
| 209 | |
| 210 | // Add label. |
Chris Dalton | 703b476 | 2018-04-06 16:11:48 -0600 | [diff] [blame] | 211 | caption.appendf("PrimitiveType_%s", |
| 212 | GrCCCoverageProcessor::PrimitiveTypeName(fPrimitiveType)); |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 213 | if (PrimitiveType::kCubics == fPrimitiveType) { |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 214 | caption.appendf(" (%s)", SkCubicTypeName(fCubicType)); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 215 | } else if (PrimitiveType::kConics == fPrimitiveType) { |
| 216 | caption.appendf(" (w=%f)", fConicWeight); |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 217 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 218 | if (fDoStroke) { |
| 219 | caption.appendf(" (stroke_width=%f)", fStrokeWidth); |
| 220 | } |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 221 | } else { |
| 222 | caption = "Use GPU backend to visualize geometry."; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | SkPaint pointsPaint; |
| 226 | pointsPaint.setColor(SK_ColorBLUE); |
| 227 | pointsPaint.setStrokeWidth(8); |
| 228 | pointsPaint.setAntiAlias(true); |
| 229 | |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 230 | if (PrimitiveType::kCubics == fPrimitiveType) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 231 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, fPoints, pointsPaint); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 232 | if (!fDoStroke) { |
| 233 | int w = this->width(), h = this->height(); |
| 234 | draw_klm_line(w, h, canvas, &fCubicKLM[0], SK_ColorYELLOW); |
| 235 | draw_klm_line(w, h, canvas, &fCubicKLM[3], SK_ColorBLUE); |
| 236 | draw_klm_line(w, h, canvas, &fCubicKLM[6], SK_ColorRED); |
| 237 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 238 | } else { |
| 239 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, fPoints, pointsPaint); |
| 240 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 1, fPoints + 3, pointsPaint); |
| 241 | } |
| 242 | |
Hal Canary | 4484b8f | 2019-01-08 14:00:08 -0500 | [diff] [blame] | 243 | SkFont font(nullptr, 20); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 244 | SkPaint captionPaint; |
Chris Dalton | 8738cf4 | 2018-03-09 11:57:40 -0700 | [diff] [blame] | 245 | captionPaint.setColor(SK_ColorWHITE); |
Hal Canary | 4484b8f | 2019-01-08 14:00:08 -0500 | [diff] [blame] | 246 | canvas->drawString(caption, 10, 30, font, captionPaint); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | void CCPRGeometryView::updateGpuData() { |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 250 | using Verb = GrCCFillGeometry::Verb; |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 251 | fTriPointInstances.reset(); |
| 252 | fQuadPointInstances.reset(); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 253 | |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 254 | fPath.reset(); |
| 255 | fPath.moveTo(fPoints[0]); |
| 256 | |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 257 | if (PrimitiveType::kCubics == fPrimitiveType) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 258 | double t[2], s[2]; |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 259 | fCubicType = GrPathUtils::getCubicKLM(fPoints, &fCubicKLM, t, s); |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 260 | GrCCFillGeometry geometry; |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 261 | geometry.beginContour(fPoints[0]); |
Chris Dalton | 7ca3b7b | 2018-04-10 00:21:19 -0600 | [diff] [blame] | 262 | geometry.cubicTo(fPoints, kDebugBloat / 2, kDebugBloat / 2); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 263 | geometry.endContour(); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 264 | int ptsIdx = 0; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 265 | for (Verb verb : geometry.verbs()) { |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 266 | switch (verb) { |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 267 | case Verb::kLineTo: |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 268 | ++ptsIdx; |
| 269 | continue; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 270 | case Verb::kMonotonicQuadraticTo: |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 271 | ptsIdx += 2; |
| 272 | continue; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 273 | case Verb::kMonotonicCubicTo: |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 274 | fQuadPointInstances.push_back().set(&geometry.points()[ptsIdx], 0, 0); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 275 | ptsIdx += 3; |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 276 | continue; |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 277 | default: |
| 278 | continue; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 279 | } |
| 280 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 281 | fPath.cubicTo(fPoints[1], fPoints[2], fPoints[3]); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 282 | } else if (PrimitiveType::kTriangles != fPrimitiveType) { |
Chris Dalton | 7ca3b7b | 2018-04-10 00:21:19 -0600 | [diff] [blame] | 283 | SkPoint P3[3] = {fPoints[0], fPoints[1], fPoints[3]}; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 284 | GrCCFillGeometry geometry; |
Chris Dalton | 7ca3b7b | 2018-04-10 00:21:19 -0600 | [diff] [blame] | 285 | geometry.beginContour(P3[0]); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 286 | if (PrimitiveType::kQuadratics == fPrimitiveType) { |
| 287 | geometry.quadraticTo(P3); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 288 | fPath.quadTo(fPoints[1], fPoints[3]); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 289 | } else { |
| 290 | SkASSERT(PrimitiveType::kConics == fPrimitiveType); |
| 291 | geometry.conicTo(P3, fConicWeight); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 292 | fPath.conicTo(fPoints[1], fPoints[3], fConicWeight); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 293 | } |
Chris Dalton | c1e5963 | 2017-09-05 00:30:07 -0600 | [diff] [blame] | 294 | geometry.endContour(); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 295 | int ptsIdx = 0, conicWeightIdx = 0; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 296 | for (Verb verb : geometry.verbs()) { |
| 297 | if (Verb::kBeginContour == verb || |
| 298 | Verb::kEndOpenContour == verb || |
| 299 | Verb::kEndClosedContour == verb) { |
Chris Dalton | c1e5963 | 2017-09-05 00:30:07 -0600 | [diff] [blame] | 300 | continue; |
| 301 | } |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 302 | if (Verb::kLineTo == verb) { |
Chris Dalton | 90e8fb1 | 2017-12-22 02:24:53 -0700 | [diff] [blame] | 303 | ++ptsIdx; |
| 304 | continue; |
| 305 | } |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 306 | SkASSERT(Verb::kMonotonicQuadraticTo == verb || Verb::kMonotonicConicTo == verb); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 307 | if (PrimitiveType::kQuadratics == fPrimitiveType && |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 308 | Verb::kMonotonicQuadraticTo == verb) { |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 309 | fTriPointInstances.push_back().set(&geometry.points()[ptsIdx], Sk2f(0, 0)); |
| 310 | } else if (PrimitiveType::kConics == fPrimitiveType && |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 311 | Verb::kMonotonicConicTo == verb) { |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 312 | fQuadPointInstances.push_back().setW(&geometry.points()[ptsIdx], Sk2f(0, 0), |
| 313 | geometry.getConicWeight(conicWeightIdx++)); |
| 314 | } |
Chris Dalton | a3e9271 | 2017-12-04 11:45:51 -0700 | [diff] [blame] | 315 | ptsIdx += 2; |
Chris Dalton | b072bb6 | 2017-08-07 09:00:46 -0600 | [diff] [blame] | 316 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 317 | } else { |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 318 | fTriPointInstances.push_back().set(fPoints[0], fPoints[1], fPoints[3], Sk2f(0, 0)); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 319 | fPath.lineTo(fPoints[1]); |
| 320 | fPath.lineTo(fPoints[3]); |
| 321 | fPath.close(); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 325 | void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state, |
| 326 | const SkRect& chainBounds) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 327 | GrResourceProvider* rp = state->resourceProvider(); |
| 328 | GrContext* context = state->gpu()->getContext(); |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 329 | GrGLGpu* glGpu = GrBackendApi::kOpenGL == context->backend() |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 330 | ? static_cast<GrGLGpu*>(state->gpu()) |
| 331 | : nullptr; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 332 | if (glGpu) { |
| 333 | glGpu->handleDirtyContext(); |
Chris Dalton | 8738cf4 | 2018-03-09 11:57:40 -0700 | [diff] [blame] | 334 | // GR_GL_CALL(glGpu->glInterface(), PolygonMode(GR_GL_FRONT_AND_BACK, GR_GL_LINE)); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 335 | GR_GL_CALL(glGpu->glInterface(), Enable(GR_GL_LINE_SMOOTH)); |
| 336 | } |
| 337 | |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 338 | GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kPlus); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 339 | |
| 340 | if (!fView->fDoStroke) { |
| 341 | GrCCCoverageProcessor proc(rp, fView->fPrimitiveType); |
| 342 | SkDEBUGCODE(proc.enableDebugBloat(kDebugBloat)); |
| 343 | |
| 344 | SkSTArray<1, GrMesh> mesh; |
| 345 | if (PrimitiveType::kCubics == fView->fPrimitiveType || |
| 346 | PrimitiveType::kConics == fView->fPrimitiveType) { |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 347 | sk_sp<GrGpuBuffer> instBuff( |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 348 | rp->createBuffer(fView->fQuadPointInstances.count() * sizeof(QuadPointInstance), |
| 349 | GrGpuBufferType::kVertex, kDynamic_GrAccessPattern, |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 350 | fView->fQuadPointInstances.begin())); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 351 | if (!fView->fQuadPointInstances.empty() && instBuff) { |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 352 | proc.appendMesh(std::move(instBuff), fView->fQuadPointInstances.count(), 0, &mesh); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 353 | } |
| 354 | } else { |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 355 | sk_sp<GrGpuBuffer> instBuff( |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 356 | rp->createBuffer(fView->fTriPointInstances.count() * sizeof(TriPointInstance), |
| 357 | GrGpuBufferType::kVertex, kDynamic_GrAccessPattern, |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 358 | fView->fTriPointInstances.begin())); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 359 | if (!fView->fTriPointInstances.empty() && instBuff) { |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 360 | proc.appendMesh(std::move(instBuff), fView->fTriPointInstances.count(), 0, &mesh); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | |
| 364 | if (!mesh.empty()) { |
| 365 | SkASSERT(1 == mesh.count()); |
| 366 | proc.draw(state, pipeline, nullptr, mesh.begin(), 1, this->bounds()); |
| 367 | } |
| 368 | } else if (PrimitiveType::kConics != fView->fPrimitiveType) { // No conic stroke support yet. |
| 369 | GrCCStroker stroker(0,0,0); |
| 370 | |
| 371 | SkPaint p; |
| 372 | p.setStyle(SkPaint::kStroke_Style); |
| 373 | p.setStrokeWidth(fView->fStrokeWidth); |
| 374 | p.setStrokeJoin(SkPaint::kMiter_Join); |
| 375 | p.setStrokeMiter(4); |
| 376 | // p.setStrokeCap(SkPaint::kRound_Cap); |
| 377 | stroker.parseDeviceSpaceStroke(fView->fPath, SkPathPriv::PointData(fView->fPath), |
| 378 | SkStrokeRec(p), p.getStrokeWidth(), GrScissorTest::kDisabled, |
| 379 | SkIRect::MakeWH(fView->width(), fView->height()), {0, 0}); |
| 380 | GrCCStroker::BatchID batchID = stroker.closeCurrentBatch(); |
| 381 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 382 | GrOnFlushResourceProvider onFlushRP(context->priv().drawingManager()); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 383 | stroker.prepareToDraw(&onFlushRP); |
| 384 | |
| 385 | SkIRect ibounds; |
| 386 | this->bounds().roundOut(&ibounds); |
| 387 | stroker.drawStrokes(state, batchID, ibounds); |
Chris Dalton | 2326177 | 2017-12-10 16:41:45 -0700 | [diff] [blame] | 388 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 389 | |
| 390 | if (glGpu) { |
| 391 | context->resetContext(kMisc_GrGLBackendState); |
| 392 | } |
| 393 | } |
| 394 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 395 | class CCPRGeometryView::Click : public Sample::Click { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 396 | public: |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 397 | Click(Sample* target, int ptIdx) : Sample::Click(target), fPtIdx(ptIdx) {} |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 398 | |
| 399 | void doClick(SkPoint points[]) { |
| 400 | if (fPtIdx >= 0) { |
| 401 | this->dragPoint(points, fPtIdx); |
| 402 | } else { |
| 403 | for (int i = 0; i < 4; ++i) { |
| 404 | this->dragPoint(points, i); |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | private: |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 410 | void dragPoint(SkPoint points[], int idx) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 411 | SkIPoint delta = fICurr - fIPrev; |
| 412 | points[idx] += SkPoint::Make(delta.x(), delta.y()); |
| 413 | } |
| 414 | |
| 415 | int fPtIdx; |
| 416 | }; |
| 417 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 418 | Sample::Click* CCPRGeometryView::onFindClickHandler(SkScalar x, SkScalar y, unsigned) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 419 | for (int i = 0; i < 4; ++i) { |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 420 | if (PrimitiveType::kCubics != fPrimitiveType && 2 == i) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 421 | continue; |
| 422 | } |
| 423 | if (fabs(x - fPoints[i].x()) < 20 && fabsf(y - fPoints[i].y()) < 20) { |
| 424 | return new Click(this, i); |
| 425 | } |
| 426 | } |
| 427 | return new Click(this, -1); |
| 428 | } |
| 429 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 430 | bool CCPRGeometryView::onClick(Sample::Click* click) { |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 431 | Click* myClick = (Click*)click; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 432 | myClick->doClick(fPoints); |
| 433 | this->updateAndInval(); |
| 434 | return true; |
| 435 | } |
| 436 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 437 | bool CCPRGeometryView::onQuery(Sample::Event* evt) { |
| 438 | if (Sample::TitleQ(*evt)) { |
| 439 | Sample::TitleR(evt, "CCPRGeometry"); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 440 | return true; |
| 441 | } |
| 442 | SkUnichar unichar; |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 443 | if (Sample::CharQ(*evt, &unichar)) { |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 444 | if (unichar >= '1' && unichar <= '4') { |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 445 | fPrimitiveType = PrimitiveType(unichar - '1'); |
Chris Dalton | 703b476 | 2018-04-06 16:11:48 -0600 | [diff] [blame] | 446 | if (fPrimitiveType >= PrimitiveType::kWeightedTriangles) { |
| 447 | fPrimitiveType = (PrimitiveType) ((int)fPrimitiveType + 1); |
| 448 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 449 | this->updateAndInval(); |
| 450 | return true; |
| 451 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 452 | float* valueToScale = nullptr; |
| 453 | if (fDoStroke) { |
| 454 | valueToScale = &fStrokeWidth; |
| 455 | } else if (PrimitiveType::kConics == fPrimitiveType) { |
| 456 | valueToScale = &fConicWeight; |
| 457 | } |
| 458 | if (valueToScale) { |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 459 | if (unichar == '+') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 460 | *valueToScale *= 2; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 461 | this->updateAndInval(); |
| 462 | return true; |
| 463 | } |
| 464 | if (unichar == '+' || unichar == '=') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 465 | *valueToScale *= 5/4.f; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 466 | this->updateAndInval(); |
| 467 | return true; |
| 468 | } |
| 469 | if (unichar == '-') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 470 | *valueToScale *= 4/5.f; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 471 | this->updateAndInval(); |
| 472 | return true; |
| 473 | } |
| 474 | if (unichar == '_') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 475 | *valueToScale *= .5f; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 476 | this->updateAndInval(); |
| 477 | return true; |
| 478 | } |
| 479 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 480 | if (unichar == 'D') { |
| 481 | SkDebugf(" SkPoint fPoints[4] = {\n"); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 482 | SkDebugf(" {%ff, %ff},\n", fPoints[0].x(), fPoints[0].y()); |
| 483 | SkDebugf(" {%ff, %ff},\n", fPoints[1].x(), fPoints[1].y()); |
| 484 | SkDebugf(" {%ff, %ff},\n", fPoints[2].x(), fPoints[2].y()); |
| 485 | SkDebugf(" {%ff, %ff}\n", fPoints[3].x(), fPoints[3].y()); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 486 | SkDebugf(" };\n"); |
| 487 | return true; |
| 488 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 489 | if (unichar == 'S') { |
| 490 | fDoStroke = !fDoStroke; |
| 491 | this->updateAndInval(); |
| 492 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 493 | } |
| 494 | return this->INHERITED::onQuery(evt); |
| 495 | } |
| 496 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 497 | DEF_SAMPLE(return new CCPRGeometryView;) |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 498 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 499 | #endif // SK_SUPPORT_GPU |