Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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),
55 std::unique_ptr<DrawPass> drawPass = DrawPass::Make(recorder.get(),
56 std::move(drawList),
57 target,
58 targetInfo,
59 {LoadOp::kClear, StoreOp::kStore},
60 {0.0f, 0.0f, 0.0f, 0.0f});
61
62 // Make sure creating the draw pass failed.
63 REPORTER_ASSERT(reporter, !drawPass);
64}
65
66} // namespace skgpu::graphite
reporter
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 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, ctsEnforcement)
Definition Test.h:373
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
int maxTextureSize() const
Definition Caps.h:134
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)
Definition DrawPass.cpp:452
static AI Rect Infinite()
Definition Rect.h:60
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted)
static constexpr Transform Identity()
const Paint & paint
uint32_t * target
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
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