Page 1 of 1

Frame component issue in falagard

Posted: Mon Jun 08, 2009 11:47
by oiram
For example:

Code: Select all

            <FrameComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
                </Area>
                <Image type="LeftEdge" imageset="Slider" image="Left" />
                <Image type="RightEdge" imageset="Slider" image="Right" />
                <Image type="Background" imageset="Slider" image="Horz" />
                <VertFormat type="Stretched" />
                <HorzFormat type="Tiled" />
            </FrameComponent>


<HorzFormat type="Tiled" />
You could see, the horzFormatting is "Tiled".
In code "cegui-0.6.2\src\falagard\ceguifalframecomponent.cpp"

Code: Select all

void FrameComponent::render_impl(Window& srcWindow, Rect& destRect, float base_z, const CEGUI::ColourRect* modColours, const Rect* clipper, bool clipToDisplay) const
...
        // right image
        if (d_frameImages[FIC_RIGHT_EDGE])
        {
            // calculate final destination area
            imageSize = d_frameImages[FIC_RIGHT_EDGE]->getSize();
            finalRect.d_top    = destRect.d_top + rightOffset;
            finalRect.d_bottom = finalRect.d_top + rightHeight;
            finalRect.d_right  = destRect.d_right;
            finalRect.d_left   = finalRect.d_right - imageSize.d_width;
            finalRect = destRect.getIntersection (finalRect);

            // adjust background area to miss this edge
            backgroundRect.d_right -= imageSize.d_width - d_frameImages[FIC_RIGHT_EDGE]->getOffsetX();
...


backgroundRect.d_right -= imageSize.d_width - d_frameImages[FIC_RIGHT_EDGE]->getOffsetX();
backgroundRect.d_right should be negative when imageSize.d_width is bigger then itself.
It's go into more code.

Code: Select all

void FrameComponent::doBackgroundRender(Window& srcWindow, Rect& destRect, float base_z, const ColourRect& colours, const Rect* clipper, bool clipToDisplay) const
...
        // calculate initial x co-ordinate and horizontal tile count according to formatting options
        switch (horzFormatting)
        {
...
            case HF_TILED:
                xpos = destRect.d_left;
                horzTiles = (uint)((destRect.getWidth() + (imgSz.d_width - 1)) / imgSz.d_width);
                break;


horzTiles = (uint)((destRect.getWidth() + (imgSz.d_width - 1)) / imgSz.d_width);
Attention!!! destRect.getWidth() return negative here. For this expression, horzTiles will be a huge number which should make bad allocation blow code.
I think it is a bug and here is my solution:

Code: Select all

            case HF_TILED:
                xpos = destRect.d_left;
            if (destRect.getWidth() > 0)
               horzTiles = (uint)((destRect.getWidth() + (imgSz.d_width - 1)) / imgSz.d_width);
            else
               horzTiles = 1;
                break;

Code: Select all

            case VF_TILED:
                ypos = destRect.d_top;
            if (destRect.getHeight() > 0)
               vertTiles = (uint)((destRect.getHeight() + (imgSz.d_height - 1)) / imgSz.d_height);
            else
               vertTiles = 1;
                break;


What's your suggestion? :P

Re: Frame component issue in falagard

Posted: Tue Jun 09, 2009 00:15
by earthsruler
You title "Frame Component Issue in Falagard" gives me nothing, and then you don't even state in plain text what the issue is, you just paste XML and code.

oiram wrote:Attention!!!
?

oiram wrote:"make bad allocation blow code."
?

i'm going to need some better information, like what are you trying to do? What is happening? What should be happening?