Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
TextureOpTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkSize.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkArenaAlloc.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrAppliedClip.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrColorSpaceXform.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrProcessorSet.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrSamplerState.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/geometry/GrQuad.h"
#include "src/gpu/ganesh/ops/GrOp.h"
#include "src/gpu/ganesh/ops/OpsTask.h"
#include "src/gpu/ganesh/ops/TextureOp.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include <utility>

Go to the source code of this file.

Classes

class  OpsTaskTestingAccess
 

Functions

static void check_chain (OpsTaskTestingAccess::OpChain *chain, SkRect firstRect, SkRect lastRect, int expectedNumOps)
 
static sk_sp< GrSurfaceProxycreate_proxy (GrRecordingContext *rContext)
 
static GrOp::Owner create_op (GrDirectContext *dContext, SkRect rect, const GrSurfaceProxyView &proxyView, bool isAA)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (TextureOpTest, reporter, ctxInfo, CtsEnforcement::kNever)
 

Function Documentation

◆ check_chain()

static void check_chain ( OpsTaskTestingAccess::OpChain chain,
SkRect  firstRect,
SkRect  lastRect,
int  expectedNumOps 
)
static

Definition at line 53 of file TextureOpTest.cpp.

54 {
55 int actualNumOps = 0;
56 for (const auto& op : GrOp::ChainRange<>(chain->head())) {
57 ++actualNumOps;
58
59 if (actualNumOps == 1) {
60 SkAssertResult(op.bounds() == firstRect.makeOutset(0.5f, 0.5f));
61 } else if (actualNumOps == expectedNumOps) {
62 SkAssertResult(op.bounds() == lastRect.makeOutset(0.5f, 0.5f));
63 }
64 }
65
66 SkAssertResult(actualNumOps == expectedNumOps);
67}
#define SkAssertResult(cond)
Definition SkAssert.h:123
Definition GrOp.h:70
SkRect makeOutset(float dx, float dy) const
Definition SkRect.h:1002

◆ create_op()

static GrOp::Owner create_op ( GrDirectContext dContext,
SkRect  rect,
const GrSurfaceProxyView proxyView,
bool  isAA 
)
static

Definition at line 88 of file TextureOpTest.cpp.

89 {
90 DrawQuad quad;
91
92 quad.fDevice = GrQuad::MakeFromRect(rect.makeOutset(0.5f, 0.5f), SkMatrix::I());
93 quad.fLocal = GrQuad(rect);
95
96 return TextureOp::Make(dContext,
97 proxyView,
99 nullptr,
100 GrSamplerState::Filter::kNearest,
101 GrSamplerState::MipmapMode::kNone,
102 {1.f, 1.f, 1.f, 1.f},
103 TextureOp::Saturate::kYes,
107 &quad,
108 nullptr);
109}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kSrcOver
r = s + (1-sa)*d
static GrQuad MakeFromRect(const SkRect &, const SkMatrix &)
Definition GrQuad.cpp:107
static const SkMatrix & I()
static GrOp::Owner Make(GrRecordingContext *, GrSurfaceProxyView, SkAlphaType srcAlphaType, sk_sp< GrColorSpaceXform >, GrSamplerState::Filter, GrSamplerState::MipmapMode, const SkPMColor4f &, Saturate, SkBlendMode, GrAAType, DrawQuad *, const SkRect *subset=nullptr)
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
GrQuad fLocal
Definition GrQuad.h:186
GrQuad fDevice
Definition GrQuad.h:185
GrQuadAAFlags fEdgeFlags
Definition GrQuad.h:187

◆ create_proxy()

static sk_sp< GrSurfaceProxy > create_proxy ( GrRecordingContext rContext)
static

Definition at line 69 of file TextureOpTest.cpp.

69 {
70 const GrCaps* caps = rContext->priv().caps();
71
72 static constexpr SkISize kDimensions = {16, 16};
73
75 GrRenderable::kYes);
76 return rContext->priv().proxyProvider()->createProxy(format,
77 kDimensions,
78 GrRenderable::kYes,
79 1,
80 skgpu::Mipmapped::kNo,
83 GrProtected::kNo,
84 /*label=*/"TextureOpTest",
86}
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition GrCaps.cpp:400
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
GrProxyProvider * proxyProvider()
GrRecordingContextPriv priv()
uint32_t uint32_t * format

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( TextureOpTest  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 112 of file TextureOpTest.cpp.

112 {
113 GrDirectContext* dContext = ctxInfo.directContext();
114 const GrCaps* caps = dContext->priv().caps();
115 SkArenaAlloc arena{nullptr, 0, 1024};
116 auto auditTrail = dContext->priv().auditTrail();
117
119 // This test requires chaining
120 return;
121 }
122
123 GrSurfaceProxyView proxyViewA(create_proxy(dContext),
126 GrSurfaceProxyView proxyViewB(create_proxy(dContext),
129 GrSurfaceProxyView proxyViewC(create_proxy(dContext),
132
133 static const SkRect kOpARect{ 0, 0, 16, 16 };
134 static const SkRect kOpBRect{ 32, 0, 48, 16 };
135 static const SkRect kOpCRect{ 0, 32, 16, 48 };
136 static const SkRect kOpDRect{ 32, 32, 48, 48 };
137
138 // opA & opB can chain together but can't merge bc they have different proxies
139 GrOp::Owner opA = create_op(dContext, kOpARect, proxyViewA, false);
140 GrOp::Owner opB = create_op(dContext, kOpBRect, proxyViewB, false);
141
144 &noClip, nullptr);
145 chain1.appendOp(std::move(opB), GrProcessorSet::EmptySetAnalysis(), nullptr, &noClip, *caps,
146 &arena, dContext->priv().auditTrail());
147 check_chain(&chain1, kOpARect, kOpBRect, 2);
148
149 // opC & opD can also chain together but can't merge (bc, again, they have different
150 // proxies). Note, however, that opA and opD do share a proxy so can be merged if opA's
151 // anti-aliasing is upgraded to coverage.
152 GrOp::Owner opC = create_op(dContext, kOpCRect, proxyViewC, true);
153 GrOp::Owner opD = create_op(dContext, kOpDRect, proxyViewA, true);
154
156 &noClip, nullptr);
157 chain2.appendOp(std::move(opD), GrProcessorSet::EmptySetAnalysis(), nullptr, &noClip, *caps,
158 &arena, auditTrail);
159 check_chain(&chain2, kOpCRect, kOpDRect, 2);
160
161 // opA and opD, now in separate chains, can merge when the two chains are combined while
162 // opB and opC can still only chain.
163 chain1.prependChain(&chain2, *caps, &arena, auditTrail);
164
165 // We should end up with the chain
166 // opC - opD/opA - opB
167 check_chain(&chain1, kOpCRect, kOpBRect, 3);
168
169 chain1.deleteOps();
170}
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
static GrOp::Owner create_op(GrDirectContext *dContext, SkRect rect, const GrSurfaceProxyView &proxyView, bool isAA)
static sk_sp< GrSurfaceProxy > create_proxy(GrRecordingContext *rContext)
static void check_chain(OpsTaskTestingAccess::OpChain *chain, SkRect firstRect, SkRect lastRect, int expectedNumOps)
static GrAppliedClip Disabled()
bool dynamicStateArrayGeometryProcessorTextureSupport() const
Definition GrCaps.h:418
GrDirectContextPriv priv()
std::unique_ptr< GrOp > Owner
Definition GrOp.h:72
static constexpr Analysis EmptySetAnalysis()
skgpu::ganesh::OpsTask::OpChain OpChain
static constexpr Swizzle RGBA()
Definition Swizzle.h:66