Agenda
Metro SDK APIWinRT API•    New APIs•    Operation that can block implemented as asynchronous operationWin32 API•    Subset...
Identifying Non Metro SDK API usageDocumentation•   http://msdn.microsoft.com/library/windows/apps/br211369Preprocessor de...
Get the desktop app ready for PortingBuild with VS 11•   Compile, test on Windows 8 desktopDesktop API usage•   Use altern...
Asynchronous operationsWinRT APIs are asynchronous•   Refactor existing code to consume asynchronous operations•   DO refa...
Isolate core logicSeparate platform specific code into abstractions•   Refactor direct call to APIs to call an abstraction...
UIUser and GDI based UI•   RewriteDirectX UI•   Available in Metro•   Use DirectX template as starting point•   Template s...
MFCMFC not available under Metro•   RewriteOptions in Metro•  UI  • XAML  • DirectX• Form based App  • Consider XAML datab...
CRTSubset available in Metro•   APIs for concepts not available in Metro not available in CRTAPIs available in Metro but n...
CRTAPIs not in Metro•   Multi-byte functions: mb* and _ismb*•   Process control: exec* and spawn functions•   Threading: b...
ATLSubset available in MetroAPIs available in metro•   DLL server•   COM objects (without IDispatch)•   CStringW•   ATL co...
Static LibsConsumption of WinRT in static libs•   C++/CX – supported•   WRL – supportedAuthoring WinRT component in static...
Using existing code in Metro(or do I need to convert all my code to WinRT components)C++ Metro Apps can use existing stati...
Convert types to WinRT typesDO change variable to WinRT type if•    It frequently crosses boundary AND•    Costly to conve...
Strategies to create WinRTcomponentChoose technology•   C++/CX, WRL, Your own implementationWrapper•   Define interface an...
Converting COM components toWinRT technologyChoose the•   C++/CX, WRL, Your own implementation•   Component already writte...
Technologies to use during portingLanguage and Libraries•   CRT and STL for utility functions and classes•   C++/CX and/or...
ConclusionMetro SDK•   Work involved to move but not all throw away•   Lot of the business logic, core application logic i...
Porting tometro
Porting tometro
Porting tometro
Porting tometro
Porting tometro
Porting tometro
Porting tometro
Porting tometro
Upcoming SlideShare
Loading in …5
×

Porting tometro

301 views
218 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
301
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Mentions these are not in order of importance. Hint of Windows on ARM, but don’t add it as a bullet.
  • Porting tometro

    1. 1. Agenda
    2. 2. Metro SDK APIWinRT API• New APIs• Operation that can block implemented as asynchronous operationWin32 API• Subset of Win32 API available in Metro• Similar Win32 API may be part of Metro SDK • InitializeCriticalSectionAndSpinCount -> InitializeCriticalSectionExCOM Components• Some OS components available under Metro
    3. 3. Identifying Non Metro SDK API usageDocumentation• http://msdn.microsoft.com/library/windows/apps/br211369Preprocessor define• WINAPI_FAMILY=WINAPI_PARTITION_APP• Add the define to C++ preprocessor settings in Projects settings• Compiler stops after 100 errors so may not get full list API not available in Metro SDKWindows App Certification Kit tool• Create an Appx package with app binaries• Run resulting package through tool• <Program Files>Windows Kits8.0App Certification Kitappcert.exe
    4. 4. Get the desktop app ready for PortingBuild with VS 11• Compile, test on Windows 8 desktopDesktop API usage• Use alternate Win32 APIs available in Metro SDK• Wrap API usage in abstractions
    5. 5. Asynchronous operationsWinRT APIs are asynchronous• Refactor existing code to consume asynchronous operations• DO refactor code to deal with partial data• DO keep UI responsive while asynchronous operations are in progressConvert long running operations to asynchronous• Schedule long running work on thread pool• DO return partial results as and when available• Options • Rewrite existing code • Write a wrapper that invokes existing code on a thread pool thread
    6. 6. Isolate core logicSeparate platform specific code into abstractions• Refactor direct call to APIs to call an abstraction over the API• Use existing abstraction in libraries if availableUse Standard C++ libraries for core logic• Refactor core logic to operate on buffers, containers, etc
    7. 7. UIUser and GDI based UI• RewriteDirectX UI• Available in Metro• Use DirectX template as starting point• Template sets up the start up code required for MetroOptions for UI in Metro• XAML• DirectX
    8. 8. MFCMFC not available under Metro• RewriteOptions in Metro• UI • XAML • DirectX• Form based App • Consider XAML databinding• Utility classes • Consider STL, CRT
    9. 9. CRTSubset available in Metro• APIs for concepts not available in Metro not available in CRTAPIs available in Metro but not recommended• File api• ANSI char functions
    10. 10. CRTAPIs not in Metro• Multi-byte functions: mb* and _ismb*• Process control: exec* and spawn functions• Threading: beginthread* and endthread*• Heap and stack functions: heapwalk, heapmin, resetstkoflw(), …• Environment variable functions and globals putenv, getenv, _enviorn, …• Console function, cprintf, cscanf, …• Port functions, outp, inp, …• Pipe functions: pipe, popen, pclose, …
    11. 11. ATLSubset available in MetroAPIs available in metro• DLL server• COM objects (without IDispatch)• CStringW• ATL container classes• CCriticalSection, CEvent, CMutex, CSemaphore, CMutexLock• CComVariant• CComSafeArray• CComBSTR
    12. 12. Static LibsConsumption of WinRT in static libs• C++/CX – supported• WRL – supportedAuthoring WinRT component in static libs• C++/CX – not supported• WRL – partially supported • Have to take explicit steps to make sure that component is part of the final binary • WrlCreatorMapIncludePragma used to make sure that specific class is pulled in from static lib
    13. 13. Using existing code in Metro(or do I need to convert all my code to WinRT components)C++ Metro Apps can use existing static libs, DLLsand COM components• DO make sure that the existing code is ported to use Metro SDK APIs• Link to static libs or import library as usual• Include binary components in APPX package, DLLs are app localUsing COM components• Use Reg-Free COM for activation• Activation through new API - CoCreateInstanceFromAppx
    14. 14. Convert types to WinRT typesDO change variable to WinRT type if• It frequently crosses boundary AND• Costly to convert between the two types• String and Array as input parameters to WinRT API can be efficiently converted without copying • StringRef, ArrayRef add a WinRT veneer using “borrow” semanticsContainer and Collections• Requires copy to go from std::* to Platform::*• std::* efficient compared to Platform::*• Use std::* or Platform::* based on how often collection contents change vs how often they cross WinRT boundary
    15. 15. Strategies to create WinRTcomponentChoose technology• C++/CX, WRL, Your own implementationWrapper• Define interface and in the implementation delegate to existing C++ code after any type conversions• Creates a WINRT veneer over your existing codeCovert existing code• Rewrite code to use WinRT types and concepts• Have good reasons to go this route
    16. 16. Converting COM components toWinRT technologyChoose the• C++/CX, WRL, Your own implementation• Component already written using ATL, may be easier to move to WRLSteps• Create WinRT interfaces corresponding to the previous interfaces• Port to one of the above technologies• Generate WinMD (if using IDL, modify MDIL flags)• Ship DLL and WinMD for others to consume the component
    17. 17. Technologies to use during portingLanguage and Libraries• CRT and STL for utility functions and classes• C++/CX and/or WRL to interact with WinRT• See other talks for details about C++/CX and WRLUI• XAML• DirectX
    18. 18. ConclusionMetro SDK• Work involved to move but not all throw away• Lot of the business logic, core application logic is portableUI• DirectX – easy• Win32 – rewrite in C++ using Modern UI frameworkC++• Two way to interact with WinRT C++/CX, WRL• Use familiar C++ concepts and types for parts that don’t directly interact with platfromBuild, test, validate often• Use Release configuration

    ×