2016-07-12 22:01:26 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2016-10-04 18:03:27 +00:00
|
|
|
#include "SkHalf.h"
|
2016-07-12 22:01:26 +00:00
|
|
|
#include "SkRasterPipeline.h"
|
|
|
|
|
|
|
|
DEF_TEST(SkRasterPipeline, r) {
|
2016-10-04 18:03:27 +00:00
|
|
|
// Build and run a simple pipeline to exercise SkRasterPipeline,
|
|
|
|
// drawing 50% transparent blue over opaque red in half-floats.
|
2016-10-05 14:36:38 +00:00
|
|
|
uint64_t red = 0x3c00000000003c00ull,
|
|
|
|
blue = 0x3800380000000000ull,
|
|
|
|
result;
|
2016-10-05 13:36:26 +00:00
|
|
|
|
2016-10-25 19:43:46 +00:00
|
|
|
void* load_s_ctx = &blue;
|
|
|
|
void* load_d_ctx = &red;
|
|
|
|
void* store_ctx = &result;
|
|
|
|
|
2016-07-12 22:01:26 +00:00
|
|
|
SkRasterPipeline p;
|
Consistent naming.
For stages that have {r,g,b,a} and {dr,dg,db,da} versions, name the {r,g,b,a} one "foo" and the {dr,dg,db,da} on "foo_d". The {r,g,b,a} registers are the ones most commonly used and fastest, so they get short ordinary names, and the d-registers are less commonly used and sometimes slower, so they get a suffix.
Some stages naturally opearate on all 8 registers (the xfermodes, accumulate). These names for those look fine and aren't ambiguous.
Also, a bit more re-arrangement in _opts.h.
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: Ia20029247642798a60a2566e8a26b84ed101dbd0
Reviewed-on: https://skia-review.googlesource.com/5291
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-11-28 23:23:23 +00:00
|
|
|
p.append(SkRasterPipeline::load_f16, &load_s_ctx);
|
2017-01-06 15:21:56 +00:00
|
|
|
p.append(SkRasterPipeline::move_src_dst);
|
|
|
|
p.append(SkRasterPipeline::load_f16, &load_d_ctx);
|
|
|
|
p.append(SkRasterPipeline::swap);
|
2016-10-04 18:03:27 +00:00
|
|
|
p.append(SkRasterPipeline::srcover);
|
2016-10-25 19:43:46 +00:00
|
|
|
p.append(SkRasterPipeline::store_f16, &store_ctx);
|
2016-11-30 18:45:06 +00:00
|
|
|
p.run(0,0, 1);
|
2016-10-04 18:03:27 +00:00
|
|
|
|
|
|
|
// We should see half-intensity magenta.
|
2016-10-05 14:36:38 +00:00
|
|
|
REPORTER_ASSERT(r, ((result >> 0) & 0xffff) == 0x3800);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 16) & 0xffff) == 0x0000);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 32) & 0xffff) == 0x3800);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 48) & 0xffff) == 0x3c00);
|
2017-01-06 17:00:31 +00:00
|
|
|
|
|
|
|
// Run again, this time compiling the pipeline.
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
auto fn = p.compile();
|
|
|
|
fn(0,0, 1);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 0) & 0xffff) == 0x3800);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 16) & 0xffff) == 0x0000);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 32) & 0xffff) == 0x3800);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 48) & 0xffff) == 0x3c00);
|
2016-07-12 22:01:26 +00:00
|
|
|
}
|
2016-07-13 15:22:20 +00:00
|
|
|
|
|
|
|
DEF_TEST(SkRasterPipeline_empty, r) {
|
|
|
|
// No asserts... just a test that this is safe to run.
|
|
|
|
SkRasterPipeline p;
|
2016-11-30 18:45:06 +00:00
|
|
|
p.run(0,0, 20);
|
2016-07-13 15:22:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(SkRasterPipeline_nonsense, r) {
|
|
|
|
// No asserts... just a test that this is safe to run and terminates.
|
2016-10-04 18:03:27 +00:00
|
|
|
// srcover() calls st->next(); this makes sure we've always got something there to call.
|
2016-07-13 15:22:20 +00:00
|
|
|
SkRasterPipeline p;
|
2016-10-04 18:03:27 +00:00
|
|
|
p.append(SkRasterPipeline::srcover);
|
2016-11-30 18:45:06 +00:00
|
|
|
p.run(0,0, 20);
|
2016-07-13 15:22:20 +00:00
|
|
|
}
|