blob: 04bec6618915bc4a0f7f0b6eba1aa8c14482098d [file] [log] [blame]
Florin Malita15a64e72018-04-18 11:14:50 -04001/*
2 * Copyright 2018 Google Inc.
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 "SkBlitMask.h"
9#include "SkColorPriv.h"
10#include "SkMask.h"
11#include "Test.h"
12
13static void test_opaque_dest(skiatest::Reporter* reporter, SkMask::Format format) {
14 const auto& row_proc = SkBlitMask::RowFactory(SkColorType::kN32_SkColorType, format,
15 static_cast<SkBlitMask::RowFlags>(0));
16
17 SkPMColor src[256],
18 dst[256];
19 uint8_t aa[256];
20
21 // Coverage -> [0..255]
22 for (size_t i = 0; i < 256; ++i) {
23 aa[i] = static_cast<uint8_t>(i);
24 }
25
26 // src -> [0..255]
27 for (size_t src_a = 0; src_a < 256; ++src_a) {
28 memset(src, src_a, sizeof(src));
29
30 // dst -> 0xff (always opaque)
31 memset(dst, 0xff, sizeof(dst));
32
33 row_proc(dst, aa, src, 256);
34
35 for (size_t i = 0; i < 256; ++i) {
36 REPORTER_ASSERT(reporter, SkGetPackedA32(dst[i]) == 0xff);
37 }
38 }
39}
40
41// Verifies that D32 dest remains opaque for any (src_alpha, coverage) combination.
42DEF_TEST(BlitMask_OpaqueD32, reporter) {
43 test_opaque_dest(reporter, SkMask::Format::kA8_Format);
44}