Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SrcSrcOverBatchTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 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// We want to make sure that if we collapse src-over down to src when blending, that batching still
9// works correctly with a draw that explicitly requests src.
10
18#include "include/core/SkRect.h"
25#include "include/gpu/GrTypes.h"
28#include "tests/Test.h"
29
30struct GrContextOptions;
31
34 ctxInfo,
36 auto ctx = ctxInfo.directContext();
37
38 static const int kSize = 8;
41
43 ctx, skgpu::Budgeted::kNo, ii, 0, kTopLeft_GrSurfaceOrigin, nullptr));
44
45 auto canvas = surface->getCanvas();
46
48 // Setting a shader so that we actually build a processor set and don't fallback to all
49 // defaults.
50 paint.setShader(SkShaders::Color(SK_ColorRED));
51
52 SkIRect rect = SkIRect::MakeWH(2, 2);
53
54 canvas->drawIRect(rect, paint);
55
56 // Now draw a rect with src blend mode. If we collapsed the previous draw to src blend mode (a
57 // setting on caps plus not having any coverage), then we expect this second draw to try to
58 // batch with it. This test is a success if we don't hit any asserts, specifically making sure
59 // that both things we decided can be batched together claim to have the same value for
60 // CompatibleWithCoverageAsAlpha.
61 canvas->translate(3, 0);
62 paint.setBlendMode(SkBlendMode::kSrc);
63 canvas->drawIRect(rect, paint);
64}
reporter
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
Definition Test.h:434
static constexpr int kSize
const Paint & paint
VkSurfaceKHR surface
Definition main.cc:49
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)