Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. InvalidateRect() Efficiency

InvalidateRect() Efficiency

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cliff Hatch
    wrote on last edited by
    #1

    Hi I'm working on an application that displays a lot of trend graphs and associated numerical values. These are updated on a regular scan in the OnIdle() function, with the processor running at full load. I started off using InvalidateRect() on the trends and the values individually to minimise the area of each View that was redrawn on each scan, but the code got a bit complicated, so I changed it to group them together. The total area redrawn is now much larger, but the number of InvalidateRect() calls has halved. I expected that the program would run a little slower but to my surprise there is no noticable difference. This gives me the impression that there is a considerable overhead associated with each InvalidateRect() call, and that if you get too fussy about drawing only those regions that have changed you rapidly run into dimishing returns. Does anyone know if this is a correct interpretation? Thanks in advance for your help. Cliff Hatch -- modified at 7:32 Sunday 16th October, 2005

    J 1 Reply Last reply
    0
    • C Cliff Hatch

      Hi I'm working on an application that displays a lot of trend graphs and associated numerical values. These are updated on a regular scan in the OnIdle() function, with the processor running at full load. I started off using InvalidateRect() on the trends and the values individually to minimise the area of each View that was redrawn on each scan, but the code got a bit complicated, so I changed it to group them together. The total area redrawn is now much larger, but the number of InvalidateRect() calls has halved. I expected that the program would run a little slower but to my surprise there is no noticable difference. This gives me the impression that there is a considerable overhead associated with each InvalidateRect() call, and that if you get too fussy about drawing only those regions that have changed you rapidly run into dimishing returns. Does anyone know if this is a correct interpretation? Thanks in advance for your help. Cliff Hatch -- modified at 7:32 Sunday 16th October, 2005

      J Offline
      J Offline
      John R Shaw
      wrote on last edited by
      #2

      It sounds like a drawing problem not an InvalidateRect() problem. No matter what the size of the invalidated rectangular area is, if you are drawing the whole area instead of just drawing in the invalid area then the drawing speed will be uneffected. Example, if you where designing a bitmap editor and modify the bitmap by adding a 10x10 pixel square, then you just want to redraw that 10x10 area in OnPaint(). If you where to just blit the whole bitmap each time OnPaint() was called, then drawing a simple line (via click and drag) becomes a nightmare. The above also applies to text editors or any othe application that does a lot of drawing. INTP Every thing is relative...

      C 1 Reply Last reply
      0
      • J John R Shaw

        It sounds like a drawing problem not an InvalidateRect() problem. No matter what the size of the invalidated rectangular area is, if you are drawing the whole area instead of just drawing in the invalid area then the drawing speed will be uneffected. Example, if you where designing a bitmap editor and modify the bitmap by adding a 10x10 pixel square, then you just want to redraw that 10x10 area in OnPaint(). If you where to just blit the whole bitmap each time OnPaint() was called, then drawing a simple line (via click and drag) becomes a nightmare. The above also applies to text editors or any othe application that does a lot of drawing. INTP Every thing is relative...

        C Offline
        C Offline
        Cliff Hatch
        wrote on last edited by
        #3

        Thanks for you comments John

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups