Global Mapper Pro

First Draw Speed Issues

jlefevre
jlefevre Global Mapper User
edited August 2010 in SDK
I'm having some issues getting the performance that I would expect using the GM_DrawLayerList function. I'm loading a shp file thats 7mb then drawing it to an in memory bitmap before outputting it to screen. The sample app (GMDLL_Tester) draws this image in under a second. My application however on the first draw takes about 22 seconds. All draws after that complete instantly but the first one for some reason takes way too long. Both the first and all the other draws are using the same code. Here is the code I'm using. This is C++ Builder 2009.

long i1;
GM_DrawFlags_t32 aDrawFlags;

GM_LayerHandle_t32* LayerListToDraw = new GM_LayerHandle_t32[(long)LayerHandleVector.size()];
for(i1 = 0; i1 < (long)LayerHandleVector.size(); ++i1)
LayerListToDraw[i1] = LayerHandleVector[i1];

// Draw the Layer to An In Memory Bitmap
TCursor CurrentCursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
TargetBitmap->SetSize(MapWindow->Width, MapWindow->Height);
TargetBitmap->Canvas->Brush->Color = clWhite;
TargetBitmap->Canvas->Pen->Color = clWhite;
TargetBitmap->Canvas->Rectangle(0, 0, TargetBitmap->Width, TargetBitmap->Height);
aDrawFlags = NULL;

GM_DrawLayerList(TargetBitmap->Canvas->Handle, LayerListToDraw,
(uint32)LayerHandleVector.size(), aDrawFlags, &mCurViewRect, 0, 0, TargetBitmap->Width, TargetBitmap->Height);

Screen->Cursor = CurrentCursor;

delete [] LayerListToDraw;
}

Comments

  • global_mapper
    global_mapper Administrator
    edited August 2010
    Have you added timings to make sure that it is the actual call to GM_DrawLayerList that is taking so much time and not something else?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • jlefevre
    jlefevre Global Mapper User
    edited August 2010
    Yes I did add timings. Everything else executes instantly. Its very frustrating because I can't seem to figure out how the sample is any different then mine. Any possible ideas?
  • jlefevre
    jlefevre Global Mapper User
    edited August 2010
    If it's any help the normal "GM_DrawLayer" takes incredibly long the first draw as well.
  • global_mapper
    global_mapper Administrator
    edited August 2010
    Do the values in your view rectangle look good? Also what is the size of your canvas that you are passing in? What happens if you pass in NULL for the layer list and for the draw rectangle so that it just draws the entire thing? What format of data are you drawing?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • jlefevre
    jlefevre Global Mapper User
    edited August 2010
    The values in my view rectangle do look good. The size of the canvas I'm passing in is 541 x 564. If I pass NULL for the layer list, 0 for the number of layers, and NULL for the rectangle it still takes forever to draw. I'm trying to draw a .shp file. After the intial draw it draws quickly. It's only the first draw that is slow. I've tested this with other .shp files and they all have the same behavior. Is anything buffered when I do the first draw?
  • global_mapper
    global_mapper Administrator
    edited August 2010
    There isn't any buffering done that I can think of. Is it possible for you to provide me with the SHP file you are using so that I can take a look? You can email it to support@globalmapper.com.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • jlefevre
    jlefevre Global Mapper User
    edited August 2010
    I just sent it.
  • global_mapper
    global_mapper Administrator
    edited August 2010
    I have received your file, but haven't found anything out of the ordinary with it or been able to reproduce the slow draw.

    Are you calling GM_SetProjection to setup the projection to draw with or anything like that? Do you have any other data loaded? Are you running a release build of your application or a debug build?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • jlefevre
    jlefevre Global Mapper User
    edited August 2010
    I'm not calling anything before trying to draw it and I don't have any other data loaded. I'm running this in debug but I doubt that is the issue. When I load it and it asks me to "Select my Projection" is it possible that I'm choosing the wrong projection? Would this cause the first draw to be slow and the others to be fast?
  • global_mapper
    global_mapper Administrator
    edited August 2010
    That really shouldn't cause any issues, but what projection are you selecting for the data? The default should really work fine. Can you try it in Release mode just to be sure? Also, can you make sure that you aren't getting multiple entries into your OnPaint handler while you are debugging so the draw isn't being called multiple times?

    The sample application's OnPaint handler does this with a static bool value (isDrawing) to prevent nested calls.

    If none of this helps, my next thought would be for me to add some timings in the GM_DrawLayerList function so that we can see where the time is going for your first draw.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • jlefevre
    jlefevre Global Mapper User
    edited August 2010
    The projection doesn't seem to make any difference. I tried it in release mode and that didn't change anything. Also I'm not doing the drawing in the OnPaint handler. I'm just drawing to an in memory bitmap once right after I load the image. Putting timings in the GM_DrawLayerList function sounds like a great idea.
Sign In or Register to comment.