-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
D2DFactory Wrapper #1085
Merged
Merged
D2DFactory Wrapper #1085
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d6ab023
D2DFactory Wrapper
MSFTFox 1f994f0
Fix path for wrapper includes in project file.
MSFTFox a636741
Moving starboard to mm file.
MSFTFox 47c77e1
Address CR feedback, remove useless code, clean up D2D factories.
MSFTFox ffa1e18
Moving header file to private location
MSFTFox 5dc6402
Factory helper should only create single threaded D2D factories.
MSFTFox 3fecf51
Actually fix the wrapper header location.
MSFTFox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//****************************************************************************** | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// | ||
// This code is licensed under the MIT License (MIT). | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
//****************************************************************************** | ||
|
||
#import <CoreGraphics/D2DWrapper.h> | ||
#import <Starboard.h> | ||
|
||
using namespace Microsoft::WRL; | ||
|
||
// Private helper for creating a D2DFactory | ||
static ComPtr<ID2D1Factory> __CreateD2DFactoryInstance() { | ||
ComPtr<ID2D1Factory> d2dFactory; | ||
THROW_IF_FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, __uuidof(ID2D1Factory), &d2dFactory)); | ||
return d2dFactory; | ||
} | ||
|
||
// Helper for accessing a single static multithreaded D2DFactory instance | ||
ComPtr<ID2D1Factory> _GetD2DFactoryInstance() { | ||
static ComPtr<ID2D1Factory> s_d2dFactory = __CreateD2DFactoryInstance(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could be dispatch_once or lambda instead of having a helper method #Closed |
||
return s_d2dFactory; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//****************************************************************************** | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// | ||
// This code is licensed under the MIT License (MIT). | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
//****************************************************************************** | ||
|
||
#pragma once | ||
|
||
#include <COMIncludes.h> | ||
#import <wrl/client.h> | ||
#import <D2d1.h> | ||
#include <COMIncludes_End.h> | ||
|
||
Microsoft::WRL::ComPtr<ID2D1Factory> _GetD2DFactoryInstance(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be D2D1_FACTORY_TYPE_SINGLE_THREADED. We dont need any locking from D2D as all our drawing is on UI thread. Specifying multi threaded here is counter intuitive and will result in worse performance. Note: even if the factory is single threaded, when we have hardware offloading, D2D will parallelize the tasks on the GPU. https://msdn.microsoft.com/en-us/library/windows/desktop/dd368104(v=vs.85).aspx has all the details. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern here is that a CGPath, which can be manipulated from multiple threads, will be backed by a thread-bound ID2D1Geometry. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any code that needs the multi-threaded access should lock what it needs. making all D2D methods thread safe is not the way to do that. Note that singlethreaded factory doesnt mean the objects cant be used in multiple threads - it just means that the caller has to ensure thread safety.
In reply to: 82073552 [](ancestors = 82073552)