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