Commit d1f9ed88 authored by Adrienne Walker's avatar Adrienne Walker Committed by Commit Bot

cc: Split up blending tests to avoid timeouts

The current tests time out quite a bit when using swiftshader.  I
suspect that this is due to shader compilation on a per-blend mode
basis, as reducing pixels rastered did not seem to make any difference.
The goal here is to reduce the maximum length of any one test so that
fewer tests time out and these tests keep causing flakiness and getting
disabled.

This test breaks up each individual blend mode test into parameterizing
by blend mode and rastering what used to be a single column in a larger
image into its own image.  Instead of saving out a million data pngs,
instead this modifies the test framework to use expected pngs as well.
This assumes that Skia's blend modes work properly and verifies that
software and gl renderer match the output of those blend modes on an
SkCanvas.

In terms of total time of the test, splitting each test up into 16
different tests on Linux debug for me has each individual test
completing in 1/4 of the time of the original (1/4x * 16 = 4x increase
overall).  However, when running the entire test suite in parallel, this
patch speeds up running cc_unittests from ~70s to ~60s overall.  So,
I think this is overall a win, both in terms of individual and total
test time.

Bug: 870326,872733
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I4791a0a2369f9f17af7bb2a6ba95d7f29dee8b42
Reviewed-on: https://chromium-review.googlesource.com/1180570Reviewed-by: default avatarweiliangc <weiliangc@chromium.org>
Commit-Queue: enne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584616}
parent 429c5dce
......@@ -110,6 +110,12 @@ void LayerTreeHostPixelResourceTest::RunPixelResourceTest(
RunPixelTest(test_type_, content_root, file_name);
}
void LayerTreeHostPixelResourceTest::RunPixelResourceTest(
scoped_refptr<Layer> content_root,
const SkBitmap& expected_bitmap) {
RunPixelTest(test_type_, content_root, expected_bitmap);
}
ParameterizedPixelResourceTest::ParameterizedPixelResourceTest()
: LayerTreeHostPixelResourceTest(::testing::get<0>(GetParam()),
::testing::get<1>(GetParam())) {}
......
......@@ -28,6 +28,8 @@ class LayerTreeHostPixelResourceTest : public LayerTreePixelTest {
void RunPixelResourceTest(scoped_refptr<Layer> content_root,
base::FilePath file_name);
void RunPixelResourceTest(scoped_refptr<Layer> content_root,
const SkBitmap& expected_bitmap);
protected:
PixelResourceTestCase test_case_;
......
......@@ -116,6 +116,14 @@ void LayerTreePixelTest::BeginTest() {
}
void LayerTreePixelTest::AfterTest() {
// Bitmap comparison.
if (ref_file_.empty()) {
EXPECT_TRUE(
MatchesBitmap(*result_bitmap_, expected_bitmap_, *pixel_comparator_));
return;
}
// File comparison.
base::FilePath test_data_dir;
EXPECT_TRUE(
base::PathService::Get(viz::Paths::DIR_TEST_DATA, &test_data_dir));
......@@ -201,6 +209,17 @@ void LayerTreePixelTest::RunPixelTest(
RunTest(CompositorMode::THREADED);
}
void LayerTreePixelTest::RunPixelTest(PixelTestType test_type,
scoped_refptr<Layer> content_root,
const SkBitmap& expected_bitmap) {
test_type_ = test_type;
content_root_ = content_root;
readback_target_ = nullptr;
ref_file_ = base::FilePath();
expected_bitmap_ = expected_bitmap;
RunTest(CompositorMode::THREADED);
}
void LayerTreePixelTest::RunSingleThreadedPixelTest(
PixelTestType test_type,
scoped_refptr<Layer> content_root,
......
......@@ -70,6 +70,9 @@ class LayerTreePixelTest : public LayerTreeTest {
void RunPixelTest(PixelTestType type,
scoped_refptr<Layer> content_root,
base::FilePath file_name);
void RunPixelTest(PixelTestType type,
scoped_refptr<Layer> content_root,
const SkBitmap& expected_bitmap);
void RunSingleThreadedPixelTest(PixelTestType test_type,
scoped_refptr<Layer> content_root,
......@@ -105,6 +108,7 @@ class LayerTreePixelTest : public LayerTreeTest {
scoped_refptr<Layer> content_root_;
Layer* readback_target_;
base::FilePath ref_file_;
SkBitmap expected_bitmap_;
std::unique_ptr<SkBitmap> result_bitmap_;
std::vector<scoped_refptr<TextureLayer>> texture_layers_;
int pending_texture_mailbox_callbacks_;
......
......@@ -49,14 +49,9 @@ bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) {
bitmap);
}
bool MatchesPNGFile(const SkBitmap& gen_bmp, base::FilePath ref_img_path,
const PixelComparator& comparator) {
SkBitmap ref_bmp;
if (!ReadPNGFile(ref_img_path, &ref_bmp)) {
LOG(ERROR) << "Cannot read reference image: " << ref_img_path.value();
return false;
}
bool MatchesBitmap(const SkBitmap& gen_bmp,
const SkBitmap& ref_bmp,
const PixelComparator& comparator) {
// Check if images size matches
if (gen_bmp.width() != ref_bmp.width() ||
gen_bmp.height() != ref_bmp.height()) {
......@@ -83,4 +78,16 @@ bool MatchesPNGFile(const SkBitmap& gen_bmp, base::FilePath ref_img_path,
return compare;
}
bool MatchesPNGFile(const SkBitmap& gen_bmp,
base::FilePath ref_img_path,
const PixelComparator& comparator) {
SkBitmap ref_bmp;
if (!ReadPNGFile(ref_img_path, &ref_bmp)) {
LOG(ERROR) << "Cannot read reference image: " << ref_img_path.value();
return false;
}
return MatchesBitmap(gen_bmp, ref_bmp, comparator);
}
} // namespace cc
......@@ -31,6 +31,12 @@ bool MatchesPNGFile(const SkBitmap& gen_bmp,
base::FilePath ref_img_path,
const PixelComparator& comparator);
// Compares two bitmaps using the given PixelComparator, and returns true if the
// comparator returns a match.
bool MatchesBitmap(const SkBitmap& gen_bmp,
const SkBitmap& ref_bmp,
const PixelComparator& comparator);
} // namespace cc
#endif // CC_TEST_PIXEL_TEST_UTILS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment