32static const int W = 1920,
H = 1080;
42 record.
replace<SkRecords::NoOp>(1);
46 REPORTER_ASSERT(r, 2 == count_instances_of_type<SkRecords::DrawRect>(record));
58 for (
int i = 0;
i < 3;
i++) {
59 assert_type<SkRecords::NoOp>(r, record,
i);
81 for (
int index = 0; index < record.
count(); index++) {
82 assert_type<SkRecords::NoOp>(r, record, index);
86DEF_TEST(RecordOpts_SaveSaveLayerRestoreRestore, r) {
97 switch (record.
count()) {
99 assert_type<SkRecords::Save> (r, record, 0);
100 assert_type<SkRecords::SaveLayer>(r, record, 1);
101 assert_type<SkRecords::Restore> (r, record, 2);
102 assert_type<SkRecords::Restore> (r, record, 3);
105 assert_type<SkRecords::SaveLayer>(r, record, 0);
106 assert_type<SkRecords::Restore> (r, record, 1);
115#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
119 bool shouldBeNoOped) {
121 if (shouldBeNoOped) {
122 assert_type<SkRecords::NoOp>(r, *record,
i);
123 assert_type<SkRecords::NoOp>(r, *record,
i+1);
125 assert_type<SkRecords::SaveLayer>(r, *record,
i);
126 assert_type<SkRecords::Restore>(r, *record,
i+1);
133 bool shouldBeNoOped) {
135 if (shouldBeNoOped) {
136 assert_type<SkRecords::NoOp>(r, *record,
i);
137 assert_type<SkRecords::NoOp>(r, *record,
i+2);
139 assert_type<SkRecords::SaveLayer>(r, *record,
i);
140 assert_type<SkRecords::Restore>(r, *record,
i+2);
151 SkPaint alphaOnlyLayerPaint, translucentLayerPaint, xfermodeLayerPaint;
152 alphaOnlyLayerPaint.
setColor(0x03000000);
153 translucentLayerPaint.
setColor(0x03040506);
156 SkPaint opaqueDrawPaint, translucentDrawPaint;
157 opaqueDrawPaint.
setColor(0xFF020202);
158 translucentDrawPaint.
setColor(0x0F020202);
175 recorder.
saveLayer(
nullptr, &translucentLayerPaint);
181 recorder.
saveLayer(
nullptr, &xfermodeLayerPaint);
187 recorder.
saveLayer(
nullptr, &alphaOnlyLayerPaint);
193 recorder.
saveLayer(
nullptr, &alphaOnlyLayerPaint);
198 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, record, 16);
204 recorder.
saveLayer({
nullptr,
nullptr, filter.
get(), 0});
214 bool shouldBeNoOped) {
216 if (shouldBeNoOped) {
217 assert_type<SkRecords::NoOp>(r, *record,
i);
218 assert_type<SkRecords::NoOp>(r, *record,
i + 6);
220 assert_type<SkRecords::SaveLayer>(r, *record,
i);
221 assert_type<SkRecords::Restore>(r, *record,
i + 6);
225DEF_TEST(RecordOpts_MergeSvgOpacityAndFilterLayers, r) {
233 alphaOnlyLayerPaint.
setColor(0x03000000);
235 translucentLayerPaint.
setColor(0x03040506);
242 SkPaint opaqueFilterLayerPaint;
243 opaqueFilterLayerPaint.
setColor(0xFF020202);
244 SkPaint translucentFilterLayerPaint;
245 translucentFilterLayerPaint.
setColor(0x0F020202);
266 SkPaint* firstPaints[] = {
nullptr, &alphaOnlyLayerPaint };
268 SkPaint* secondPaints[] = { &opaqueFilterLayerPaint, &translucentFilterLayerPaint };
270 for (
auto outerF : filters) {
271 bool outerNoOped = !outerF;
272 for (
auto innerF : filters) {
274 for (
size_t j = 0; j <
std::size(firstPaints); ++j) {
275 for (
size_t k = 0; k <
std::size(secondBounds); ++k) {
277 bool innerNoOped = !secondBounds[k] && !secondPaints[
m] && !innerF;
279 recorder.
saveLayer({firstBounds[
i], firstPaints[j], outerF, 0});
282 recorder.
saveLayer({secondBounds[k], secondPaints[
m], innerF, 0});
288 #ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
304 } noChangeTests[] = {
306 { &alphaOnlyLayerPaint,
nullptr },
308 { &translucentLayerPaint, &opaqueFilterLayerPaint },
310 { &xfermodePaint, &opaqueFilterLayerPaint },
312 { &alphaOnlyLayerPaint, &xfermodePaint },
314 { &colorFilterPaint, &opaqueFilterLayerPaint },
317 { &alphaOnlyLayerPaint, &colorFilterPaint }
321 recorder.
saveLayer(
nullptr, noChangeTests[
i].firstPaint);
324 recorder.
saveLayer(
nullptr, noChangeTests[
i].secondPaint);
333 recorder.
saveLayer(
nullptr, &alphaOnlyLayerPaint);
336 recorder.
saveLayer(
nullptr, &opaqueFilterLayerPaint);
342 const SkRecords::SaveLayer* saveLayer = assert_type<SkRecords::SaveLayer>(r, record, index + 3);
350 recorder.
saveLayer(
nullptr, &alphaOnlyLayerPaint);
351 recorder.
saveLayer(
nullptr, &opaqueFilterLayerPaint);
355 assert_type<SkRecords::SaveLayer>(r, record, index);
356 assert_type<SkRecords::SaveLayer>(r, record, index + 1);
357 assert_type<SkRecords::Restore>(r, record, index + 2);
358 assert_type<SkRecords::Restore>(r, record, index + 3);
392 for (
int doPicture = 0; doPicture <= 1; ++doPicture) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static bool is_equal(SkSurface *a, SkSurface *b)
static void do_draw(SkCanvas *canvas, SkColor color, bool doLayer)
DEF_TEST(RecordOpts_NoopDraw, r)
static void assert_savelayer_draw_restore(skiatest::Reporter *r, SkRecord *record, int i, bool shouldBeNoOped)
static void assert_merge_svg_opacity_and_filter_layers(skiatest::Reporter *r, SkRecord *record, int i, bool shouldBeNoOped)
static void assert_savelayer_restore(skiatest::Reporter *r, SkRecord *record, int i, bool shouldBeNoOped)
static void do_savelayer_srcmode(skiatest::Reporter *r, SkColor color)
constexpr SkColor SK_ColorLTGRAY
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorWHITE
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
void SkRecordNoopSaveRestores(SkRecord *record)
void SkRecordMergeSvgOpacityAndFilterLayers(SkRecord *record)
void SkRecordNoopSaveLayerDrawRestores(SkRecord *record)
#define REPORTER_ASSERT(r, cond,...)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawPaint(const SkPaint &paint)
void drawPicture(const SkPicture *picture)
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Picture(sk_sp< SkPicture > pic, const SkRect &targetRect)
void setColor(SkColor color)
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
void setBlendMode(SkBlendMode mode)
void setColorFilter(sk_sp< SkColorFilter > colorFilter)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
Optional< SkRect > bounds
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeWH(float w, float h)