aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/BlitMaskTest.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-04-18 11:14:50 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-18 19:52:53 +0000
commit15a64e71f68f7d1fcd16247c3d30375d3e2f41e8 (patch)
treea4aec01af06e2f855ea339312cf68e1b175a4e4d /tests/BlitMaskTest.cpp
parent63f69cdc326b2bbd4361aa4997f41a197a08d2f0 (diff)
Convert A8 D32 mask blitters to Sk4px
Improves the newly added bench by ~25% (hsw): -- before -- micros bench 2298.34 shadermaskfilter_picture_80 8888 2339.60 shadermaskfilter_picture_ff 8888 2287.11 shadermaskfilter_bitmap_80 8888 2223.14 shadermaskfilter_bitmap_ff 8888 -- after -- 1693.36 shadermaskfilter_picture_80 8888 1637.45 shadermaskfilter_picture_ff 8888 1691.65 shadermaskfilter_bitmap_80 8888 1637.70 shadermaskfilter_bitmap_ff 8888 But: skia:7810 Change-Id: I7274b10f517551ee2c0646842f72e0372d55e509 Reviewed-on: https://skia-review.googlesource.com/121642 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'tests/BlitMaskTest.cpp')
-rw-r--r--tests/BlitMaskTest.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/BlitMaskTest.cpp b/tests/BlitMaskTest.cpp
new file mode 100644
index 0000000000..04bec66189
--- /dev/null
+++ b/tests/BlitMaskTest.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBlitMask.h"
+#include "SkColorPriv.h"
+#include "SkMask.h"
+#include "Test.h"
+
+static void test_opaque_dest(skiatest::Reporter* reporter, SkMask::Format format) {
+ const auto& row_proc = SkBlitMask::RowFactory(SkColorType::kN32_SkColorType, format,
+ static_cast<SkBlitMask::RowFlags>(0));
+
+ SkPMColor src[256],
+ dst[256];
+ uint8_t aa[256];
+
+ // Coverage -> [0..255]
+ for (size_t i = 0; i < 256; ++i) {
+ aa[i] = static_cast<uint8_t>(i);
+ }
+
+ // src -> [0..255]
+ for (size_t src_a = 0; src_a < 256; ++src_a) {
+ memset(src, src_a, sizeof(src));
+
+ // dst -> 0xff (always opaque)
+ memset(dst, 0xff, sizeof(dst));
+
+ row_proc(dst, aa, src, 256);
+
+ for (size_t i = 0; i < 256; ++i) {
+ REPORTER_ASSERT(reporter, SkGetPackedA32(dst[i]) == 0xff);
+ }
+ }
+}
+
+// Verifies that D32 dest remains opaque for any (src_alpha, coverage) combination.
+DEF_TEST(BlitMask_OpaqueD32, reporter) {
+ test_opaque_dest(reporter, SkMask::Format::kA8_Format);
+}