AntiAlias and getDc

When I have something like:

myDc = myBuffer.getDc();
myDc.setAntiAlias(true);
myDc.fillPolygon(somePoints);

then antialiasing works as expected. But when I have:

myBuffer.getDc().setAntiAlias(true);
myBuffer.getDc().fillPolygon(somePoints);

AntiAliasing doesn't happen. But, when I pass myBuffer.getDc() as an argument to a function:

function myDraw(mydc as Dc) {
    mydc.setAntiAlias(true);
    mydc.drawPolygon(somePoints);
}

myDraw(myBuffer.getDc());

Then antialiasing is working again. Is this by design, or a "feature"? I'm trying to save some memory because it seems that in the first example myDc is a copy and not a reference, so it can be 40K+ for a full screen bitmap. Is it possible to have myDc as a reference and not a copy without having to wrap everything in a function?

  • it seems that in the first example myDc is a copy and not a reference

    looks like you already got an answer to your question Slight smile

    "setAntiAlias(true)" doesn't change some global state but only modifies a copy of the Dc object that can be used to actually draw some element.

    Simpler analogy in the programming world - passing a number as a value into a method. You may reassign this variable inside the method but its value will still remain unchanged outside the method

  • You'll also see it works differently on a CIQ 4 device with a GPU and the graphics pool.

  • I have a Fenix 7x so yes, it uses buffers from the graphics pool thus using the first method doesn't use a significant amount of memory. My other watch is a Forerunner 235 which is CIQ 1 so it doesn't have buffers, so again not an issue. I'm trying to test my watch face on CIQ 2 and 3 devices in the simulator so I'm having to work more on memory management now.

    I think I am being lead astray by the "Active Memory" dialog. It shows 119k used, but when I use the first method is shows 117k of data being used along with 39k of code. That math doesn't work. As I experiment I see that while the first method looks like a copy it shows the same amount of memory used as the third method, but it shows 69k of data used (the bitmap is 48k). So, the first method is apparently a reference for CIQ 2 and 3 bitmaps. It's harder to tell with CIQ 4, but if the others are references then it would make sense the the latest one is too.