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