2018-07-27 18:38:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkBlendMode.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkColorSpace.h"
|
|
|
|
#include "include/core/SkMatrix.h"
|
|
|
|
#include "include/core/SkPoint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
2020-07-01 16:55:01 +00:00
|
|
|
#include "include/gpu/GrRecordingContext.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/gpu/GrTypes.h"
|
|
|
|
#include "include/private/GrTypesPriv.h"
|
|
|
|
#include "include/private/SkColorData.h"
|
2021-07-21 19:39:51 +00:00
|
|
|
#include "src/core/SkCanvasPriv.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "src/gpu/GrBuffer.h"
|
|
|
|
#include "src/gpu/GrCaps.h"
|
|
|
|
#include "src/gpu/GrColorSpaceXform.h"
|
2020-10-14 15:23:11 +00:00
|
|
|
#include "src/gpu/GrDirectContextPriv.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "src/gpu/GrGeometryProcessor.h"
|
|
|
|
#include "src/gpu/GrGpuBuffer.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrMemoryPool.h"
|
|
|
|
#include "src/gpu/GrOpFlushState.h"
|
2019-08-26 15:08:51 +00:00
|
|
|
#include "src/gpu/GrOpsRenderPass.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "src/gpu/GrPipeline.h"
|
|
|
|
#include "src/gpu/GrProcessor.h"
|
|
|
|
#include "src/gpu/GrProcessorSet.h"
|
2019-10-08 16:32:56 +00:00
|
|
|
#include "src/gpu/GrProgramInfo.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrRecordingContextPriv.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "src/gpu/GrResourceProvider.h"
|
2019-08-14 21:00:30 +00:00
|
|
|
#include "src/gpu/GrSamplerState.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "src/gpu/GrShaderCaps.h"
|
|
|
|
#include "src/gpu/GrShaderVar.h"
|
2019-06-18 13:58:02 +00:00
|
|
|
#include "src/gpu/GrSurfaceProxy.h"
|
|
|
|
#include "src/gpu/GrTextureProxy.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
|
|
|
#include "src/gpu/glsl/GrGLSLVarying.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "src/gpu/ops/GrDrawOp.h"
|
|
|
|
#include "src/gpu/ops/GrOp.h"
|
2021-07-28 19:13:20 +00:00
|
|
|
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
2019-11-21 21:02:34 +00:00
|
|
|
#include "tools/gpu/ProxyUtils.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
class GrAppliedClip;
|
|
|
|
class GrGLSLProgramDataManager;
|
2018-07-27 18:38:35 +00:00
|
|
|
|
2019-07-18 16:36:54 +00:00
|
|
|
namespace {
|
2018-07-27 18:38:35 +00:00
|
|
|
|
2018-09-14 20:16:55 +00:00
|
|
|
static constexpr GrGeometryProcessor::Attribute gVertex =
|
2019-06-19 18:19:47 +00:00
|
|
|
{"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
2018-07-27 18:38:35 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SkSL code.
|
|
|
|
|
|
|
|
class ClockwiseTestProcessor : public GrGeometryProcessor {
|
|
|
|
public:
|
2019-11-18 16:19:51 +00:00
|
|
|
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool readSkFragCoord) {
|
2020-12-14 21:59:09 +00:00
|
|
|
return arena->make([&](void* ptr) {
|
|
|
|
return new (ptr) ClockwiseTestProcessor(readSkFragCoord);
|
|
|
|
});
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
2019-11-15 19:57:05 +00:00
|
|
|
|
|
|
|
const char* name() const final { return "ClockwiseTestProcessor"; }
|
|
|
|
|
2021-08-06 19:33:58 +00:00
|
|
|
void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const final {
|
2018-07-27 18:38:35 +00:00
|
|
|
b->add32(fReadSkFragCoord);
|
|
|
|
}
|
2019-11-15 19:57:05 +00:00
|
|
|
|
2021-08-09 19:56:24 +00:00
|
|
|
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
|
2018-07-27 18:38:35 +00:00
|
|
|
|
2019-11-18 16:19:51 +00:00
|
|
|
bool readSkFragCoord() const { return fReadSkFragCoord; }
|
|
|
|
|
2018-07-27 18:38:35 +00:00
|
|
|
private:
|
2019-11-15 19:57:05 +00:00
|
|
|
ClockwiseTestProcessor(bool readSkFragCoord)
|
|
|
|
: GrGeometryProcessor(kClockwiseTestProcessor_ClassID)
|
|
|
|
, fReadSkFragCoord(readSkFragCoord) {
|
|
|
|
this->setVertexAttributes(&gVertex, 1);
|
|
|
|
}
|
|
|
|
|
2018-07-27 18:38:35 +00:00
|
|
|
const bool fReadSkFragCoord;
|
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GrGeometryProcessor;
|
2018-07-27 18:38:35 +00:00
|
|
|
};
|
|
|
|
|
2021-08-09 19:56:24 +00:00
|
|
|
std::unique_ptr<GrGeometryProcessor::ProgramImpl> ClockwiseTestProcessor::makeProgramImpl(
|
|
|
|
const GrShaderCaps&) const {
|
2021-08-11 13:59:56 +00:00
|
|
|
class Impl : public ProgramImpl {
|
|
|
|
public:
|
|
|
|
void setData(const GrGLSLProgramDataManager&,
|
|
|
|
const GrShaderCaps&,
|
|
|
|
const GrGeometryProcessor&) override {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
|
|
|
const ClockwiseTestProcessor& proc = args.fGeomProc.cast<ClockwiseTestProcessor>();
|
|
|
|
args.fVaryingHandler->emitAttributes(proc);
|
|
|
|
gpArgs->fPositionVar.set(kFloat2_GrSLType, "position");
|
|
|
|
args.fFragBuilder->codeAppendf(
|
|
|
|
"half4 %s = sk_Clockwise ? half4(0,1,0,1) : half4(1,0,0,1);",
|
|
|
|
args.fOutputColor);
|
|
|
|
if (!proc.readSkFragCoord()) {
|
|
|
|
args.fFragBuilder->codeAppendf("const half4 %s = half4(1);", args.fOutputCoverage);
|
|
|
|
} else {
|
|
|
|
// Verify layout(origin_upper_left) on gl_FragCoord does not affect gl_FrontFacing.
|
|
|
|
args.fFragBuilder->codeAppendf("half4 %s = half4(min(half(sk_FragCoord.y), 1));",
|
|
|
|
args.fOutputCoverage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return std::make_unique<Impl>();
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Draw Op.
|
|
|
|
|
|
|
|
class ClockwiseTestOp : public GrDrawOp {
|
|
|
|
public:
|
|
|
|
DEFINE_OP_CLASS_ID
|
|
|
|
|
2020-10-07 20:46:15 +00:00
|
|
|
static GrOp::Owner Make(GrRecordingContext* context,
|
|
|
|
bool readSkFragCoord, int y = 0) {
|
|
|
|
return GrOp::Make<ClockwiseTestOp>(context, readSkFragCoord, y);
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ClockwiseTestOp(bool readSkFragCoord, float y)
|
2019-11-18 16:19:51 +00:00
|
|
|
: GrDrawOp(ClassID())
|
|
|
|
, fReadSkFragCoord(readSkFragCoord)
|
|
|
|
, fY(y) {
|
2019-10-01 19:14:44 +00:00
|
|
|
this->setBounds(SkRect::MakeXYWH(0, fY, 100, 100), HasAABloat::kNo, IsHairline::kNo);
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* name() const override { return "ClockwiseTestOp"; }
|
|
|
|
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
|
2021-04-22 18:57:28 +00:00
|
|
|
GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, GrClampType) override {
|
2019-01-15 18:53:00 +00:00
|
|
|
return GrProcessorSet::EmptySetAnalysis();
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
2019-11-15 19:57:05 +00:00
|
|
|
|
2020-02-28 21:02:40 +00:00
|
|
|
GrProgramInfo* createProgramInfo(const GrCaps* caps,
|
|
|
|
SkArenaAlloc* arena,
|
2020-11-19 18:41:26 +00:00
|
|
|
const GrSurfaceProxyView& writeView,
|
2021-08-26 16:05:11 +00:00
|
|
|
bool usesMSAASurface,
|
2020-02-28 21:02:40 +00:00
|
|
|
GrAppliedClip&& appliedClip,
|
2021-06-02 15:58:05 +00:00
|
|
|
const GrDstProxyView& dstProxyView,
|
2020-11-20 15:22:43 +00:00
|
|
|
GrXferBarrierFlags renderPassXferBarriers,
|
|
|
|
GrLoadOp colorLoadOp) const {
|
2020-02-28 21:02:40 +00:00
|
|
|
GrGeometryProcessor* geomProc = ClockwiseTestProcessor::Make(arena, fReadSkFragCoord);
|
|
|
|
|
2021-08-26 16:05:11 +00:00
|
|
|
return sk_gpu_test::CreateProgramInfo(caps, arena, writeView, usesMSAASurface,
|
2020-02-28 21:02:40 +00:00
|
|
|
std::move(appliedClip), dstProxyView,
|
|
|
|
geomProc, SkBlendMode::kPlus,
|
2020-09-11 13:33:54 +00:00
|
|
|
GrPrimitiveType::kTriangleStrip,
|
2020-11-20 15:22:43 +00:00
|
|
|
renderPassXferBarriers, colorLoadOp);
|
2020-02-28 21:02:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const {
|
|
|
|
return this->createProgramInfo(&flushState->caps(),
|
|
|
|
flushState->allocator(),
|
2020-04-01 20:22:00 +00:00
|
|
|
flushState->writeView(),
|
2021-08-26 16:05:11 +00:00
|
|
|
flushState->usesMSAASurface(),
|
2020-02-28 21:02:40 +00:00
|
|
|
flushState->detachAppliedClip(),
|
2020-09-11 13:33:54 +00:00
|
|
|
flushState->dstProxyView(),
|
2020-11-20 15:22:43 +00:00
|
|
|
flushState->renderPassBarriers(),
|
|
|
|
flushState->colorLoadOp());
|
2020-02-28 21:02:40 +00:00
|
|
|
}
|
|
|
|
|
2019-11-15 19:57:05 +00:00
|
|
|
void onPrePrepare(GrRecordingContext* context,
|
2020-11-19 18:41:26 +00:00
|
|
|
const GrSurfaceProxyView& writeView,
|
2019-11-21 21:02:34 +00:00
|
|
|
GrAppliedClip* clip,
|
2021-06-02 15:58:05 +00:00
|
|
|
const GrDstProxyView& dstProxyView,
|
2020-11-20 15:22:43 +00:00
|
|
|
GrXferBarrierFlags renderPassXferBarriers,
|
|
|
|
GrLoadOp colorLoadOp) final {
|
2019-11-15 22:28:37 +00:00
|
|
|
SkArenaAlloc* arena = context->priv().recordTimeAllocator();
|
2019-11-15 19:57:05 +00:00
|
|
|
|
2021-08-26 16:05:11 +00:00
|
|
|
// DMSAA is not supported on DDL.
|
|
|
|
bool usesMSAASurface = writeView.asRenderTargetProxy()->numSamples() > 1;
|
|
|
|
|
2019-11-21 21:02:34 +00:00
|
|
|
// This is equivalent to a GrOpFlushState::detachAppliedClip
|
Reland "Improve scissor state tracking in GrRTC"
This reverts commit 4926b07217f07e8f5ff1dba15d23bab960ffded3.
Reason for revert: fix wip
Original change's description:
> Revert "Improve scissor state tracking in GrRTC"
>
> This reverts commit 3b923a880bc0855772daffd95b5728795f515d5f.
>
> Reason for revert: GrAppliedHardClip isn't tracking scissor state properly
>
> Original change's description:
> > Improve scissor state tracking in GrRTC
> >
> > At a low level, this changes GrScissorState from a rect+bool to a rect+size.
> > The scissor test is considered enablebd if the rect does not fill the
> > device bounds rect specified by the size. This has a number of benefits:
> >
> > 1. We can always access the scissor rect and know that it will be
> > restricted to the render target dimensions.
> > 2. It helps consolidate code that previously had to test the scissor rect
> > and render target bounds separately.
> > 3. The clear operations can now match the proper backing store dimensions
> > of the render target.
> > 4. It makes it easier to reason about scissors applying to the logical
> > dimensions of the render target vs. its backing store dimensions.
> >
> > Originally, I was going to have the extra scissor guards for the logical
> > dimensions be added in a separate CL (with the cleanup for
> > attemptQuadOptimization). However, it became difficult to ensure correct
> > behavior respecting the vulkan render pass bounds without applying this
> > new logic at the same time.
> >
> > So now, with this CL, GrAppliedClips are sized to the backing store
> > dimensions of the render target. GrOpsTasks also clip bounds to the
> > backing store dimensions instead of the logical dimensions (which seems
> > more correct since that's where the auto-clipping happens). Then when
> > we convert a GrClip to a GrAppliedClip, the GrRTC automatically enforces
> > the logical dimensions scissor if we have stencil settings (to ensure
> > the padded pixels don't get corrupted). It also may remove the scissor
> > if the draw was just a color buffer update.
> >
> > Change-Id: I75671c9cc921f4696b1dd5231e02486090aa4282
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290654
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com
>
> Change-Id: Ie98d084158e3a537604ab0fecee69bde3e744d1b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294340
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: I2116e52146890ee4b7ea007f3c3d5c3e532e4bdd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294257
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-06-04 19:52:44 +00:00
|
|
|
GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip::Disabled();
|
2019-11-21 21:02:34 +00:00
|
|
|
|
2020-04-01 20:22:00 +00:00
|
|
|
fProgramInfo = this->createProgramInfo(context->priv().caps(), arena, writeView,
|
2021-08-26 16:05:11 +00:00
|
|
|
usesMSAASurface, std::move(appliedClip),
|
|
|
|
dstProxyView, renderPassXferBarriers, colorLoadOp);
|
2019-11-21 21:02:34 +00:00
|
|
|
|
2020-02-28 21:02:40 +00:00
|
|
|
context->priv().recordProgramInfo(fProgramInfo);
|
2019-11-15 19:57:05 +00:00
|
|
|
}
|
|
|
|
|
2019-09-05 17:23:23 +00:00
|
|
|
void onPrepare(GrOpFlushState* flushState) override {
|
2018-07-27 18:38:35 +00:00
|
|
|
SkPoint vertices[4] = {
|
|
|
|
{100, fY},
|
|
|
|
{0, fY+100},
|
|
|
|
{0, fY},
|
|
|
|
{100, fY+100},
|
|
|
|
};
|
2019-09-05 17:23:23 +00:00
|
|
|
fVertexBuffer = flushState->resourceProvider()->createBuffer(
|
|
|
|
sizeof(vertices), GrGpuBufferType::kVertex, kStatic_GrAccessPattern, vertices);
|
|
|
|
}
|
2019-11-15 19:57:05 +00:00
|
|
|
|
2019-09-05 17:23:23 +00:00
|
|
|
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
|
|
|
if (!fVertexBuffer) {
|
2018-07-27 20:15:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-11-15 19:57:05 +00:00
|
|
|
|
2019-11-21 21:02:34 +00:00
|
|
|
if (!fProgramInfo) {
|
2020-02-28 21:02:40 +00:00
|
|
|
fProgramInfo = this->createProgramInfo(flushState);
|
2019-11-21 21:02:34 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 16:05:11 +00:00
|
|
|
flushState->bindPipeline(*fProgramInfo, SkRect::MakeXYWH(0, fY, 100, 100));
|
2020-07-20 15:37:38 +00:00
|
|
|
flushState->bindBuffers(nullptr, nullptr, std::move(fVertexBuffer));
|
2020-03-16 16:05:11 +00:00
|
|
|
flushState->draw(4, 0);
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
|
|
|
|
2019-11-18 16:19:51 +00:00
|
|
|
sk_sp<GrBuffer> fVertexBuffer;
|
|
|
|
const bool fReadSkFragCoord;
|
|
|
|
const float fY;
|
2019-11-15 19:57:05 +00:00
|
|
|
|
2021-03-22 18:48:09 +00:00
|
|
|
// The program info (and both the GrPipeline and GrGeometryProcessor it relies on), when
|
2019-11-21 21:02:34 +00:00
|
|
|
// allocated, are allocated in either the ddl-record-time or flush-time arena. It is the
|
|
|
|
// arena's job to free up their memory so we just have a bare programInfo pointer here. We
|
2021-03-22 18:48:09 +00:00
|
|
|
// don't even store the GrPipeline and GrGeometryProcessor pointers here bc they are
|
2019-11-21 21:02:34 +00:00
|
|
|
// guaranteed to have the same lifetime as the program info.
|
2019-11-18 16:19:51 +00:00
|
|
|
GrProgramInfo* fProgramInfo = nullptr;
|
2018-07-27 18:38:35 +00:00
|
|
|
|
2020-10-07 20:46:15 +00:00
|
|
|
friend class ::GrOp; // for ctor
|
2019-11-18 16:19:51 +00:00
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GrDrawOp;
|
2018-07-27 18:38:35 +00:00
|
|
|
};
|
|
|
|
|
2021-07-21 19:39:51 +00:00
|
|
|
} // namespace
|
|
|
|
|
2018-07-27 18:38:35 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Test.
|
|
|
|
|
2021-07-21 19:39:51 +00:00
|
|
|
namespace skiagm {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a GPU-backend specific test. It ensures that SkSL properly identifies clockwise-winding
|
|
|
|
* triangles (sk_Clockwise), in terms of to Skia device space, in all backends and with all render
|
|
|
|
* target origins. We draw clockwise triangles green and counter-clockwise red.
|
|
|
|
*/
|
|
|
|
class ClockwiseGM : public GpuGM {
|
|
|
|
SkString onShortName() override { return SkString("clockwise"); }
|
|
|
|
SkISize onISize() override { return {300, 200}; }
|
|
|
|
DrawResult onDraw(GrRecordingContext*, SkCanvas*, SkString* errorMsg) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
DrawResult ClockwiseGM::onDraw(GrRecordingContext* rContext, SkCanvas* canvas, SkString* errorMsg) {
|
|
|
|
auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
|
|
|
if (!sdc) {
|
|
|
|
*errorMsg = kErrorMsg_DrawSkippedGpuOnly;
|
|
|
|
return DrawResult::kSkip;
|
|
|
|
}
|
|
|
|
|
2021-06-03 14:14:16 +00:00
|
|
|
sdc->clear(SK_PMColor4fBLACK);
|
2018-07-27 18:38:35 +00:00
|
|
|
|
|
|
|
// Draw the test directly to the frame buffer.
|
2021-07-21 19:39:51 +00:00
|
|
|
sdc->addDrawOp(ClockwiseTestOp::Make(rContext, false, 0));
|
|
|
|
sdc->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
2018-07-27 18:38:35 +00:00
|
|
|
|
|
|
|
// Draw the test to an off-screen, top-down render target.
|
2021-07-28 19:13:20 +00:00
|
|
|
GrColorType sdcColorType = sdc->colorInfo().colorType();
|
|
|
|
if (auto topLeftSDC = skgpu::v1::SurfaceDrawContext::Make(
|
|
|
|
rContext, sdcColorType, nullptr, SkBackingFit::kExact, {100, 200}, SkSurfaceProps(),
|
2021-04-19 23:27:09 +00:00
|
|
|
1, GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin,
|
|
|
|
SkBudgeted::kYes)) {
|
2021-07-28 19:13:20 +00:00
|
|
|
topLeftSDC->clear(SK_PMColor4fTRANSPARENT);
|
|
|
|
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, false, 0));
|
|
|
|
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
2021-06-03 14:14:16 +00:00
|
|
|
sdc->drawTexture(nullptr,
|
2021-07-28 19:13:20 +00:00
|
|
|
topLeftSDC->readSurfaceView(),
|
2021-06-03 14:14:16 +00:00
|
|
|
sdc->colorInfo().alphaType(),
|
2020-07-22 15:18:06 +00:00
|
|
|
GrSamplerState::Filter::kNearest,
|
|
|
|
GrSamplerState::MipmapMode::kNone,
|
|
|
|
SkBlendMode::kSrcOver,
|
|
|
|
SK_PMColor4fWHITE,
|
|
|
|
{0, 0, 100, 200},
|
|
|
|
{100, 0, 200, 200},
|
|
|
|
GrAA::kNo,
|
|
|
|
GrQuadAAFlags::kNone,
|
|
|
|
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint,
|
|
|
|
SkMatrix::I(),
|
2018-11-19 15:42:10 +00:00
|
|
|
nullptr);
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the test to an off-screen, bottom-up render target.
|
2021-07-28 19:13:20 +00:00
|
|
|
if (auto topLeftSDC = skgpu::v1::SurfaceDrawContext::Make(
|
|
|
|
rContext, sdcColorType, nullptr, SkBackingFit::kExact, {100, 200}, SkSurfaceProps(),
|
2021-04-19 23:27:09 +00:00
|
|
|
1, GrMipmapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin,
|
|
|
|
SkBudgeted::kYes)) {
|
2021-07-28 19:13:20 +00:00
|
|
|
topLeftSDC->clear(SK_PMColor4fTRANSPARENT);
|
|
|
|
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, false, 0));
|
|
|
|
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
2021-06-03 14:14:16 +00:00
|
|
|
sdc->drawTexture(nullptr,
|
2021-07-28 19:13:20 +00:00
|
|
|
topLeftSDC->readSurfaceView(),
|
2021-06-03 14:14:16 +00:00
|
|
|
sdc->colorInfo().alphaType(),
|
2020-07-22 15:18:06 +00:00
|
|
|
GrSamplerState::Filter::kNearest,
|
|
|
|
GrSamplerState::MipmapMode::kNone,
|
|
|
|
SkBlendMode::kSrcOver,
|
|
|
|
SK_PMColor4fWHITE,
|
|
|
|
{0, 0, 100, 200},
|
|
|
|
{200, 0, 300, 200},
|
|
|
|
GrAA::kNo,
|
|
|
|
GrQuadAAFlags::kNone,
|
|
|
|
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint,
|
|
|
|
SkMatrix::I(),
|
2018-11-19 15:42:10 +00:00
|
|
|
nullptr);
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
2021-07-21 19:39:51 +00:00
|
|
|
|
|
|
|
return DrawResult::kOk;
|
2018-07-27 18:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
DEF_GM( return new ClockwiseGM(); )
|
|
|
|
|
2021-07-21 19:39:51 +00:00
|
|
|
} // namespace skiagm
|