كيف يتم الرسم مع Dawingcontext في عمل OnRender خلف المشهد؟

StackOverflow https://stackoverflow.com/questions/9519504

  •  14-11-2019
  •  | 
  •  

سؤال

أنا أرسم "صورة" معقدة إلى حد ما (والتي غالبا ما يجب تحديثها ولديها العديد من البدائيات الرسمية) في نافذة WPF من خلال تجاوز طريقة OnRender الخاصة ب Uielement منفصلة واستخدام DAGALCONTEXT لاجتياز البدائيات مباشرة.

سؤالي هو، ما يحدث بالضبط وراء الكواليس؟بقدر ما أفهم هذا لا يستخدم الوضع المحتجز (الذي سيكون الحال إذا كنت قد وضعت الأشكال في عنصر التحكم).أنا أسأل السؤال لأنني حريص أن الرسم مثل هذا سيستخدم بالفعل GDI + عند الظهر الذي يجلب مشكلاته الخاصة (على سبيل المثال، الاشياء الطباعة المرسومة مع GDI + قد كلفنا بالفعل الوقت والجهد).

هل هناك أي موارد جيدة (إلى جانب موارد MSDN واضحة التي لم تكن قادرا على تنويري؟

أو هل حصلت على كل شيء خاطئ تماما؟

شكرا لأي إجابات تشير إلي في الاتجاه الصحيح. [تحرير: الإملاء]

هل كانت مفيدة؟

المحلول

You are still using retained mode, you're just not using high level objects (no animating objects, etc..), but instead simple points, lines, etc..

I've dug into the sources of DrawingContext and from what I can tell, it seems to be pushing all those DrawXYZ commands into a queue using some low-level wizardry (the queue itself consists of arbitrarily sized structs, each denoting a certain command).

WPF then processes this queue on another thread, denoted the rendering thread in this question. I haven't verified this, but I'm guessing that WPF uses the StreamingContext for all its drawing.

Furthermore, WPF is using DirectX for rendering, as can be seen by this bogpost, which takes a better look at what WPF actually does.

I hope this clarifies things for you.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top