Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
IceT
IceT
Commits
ffd61e26
Commit
ffd61e26
authored
May 13, 2011
by
Kenneth Moreland
Browse files
Merge branch 'DistributedBackgroundCorrect'
parents
3b07020a
8f744038
Changes
16
Hide whitespace changes
Inline
Side-by-side
Changes.txt
View file @
ffd61e26
...
...
@@ -105,3 +105,13 @@ Added Alltoall to communicator. (Search for Allgather for places to add in
documentation.)
icetSendRecvLargeMessages takes const array for messageDestinations.
ICET_CORRECT_COLORED_BACKGROUND is now the responsibility of the strategy,
not done automatically. icetSingleImageCollect does it for you, though.
Added internal state variables ICET_NEED_BACKGROUND_CORRECTION,
ICET_TRUE_BACKGROUND_COLOR, and ICET_TRUE_BACKGROUND_COLOR_WORD.
icetImageCorrectBackground, icetClearImageTrueBackground,
icetDecompressImageCorrectBackground, and
icetDecompressSubImageCorrectBackground functions.
src/ice-t/decompress_func_body.h
View file @
ffd61e26
...
...
@@ -34,6 +34,9 @@
* values.
* BLEND_RGBA_FLOAT(src, dest) - same as above except src and dest
* are IceTFloat arrays.
* CORRECT_BACKGROUND - if defined, the output color will be blended
* with the true background color. This should only be set
* if ICET_NEED_BACKGROUND_CORRECTION is true.
* OFFSET - If defined to a number (or variable holding a number), skips
* that many pixels at the beginning of the image.
* PIXEL_COUNT - If defined to a number (or a variable holding a number),
...
...
@@ -247,11 +250,21 @@
#ifdef OFFSET
_color
+=
OFFSET
;
#endif
#ifdef CORRECT_BACKGROUND
icetGetIntegerv
(
ICET_TRUE_BACKGROUND_COLOR_WORD
,
(
IceTInt
*
)
&
_background_color
);
#else
icetGetIntegerv
(
ICET_BACKGROUND_COLOR_WORD
,
(
IceTInt
*
)
&
_background_color
);
#endif
#ifdef COMPOSITE
#define COPY_PIXEL(c_src, c_dest) \
BLEND_RGBA_UBYTE(((IceTUByte*)c_src), ((IceTUByte*)c_dest))
#elif defined(CORRECT_BACKGROUND)
#define COPY_PIXEL(c_src, c_dest) \
ICET_BLEND_UBYTE(((IceTUByte*)c_src), \
((IceTUByte*)&_background_color), \
((IceTUByte*)c_dest))
#else
#define COPY_PIXEL(c_src, c_dest) \
c_dest[0] = c_src[0];
...
...
@@ -282,9 +295,16 @@
#ifdef OFFSET
_color
+=
4
*
(
OFFSET
);
#endif
#ifdef CORRECT_BACKGROUND
icetGetFloatv
(
ICET_TRUE_BACKGROUND_COLOR
,
_background_color
);
#else
icetGetFloatv
(
ICET_BACKGROUND_COLOR
,
_background_color
);
#endif
#ifdef COMPOSITE
#define COPY_PIXEL(c_src, c_dest) BLEND_RGBA_FLOAT(c_src, c_dest);
#elif defined(CORRECT_BACKGROUND)
#define COPY_PIXEL(c_src, c_dest) \
ICET_BLEND_FLOAT(c_src, _background_color, c_dest);
#else
#define COPY_PIXEL(c_src, c_dest) \
c_dest[0] = c_src[0]; \
...
...
src/ice-t/draw.c
View file @
ffd61e26
...
...
@@ -163,23 +163,25 @@ void icetDataReplicationGroupColor(IceTInt color)
static
IceTFloat
black
[]
=
{
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
};
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
...
...
@@ -188,18 +190,16 @@ static void drawUseBackgroundColor(const IceTFloat *background_color,
icetStateSetInteger
(
ICET_BACKGROUND_COLOR_WORD
,
0
);
icetGetIntegerv
(
ICET_TILE_DISPLAYED
,
&
display_tile
);
if
(
(
display_tile
>=
0
)
&&
(
*
background_color_word_p
!=
0
)
if
(
(
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 +728,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 +738,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 +757,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 +802,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
);
...
...
src/ice-t/image.c
View file @
ffd61e26
...
...
@@ -2002,6 +2002,47 @@ void icetDecompressSubImage(const IceTSparseImage compressed_image,
#include
"decompress_func_body.h"
}
void
icetDecompressImageCorrectBackground
(
const
IceTSparseImage
compressed_image
,
IceTImage
image
)
{
icetImageSetDimensions
(
image
,
icetSparseImageGetWidth
(
compressed_image
),
icetSparseImageGetHeight
(
compressed_image
));
icetDecompressSubImageCorrectBackground
(
compressed_image
,
0
,
image
);
}
void
icetDecompressSubImageCorrectBackground
(
const
IceTSparseImage
compressed_image
,
IceTSizeType
offset
,
IceTImage
image
)
{
IceTBoolean
need_correction
;
const
IceTFloat
*
background_color
;
const
IceTUByte
*
background_color_word
;
icetGetBooleanv
(
ICET_NEED_BACKGROUND_CORRECTION
,
&
need_correction
);
if
(
!
need_correction
)
{
/* Do a normal decompress. */
icetDecompressSubImage
(
compressed_image
,
offset
,
image
);
}
ICET_TEST_IMAGE_HEADER
(
image
);
ICET_TEST_SPARSE_IMAGE_HEADER
(
compressed_image
);
background_color
=
icetUnsafeStateGetFloat
(
ICET_TRUE_BACKGROUND_COLOR
);
background_color_word
=
(
IceTUByte
*
)
icetUnsafeStateGetInteger
(
ICET_TRUE_BACKGROUND_COLOR_WORD
);
#define INPUT_SPARSE_IMAGE compressed_image
#define OUTPUT_IMAGE image
#define TIME_DECOMPRESSION
#define OFFSET offset
#define PIXEL_COUNT icetSparseImageGetNumPixels(compressed_image)
#define CORRECT_BACKGROUND
#include
"decompress_func_body.h"
}
void
icetComposite
(
IceTImage
destBuffer
,
const
IceTImage
srcBuffer
,
int
srcOnTop
)
...
...
@@ -2187,6 +2228,75 @@ 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
();
}
void
icetClearImageTrueBackground
(
IceTImage
image
)
{
IceTFloat
true_background
[
4
];
IceTInt
true_background_word
;
IceTFloat
original_background
[
4
];
IceTInt
original_background_word
;
icetGetFloatv
(
ICET_TRUE_BACKGROUND_COLOR
,
true_background
);
icetGetIntegerv
(
ICET_TRUE_BACKGROUND_COLOR_WORD
,
&
true_background_word
);
icetGetFloatv
(
ICET_BACKGROUND_COLOR
,
original_background
);
icetGetIntegerv
(
ICET_BACKGROUND_COLOR_WORD
,
&
original_background_word
);
icetStateSetFloatv
(
ICET_BACKGROUND_COLOR
,
4
,
true_background
);
icetStateSetInteger
(
ICET_BACKGROUND_COLOR_WORD
,
true_background_word
);
icetClearImage
(
image
);
icetStateSetFloatv
(
ICET_BACKGROUND_COLOR
,
4
,
original_background
);
icetStateSetInteger
(
ICET_BACKGROUND_COLOR_WORD
,
original_background_word
);
}
static
IceTImage
renderTile
(
int
tile
,
IceTInt
*
screen_viewport
,
IceTInt
*
target_viewport
,
...
...
src/include/IceT.h
View file @
ffd61e26
...
...
@@ -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
...
...
src/include/IceTDevImage.h
View file @
ffd61e26
...
...
@@ -153,6 +153,15 @@ ICET_EXPORT void icetDecompressSubImage(const IceTSparseImage compressed_image,
IceTSizeType
offset
,
IceTImage
image
);
ICET_EXPORT
void
icetDecompressImageCorrectBackground
(
const
IceTSparseImage
compressed_image
,
IceTImage
image
);
ICET_EXPORT
void
icetDecompressSubImageCorrectBackground
(
const
IceTSparseImage
compressed_image
,
IceTSizeType
offset
,
IceTImage
image
);
ICET_EXPORT
void
icetComposite
(
IceTImage
destBuffer
,
const
IceTImage
srcBuffer
,
int
srcOnTop
);
...
...
@@ -171,6 +180,9 @@ ICET_EXPORT void icetCompressedCompressedComposite(
const
IceTSparseImage
back_buffer
,
IceTSparseImage
dest_buffer
);
ICET_EXPORT
void
icetImageCorrectBackground
(
IceTImage
image
);
ICET_EXPORT
void
icetClearImageTrueBackground
(
IceTImage
image
);
#define ICET_BLEND_UBYTE(front, back, dest) \
{ \
IceTUInt afactor = 255 - (front)[3]; \
...
...
src/strategies/common.c
View file @
ffd61e26
...
...
@@ -672,7 +672,9 @@ void icetSingleImageCollect(const IceTSparseImage input_image,
if
(
piece_size
>
0
)
{
/* Decompress data into appropriate offset of result image. */
icetDecompressSubImage
(
input_image
,
piece_offset
,
result_image
);
icetDecompressSubImageCorrectBackground
(
input_image
,
piece_offset
,
result_image
);
}
else
if
(
rank
!=
dest
)
{
/* If this function is called for multiple collections, it is likely
that the local process will not have data for all collections. To
...
...
src/strategies/direct.c
View file @
ffd61e26
...
...
@@ -71,17 +71,24 @@ IceTImage icetDirectCompose(void)
outSparseImage
,
tile_image_dest
);
if
((
display_tile
>=
0
)
&&
(
num_contributors
<
1
))
{
/* Must be displaying a blank tile. */
const
IceTInt
*
tile_viewports
=
icetUnsafeStateGetInteger
(
ICET_TILE_VIEWPORTS
);
const
IceTInt
*
display_tile_viewport
=
tile_viewports
+
4
*
display_tile
;
IceTInt
display_tile_width
=
display_tile_viewport
[
2
];
IceTInt
display_tile_height
=
display_tile_viewport
[
3
];
if
(
display_tile
>=
0
)
{
if
(
num_contributors
>
0
)
{
icetImageCorrectBackground
(
image
);
}
else
{
/* Must be displaying a blank tile. */
const
IceTInt
*
tile_viewports
=
icetUnsafeStateGetInteger
(
ICET_TILE_VIEWPORTS
);
const
IceTInt
*
display_tile_viewport
=
tile_viewports
+
4
*
display_tile
;
IceTInt
display_tile_width
=
display_tile_viewport
[
2
];
IceTInt
display_tile_height
=
display_tile_viewport
[
3
];
icetRaiseDebug
(
"Returning blank tile."
);
icetImageSetDimensions
(
image
,
display_tile_width
,
display_tile_height
);
icetClearImage
(
image
);
icetRaiseDebug
(
"Returning blank tile."
);
icetImageSetDimensions
(
image
,
display_tile_width
,
display_tile_height
);
icetClearImageTrueBackground
(
image
);
}
}
return
image
;
...
...
src/strategies/reduce.c
View file @
ffd61e26
...
...
@@ -515,7 +515,7 @@ IceTImage reduceCollect(const IceTSparseImage composited_image,
if
((
tile_displayed
>=
0
)
&&
(
tile_displayed
!=
compose_tile
))
{
/* Return empty image if nothing in this tile. */
icetRaiseDebug
(
"Clearing pixels"
);
icetClearImage
(
result_image
);
icetClearImage
TrueBackground
(
result_image
);
}
return
result_image
;
...
...
src/strategies/split.c
View file @
ffd61e26
...
...
@@ -60,6 +60,8 @@ static void icetCollectImage(IceTImage imageFragment,
color_format
=
icetImageGetColorFormat
(
imageFragment
);
depth_format
=
icetImageGetDepthFormat
(
imageFragment
);
icetImageCorrectBackground
(
imageFragment
);
icetTimingCollectBegin
();
if
(
color_format
!=
ICET_IMAGE_COLOR_NONE
)
{
...
...
@@ -122,7 +124,7 @@ static void icetCollectImage(IceTImage imageFragment,
}
}
}
else
{
icetClearImage
(
fullImage
);
icetClearImage
TrueBackground
(
fullImage
);
}
}
...
...
@@ -200,7 +202,7 @@ IceTImage icetSplitCompose(void)
my_height
=
tile_viewports
[
4
*
tile_displayed
+
3
];
fullImage
=
icetGetStateBufferImage
(
SPLIT_FULL_IMAGE_BUFFER
,
my_width
,
my_height
);
icetClearImage
(
fullImage
);
icetClearImage
TrueBackground
(
fullImage
);
}
return
fullImage
;
}
...
...
src/strategies/vtree.c
View file @
ffd61e26
...
...
@@ -226,13 +226,35 @@ IceTImage icetVtreeCompose(void)
/* Hacks for when "this" tile was not rendered. */
if
((
tile_displayed
>=
0
)
&&
(
tile_displayed
!=
tile_held
))
{
if
(
all_contained_tmasks
[
rank
*
num_tiles
+
tile_displayed
])
{
/* Only "this" node draws "this" tile. Because the image never */
/* needed to be transferred, it was never rendered above. Just */
/* render it now. */
/* Only "this" node draws "this" tile. Because the image never needed
to be transferred, it was never rendered above. Just render it
now. We might save some time by rendering with the true
background color rather than correcting it later. */
IceTFloat
true_background
[
4
];
IceTInt
true_background_word
;
IceTFloat
original_background
[
4
];
IceTInt
original_background_word
;
icetGetFloatv
(
ICET_TRUE_BACKGROUND_COLOR
,
true_background
);
icetGetIntegerv
(
ICET_TRUE_BACKGROUND_COLOR_WORD
,
&
true_background_word
);
icetGetFloatv
(
ICET_BACKGROUND_COLOR
,
original_background
);
icetGetIntegerv
(
ICET_BACKGROUND_COLOR_WORD
,
&
original_background_word
);
icetStateSetFloatv
(
ICET_BACKGROUND_COLOR
,
4
,
true_background
);
icetStateSetInteger
(
ICET_BACKGROUND_COLOR_WORD
,
true_background_word
);
icetRaiseDebug
(
"Rendering tile to display."
);
/* This may uncessarily read a buffer if not outputing an input
buffer */
icetGetTileImage
(
tile_displayed
,
image
);
icetStateSetFloatv
(
ICET_BACKGROUND_COLOR
,
4
,
original_background
);
icetStateSetInteger
(
ICET_BACKGROUND_COLOR_WORD
,
original_background_word
);
}
else
{
/* "This" tile is blank. */
const
IceTInt
*
display_tile_viewport
...
...
@@ -243,8 +265,10 @@ IceTImage icetVtreeCompose(void)
icetRaiseDebug
(
"Returning blank image."
);
icetImageSetDimensions
(
image
,
display_tile_width
,
display_tile_height
);
icetClearImage
(
image
);
icetClearImage
TrueBackground
(
image
);
}
}
else
if
(
tile_displayed
>=
0
)
{
icetImageCorrectBackground
(
image
);
}
return
image
;
...
...
tests/BackgroundCorrect.c
0 → 100644
View file @
ffd61e26
/* -*- c -*- *****************************************************************
** Copyright (C) 2011 Sandia Corporation
** Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
** the U.S. Government retains certain rights in this software.
**
** This source code is released under the New BSD License.
**
** This tests the ICET_CORRECT_COLORED_BACKGROUND option.
** This tests the ICET_MAX_IMAGE_SPLIT option. It sets the max image split to
** less than the total number of processes and makes sure that the image is
** still composited correctly.
*****************************************************************************/
#include
<IceT.h>
#include
"test_codes.h"
#include
"test-util.h"
#include
<IceTDevContext.h>
#include
<IceTDevImage.h>
#include
<IceTDevMatrix.h>
#include
<stdlib.h>
#include
<stdio.h>
#include
<string.h>
#define PROC_REGION_WIDTH 10
#define PROC_REGION_HEIGHT 10
const
IceTFloat
g_background_color
[
4
]
=
{
0
.
5
,
0
.
5
,
0
.
5
,
1
.
0
};
const
IceTFloat
g_foreground_color
[
4
]
=
{
0
.
0
,
0
.
25
,
0
.
5
,
0
.
5
};
const
IceTFloat
g_blended_color
[
4
]
=
{
0
.
25
,
0
.
5
,
0
.
75
,
1
.
0
};
static
IceTBoolean
ColorsEqual
(
const
IceTFloat
*
color1
,
const
IceTFloat
*
color2
)
{
IceTBoolean
result
;
result
=
(
color1
[
0
]
==
color2
[
0
]);
result
&=
(
color1
[
1
]
==
color2
[
1
]);
result
&=
(
color1
[
2
]
==
color2
[
2
]);
result
&=
(
color1
[
3
]
==
color2
[
3
]);
return
result
;
}
static
void
BackgroundCorrectDraw
(
const
IceTDouble
*
projection_matrix
,
const
IceTDouble
*
modelview_matrix
,
const
IceTFloat
*
background_color
,
const
IceTInt
*
readback_viewport
,
IceTImage
result
)
{
IceTDouble
full_transform
[
16
];
IceTSizeType
width
;
IceTSizeType
height
;
IceTFloat
*
colors
;
IceTFloat
blended_color
[
4
];
/* This is mostly done for completeness. Because we are blending and
correcting the color, we totally expect background_color to be all zeros,
and therefore blended_color should be equal to g_foreground_color. The
real blending will happen within IceT under the covers. */
ICET_BLEND_FLOAT
(
g_foreground_color
,
background_color
,
blended_color
);
width
=
icetImageGetWidth
(
result
);
height
=
icetImageGetHeight
(
result
);
colors
=
icetImageGetColorf
(
result
);
/* Get full transform all the way to window coordinates (pixels). */
{
IceTDouble
scale_transform
[
16
];
IceTDouble
translate_transform
[
16
];
icetMatrixScale
(
0
.
5
*
width
,
0
.
5
*
height
,
0
.
5
,
scale_transform
);
icetMatrixTranslate
(
1
.
0
,
1
.
0
,
1
.
0
,
translate_transform
);
icetMatrixMultiply
(
full_transform
,
scale_transform
,
translate_transform
);
icetMatrixPostMultiply
(
full_transform
,
projection_matrix
);
icetMatrixPostMultiply
(
full_transform
,
modelview_matrix
);
}
/* Clear out the image (testing purposes only). */
{
IceTSizeType
pixel
;
for
(
pixel
=
0
;
pixel
<
width
*
height
;
pixel
++
)
{
colors
[
pixel
]
=
-
1
.
0
;
}
}
/* Set my pixels. */
{
IceTInt
rank
;
IceTSizeType
region_y_start
;
IceTSizeType
region_x
;
IceTSizeType
region_y
;
icetGetIntegerv
(
ICET_RANK
,
&
rank
);
region_y_start
=
rank
*
PROC_REGION_HEIGHT
;
for
(
region_y
=
0
;
region_y
<
PROC_REGION_HEIGHT
;
region_y
++
)
{
for
(
region_x
=
0
;
region_x
<
PROC_REGION_WIDTH
;
region_x
++
)
{
IceTDouble
object_coord
[
4
];
IceTDouble
window_coord
[
4
];
IceTSizeType
window_pixel
[
2
];
IceTSizeType
readback_lower
[
2
];
IceTSizeType
readback_upper
[
2
];
IceTBoolean
in_readback
;
object_coord
[
0
]
=
(
IceTDouble
)
region_x
;
object_coord
[
1
]
=
(
IceTDouble
)(
region_y
+
region_y_start
);
object_coord
[
2
]
=
0
.
0
;
object_coord
[
3
]
=
1
.
0
;
icetMatrixVectorMultiply
(
window_coord
,