Skip to content

Commit

Permalink
make sure frames are ready to render before rendering them.., so that…
Browse files Browse the repository at this point in the history
… partially converted frames are not shown. add some additional debug.
  • Loading branch information
Kalamatee committed Feb 19, 2020
1 parent 05eba0a commit 9f206e3
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 114 deletions.
2 changes: 1 addition & 1 deletion workbench/classes/datatypes/animation/animation.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##begin config
version 41.9
version 41.10
copyright � The AROS Dev Team
classdatatype struct Animation_Data
##end config
Expand Down
12 changes: 11 additions & 1 deletion workbench/classes/datatypes/animation/animationbuffer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2015-2016, The AROS Development Team. All rights reserved.
Copyright © 2015-2020, The AROS Development Team. All rights reserved.
$Id$
*/

Expand Down Expand Up @@ -76,6 +76,8 @@ struct AnimFrame *NextToBuffer(struct ProcessPrivate *priv, struct AnimFrame *ne
else
prevFrame = startFrame;

DFRAMES("[animation.datatype/BUFFER]: %s: starting frame @ 0x%p\n", __func__, prevFrame)

findprevframe:
while ((prevFrame->af_Node.ln_Succ) && (prevFrame->af_Node.ln_Succ->ln_Succ) &&
((prevFrame == (struct AnimFrame *)&priv->pp_Data->ad_FrameData.afd_AnimFrames) ||
Expand All @@ -84,6 +86,8 @@ struct AnimFrame *NextToBuffer(struct ProcessPrivate *priv, struct AnimFrame *ne
prevFrame = (struct AnimFrame *)prevFrame->af_Node.ln_Succ;
}

DFRAMES("[animation.datatype/BUFFER]: %s: trying frame @ 0x%p (ID %u)\n", __func__, prevFrame, GetNODEID(prevFrame))

if (GetNODEID(prevFrame) == (priv->pp_Data->ad_FrameData.afd_Frames - 1))
{
prevFrame = (struct AnimFrame *)&priv->pp_Data->ad_FrameData.afd_AnimFrames;
Expand All @@ -94,13 +98,17 @@ struct AnimFrame *NextToBuffer(struct ProcessPrivate *priv, struct AnimFrame *ne
}
}

DFRAMES("[animation.datatype/BUFFER]: %s: prevframe @ 0x%p\n", __func__, prevFrame)

if (prevFrame != (struct AnimFrame *)&priv->pp_Data->ad_FrameData.afd_AnimFrames)
{
startFrame = prevFrame;
newFrame->af_Frame.alf_Frame = GetNODEID(prevFrame) + 1;
DFRAMES("[animation.datatype/BUFFER]: %s: start at frame #%u\n", __func__, newFrame->af_Frame.alf_Frame)
}
else
{
DFRAMES("[animation.datatype/BUFFER]: %s: start at the begining\n", __func__)
startFrame = NULL;
newFrame->af_Frame.alf_Frame = 0;
}
Expand Down Expand Up @@ -255,6 +263,7 @@ AROS_UFH3(void, bufferProc,
if ((curFrame) ||
((curFrame = AllocMem(sizeof(struct AnimFrame), MEMF_ANY|MEMF_CLEAR)) != NULL))
{
D(bug("[animation.datatype/BUFFER]: %s: frame @ 0x%p\n", __func__, curFrame);)
curFrame->af_Frame.MethodID = ADTM_LOADFRAME;

ObtainSemaphoreShared(&priv->pp_Data->ad_FrameData.afd_AnimFramesLock);
Expand All @@ -263,6 +272,7 @@ AROS_UFH3(void, bufferProc,
if (priv->pp_PlaybackSync != -1)
playbacksig |= (1 << priv->pp_PlaybackSync);

D(bug("[animation.datatype/BUFFER]: %s: BufferSpecific = #%d\n", __func__, priv->pp_BufferSpecific);)
curFrame->af_Frame.alf_Frame = priv->pp_BufferSpecific;
priv->pp_BufferSpecific = -1;
startFrame = (struct AnimFrame *)&priv->pp_Data->ad_FrameData.afd_AnimFrames;
Expand Down
219 changes: 112 additions & 107 deletions workbench/classes/datatypes/animation/animationclass.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2015-2016, The AROS Development Team. All rights reserved.
Copyright © 2015-2020, The AROS Development Team. All rights reserved.
$Id$
*/

Expand Down Expand Up @@ -576,150 +576,155 @@ IPTR DT_RemapFrame(struct IClass *cl, struct Gadget *g, struct privRenderFrame *

D(bug("[animation.datatype]: %s()\n", __func__);)

// remap the frame bitmap ..
if (msg->Target && ((tmpline = AllocVec(animd->ad_BitMapHeader.bmh_Width, MEMF_ANY)) != NULL))
if (msg->Frame)
{
buffdepth = (UBYTE)GetBitMapAttr(msg->Target, BMA_DEPTH);
srcdepth = (UBYTE)GetBitMapAttr(msg->Frame->af_Frame.alf_BitMap, BMA_DEPTH);

if (((animd->ad_ModeID & HAM_KEY) && (srcdepth <= 8)) || (buffdepth > 8))
// remap the frame bitmap ..
if (msg->Target && ((tmpline = AllocVec(animd->ad_BitMapHeader.bmh_Width, MEMF_ANY)) != NULL))
{
D(
if (animd->ad_ModeID & HAM_KEY)
bug("[animation.datatype] %s: remapping HAM%d\n", __func__, srcdepth);
else
bug("[animation.datatype] %s: remapping to %dbit\n", __func__, buffdepth);
)
outline = AllocVec((animd->ad_BitMapHeader.bmh_Width << 2), MEMF_ANY);
}
else
outline = tmpline;
buffdepth = (UBYTE)GetBitMapAttr(msg->Target, BMA_DEPTH);
srcdepth = (UBYTE)GetBitMapAttr(msg->Frame->af_Frame.alf_BitMap, BMA_DEPTH);

if ((remapRP = CreateRastPort()) != NULL)
{
if ((targetRP = CreateRastPort()) != NULL)
if (((animd->ad_ModeID & HAM_KEY) && (srcdepth <= 8)) || (buffdepth > 8))
{
remapRP->BitMap = msg->Frame->af_Frame.alf_BitMap;
targetRP->BitMap = msg->Target;
D(
if (animd->ad_ModeID & HAM_KEY)
bug("[animation.datatype] %s: remapping HAM%d\n", __func__, srcdepth);
else
bug("[animation.datatype] %s: remapping to %dbit\n", __func__, buffdepth);
)
outline = AllocVec((animd->ad_BitMapHeader.bmh_Width << 2), MEMF_ANY);
}
else
outline = tmpline;

for(i = 0; i < animd->ad_BitMapHeader.bmh_Height; i++)
if ((remapRP = CreateRastPort()) != NULL)
{
if ((targetRP = CreateRastPort()) != NULL)
{
if ((animd->ad_ModeID & HAM_KEY) && (srcdepth <= 8))
{
UBYTE hamr = 0, hamg = 0, hamb = 0;
remapRP->BitMap = msg->Frame->af_Frame.alf_BitMap;
targetRP->BitMap = msg->Target;

for(x = 0; x < animd->ad_BitMapHeader.bmh_Width; x++)
for(i = 0; i < animd->ad_BitMapHeader.bmh_Height; i++)
{
if ((animd->ad_ModeID & HAM_KEY) && (srcdepth <= 8))
{
BOOL compose = TRUE;
ULONG mask = 1 << (7 - (x & 7));
UBYTE p;
UBYTE hamr = 0, hamg = 0, hamb = 0;

tmpline[x] = 0;
for (p = 0; p < srcdepth; p++)
for(x = 0; x < animd->ad_BitMapHeader.bmh_Width; x++)
{
UBYTE *planedata = (UBYTE *)msg->Frame->af_Frame.alf_BitMap->Planes[p];
ULONG offset = (i * animd->ad_BitMapHeader.bmh_Width) + x;
BOOL compose = TRUE;
ULONG mask = 1 << (7 - (x & 7));
UBYTE p;

if ((planedata) && (planedata[offset / 8 ] & mask))
tmpline[x] |= (1 << p);
}
tmpline[x] = 0;
for (p = 0; p < srcdepth; p++)
{
UBYTE *planedata = (UBYTE *)msg->Frame->af_Frame.alf_BitMap->Planes[p];
ULONG offset = (i * animd->ad_BitMapHeader.bmh_Width) + x;

curpen = tmpline[x];
if (HAMFlag(srcdepth, curpen) == 0)
{
curpen = HAMComponent(srcdepth, curpen);
if (buffdepth <= 8)
if ((planedata) && (planedata[offset / 8 ] & mask))
tmpline[x] |= (1 << p);
}

curpen = tmpline[x];
if (HAMFlag(srcdepth, curpen) == 0)
{
compose = FALSE;
outline[x] = animd->ad_ColorData.acd_ColorTable[1][curpen];
curpen = HAMComponent(srcdepth, curpen);
if (buffdepth <= 8)
{
compose = FALSE;
outline[x] = animd->ad_ColorData.acd_ColorTable[1][curpen];
}
hamr = (animd->ad_ColorData.acd_GRegs[curpen * 3] & 0xFF);
hamg = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 1] & 0xFF);
hamb = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 2] & 0xFF);
}
else if (HAMFlag(srcdepth, curpen) == 1)
{
//modify blue..
hamb = HAMColor(srcdepth, curpen, hamb);
}
else if (HAMFlag(srcdepth, curpen) == 2)
{
// modify red
hamr = HAMColor(srcdepth, curpen, hamr);
}
else if (HAMFlag(srcdepth, curpen) == 3)
{
//modify green
hamg = HAMColor(srcdepth, curpen, hamg);
}

if (compose)
{
if (buffdepth <= 8)
{
// TODO: Map pixel color
outline[x] = 0;
}
else
{
outline[x * 4] = 0;
outline[x * 4 + 1] = hamr;
outline[x * 4 + 2] = hamg;
outline[x * 4 + 3] = hamb;
}
}
hamr = (animd->ad_ColorData.acd_GRegs[curpen * 3] & 0xFF);
hamg = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 1] & 0xFF);
hamb = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 2] & 0xFF);
}
else if (HAMFlag(srcdepth, curpen) == 1)
{
//modify blue..
hamb = HAMColor(srcdepth, curpen, hamb);
}
else if (HAMFlag(srcdepth, curpen) == 2)
if (buffdepth <= 8)
{
// modify red
hamr = HAMColor(srcdepth, curpen, hamr);
bug("[animation.datatype] %s: HAM->CM WritePixelLine8(0x%p)\n", __func__, outline);
WritePixelLine8(targetRP,0,i,animd->ad_BitMapHeader.bmh_Width,outline,NULL);
}
else if (HAMFlag(srcdepth, curpen) == 3)
else
{
//modify green
hamg = HAMColor(srcdepth, curpen, hamg);
bug("[animation.datatype] %s: HAM->TC WritePixelArray(0x%p, RECTFMT_ARGB)\n", __func__, outline);
WritePixelArray(outline, 0, 0, animd->ad_BitMapHeader.bmh_Width, targetRP, 0, i, animd->ad_BitMapHeader.bmh_Width, 1, RECTFMT_ARGB);
}
}
else
{
ReadPixelLine8(remapRP,0,i,animd->ad_BitMapHeader.bmh_Width,tmpline,NULL);

if (compose)
for(x = 0; x < animd->ad_BitMapHeader.bmh_Width; x++)
{
curpen = tmpline[x];
if (buffdepth <= 8)
{
// TODO: Map pixel color
outline[x] = 0;
}
outline[x] = animd->ad_ColorData.acd_ColorTable[1][curpen];
else
{
outline[x * 4] = 0;
outline[x * 4 + 1] = hamr;
outline[x * 4 + 2] = hamg;
outline[x * 4 + 3] = hamb;
outline[x * 4 + 1] = (animd->ad_ColorData.acd_GRegs[curpen * 3] & 0xFF);
outline[x * 4 + 2] = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 1] & 0xFF);
outline[x * 4 + 3] = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 2] & 0xFF);
}
}
}
if (buffdepth <= 8)
{
D(bug("[animation.datatype] %s: HAM->CM WritePixelLine8(0x%p)\n", __func__, outline);)
WritePixelLine8(targetRP,0,i,animd->ad_BitMapHeader.bmh_Width,outline,NULL);
}
else
{
D(bug("[animation.datatype] %s: HAM->TC WritePixelArray(0x%p, RECTFMT_ARGB)\n", __func__, outline);)
WritePixelArray(outline, 0, 0, animd->ad_BitMapHeader.bmh_Width, targetRP, 0, i, animd->ad_BitMapHeader.bmh_Width, 1, RECTFMT_ARGB);
}
}
else
{
ReadPixelLine8(remapRP,0,i,animd->ad_BitMapHeader.bmh_Width,tmpline,NULL);

for(x = 0; x < animd->ad_BitMapHeader.bmh_Width; x++)
{
curpen = tmpline[x];
if (buffdepth <= 8)
outline[x] = animd->ad_ColorData.acd_ColorTable[1][curpen];
{
bug("[animation.datatype] %s: ->CM WritePixelLine8(0x%p)\n", __func__, outline);
WritePixelLine8(targetRP,0,i,animd->ad_BitMapHeader.bmh_Width,outline,NULL);
}
else
{
outline[x * 4] = 0;
outline[x * 4 + 1] = (animd->ad_ColorData.acd_GRegs[curpen * 3] & 0xFF);
outline[x * 4 + 2] = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 1] & 0xFF);
outline[x * 4 + 3] = (animd->ad_ColorData.acd_GRegs[curpen * 3 + 2] & 0xFF);
bug("[animation.datatype] %s: ->TC WritePixelArray(0x%p, RECTFMT_ARGB)\n", __func__, outline);
WritePixelArray(outline, 0, 0, animd->ad_BitMapHeader.bmh_Width, targetRP, 0, i, animd->ad_BitMapHeader.bmh_Width, 1, RECTFMT_ARGB);
}
}

if (buffdepth <= 8)
{
D(bug("[animation.datatype] %s: ->CM WritePixelLine8(0x%p)\n", __func__, outline);)
WritePixelLine8(targetRP,0,i,animd->ad_BitMapHeader.bmh_Width,outline,NULL);
}
else
{
D(bug("[animation.datatype] %s: ->TC WritePixelArray(0x%p, RECTFMT_ARGB)\n", __func__, outline);)
WritePixelArray(outline, 0, 0, animd->ad_BitMapHeader.bmh_Width, targetRP, 0, i, animd->ad_BitMapHeader.bmh_Width, 1, RECTFMT_ARGB);
}
}
targetRP->BitMap = NULL;
FreeRastPort(targetRP);
}
targetRP->BitMap = NULL;
FreeRastPort(targetRP);
remapRP->BitMap = NULL;
FreeRastPort(remapRP);
}
remapRP->BitMap = NULL;
FreeRastPort(remapRP);

if (outline != tmpline)
FreeVec(outline);
FreeVec(tmpline);
}

if (outline != tmpline)
FreeVec(outline);
FreeVec(tmpline);
msg->Frame->af_Flags = AFFLAGF_READY;
}

return 1;
Expand Down
6 changes: 5 additions & 1 deletion workbench/classes/datatypes/animation/animationclass.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2015-2016, The AROS Development Team. All rights reserved.
Copyright © 2015-2020, The AROS Development Team. All rights reserved.
$Id$
*/

Expand Down Expand Up @@ -78,9 +78,13 @@ struct AnimFrame
{
struct Node af_Node;
#define af_CacheBM af_Node.ln_Name
ULONG af_Flags;
struct adtNewFormatFrame af_Frame;
};

#define AFFLAGB_READY 0
#define AFFLAGF_READY (1 << 0)

/* for sanity, we embed the frame number in the ln_type/ln_pri fields */
static inline UWORD GetNODEID(struct AnimFrame *node) {
UWORD *id_ptr = (UWORD *)&node->af_Node.ln_Type;
Expand Down
3 changes: 2 additions & 1 deletion workbench/classes/datatypes/animation/animationframe.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2016, The AROS Development Team. All rights reserved.
Copyright © 2016-2020, The AROS Development Team. All rights reserved.
$Id$
*/

Expand Down Expand Up @@ -41,6 +41,7 @@ void cacheFrame(struct Animation_Data *animd, struct AnimFrame *frame)
frame->af_CacheBM = (char *)AllocBitMap(animd->ad_BitMapHeader.bmh_Width, animd->ad_BitMapHeader.bmh_Height, 24,
BMF_CLEAR, animd->ad_CacheBM);
rendFrameMsg.Target = (struct BitMap *)frame->af_CacheBM;
frame->af_Flags = 0;
DFRAMES("[animation.datatype/CACHE]: %s: allocated frame cache bm @ 0x%p (friend @ 0x%p)\n", __func__, frame->af_CacheBM, animd->ad_CacheBM)
}
DoMethodA(animd->ad_ProcessData->pp_Object, (Msg)&rendFrameMsg);
Expand Down
Loading

0 comments on commit 9f206e3

Please sign in to comment.