Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkBlendMode.h" |
| 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkColorSpace.h" |
| 12 | #include "include/core/SkMatrix.h" |
| 13 | #include "include/core/SkPoint.h" |
| 14 | #include "include/core/SkRect.h" |
| 15 | #include "include/core/SkRefCnt.h" |
| 16 | #include "include/core/SkSize.h" |
| 17 | #include "include/core/SkString.h" |
| 18 | #include "include/core/SkTypes.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "include/gpu/GrContext.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 20 | #include "include/gpu/GrTypes.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 21 | #include "include/private/GrRecordingContext.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 22 | #include "include/private/GrTypesPriv.h" |
| 23 | #include "include/private/SkColorData.h" |
| 24 | #include "src/gpu/GrBuffer.h" |
| 25 | #include "src/gpu/GrCaps.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 26 | #include "src/gpu/GrClip.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 27 | #include "src/gpu/GrColorSpaceXform.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 28 | #include "src/gpu/GrContextPriv.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 29 | #include "src/gpu/GrGeometryProcessor.h" |
| 30 | #include "src/gpu/GrGpuBuffer.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 31 | #include "src/gpu/GrMemoryPool.h" |
| 32 | #include "src/gpu/GrOpFlushState.h" |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 33 | #include "src/gpu/GrOpsRenderPass.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 34 | #include "src/gpu/GrPipeline.h" |
| 35 | #include "src/gpu/GrPrimitiveProcessor.h" |
| 36 | #include "src/gpu/GrProcessor.h" |
| 37 | #include "src/gpu/GrProcessorSet.h" |
Robert Phillips | 901aff0 | 2019-10-08 12:32:56 -0400 | [diff] [blame] | 38 | #include "src/gpu/GrProgramInfo.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 39 | #include "src/gpu/GrRecordingContextPriv.h" |
| 40 | #include "src/gpu/GrRenderTargetContext.h" |
| 41 | #include "src/gpu/GrRenderTargetContextPriv.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 42 | #include "src/gpu/GrResourceProvider.h" |
Brian Salomon | 201cdbb | 2019-08-14 17:00:30 -0400 | [diff] [blame] | 43 | #include "src/gpu/GrSamplerState.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 44 | #include "src/gpu/GrShaderCaps.h" |
| 45 | #include "src/gpu/GrShaderVar.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 46 | #include "src/gpu/GrSurfaceProxy.h" |
| 47 | #include "src/gpu/GrTextureProxy.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 48 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
| 49 | #include "src/gpu/glsl/GrGLSLGeometryProcessor.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 50 | #include "src/gpu/glsl/GrGLSLPrimitiveProcessor.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 51 | #include "src/gpu/glsl/GrGLSLVarying.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 52 | #include "src/gpu/ops/GrDrawOp.h" |
| 53 | #include "src/gpu/ops/GrOp.h" |
Robert Phillips | 34cea00 | 2019-11-21 16:02:34 -0500 | [diff] [blame] | 54 | #include "tools/gpu/ProxyUtils.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 55 | |
| 56 | #include <memory> |
| 57 | #include <utility> |
| 58 | |
| 59 | class GrAppliedClip; |
| 60 | class GrGLSLProgramDataManager; |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 61 | |
Hal Canary | fa3305a | 2019-07-18 12:36:54 -0400 | [diff] [blame] | 62 | namespace { |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 63 | |
Brian Osman | d4c2970 | 2018-09-14 16:16:55 -0400 | [diff] [blame] | 64 | static constexpr GrGeometryProcessor::Attribute gVertex = |
Stephen White | 1e1ad8d | 2019-06-19 14:19:47 -0400 | [diff] [blame] | 65 | {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * This is a GPU-backend specific test. It ensures that SkSL properly identifies clockwise-winding |
| 69 | * triangles (sk_Clockwise), in terms of to Skia device space, in all backends and with all render |
| 70 | * target origins. We draw clockwise triangles green and counter-clockwise red. |
| 71 | */ |
Hal Canary | fa3305a | 2019-07-18 12:36:54 -0400 | [diff] [blame] | 72 | class ClockwiseGM : public skiagm::GpuGM { |
| 73 | SkString onShortName() override { return SkString("clockwise"); } |
| 74 | SkISize onISize() override { return {300, 200}; } |
Chris Dalton | 3a77837 | 2019-02-07 15:23:36 -0700 | [diff] [blame] | 75 | void onDraw(GrContext*, GrRenderTargetContext*, SkCanvas*) override; |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 79 | // SkSL code. |
| 80 | |
| 81 | class ClockwiseTestProcessor : public GrGeometryProcessor { |
| 82 | public: |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 83 | static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool readSkFragCoord) { |
| 84 | return arena->make<ClockwiseTestProcessor>(readSkFragCoord); |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | const char* name() const final { return "ClockwiseTestProcessor"; } |
| 88 | |
| 89 | void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const final { |
| 90 | b->add32(fReadSkFragCoord); |
| 91 | } |
| 92 | |
| 93 | GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const final; |
| 94 | |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 95 | bool readSkFragCoord() const { return fReadSkFragCoord; } |
| 96 | |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 97 | private: |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 98 | friend class ::SkArenaAlloc; // for access to ctor |
| 99 | |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 100 | ClockwiseTestProcessor(bool readSkFragCoord) |
| 101 | : GrGeometryProcessor(kClockwiseTestProcessor_ClassID) |
| 102 | , fReadSkFragCoord(readSkFragCoord) { |
Brian Osman | f04fb3c | 2018-11-12 15:34:00 -0500 | [diff] [blame] | 103 | this->setVertexAttributes(&gVertex, 1); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 104 | } |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 105 | |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 106 | const bool fReadSkFragCoord; |
| 107 | |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 108 | typedef GrGeometryProcessor INHERITED; |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | class GLSLClockwiseTestProcessor : public GrGLSLGeometryProcessor { |
| 112 | void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor&, |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 113 | const CoordTransformRange&) override {} |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 114 | |
| 115 | void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
| 116 | const ClockwiseTestProcessor& proc = args.fGP.cast<ClockwiseTestProcessor>(); |
| 117 | args.fVaryingHandler->emitAttributes(proc); |
Stephen White | 1e1ad8d | 2019-06-19 14:19:47 -0400 | [diff] [blame] | 118 | gpArgs->fPositionVar.set(kFloat2_GrSLType, "position"); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 119 | args.fFragBuilder->codeAppendf( |
| 120 | "%s = sk_Clockwise ? half4(0,1,0,1) : half4(1,0,0,1);", args.fOutputColor); |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 121 | if (!proc.readSkFragCoord()) { |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 122 | args.fFragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage); |
| 123 | } else { |
| 124 | // Verify layout(origin_upper_left) on gl_FragCoord does not affect gl_FrontFacing. |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 125 | args.fFragBuilder->codeAppendf("%s = half4(min(half(sk_FragCoord.y), 1));", |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 126 | args.fOutputCoverage); |
| 127 | } |
| 128 | } |
| 129 | }; |
| 130 | |
| 131 | GrGLSLPrimitiveProcessor* ClockwiseTestProcessor::createGLSLInstance( |
| 132 | const GrShaderCaps&) const { |
| 133 | return new GLSLClockwiseTestProcessor; |
| 134 | } |
| 135 | |
| 136 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 137 | // Draw Op. |
| 138 | |
| 139 | class ClockwiseTestOp : public GrDrawOp { |
| 140 | public: |
| 141 | DEFINE_OP_CLASS_ID |
| 142 | |
Robert Phillips | be9aff2 | 2019-02-15 11:33:22 -0500 | [diff] [blame] | 143 | static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, |
| 144 | bool readSkFragCoord, int y = 0) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 145 | GrOpMemoryPool* pool = context->priv().opMemoryPool(); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 146 | return pool->allocate<ClockwiseTestOp>(readSkFragCoord, y); |
| 147 | } |
| 148 | |
| 149 | private: |
| 150 | ClockwiseTestOp(bool readSkFragCoord, float y) |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 151 | : GrDrawOp(ClassID()) |
| 152 | , fReadSkFragCoord(readSkFragCoord) |
| 153 | , fY(y) { |
Greg Daniel | 5faf474 | 2019-10-01 15:14:44 -0400 | [diff] [blame] | 154 | this->setBounds(SkRect::MakeXYWH(0, fY, 100, 100), HasAABloat::kNo, IsHairline::kNo); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | const char* name() const override { return "ClockwiseTestOp"; } |
| 158 | FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; } |
Chris Dalton | 6ce447a | 2019-06-23 18:07:38 -0600 | [diff] [blame] | 159 | GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, |
| 160 | bool hasMixedSampledCoverage, GrClampType) override { |
Chris Dalton | 4b62aed | 2019-01-15 11:53:00 -0700 | [diff] [blame] | 161 | return GrProcessorSet::EmptySetAnalysis(); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 162 | } |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 163 | |
Robert Phillips | ac6156c | 2020-02-28 16:02:40 -0500 | [diff] [blame] | 164 | GrProgramInfo* createProgramInfo(const GrCaps* caps, |
| 165 | SkArenaAlloc* arena, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 166 | const GrSurfaceProxyView* writeView, |
Robert Phillips | ac6156c | 2020-02-28 16:02:40 -0500 | [diff] [blame] | 167 | GrAppliedClip&& appliedClip, |
| 168 | const GrXferProcessor::DstProxyView& dstProxyView) const { |
| 169 | GrGeometryProcessor* geomProc = ClockwiseTestProcessor::Make(arena, fReadSkFragCoord); |
| 170 | |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 171 | return sk_gpu_test::CreateProgramInfo(caps, arena, writeView, |
Robert Phillips | ac6156c | 2020-02-28 16:02:40 -0500 | [diff] [blame] | 172 | std::move(appliedClip), dstProxyView, |
| 173 | geomProc, SkBlendMode::kPlus, |
| 174 | GrPrimitiveType::kTriangleStrip); |
| 175 | } |
| 176 | |
| 177 | GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const { |
| 178 | return this->createProgramInfo(&flushState->caps(), |
| 179 | flushState->allocator(), |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 180 | flushState->writeView(), |
Robert Phillips | ac6156c | 2020-02-28 16:02:40 -0500 | [diff] [blame] | 181 | flushState->detachAppliedClip(), |
| 182 | flushState->dstProxyView()); |
| 183 | } |
| 184 | |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 185 | void onPrePrepare(GrRecordingContext* context, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 186 | const GrSurfaceProxyView* writeView, |
Robert Phillips | 34cea00 | 2019-11-21 16:02:34 -0500 | [diff] [blame] | 187 | GrAppliedClip* clip, |
Robert Phillips | 8053c97 | 2019-11-21 10:44:53 -0500 | [diff] [blame] | 188 | const GrXferProcessor::DstProxyView& dstProxyView) final { |
Robert Phillips | d4fb7c7 | 2019-11-15 17:28:37 -0500 | [diff] [blame] | 189 | SkArenaAlloc* arena = context->priv().recordTimeAllocator(); |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 190 | |
Robert Phillips | 34cea00 | 2019-11-21 16:02:34 -0500 | [diff] [blame] | 191 | // This is equivalent to a GrOpFlushState::detachAppliedClip |
| 192 | GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip(); |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 193 | |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 194 | fProgramInfo = this->createProgramInfo(context->priv().caps(), arena, writeView, |
Robert Phillips | ac6156c | 2020-02-28 16:02:40 -0500 | [diff] [blame] | 195 | std::move(appliedClip), dstProxyView); |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 196 | |
Robert Phillips | ac6156c | 2020-02-28 16:02:40 -0500 | [diff] [blame] | 197 | context->priv().recordProgramInfo(fProgramInfo); |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 198 | } |
| 199 | |
Greg Daniel | f793de1 | 2019-09-05 13:23:23 -0400 | [diff] [blame] | 200 | void onPrepare(GrOpFlushState* flushState) override { |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 201 | SkPoint vertices[4] = { |
| 202 | {100, fY}, |
| 203 | {0, fY+100}, |
| 204 | {0, fY}, |
| 205 | {100, fY+100}, |
| 206 | }; |
Greg Daniel | f793de1 | 2019-09-05 13:23:23 -0400 | [diff] [blame] | 207 | fVertexBuffer = flushState->resourceProvider()->createBuffer( |
| 208 | sizeof(vertices), GrGpuBufferType::kVertex, kStatic_GrAccessPattern, vertices); |
| 209 | } |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 210 | |
Greg Daniel | f793de1 | 2019-09-05 13:23:23 -0400 | [diff] [blame] | 211 | void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { |
| 212 | if (!fVertexBuffer) { |
Chris Dalton | 79f99f7 | 2018-07-27 14:15:10 -0600 | [diff] [blame] | 213 | return; |
| 214 | } |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 215 | |
Robert Phillips | 34cea00 | 2019-11-21 16:02:34 -0500 | [diff] [blame] | 216 | if (!fProgramInfo) { |
Robert Phillips | ac6156c | 2020-02-28 16:02:40 -0500 | [diff] [blame] | 217 | fProgramInfo = this->createProgramInfo(flushState); |
Robert Phillips | 34cea00 | 2019-11-21 16:02:34 -0500 | [diff] [blame] | 218 | } |
| 219 | |
Chris Dalton | aa0e45c | 2020-03-16 10:05:11 -0600 | [diff] [blame] | 220 | flushState->bindPipeline(*fProgramInfo, SkRect::MakeXYWH(0, fY, 100, 100)); |
| 221 | flushState->bindBuffers(nullptr, nullptr, fVertexBuffer.get()); |
| 222 | flushState->draw(4, 0); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 223 | } |
| 224 | |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 225 | sk_sp<GrBuffer> fVertexBuffer; |
| 226 | const bool fReadSkFragCoord; |
| 227 | const float fY; |
Robert Phillips | df70f15 | 2019-11-15 14:57:05 -0500 | [diff] [blame] | 228 | |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 229 | // The program info (and both the GrPipeline and GrPrimitiveProcessor it relies on), when |
Robert Phillips | 34cea00 | 2019-11-21 16:02:34 -0500 | [diff] [blame] | 230 | // allocated, are allocated in either the ddl-record-time or flush-time arena. It is the |
| 231 | // arena's job to free up their memory so we just have a bare programInfo pointer here. We |
| 232 | // don't even store the GrPipeline and GrPrimitiveProcessor pointers here bc they are |
| 233 | // guaranteed to have the same lifetime as the program info. |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 234 | GrProgramInfo* fProgramInfo = nullptr; |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 235 | |
| 236 | friend class ::GrOpMemoryPool; // for ctor |
Robert Phillips | 5d07c52 | 2019-11-18 11:19:51 -0500 | [diff] [blame] | 237 | |
| 238 | typedef GrDrawOp INHERITED; |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 242 | // Test. |
| 243 | |
Chris Dalton | 3a77837 | 2019-02-07 15:23:36 -0700 | [diff] [blame] | 244 | void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* canvas) { |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 245 | rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 246 | |
| 247 | // Draw the test directly to the frame buffer. |
| 248 | rtc->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0)); |
| 249 | rtc->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, true, 100)); |
| 250 | |
| 251 | // Draw the test to an off-screen, top-down render target. |
Greg Daniel | c594e62 | 2019-10-15 14:01:49 -0400 | [diff] [blame] | 252 | GrColorType rtcColorType = rtc->colorInfo().colorType(); |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 253 | if (auto topLeftRTC = GrRenderTargetContext::Make( |
| 254 | ctx, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, 1, |
| 255 | GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin, SkBudgeted::kYes, |
| 256 | nullptr)) { |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 257 | topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT, |
| 258 | GrRenderTargetContext::CanClearFullscreen::kYes); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 259 | topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0)); |
| 260 | topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, true, 100)); |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 261 | rtc->drawTexture(GrNoClip(), topLeftRTC->readSurfaceView(), rtc->colorInfo().alphaType(), |
| 262 | GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver, SK_PMColor4fWHITE, |
| 263 | {0, 0, 100, 200}, {100, 0, 200, 200}, GrAA::kNo, GrQuadAAFlags::kNone, |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 264 | SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint, SkMatrix::I(), |
Brian Osman | 3d139a4 | 2018-11-19 10:42:10 -0500 | [diff] [blame] | 265 | nullptr); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | // Draw the test to an off-screen, bottom-up render target. |
Greg Daniel | e20fcad | 2020-01-08 11:52:34 -0500 | [diff] [blame] | 269 | if (auto topLeftRTC = GrRenderTargetContext::Make( |
| 270 | ctx, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, 1, |
| 271 | GrMipMapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin, SkBudgeted::kYes, |
| 272 | nullptr)) { |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 273 | topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT, |
| 274 | GrRenderTargetContext::CanClearFullscreen::kYes); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 275 | topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0)); |
| 276 | topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, true, 100)); |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 277 | rtc->drawTexture(GrNoClip(), topLeftRTC->readSurfaceView(), rtc->colorInfo().alphaType(), |
| 278 | GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver, SK_PMColor4fWHITE, |
| 279 | {0, 0, 100, 200}, {200, 0, 300, 200}, GrAA::kNo, GrQuadAAFlags::kNone, |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 280 | SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint, SkMatrix::I(), |
Brian Osman | 3d139a4 | 2018-11-19 10:42:10 -0500 | [diff] [blame] | 281 | nullptr); |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
| 285 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 286 | |
| 287 | DEF_GM( return new ClockwiseGM(); ) |
| 288 | |
| 289 | } |