nr-compose-test.h revision 9eb886f0efdd076022ef171278e8475a580a1e91
#include <cxxtest/TestSuite.h>
#include "nr-compose.h"
#include "nr-compose-reference.h"
#include <glib.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { return (v+divisor/2)/divisor; }
static inline unsigned char NR_PREMUL_111(unsigned int c, unsigned int a) { return static_cast<unsigned char>(DIV_ROUND(c*a, 255)); }
static int IMGCMP(const unsigned char* a, const unsigned char* b, size_t n) { return memcmp(a, b, n); }
template<>
{
// If two pixels each have their alpha channel set to zero they're equivalent
// Note that this doesn't work for premultiplied values, as their color values should
// be zero when alpha is zero.
int cr = 0;
while(n && cr == 0) {
if ( a[3] != 0 || b[3] != 0 ) {
}
a+=4;
b+=4;
n-=4;
}
return cr;
}
int const w, h;
unsigned char* const dst_rgba_n_org;
unsigned char* const dst_rgba_p_org;
unsigned char* const dst_rgb_org;
unsigned char* const dst1_rgba;
unsigned char* const dst2_rgba;
unsigned char* const src_rgba_n;
unsigned char* const src_rgba_p;
unsigned char* const dst1_rgb;
unsigned char* const dst2_rgb;
unsigned char* const src_rgb;
unsigned char* const mask;
static unsigned int const alpha_vals[7];
static unsigned int const rgb_vals[3];
NrComposeTest() :
w(13),
h(5),
{
srand(23874683); // It shouldn't really matter what this is, as long as it's always the same (to be reproducible)
for(int y=0; y<h; y++) {
for(int x=0; x<w; x++) {
for(int i=0; i<3; i++) {
}
}
}
}
{
delete[] src_rgba_n;
delete[] src_rgba_p;
}
// createSuite and destroySuite get us per-suite setup and teardown
// without us having to worry about static initialization order, etc.
// FINAL DST SRC
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
// FINAL DST SRC MASK
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
// FINAL DST MASK COLOR
{
char msg[100];
sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
}
}
}
{
char msg[100];
sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
}
}
}
{
char msg[100];
sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
}
}
}
{
char msg[100];
sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
}
}
}
{
char msg[100];
sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
}
}
}
// RGB
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
{
unsigned int alpha = alpha_vals[i];
char msg[40];
}
}
};
( 0u<<24u)+( 1u<<16u)+( 92u<<8u),
(127u<<24u)+(128u<<16u)+(129u<<8u),
(163u<<24u)+(254u<<16u)+(255u<<8u)};
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :