Acknowledged

dc.clear() documentation is not clear on what should happen if the background is COLOR_TRANSPARENT and there's only 1 layer

The dc.clear() doc says:

Erase the screen using the background color.

Note:

Starting form version 3.1.0, COLOR_TRANSPARENT will also be honored as background color, which will cause the value of pixels in the clip region to be replaced by COLOR_TRANSPARENT. For example, this can be used to clear the transparent overlay layer so animation background is visible.

(note the small typo: "Starting form")

What's supposed to happen if there's only 1 layer, the background colour is COLOR_TRANSPARENT, and dc.clear() is called?

Should the screen be cleared as the doc seemingly suggests? Or should nothing happen (which is what the behaviour of the simulator suggests)? (Testing on a real fr955 is inconclusive as it seems to automatically clear the dc anyway -- see below).

Yes, it could be argued that setting pixels to transparent means nothing if there's only one layer.

However, one could argue that:

- in the case of a data field, the data field background colour should be used if a dc pixel's colour is transparent

- in the case of a device app, an arbitrary colour could be used (the same colour that would be used if the app does not draw or clear anything, such as black)

One could also argue that the docs should make it clear under what situations "[causing] the value of pixels in the clip region to be replaced by COLOR_TRANSPARENT" is actually meaningful. I think that the word "replaced" is key, as it seems to imply that the existing pixels will be erased in all situations.

I am unable to test this exhaustively with my real fr955 device as:

- for a data field, both the sim and the real fr955 apparently clear the dc before calling onUpdate()

- for a device app, the real fr955 clears the dc before calling onUpdate(), while the sim does not

However, the behaviour of a simulated fr955, for a device app, is that calling dc.clear() with a transparent background color has no effect.

More context:

https://forums.garmin.com/developer/connect-iq/f/discussion/405718/screen-not-properly-redraw/1908585#1908585

Here's how I tested:

1) created device app using new project.

2) removed layout-related code

3) remove call to View.onUpdate()

4) Set up recurring timer that calls WatchUi.requestUpdate() once per second

5) clear screen once in setLayout() using background colour of black

6) in onUpdate():

6a) set foreground color to white, set background to transparent

6b) call dc.clear()

6c) increment integer counter (1, 2, 3, ...)

6d) use dc.drawText() to draw counter on the screen

Results:

- for complex data field (similar to device app, except obviously without a timer or requestUpdate()) - no layout, and View.onUpdate() is not called

  - inconclusive: dc is cleared whether or not dc.clear() is called, on both real and simulated fr955

- for device app as described above:
  - real fr955: inconclusive - dc is cleared whether or not dc.clear() is called.

  - simulated fr955: screen is not cleared if dc.clear() is not called. if dc.clear() is called with black background, screen is cleared. if dc.clear() is called with transparent background (as described above), screen is not cleared, and the text from previous updates remains on the screen while subsequent updates are rendered

  • To be clear, if the following statement is true...

    "it could be argued that setting pixels to transparent means nothing if there's only one layer."

    ...it would be nice if the doc for dc.clear() would clarify that.