skia2/tests/SkRasterPipelineTest.cpp
Mike Klein d0ccb57ec4 looks like red and blue start wrong (more unit test debugging)
BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3001

CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release-GN-Trybot

Change-Id: I8d26b5484a2bf67d5d5891475640970046e470d8
Reviewed-on: https://skia-review.googlesource.com/3001
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
2016-10-05 13:56:40 +00:00

58 lines
1.8 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
#include "SkHalf.h"
#include "SkRasterPipeline.h"
DEF_TEST(SkRasterPipeline, r) {
// Build and run a simple pipeline to exercise SkRasterPipeline,
// drawing 50% transparent blue over opaque red in half-floats.
Sk4h red = SkFloatToHalf_finite_ftz({ 1.0f, 0.0f, 0.0f, 1.0f }),
blue = SkFloatToHalf_finite_ftz({ 0.0f, 0.0f, 0.5f, 0.5f }),
result = { 1, 2, 3, 4 };
uint64_t bits;
memcpy(&bits, &red, 8);
SkDebugf("SkRasterPipeline red: 0x%016llx, want 0x3c00000000003c00\n", bits);
memcpy(&bits, &blue, 8);
SkDebugf("SkRasterPipeline blue: 0x%016llx, want 0x3800380000000000\n", bits);
SkRasterPipeline p;
p.append(SkRasterPipeline::load_s_f16, &blue);
p.append(SkRasterPipeline::load_d_f16, &red);
p.append(SkRasterPipeline::srcover);
p.append(SkRasterPipeline::store_f16, &result);
p.run(1);
Sk4f f = SkHalfToFloat_finite_ftz(result);
memcpy(&bits, &result, 8);
SkDebugf("SkRasterPipeline result: 0x%016llx, want 0x3c00380000003800\n", bits);
// We should see half-intensity magenta.
REPORTER_ASSERT(r, f[0] == 0.5f);
REPORTER_ASSERT(r, f[1] == 0.0f);
REPORTER_ASSERT(r, f[2] == 0.5f);
REPORTER_ASSERT(r, f[3] == 1.0f);
}
DEF_TEST(SkRasterPipeline_empty, r) {
// No asserts... just a test that this is safe to run.
SkRasterPipeline p;
p.run(20);
}
DEF_TEST(SkRasterPipeline_nonsense, r) {
// No asserts... just a test that this is safe to run and terminates.
// srcover() calls st->next(); this makes sure we've always got something there to call.
SkRasterPipeline p;
p.append(SkRasterPipeline::srcover);
p.run(20);
}