summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c1b4117)
raw | patch | inline | side by side (parent: c1b4117)
author | mental <mental@users.sourceforge.net> | |
Tue, 21 Aug 2007 03:46:10 +0000 (03:46 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Tue, 21 Aug 2007 03:46:10 +0000 (03:46 +0000) |
src/libnr/nr-gradient.cpp | patch | blob | history |
index d4ce764c1ac4c239083dbabd6b3f5ff424d11095..cd771e7de638fadd1ccb6f0d95744b5de5b10db7 100644 (file)
#include <libnr/nr-pixblock-pixel.h>
#include <libnr/nr-blit.h>
#include <libnr/nr-gradient.h>
+#include <glib/gtypes.h>
+#include <stdio.h>
/* Common */
#define NRG_MASK (NR_GRADIENT_VECTOR_LENGTH - 1)
#define NRG_2MASK ((long long) ((NR_GRADIENT_VECTOR_LENGTH << 1) - 1))
+static guint32 msr_state=0xfefefefe;
+
+inline guint32 msr_next() {
+ guint32 lsb = msr_state & 1;
+ guint32 msb = ( lsb << 31 ) ^ ( ( msr_state & 2) << 30 );
+ msr_state = ( msr_state >> 1 ) | msb;
+ return lsb;
+}
+
inline unsigned char const *index_to_pointer(int idx,
unsigned char const *vector)
{
inline unsigned char const *r_to_pointer_pad(NR::Coord r,
unsigned char const *vector)
{
+ r += msr_next();
return index_to_pointer((int)CLAMP(r, 0, (double)(NR_GRADIENT_VECTOR_LENGTH - 1)), vector);
}
inline unsigned char const *r_to_pointer_repeat(NR::Coord r,
unsigned char const *vector)
{
+ r += msr_next();
return index_to_pointer((int)((long long)r & NRG_MASK), vector);
}
inline unsigned char const *r_to_pointer_reflect(NR::Coord r,
unsigned char const *vector)
{
+ r += msr_next();
int idx = (int) ((long long)r & NRG_2MASK);
if (idx > NRG_MASK) idx = NRG_2MASK - idx;
return index_to_pointer(idx, vector);