Skip to content

Commit

Permalink
Live preview: prevent the effect renderer progress property from exce…
Browse files Browse the repository at this point in the history
…eding 1.
  • Loading branch information
xxgreg committed Mar 29, 2010
1 parent ef1d326 commit 67c68c6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Pinta.Core/Classes/AsyncEffectRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ internal bool IsRendering {

internal double Progress {
get {
return (total_tiles == 0 || current_tile == -1)
? 0
: (double)current_tile / (double)total_tiles;
if (total_tiles == 0 || current_tile < 0)
return 0;
else if (current_tile < total_tiles)
return (double)current_tile / (double)total_tiles;
else
return 1;
}
}

Expand Down Expand Up @@ -232,15 +235,13 @@ void Render (int renderId, int threadId)
{
// Fetch the next tile index and render it.
for (;;) {
if (current_tile >= total_tiles || cancel_render_flag)
return;

int tileId = Interlocked.Increment (ref current_tile);
int tileIndex = Interlocked.Increment (ref current_tile);

if (tileId >= total_tiles || cancel_render_flag)
return;
if (tileIndex >= total_tiles || cancel_render_flag)
return;

RenderTile (renderId, threadId, tileId);
RenderTile (renderId, threadId, tileIndex);
}
}

Expand All @@ -266,6 +267,7 @@ void RenderTile (int renderId, int threadId, int tileIndex)
if (!IsRendering || renderId != render_id)
return;

// Update bounds to be shown on next expose.
lock (updated_lock) {
if (is_updated) {
updated_x1 = Math.Min (bounds.X, updated_x1);
Expand Down

0 comments on commit 67c68c6

Please sign in to comment.