Slow Drawing in windows vista

4 views
Skip to first unread message

Nilesh

unread,
Feb 19, 2007, 10:46:35 PM2/19/07
to
will anybody tell me, why drawing is slow in windows vista as
compared
to windows XP..... ( may be i am wrong )
i m running an application of moving a rectangle,.......
i am drawing rectangle in WM_PAINT handler.........
i observed that rectangle drawing is slow in windows vista.........
also i want to know does the behaviour of WM_PAINT is same or changed
in vista.

i will be thankfull if anybody clarifies where i m wrong....or is
this the problem with vista....

Jon Potter

unread,
Feb 20, 2007, 1:54:35 AM2/20/07
to
You're not drawing to the screen DC are you? (eg, HDC hdc=GetDC(0))? This
will be very slow under Vista with the DWM enabled as the screen DC no
longer "exists" as such but must be emulated whenever a program writes to it
directly.

"Nilesh" <nileshk...@gmail.com> wrote in message
news:1171943195....@v33g2000cwv.googlegroups.com...

Nilesh

unread,
Feb 20, 2007, 4:35:15 AM2/20/07
to
On Feb 20, 11:54 am, "Jon Potter" <gps...@nospam.nospam> wrote:
> You're not drawing to the screen DC are you? (eg, HDC hdc=GetDC(0))? This
> will be very slow under Vista with the DWM enabled as the screen DC no
> longer "exists" as such but must be emulated whenever a program writes to it
> directly.
> hi Jon, thnx for ur rply, as u said , I m using DC for drawing...............
u said it will be slower but can u please give some more explanation
on this....so that i will understand better...
thnx.....waiting for ur rply....

> "Nilesh" <nileshkontam...@gmail.com> wrote in message


>
> news:1171943195....@v33g2000cwv.googlegroups.com...
>
>
>
> > will anybody tell me, why drawing is slow in windows vista as
> > compared
> > to windows XP..... ( may be i am wrong )
> > i m running an application of moving a rectangle,.......
> > i am drawing rectangle in WM_PAINT handler.........
> > i observed that rectangle drawing is slow in windows vista.........
> > also i want to know does the behaviour of WM_PAINT is same or changed
> > in vista.
>
> > i will be thankfull if anybody clarifies where i m wrong....or is

> > this the problem with vista....- Hide quoted text -
>
> - Show quoted text -


Jon Potter

unread,
Feb 20, 2007, 4:47:00 AM2/20/07
to
Slower - ie, not as fast :)

Are you drawing to the screen DC or not?

"Nilesh" <nileshk...@gmail.com> wrote in message

news:1171964115....@s48g2000cws.googlegroups.com...

Nilesh

unread,
Feb 20, 2007, 5:57:38 AM2/20/07
to
On Feb 20, 2:47 pm, "Jon Potter" <gps...@nospam.nospam> wrote:
> Slower - ie, not as fast :)
>
> Are you drawing to the screen DC or not?
>
> "Nilesh" <nileshkontam...@gmail.com> wrote in message
>
> news:1171964115....@s48g2000cws.googlegroups.com...
>
> No, i m not using screen device.........
but even then please answer, i.e. if i will use screen DC how can i
overcome this problem...

>
> > On Feb 20, 11:54 am, "Jon Potter" <gps...@nospam.nospam> wrote:
> >> You're not drawing to the screen DC are you? (eg, HDC hdc=GetDC(0))? This
> >> will be very slow under Vista with the DWM enabled as the screen DC no
> >> longer "exists" as such but must be emulated whenever a program writes to
> >> it
> >> directly.
> >> hi Jon, thnx for ur rply, as u said , I m using DC for
> >> drawing...............
> > u said it will be slower but can u please give some more explanation
> > on this....so that i will understand better...
> > thnx.....waiting for ur rply....
>
> >> "Nilesh" <nileshkontam...@gmail.com> wrote in message
>
> >>news:1171943195....@v33g2000cwv.googlegroups.com...
>
> >> > will anybody tell me, why drawing is slow in windows vista as
> >> > compared
> >> > to windows XP..... ( may be i am wrong )
> >> > i m running an application of moving a rectangle,.......
> >> > i am drawing rectangle in WM_PAINT handler.........
> >> > i observed that rectangle drawing is slow in windows vista.........
> >> > also i want to know does the behaviour of WM_PAINT is same or changed
> >> > in vista.
>
> >> > i will be thankfull if anybody clarifies where i m wrong....or is
> >> > this the problem with vista....- Hide quoted text -
>
> >> - Show quoted text -- Hide quoted text -

Ivan Brugiolo [MSFT]

unread,
Feb 20, 2007, 12:03:54 PM2/20/07
to
Let's analize the problems top-down:

Which kind of display-dirver model do you have ?
-a- XPDM
There should be no difference between Vista and WinXp

-b- WDDM
Do you have desktop composition ON of OFF?

-b.1- Desktop Composition OFF.
What happens is:
The GDI drawing is done in software by Eng.
The drawing is done on the primary, that is a system-memory surface.
Every 50ms or so, the clip region of the drawing accumulated on the primary
is flushed towards the video-memory. Reading back from the screen
will read back from the system-memory surface, unless
you have mixed DirectX/DirectDraw/DirectVideoAcceleration content.
In the second case, a region syncronization process happens, and,
you may end-up reading from video-to-system, and writing from
system-to-video.

-b.2- Desktop Composition ON.
The GDI drawing is done in software by Eng.
The GDI drawing happens of a redirection surface.
At selected syncronization points, the Compositor (living in DWM.exe)
will pick-up the redirection surfaces, render the scene,
and present the scene to the screen.

The b.2 case is somewhat tricky with regard of applications that
attempts to misuse HDCs.
Example: Pre-Vista, the window-DC and the screen-DC were the same
(excluding some multi-mon scenarios). In Vista, the Window-DC is
a redirection DC, and the Screen DC is a separate beast.

There are applications that do things like
WNDCLASSEDX wc;
wc.style = CS_OWNDC;
RegisterClass(&wc);
hWnd = CreateWindow(L"ClassWithOwnDC");
m_CachedHDC = GetDC(hWnd); //<<------- 1
DestroyDC(m_CachedHDC); //<<------- 2
BitBlt(m_CachedHDC,0,0,10,10,hSrc,0,0,SRCOPY); //<<--- 3

Step -3- after -2- is clearly undefined behavior
(you should have called ReleaseDC instead of DestroyDC, and,
you should have re-acquired the DC), and, it has interesting
consequence when Desktop Composition is ON.

Given the background, can you please try to understand:
- which scenario you are in: a, b.1, b.2 ?
- which DC are you using ? Screen DC, Window DC ?
- are you using properly matched API to acquire and release a DC ?

The `slow` drawing, in the WindowDC case, could be a sign that
the compositor is not picking up the dirty-notification from NtGdi.

--
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Nilesh" <nileshk...@gmail.com> wrote in message

news:1171969058....@t69g2000cwt.googlegroups.com...

Reply all
Reply to author
Forward
0 new messages