Flutter Engine
The Flutter Engine
DrawPassTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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
8#include "tests/Test.h"
9
15
16namespace skgpu::graphite {
17
18// Tests that creating a draw pass that fails a dst copy doesn't result in a segfault.
19DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(DrawPassTestFailedDstCopy,
21 context,
23 const Caps* caps = context->priv().caps();
24 std::unique_ptr<Recorder> recorder = context->makeRecorder();
25
26 // Define a paint that requires a dst copy.
28 PaintParams paintParams{paint, nullptr, nullptr, DstReadRequirement::kTextureCopy, false};
29
30 // Define a draw that uses the paint, but is larger than the max texture size. In this case the
31 // dst copy will fail.
32 const SkIRect drawSize = SkIRect::MakeWH(caps->maxTextureSize() + 1, 1);
33 std::unique_ptr<DrawList> drawList = std::make_unique<DrawList>();
34 drawList->recordDraw(recorder->priv().rendererProvider()->analyticRRect(),
36 Geometry(Shape(SkRect::Make(drawSize))),
37 Clip(Rect::Infinite(), Rect::Infinite(), drawSize, nullptr),
39 &paintParams,
40 nullptr);
41
42 // Attempt to make a draw pass with the draw.
43 static constexpr SkISize targetSize = SkISize::Make(1, 1);
44 static constexpr SkColorType targetColorType = kN32_SkColorType;
45 static constexpr SkAlphaType targetAlphaType = kPremul_SkAlphaType;
46 const SkImageInfo targetInfo = SkImageInfo::Make(targetSize, targetColorType, targetAlphaType);
48 caps,
49 recorder->priv().resourceProvider(),
50 targetSize,
52 targetColorType, Mipmapped::kNo,
53 recorder->priv().isProtected(), Renderable::kYes),
54 "DrawPassTestTargetProxy",
56 std::unique_ptr<DrawPass> drawPass = DrawPass::Make(recorder.get(),
57 std::move(drawList),
58 target,
59 targetInfo,
60 {LoadOp::kClear, StoreOp::kStore},
61 {0.0f, 0.0f, 0.0f, 0.0f},
62 /*dstCopy=*/nullptr,
63 /*dstCopyOffset=*/{0,0});
64
65 // Make sure creating the draw pass failed.
66 REPORTER_ASSERT(reporter, !drawPass);
67}
68
69} // namespace skgpu::graphite
reporter
Definition: FontMgrTest.cpp:39
static float next(float f)
SkAlphaType
Definition: SkAlphaType.h:26
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Definition: SkColorType.h:19
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
Shape
Definition: aaxfermodes.cpp:43
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
int maxTextureSize() const
Definition: Caps.h:141
static constexpr PaintersDepth kClearDepth
Definition: DrawOrder.h:109
static std::unique_ptr< DrawPass > Make(Recorder *, std::unique_ptr< DrawList >, sk_sp< TextureProxy > target, const SkImageInfo &targetInfo, std::pair< LoadOp, StoreOp >, std::array< float, 4 > clearColor, sk_sp< TextureProxy > dstCopy, SkIPoint dstCopyOffset)
Definition: DrawPass.cpp:458
static AI Rect Infinite()
Definition: Rect.h:60
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
static constexpr Transform Identity()
const Paint & paint
Definition: color_source.cc:38
uint32_t * target
Clip
Definition: layer.h:53
DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(DeviceTestVertexTransparency, reporter, context, CtsEnforcement::kNextRelease)
Definition: DeviceTest.cpp:21
Definition: SkRect.h:32
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669