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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkTypes.h" |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 9 | |
| 10 | #if SK_SUPPORT_GPU |
| 11 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "include/core/SkCanvas.h" |
| 13 | #include "include/core/SkPaint.h" |
| 14 | #include "include/core/SkPath.h" |
Robert Phillips | 30ebcf7 | 2020-07-09 13:25:17 -0400 | [diff] [blame] | 15 | #include "include/gpu/GrDirectContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "samplecode/Sample.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 17 | #include "src/core/SkRectPriv.h" |
Adlai Holler | a069304 | 2020-10-14 11:23:11 -0400 | [diff] [blame] | 18 | #include "src/gpu/GrDirectContextPriv.h" |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 19 | #include "src/gpu/GrGpu.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/gpu/GrMemoryPool.h" |
Robert Phillips | e19babf | 2020-04-06 13:57:30 -0400 | [diff] [blame] | 21 | #include "src/gpu/GrOnFlushResourceProvider.h" |
| 22 | #include "src/gpu/GrOpFlushState.h" |
Robert Phillips | 30ebcf7 | 2020-07-09 13:25:17 -0400 | [diff] [blame] | 23 | #include "src/gpu/GrRecordingContextPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 24 | #include "src/gpu/GrRenderTargetContext.h" |
| 25 | #include "src/gpu/GrRenderTargetContextPriv.h" |
| 26 | #include "src/gpu/GrResourceProvider.h" |
| 27 | #include "src/gpu/ccpr/GrCCCoverageProcessor.h" |
| 28 | #include "src/gpu/ccpr/GrCCFillGeometry.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 29 | #include "src/gpu/ccpr/GrGSCoverageProcessor.h" |
| 30 | #include "src/gpu/ccpr/GrVSCoverageProcessor.h" |
Michael Ludwig | 663afe5 | 2019-06-03 16:46:19 -0400 | [diff] [blame] | 31 | #include "src/gpu/geometry/GrPathUtils.h" |
Robert Phillips | 03e4c95 | 2019-11-26 16:20:22 -0500 | [diff] [blame] | 32 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 33 | #include "src/gpu/ops/GrDrawOp.h" |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 34 | |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 35 | #ifdef SK_GL |
| 36 | #include "src/gpu/gl/GrGLGpu.h" |
| 37 | #endif |
| 38 | |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 39 | using TriPointInstance = GrCCCoverageProcessor::TriPointInstance; |
| 40 | using QuadPointInstance = GrCCCoverageProcessor::QuadPointInstance; |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 41 | using PrimitiveType = GrCCCoverageProcessor::PrimitiveType; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 42 | |
Chris Dalton | a640c49 | 2017-09-11 22:04:03 -0700 | [diff] [blame] | 43 | static constexpr float kDebugBloat = 40; |
| 44 | |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 45 | /** |
| 46 | * This sample visualizes the AA bloat geometry generated by the ccpr geometry shaders. It |
| 47 | * increases the AA bloat by 50x and outputs color instead of coverage (coverage=+1 -> green, |
| 48 | * coverage=0 -> black, coverage=-1 -> red). Use the keys 1-7 to cycle through the different |
| 49 | * geometry processors. |
| 50 | */ |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 51 | class CCPRGeometryView : public Sample { |
Hal Canary | d7639af | 2019-07-17 09:08:11 -0400 | [diff] [blame] | 52 | void onOnceBeforeDraw() override { this->updateGpuData(); } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 53 | void onDrawContent(SkCanvas*) override; |
| 54 | |
Hal Canary | b1f411a | 2019-08-29 10:39:22 -0400 | [diff] [blame] | 55 | Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) override; |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 56 | bool onClick(Sample::Click*) override; |
Hal Canary | 6cc65e1 | 2019-07-03 15:53:04 -0400 | [diff] [blame] | 57 | bool onChar(SkUnichar) override; |
Hal Canary | 8a02731 | 2019-07-03 10:55:44 -0400 | [diff] [blame] | 58 | SkString name() override { return SkString("CCPRGeometry"); } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 59 | |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 60 | class Click; |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 61 | class DrawCoverageCountOp; |
| 62 | class VisualizeCoverageCountFP; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 63 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 64 | void updateAndInval() { this->updateGpuData(); } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 65 | |
| 66 | void updateGpuData(); |
| 67 | |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 68 | PrimitiveType fPrimitiveType = PrimitiveType::kCubics; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 69 | |
| 70 | SkPoint fPoints[4] = { |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 71 | {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] | 72 | |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 73 | float fConicWeight = .5; |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 74 | float fStrokeWidth = 40; |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 75 | SkPaint::Join fStrokeJoin = SkPaint::kMiter_Join; |
| 76 | SkPaint::Cap fStrokeCap = SkPaint::kButt_Cap; |
| 77 | bool fDoStroke = true; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 78 | |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 79 | SkTArray<TriPointInstance> fTriPointInstances; |
| 80 | SkTArray<QuadPointInstance> fQuadPointInstances; |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 81 | SkPath fPath; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 82 | }; |
| 83 | |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 84 | class CCPRGeometryView::DrawCoverageCountOp : public GrDrawOp { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 85 | DEFINE_OP_CLASS_ID |
| 86 | |
| 87 | public: |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 88 | DrawCoverageCountOp(CCPRGeometryView* view) : INHERITED(ClassID()), fView(view) { |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 89 | this->setBounds(SkRect::MakeIWH(fView->width(), fView->height()), GrOp::HasAABloat::kNo, |
Greg Daniel | 5faf474 | 2019-10-01 15:14:44 -0400 | [diff] [blame] | 90 | GrOp::IsHairline::kNo); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 91 | } |
| 92 | |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 93 | const char* name() const override { |
| 94 | return "[Testing/Sample code] CCPRGeometryView::DrawCoverageCountOp"; |
| 95 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 96 | |
| 97 | private: |
| 98 | FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; } |
Chris Dalton | 6ce447a | 2019-06-23 18:07:38 -0600 | [diff] [blame] | 99 | GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, |
| 100 | bool hasMixedSampledCoverage, GrClampType) override { |
Chris Dalton | 4b62aed | 2019-01-15 11:53:00 -0700 | [diff] [blame] | 101 | return GrProcessorSet::EmptySetAnalysis(); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 102 | } |
Robert Phillips | c655c3a | 2020-03-18 13:23:45 -0400 | [diff] [blame] | 103 | void onPrePrepare(GrRecordingContext*, |
Adlai Holler | e2296f7 | 2020-11-19 13:41:26 -0500 | [diff] [blame] | 104 | const GrSurfaceProxyView& writeView, |
Robert Phillips | c655c3a | 2020-03-18 13:23:45 -0400 | [diff] [blame] | 105 | GrAppliedClip*, |
Greg Daniel | d358cbe | 2020-09-11 09:33:54 -0400 | [diff] [blame] | 106 | const GrXferProcessor::DstProxyView&, |
Greg Daniel | 42dbca5 | 2020-11-20 10:22:43 -0500 | [diff] [blame^] | 107 | GrXferBarrierFlags renderPassXferBarriers, |
| 108 | GrLoadOp colorLoadOp) override {} |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 109 | void onPrepare(GrOpFlushState*) override {} |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 110 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 111 | |
| 112 | CCPRGeometryView* fView; |
| 113 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 114 | using INHERITED = GrDrawOp; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 115 | }; |
| 116 | |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 117 | class CCPRGeometryView::VisualizeCoverageCountFP : public GrFragmentProcessor { |
| 118 | public: |
John Stiles | 39156c2 | 2020-07-21 12:05:47 -0400 | [diff] [blame] | 119 | static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> inputFP) { |
| 120 | return std::unique_ptr<GrFragmentProcessor>( |
| 121 | new VisualizeCoverageCountFP(std::move(inputFP))); |
| 122 | } |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 123 | |
| 124 | private: |
| 125 | const char* name() const override { |
John Stiles | 39156c2 | 2020-07-21 12:05:47 -0400 | [diff] [blame] | 126 | return "VisualizeCoverageCountFP"; |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 127 | } |
| 128 | std::unique_ptr<GrFragmentProcessor> clone() const override { |
John Stiles | 39156c2 | 2020-07-21 12:05:47 -0400 | [diff] [blame] | 129 | return std::unique_ptr<GrFragmentProcessor>(new VisualizeCoverageCountFP(*this)); |
| 130 | } |
| 131 | VisualizeCoverageCountFP(std::unique_ptr<GrFragmentProcessor> inputFP) |
| 132 | : GrFragmentProcessor(kTestFP_ClassID, kNone_OptimizationFlags) { |
| 133 | this->registerChild(std::move(inputFP)); |
| 134 | } |
| 135 | VisualizeCoverageCountFP(const VisualizeCoverageCountFP& that) |
| 136 | : GrFragmentProcessor(kTestFP_ClassID, kNone_OptimizationFlags) { |
| 137 | this->cloneAndRegisterAllChildProcessors(that); |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 138 | } |
| 139 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} |
| 140 | bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| 141 | |
| 142 | class Impl : public GrGLSLFragmentProcessor { |
| 143 | void emitCode(EmitArgs& args) override { |
| 144 | GrGLSLFPFragmentBuilder* f = args.fFragBuilder; |
John Stiles | 39156c2 | 2020-07-21 12:05:47 -0400 | [diff] [blame] | 145 | static constexpr int kInputFPIndex = 0; |
| 146 | SkString inputColor = this->invokeChild(kInputFPIndex, args); |
| 147 | f->codeAppendf("half count = %s.a;", inputColor.c_str()); |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 148 | f->codeAppendf("%s = half4(clamp(-count, 0, 1), clamp(+count, 0, 1), 0, abs(count));", |
| 149 | args.fOutputColor); |
| 150 | } |
| 151 | }; |
| 152 | |
| 153 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new Impl; } |
| 154 | }; |
| 155 | |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 156 | void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { |
Chris Dalton | 8738cf4 | 2018-03-09 11:57:40 -0700 | [diff] [blame] | 157 | canvas->clear(SK_ColorBLACK); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 158 | |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 159 | SkPaint outlinePaint; |
| 160 | outlinePaint.setColor(0xff808080); |
| 161 | outlinePaint.setStyle(SkPaint::kStroke_Style); |
| 162 | if (fDoStroke) { |
| 163 | outlinePaint.setStrokeWidth(fStrokeWidth); |
| 164 | } else { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 165 | outlinePaint.setStrokeWidth(0); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 166 | } |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 167 | outlinePaint.setStrokeJoin(fStrokeJoin); |
| 168 | outlinePaint.setStrokeCap(fStrokeCap); |
| 169 | outlinePaint.setAntiAlias(true); |
| 170 | canvas->drawPath(fPath, outlinePaint); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 171 | |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 172 | #if 0 |
| 173 | SkPaint gridPaint; |
| 174 | gridPaint.setColor(0x10000000); |
| 175 | gridPaint.setStyle(SkPaint::kStroke_Style); |
| 176 | gridPaint.setStrokeWidth(0); |
| 177 | gridPaint.setAntiAlias(true); |
Chris Dalton | a640c49 | 2017-09-11 22:04:03 -0700 | [diff] [blame] | 178 | for (int y = 0; y < this->height(); y += kDebugBloat) { |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 179 | canvas->drawLine(0, y, this->width(), y, gridPaint); |
| 180 | } |
Chris Dalton | a640c49 | 2017-09-11 22:04:03 -0700 | [diff] [blame] | 181 | for (int x = 0; x < this->width(); x += kDebugBloat) { |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 182 | canvas->drawLine(x, 0, x, this->height(), outlinePaint); |
| 183 | } |
| 184 | #endif |
| 185 | |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 186 | SkString caption; |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 187 | caption.appendf("PrimitiveType_%s", |
| 188 | GrCCCoverageProcessor::PrimitiveTypeName(fPrimitiveType)); |
| 189 | if (PrimitiveType::kCubics == fPrimitiveType) { |
Chris Dalton | a3df500 | 2020-10-30 12:26:20 -0600 | [diff] [blame] | 190 | caption.appendf(" (%s)", SkCubicTypeName(SkClassifyCubic(fPoints))); |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 191 | } else if (PrimitiveType::kConics == fPrimitiveType) { |
| 192 | caption.appendf(" (w=%f)", fConicWeight); |
| 193 | } |
| 194 | |
| 195 | if (fDoStroke) { |
| 196 | caption.appendf(" (stroke_width=%f)", fStrokeWidth); |
| 197 | } else if (GrRenderTargetContext* rtc = |
| 198 | canvas->internal_private_accessTopLayerRenderTargetContext()) { |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 199 | // Render coverage count. |
Robert Phillips | 30ebcf7 | 2020-07-09 13:25:17 -0400 | [diff] [blame] | 200 | auto ctx = canvas->recordingContext(); |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 201 | SkASSERT(ctx); |
| 202 | |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 203 | int width = this->width(); |
| 204 | int height = this->height(); |
| 205 | auto ccbuff = GrRenderTargetContext::Make( |
| 206 | ctx, GrColorType::kAlpha_F16, nullptr, SkBackingFit::kApprox, {width, height}); |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 207 | SkASSERT(ccbuff); |
Michael Ludwig | 81d4172 | 2020-05-26 16:57:38 -0400 | [diff] [blame] | 208 | ccbuff->clear(SK_PMColor4fTRANSPARENT); |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 209 | ccbuff->priv().testingOnly_addDrawOp(GrOp::Make<DrawCoverageCountOp>(ctx, this)); |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 210 | |
| 211 | // Visualize coverage count in main canvas. |
| 212 | GrPaint paint; |
John Stiles | 5933d7d | 2020-07-21 12:28:35 -0400 | [diff] [blame] | 213 | paint.setColorFragmentProcessor(VisualizeCoverageCountFP::Make( |
John Stiles | 39156c2 | 2020-07-21 12:05:47 -0400 | [diff] [blame] | 214 | GrTextureEffect::Make(ccbuff->readSurfaceView(), ccbuff->colorInfo().alphaType()))); |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 215 | paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver); |
Michael Ludwig | 7c12e28 | 2020-05-29 09:54:07 -0400 | [diff] [blame] | 216 | rtc->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(), |
Chris Dalton | 8d38a7f | 2018-03-19 14:16:44 -0600 | [diff] [blame] | 217 | SkRect::MakeIWH(this->width(), this->height())); |
Chris Dalton | be4ffab | 2017-12-08 10:59:58 -0700 | [diff] [blame] | 218 | } else { |
| 219 | caption = "Use GPU backend to visualize geometry."; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | SkPaint pointsPaint; |
| 223 | pointsPaint.setColor(SK_ColorBLUE); |
| 224 | pointsPaint.setStrokeWidth(8); |
| 225 | pointsPaint.setAntiAlias(true); |
| 226 | |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 227 | if (PrimitiveType::kCubics == fPrimitiveType) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 228 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, fPoints, pointsPaint); |
| 229 | } else { |
| 230 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, fPoints, pointsPaint); |
| 231 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 1, fPoints + 3, pointsPaint); |
| 232 | } |
| 233 | |
Hal Canary | 4484b8f | 2019-01-08 14:00:08 -0500 | [diff] [blame] | 234 | SkFont font(nullptr, 20); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 235 | SkPaint captionPaint; |
Chris Dalton | 8738cf4 | 2018-03-09 11:57:40 -0700 | [diff] [blame] | 236 | captionPaint.setColor(SK_ColorWHITE); |
Hal Canary | 4484b8f | 2019-01-08 14:00:08 -0500 | [diff] [blame] | 237 | canvas->drawString(caption, 10, 30, font, captionPaint); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | void CCPRGeometryView::updateGpuData() { |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 241 | using Verb = GrCCFillGeometry::Verb; |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 242 | fTriPointInstances.reset(); |
| 243 | fQuadPointInstances.reset(); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 244 | |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 245 | fPath.reset(); |
| 246 | fPath.moveTo(fPoints[0]); |
| 247 | |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 248 | if (PrimitiveType::kCubics == fPrimitiveType) { |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 249 | GrCCFillGeometry geometry; |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 250 | geometry.beginContour(fPoints[0]); |
Chris Dalton | 7ca3b7b | 2018-04-10 00:21:19 -0600 | [diff] [blame] | 251 | geometry.cubicTo(fPoints, kDebugBloat / 2, kDebugBloat / 2); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 252 | geometry.endContour(); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 253 | int ptsIdx = 0; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 254 | for (Verb verb : geometry.verbs()) { |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 255 | switch (verb) { |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 256 | case Verb::kLineTo: |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 257 | ++ptsIdx; |
| 258 | continue; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 259 | case Verb::kMonotonicQuadraticTo: |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 260 | ptsIdx += 2; |
| 261 | continue; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 262 | case Verb::kMonotonicCubicTo: |
Chris Dalton | 84403d7 | 2018-02-13 21:46:17 -0500 | [diff] [blame] | 263 | fQuadPointInstances.push_back().set(&geometry.points()[ptsIdx], 0, 0); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 264 | ptsIdx += 3; |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 265 | continue; |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 266 | default: |
| 267 | continue; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 268 | } |
| 269 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 270 | fPath.cubicTo(fPoints[1], fPoints[2], fPoints[3]); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 271 | } else if (PrimitiveType::kTriangles != fPrimitiveType) { |
Chris Dalton | 7ca3b7b | 2018-04-10 00:21:19 -0600 | [diff] [blame] | 272 | SkPoint P3[3] = {fPoints[0], fPoints[1], fPoints[3]}; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 273 | GrCCFillGeometry geometry; |
Chris Dalton | 7ca3b7b | 2018-04-10 00:21:19 -0600 | [diff] [blame] | 274 | geometry.beginContour(P3[0]); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 275 | if (PrimitiveType::kQuadratics == fPrimitiveType) { |
| 276 | geometry.quadraticTo(P3); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 277 | fPath.quadTo(fPoints[1], fPoints[3]); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 278 | } else { |
| 279 | SkASSERT(PrimitiveType::kConics == fPrimitiveType); |
| 280 | geometry.conicTo(P3, fConicWeight); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 281 | fPath.conicTo(fPoints[1], fPoints[3], fConicWeight); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 282 | } |
Chris Dalton | c1e5963 | 2017-09-05 00:30:07 -0600 | [diff] [blame] | 283 | geometry.endContour(); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 284 | int ptsIdx = 0, conicWeightIdx = 0; |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 285 | for (Verb verb : geometry.verbs()) { |
| 286 | if (Verb::kBeginContour == verb || |
| 287 | Verb::kEndOpenContour == verb || |
| 288 | Verb::kEndClosedContour == verb) { |
Chris Dalton | c1e5963 | 2017-09-05 00:30:07 -0600 | [diff] [blame] | 289 | continue; |
| 290 | } |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 291 | if (Verb::kLineTo == verb) { |
Chris Dalton | 90e8fb1 | 2017-12-22 02:24:53 -0700 | [diff] [blame] | 292 | ++ptsIdx; |
| 293 | continue; |
| 294 | } |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 295 | SkASSERT(Verb::kMonotonicQuadraticTo == verb || Verb::kMonotonicConicTo == verb); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 296 | if (PrimitiveType::kQuadratics == fPrimitiveType && |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 297 | Verb::kMonotonicQuadraticTo == verb) { |
Chris Dalton | c3318f0 | 2019-07-19 14:20:53 -0600 | [diff] [blame] | 298 | fTriPointInstances.push_back().set( |
| 299 | &geometry.points()[ptsIdx], Sk2f(0, 0), |
| 300 | TriPointInstance::Ordering::kXYTransposed); |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 301 | } else if (PrimitiveType::kConics == fPrimitiveType && |
Chris Dalton | e163969 | 2018-08-20 14:00:30 -0600 | [diff] [blame] | 302 | Verb::kMonotonicConicTo == verb) { |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 303 | fQuadPointInstances.push_back().setW(&geometry.points()[ptsIdx], Sk2f(0, 0), |
| 304 | geometry.getConicWeight(conicWeightIdx++)); |
| 305 | } |
Chris Dalton | a3e9271 | 2017-12-04 11:45:51 -0700 | [diff] [blame] | 306 | ptsIdx += 2; |
Chris Dalton | b072bb6 | 2017-08-07 09:00:46 -0600 | [diff] [blame] | 307 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 308 | } else { |
Chris Dalton | c3318f0 | 2019-07-19 14:20:53 -0600 | [diff] [blame] | 309 | fTriPointInstances.push_back().set( |
| 310 | fPoints[0], fPoints[1], fPoints[3], Sk2f(0, 0), |
| 311 | TriPointInstance::Ordering::kXYTransposed); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 312 | fPath.lineTo(fPoints[1]); |
| 313 | fPath.lineTo(fPoints[3]); |
| 314 | fPath.close(); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 318 | void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state, |
| 319 | const SkRect& chainBounds) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 320 | GrResourceProvider* rp = state->resourceProvider(); |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 321 | #ifdef SK_GL |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 322 | auto direct = state->gpu()->getContext(); |
Robert Phillips | 30ebcf7 | 2020-07-09 13:25:17 -0400 | [diff] [blame] | 323 | GrGLGpu* glGpu = GrBackendApi::kOpenGL == direct->backend() |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 324 | ? static_cast<GrGLGpu*>(state->gpu()) |
| 325 | : nullptr; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 326 | if (glGpu) { |
| 327 | glGpu->handleDirtyContext(); |
Chris Dalton | 8738cf4 | 2018-03-09 11:57:40 -0700 | [diff] [blame] | 328 | // 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] | 329 | GR_GL_CALL(glGpu->glInterface(), Enable(GR_GL_LINE_SMOOTH)); |
| 330 | } |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 331 | #endif |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 332 | |
Greg Daniel | 2c3398d | 2019-06-19 11:58:01 -0400 | [diff] [blame] | 333 | GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kPlus, |
Adlai Holler | e2296f7 | 2020-11-19 13:41:26 -0500 | [diff] [blame] | 334 | state->drawOpArgs().writeView().swizzle()); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 335 | |
Chris Dalton | 2c5e011 | 2019-03-29 13:14:18 -0500 | [diff] [blame] | 336 | std::unique_ptr<GrCCCoverageProcessor> proc; |
| 337 | if (state->caps().shaderCaps()->geometryShaderSupport()) { |
Mike Klein | f46d5ca | 2019-12-11 10:45:01 -0500 | [diff] [blame] | 338 | proc = std::make_unique<GrGSCoverageProcessor>(); |
Chris Dalton | 2c5e011 | 2019-03-29 13:14:18 -0500 | [diff] [blame] | 339 | } else { |
Mike Klein | f46d5ca | 2019-12-11 10:45:01 -0500 | [diff] [blame] | 340 | proc = std::make_unique<GrVSCoverageProcessor>(); |
Chris Dalton | 2c5e011 | 2019-03-29 13:14:18 -0500 | [diff] [blame] | 341 | } |
Chris Dalton | 39ca973 | 2020-03-10 10:34:17 -0600 | [diff] [blame] | 342 | SkDEBUGCODE(proc->enableDebugBloat(kDebugBloat)); |
| 343 | |
| 344 | GrOpsRenderPass* renderPass = state->opsRenderPass(); |
Chris Dalton | 2c5e011 | 2019-03-29 13:14:18 -0500 | [diff] [blame] | 345 | |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 346 | for (int i = 0; i < proc->numSubpasses(); ++i) { |
| 347 | proc->reset(fView->fPrimitiveType, i, rp); |
| 348 | proc->bindPipeline(state, pipeline, this->bounds()); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 349 | |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 350 | if (PrimitiveType::kCubics == fView->fPrimitiveType || |
| 351 | PrimitiveType::kConics == fView->fPrimitiveType) { |
| 352 | sk_sp<GrGpuBuffer> instBuff(rp->createBuffer( |
| 353 | fView->fQuadPointInstances.count() * sizeof(QuadPointInstance), |
| 354 | GrGpuBufferType::kVertex, kDynamic_GrAccessPattern, |
| 355 | fView->fQuadPointInstances.begin())); |
| 356 | if (!fView->fQuadPointInstances.empty() && instBuff) { |
| 357 | proc->bindBuffers(renderPass, std::move(instBuff)); |
| 358 | proc->drawInstances(renderPass, fView->fQuadPointInstances.count(), 0); |
| 359 | } |
| 360 | } else { |
| 361 | sk_sp<GrGpuBuffer> instBuff(rp->createBuffer( |
| 362 | fView->fTriPointInstances.count() * sizeof(TriPointInstance), |
| 363 | GrGpuBufferType::kVertex, kDynamic_GrAccessPattern, |
| 364 | fView->fTriPointInstances.begin())); |
| 365 | if (!fView->fTriPointInstances.empty() && instBuff) { |
| 366 | proc->bindBuffers(renderPass, std::move(instBuff)); |
| 367 | proc->drawInstances(renderPass, fView->fTriPointInstances.count(), 0); |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 368 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 369 | } |
Chris Dalton | 2326177 | 2017-12-10 16:41:45 -0700 | [diff] [blame] | 370 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 371 | |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 372 | #ifdef SK_GL |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 373 | if (glGpu) { |
Robert Phillips | 30ebcf7 | 2020-07-09 13:25:17 -0400 | [diff] [blame] | 374 | direct->resetContext(kMisc_GrGLBackendState); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 375 | } |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 376 | #endif |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 377 | } |
| 378 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 379 | class CCPRGeometryView::Click : public Sample::Click { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 380 | public: |
Hal Canary | fcf6359 | 2019-07-12 11:32:43 -0400 | [diff] [blame] | 381 | Click(int ptIdx) : fPtIdx(ptIdx) {} |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 382 | |
| 383 | void doClick(SkPoint points[]) { |
| 384 | if (fPtIdx >= 0) { |
Hal Canary | fcf6359 | 2019-07-12 11:32:43 -0400 | [diff] [blame] | 385 | points[fPtIdx] += fCurr - fPrev; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 386 | } else { |
| 387 | for (int i = 0; i < 4; ++i) { |
Hal Canary | fcf6359 | 2019-07-12 11:32:43 -0400 | [diff] [blame] | 388 | points[i] += fCurr - fPrev; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | private: |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 394 | int fPtIdx; |
| 395 | }; |
| 396 | |
Hal Canary | b1f411a | 2019-08-29 10:39:22 -0400 | [diff] [blame] | 397 | Sample::Click* CCPRGeometryView::onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 398 | for (int i = 0; i < 4; ++i) { |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 399 | if (PrimitiveType::kCubics != fPrimitiveType && 2 == i) { |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 400 | continue; |
| 401 | } |
| 402 | if (fabs(x - fPoints[i].x()) < 20 && fabsf(y - fPoints[i].y()) < 20) { |
Hal Canary | fcf6359 | 2019-07-12 11:32:43 -0400 | [diff] [blame] | 403 | return new Click(i); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 404 | } |
| 405 | } |
Hal Canary | fcf6359 | 2019-07-12 11:32:43 -0400 | [diff] [blame] | 406 | return new Click(-1); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 407 | } |
| 408 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 409 | bool CCPRGeometryView::onClick(Sample::Click* click) { |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 410 | Click* myClick = (Click*)click; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 411 | myClick->doClick(fPoints); |
| 412 | this->updateAndInval(); |
| 413 | return true; |
| 414 | } |
| 415 | |
Hal Canary | 6cc65e1 | 2019-07-03 15:53:04 -0400 | [diff] [blame] | 416 | bool CCPRGeometryView::onChar(SkUnichar unichar) { |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 417 | if (unichar >= '1' && unichar <= '4') { |
Chris Dalton | 8dfc70f | 2018-03-26 19:15:22 -0600 | [diff] [blame] | 418 | fPrimitiveType = PrimitiveType(unichar - '1'); |
Chris Dalton | 703b476 | 2018-04-06 16:11:48 -0600 | [diff] [blame] | 419 | if (fPrimitiveType >= PrimitiveType::kWeightedTriangles) { |
| 420 | fPrimitiveType = (PrimitiveType) ((int)fPrimitiveType + 1); |
| 421 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 422 | this->updateAndInval(); |
| 423 | return true; |
| 424 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 425 | float* valueToScale = nullptr; |
| 426 | if (fDoStroke) { |
| 427 | valueToScale = &fStrokeWidth; |
| 428 | } else if (PrimitiveType::kConics == fPrimitiveType) { |
| 429 | valueToScale = &fConicWeight; |
| 430 | } |
| 431 | if (valueToScale) { |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 432 | if (unichar == '+') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 433 | *valueToScale *= 2; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 434 | this->updateAndInval(); |
| 435 | return true; |
| 436 | } |
| 437 | if (unichar == '+' || unichar == '=') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 438 | *valueToScale *= 5/4.f; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 439 | this->updateAndInval(); |
| 440 | return true; |
| 441 | } |
| 442 | if (unichar == '-') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 443 | *valueToScale *= 4/5.f; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 444 | this->updateAndInval(); |
| 445 | return true; |
| 446 | } |
| 447 | if (unichar == '_') { |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 448 | *valueToScale *= .5f; |
Chris Dalton | 9f2dab0 | 2018-04-18 14:07:03 -0600 | [diff] [blame] | 449 | this->updateAndInval(); |
| 450 | return true; |
| 451 | } |
| 452 | } |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 453 | if (unichar == 'D') { |
| 454 | SkDebugf(" SkPoint fPoints[4] = {\n"); |
Chris Dalton | 7f578bf | 2017-09-05 16:46:48 -0600 | [diff] [blame] | 455 | SkDebugf(" {%ff, %ff},\n", fPoints[0].x(), fPoints[0].y()); |
| 456 | SkDebugf(" {%ff, %ff},\n", fPoints[1].x(), fPoints[1].y()); |
| 457 | SkDebugf(" {%ff, %ff},\n", fPoints[2].x(), fPoints[2].y()); |
| 458 | SkDebugf(" {%ff, %ff}\n", fPoints[3].x(), fPoints[3].y()); |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 459 | SkDebugf(" };\n"); |
| 460 | return true; |
| 461 | } |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 462 | if (unichar == 'S') { |
| 463 | fDoStroke = !fDoStroke; |
| 464 | this->updateAndInval(); |
Chris Dalton | 9eea916 | 2020-07-23 15:36:25 -0600 | [diff] [blame] | 465 | return true; |
| 466 | } |
| 467 | if (unichar == 'J') { |
| 468 | fStrokeJoin = (SkPaint::Join)((fStrokeJoin + 1) % 3); |
| 469 | this->updateAndInval(); |
| 470 | return true; |
| 471 | } |
| 472 | if (unichar == 'C') { |
| 473 | fStrokeCap = (SkPaint::Cap)((fStrokeCap + 1) % 3); |
| 474 | this->updateAndInval(); |
| 475 | return true; |
Chris Dalton | 09a7bb2 | 2018-08-31 19:53:15 +0800 | [diff] [blame] | 476 | } |
Hal Canary | 6cc65e1 | 2019-07-03 15:53:04 -0400 | [diff] [blame] | 477 | return false; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 478 | } |
| 479 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 480 | DEF_SAMPLE(return new CCPRGeometryView;) |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 481 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 482 | #endif // SK_SUPPORT_GPU |