Commit d3870aaf authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Remove background collection from draw. Set state variables instead.

Created new state variables to capture the final background and a
flag whether the correction is really necessary.  Also moved the
background correct function to image.c, but it is not used yet.
parent d1f08098
......@@ -108,3 +108,6 @@ icetSendRecvLargeMessages takes const array for messageDestinations.
ICET_CORRECT_COLORED_BACKGROUND is now the responsibility of the strategy,
not done automatically.
Added internal state variables ICET_NEED_BACKGROUND_CORRECTION,
ICET_TRUE_BACKGROUND_COLOR, and ICET_TRUE_BACKGROUND_COLOR_WORD.
......@@ -163,23 +163,25 @@ void icetDataReplicationGroupColor(IceTInt color)
static IceTFloat black[] = {0.0f, 0.0f, 0.0f, 0.0f};
static void drawUseBackgroundColor(const IceTFloat *background_color,
IceTUInt *background_color_word_p,
IceTBoolean *need_color_correction_p)
static void drawUseBackgroundColor(const IceTFloat *background_color)
{
IceTBoolean use_color_blending
= (IceTBoolean)( *(icetUnsafeStateGetInteger(ICET_COMPOSITE_MODE))
== ICET_COMPOSITE_MODE_BLEND);
/* Make sure background color is up to date. */
((IceTUByte *)background_color_word_p)[0]
= (IceTUByte)(255*background_color[0]);
((IceTUByte *)background_color_word_p)[1]
= (IceTUByte)(255*background_color[1]);
((IceTUByte *)background_color_word_p)[2]
= (IceTUByte)(255*background_color[2]);
((IceTUByte *)background_color_word_p)[3]
= (IceTUByte)(255*background_color[3]);
IceTUInt background_color_word;
IceTBoolean use_color_blending
= (IceTBoolean)( *(icetUnsafeStateGetInteger(ICET_COMPOSITE_MODE))
== ICET_COMPOSITE_MODE_BLEND);
((IceTUByte *)&background_color_word)[0]
= (IceTUByte)(255*background_color[0]);
((IceTUByte *)&background_color_word)[1]
= (IceTUByte)(255*background_color[1]);
((IceTUByte *)&background_color_word)[2]
= (IceTUByte)(255*background_color[2]);
((IceTUByte *)&background_color_word)[3]
= (IceTUByte)(255*background_color[3]);
icetStateSetFloatv(ICET_TRUE_BACKGROUND_COLOR, 4, background_color);
icetStateSetInteger(ICET_TRUE_BACKGROUND_COLOR_WORD, background_color_word);
if (use_color_blending) {
IceTInt display_tile;
/* We need to correct the background color by zeroing it out at
......@@ -189,17 +191,16 @@ static void drawUseBackgroundColor(const IceTFloat *background_color,
icetGetIntegerv(ICET_TILE_DISPLAYED, &display_tile);
if ( (display_tile >= 0)
&& (*background_color_word_p != 0)
&& (background_color_word != 0)
&& icetIsEnabled(ICET_CORRECT_COLORED_BACKGROUND) ) {
*need_color_correction_p = ICET_TRUE;
icetStateSetBoolean(ICET_NEED_BACKGROUND_CORRECTION, ICET_TRUE);
} else {
*need_color_correction_p = ICET_FALSE;
icetStateSetBoolean(ICET_NEED_BACKGROUND_CORRECTION, ICET_FALSE);
}
} else {
icetStateSetFloatv(ICET_BACKGROUND_COLOR, 4, background_color);
icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD,
*background_color_word_p);
*need_color_correction_p = ICET_FALSE;
icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD, background_color_word);
icetStateSetBoolean(ICET_NEED_BACKGROUND_CORRECTION, ICET_FALSE);
}
}
......@@ -728,36 +729,6 @@ static IceTImage drawInvokeStrategy(void)
return image;
}
static void drawCorrectBackground(IceTImage image,
const IceTFloat *background_color,
IceTUInt background_color_word)
{
IceTSizeType pixels = icetImageGetWidth(image)*icetImageGetHeight(image);
IceTEnum color_format = icetImageGetColorFormat(image);
icetTimingBlendBegin();
if (color_format == ICET_IMAGE_COLOR_RGBA_UBYTE) {
IceTUByte *color = icetImageGetColorub(image);
IceTUByte *bc = (IceTUByte *)(&background_color_word);
IceTSizeType p;
for (p = 0; p < pixels; p++, color += 4) {
ICET_UNDER_UBYTE(bc, color);
}
} else if (color_format == ICET_IMAGE_COLOR_RGBA_FLOAT) {
IceTFloat *color = icetImageGetColorf(image);
IceTSizeType p;
for (p = 0; p < pixels; p++, color += 4) {
ICET_UNDER_FLOAT(background_color, color);
}
} else {
icetRaiseError("Encountered invalid color buffer type"
" with color blending.", ICET_SANITY_CHECK_FAIL);
}
icetTimingBlendEnd();
}
IceTImage icetDrawFrame(const IceTDouble *projection_matrix,
const IceTDouble *modelview_matrix,
const IceTFloat *background_color)
......@@ -768,8 +739,6 @@ IceTImage icetDrawFrame(const IceTDouble *projection_matrix,
IceTDouble buf_read_time;
IceTDouble compose_time;
IceTDouble total_time;
IceTUInt background_color_word;
IceTBoolean need_color_correction;
icetRaiseDebug("In icetDrawFrame");
......@@ -789,9 +758,7 @@ IceTImage icetDrawFrame(const IceTDouble *projection_matrix,
icetStateSetDoublev(ICET_PROJECTION_MATRIX, 16, projection_matrix);
icetStateSetDoublev(ICET_MODELVIEW_MATRIX, 16, modelview_matrix);
drawUseBackgroundColor(background_color,
&background_color_word,
&need_color_correction);
drawUseBackgroundColor(background_color);
icetGetIntegerv(ICET_FRAME_COUNT, &frame_count);
frame_count++;
......@@ -836,11 +803,6 @@ IceTImage icetDrawFrame(const IceTDouble *projection_matrix,
image = drawInvokeStrategy();
/* Correct background color where applicable. */
if (need_color_correction) {
drawCorrectBackground(image, background_color, background_color_word);
}
/* Calculate times. */
icetGetDoublev(ICET_RENDER_TIME, &render_time);
icetGetDoublev(ICET_BUFFER_READ_TIME, &buf_read_time);
......
......@@ -2187,6 +2187,53 @@ void icetCompressedCompressedComposite(const IceTSparseImage front_buffer,
icetTimingBlendEnd();
}
void icetImageCorrectBackground(IceTImage image)
{
IceTBoolean need_correction;
IceTSizeType num_pixels;
IceTEnum color_format;
icetGetBooleanv(ICET_NEED_BACKGROUND_CORRECTION, &need_correction);
if (!need_correction) { return; }
num_pixels = icetImageGetNumPixels(image);
color_format = icetImageGetColorFormat(image);
icetTimingBlendBegin();
if (color_format == ICET_IMAGE_COLOR_RGBA_UBYTE) {
IceTUByte *color = icetImageGetColorub(image);
IceTInt background_color_word;
IceTUByte *bc;
IceTSizeType p;
icetGetIntegerv(ICET_TRUE_BACKGROUND_COLOR_WORD,
&background_color_word);
bc = (IceTUByte *)(&background_color_word);
for (p = 0; p < num_pixels; p++) {
ICET_UNDER_UBYTE(bc, color);
color += 4;
}
} else if (color_format == ICET_IMAGE_COLOR_RGBA_FLOAT) {
IceTFloat *color = icetImageGetColorf(image);
IceTFloat background_color[4];
IceTSizeType p;
icetGetFloatv(ICET_TRUE_BACKGROUND_COLOR, background_color);
for (p = 0; p < num_pixels; p++) {
ICET_UNDER_FLOAT(background_color, color);
color += 4;
}
} else {
icetRaiseError("Encountered invalid color buffer type"
" with color blending.", ICET_SANITY_CHECK_FAIL);
}
icetTimingBlendEnd();
}
static IceTImage renderTile(int tile,
IceTInt *screen_viewport,
IceTInt *target_viewport,
......
......@@ -305,16 +305,19 @@ ICET_EXPORT void icetDiagnostics(IceTBitField mask);
#define ICET_ALL_CONTAINED_TILES_MASKS (ICET_STATE_FRAME_START|(IceTEnum)0x0009)
#define ICET_TILE_CONTRIB_COUNTS (ICET_STATE_FRAME_START| (IceTEnum)0x000A)
#define ICET_TOTAL_IMAGE_COUNT (ICET_STATE_FRAME_START | (IceTEnum)0x000B)
#define ICET_VALID_PIXELS_TILE (ICET_STATE_FRAME_START | (IceTEnum)0x000C)
#define ICET_VALID_PIXELS_OFFSET (ICET_STATE_FRAME_START | (IceTEnum)0x000D)
#define ICET_VALID_PIXELS_NUM (ICET_STATE_FRAME_START | (IceTEnum)0x000E)
#define ICET_RENDERED_VIEWPORT (ICET_STATE_FRAME_START | (IceTEnum)0x0010)
#define ICET_RENDER_BUFFER (ICET_STATE_FRAME_START | (IceTEnum)0x0011)
#define ICET_RENDER_BUFFER_SIZE (ICET_STATE_FRAME_START | (IceTEnum)0x0012)
#define ICET_RENDER_BUFFER_HOLD (ICET_STATE_FRAME_START | (IceTEnum)0x0013)
#define ICET_TILE_PROJECTIONS (ICET_STATE_FRAME_START | (IceTEnum)0x0014)
#define ICET_NEED_BACKGROUND_CORRECTION (ICET_STATE_FRAME_START | (IceTEnum)0x000C)
#define ICET_TRUE_BACKGROUND_COLOR (ICET_STATE_FRAME_START | (IceTEnum)0x000D)
#define ICET_TRUE_BACKGROUND_COLOR_WORD (ICET_STATE_FRAME_START | (IceTEnum)0x000E)
#define ICET_VALID_PIXELS_TILE (ICET_STATE_FRAME_START | (IceTEnum)0x0018)
#define ICET_VALID_PIXELS_OFFSET (ICET_STATE_FRAME_START | (IceTEnum)0x0019)
#define ICET_VALID_PIXELS_NUM (ICET_STATE_FRAME_START | (IceTEnum)0x001A)
#define ICET_RENDERED_VIEWPORT (ICET_STATE_FRAME_START | (IceTEnum)0x0020)
#define ICET_RENDER_BUFFER (ICET_STATE_FRAME_START | (IceTEnum)0x0021)
#define ICET_RENDER_BUFFER_SIZE (ICET_STATE_FRAME_START | (IceTEnum)0x0022)
#define ICET_RENDER_BUFFER_HOLD (ICET_STATE_FRAME_START | (IceTEnum)0x0023)
#define ICET_TILE_PROJECTIONS (ICET_STATE_FRAME_START | (IceTEnum)0x0024)
#define ICET_STATE_TIMING_START (IceTEnum)0x000000C0
......
......@@ -171,6 +171,8 @@ ICET_EXPORT void icetCompressedCompressedComposite(
const IceTSparseImage back_buffer,
IceTSparseImage dest_buffer);
ICET_EXPORT void icetImageCorrectBackground(IceTImage image);
#define ICET_BLEND_UBYTE(front, back, dest) \
{ \
IceTUInt afactor = 255 - (front)[3]; \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment