-
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
CoreText Performance: Call ID2D1RenderTarget::BeginDraw()/EndDraw() f… #1705
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
#import "UIGestureRecognizerInternal.h" | ||
#import "CALayerInternal.h" | ||
#import "CAAnimationInternal.h" | ||
#import "CGContextInternal.h" | ||
#import <AutoLayout.h> | ||
#import <NSLayoutConstraint+AutoLayout.h> | ||
#import "NSLayoutAnchorInternal.h" | ||
|
@@ -243,7 +244,7 @@ - (bool)_processGesturesForTouch:(UITouch*)touch event:(UIEvent*)event touchEven | |
// scanning DManip Gestures, if one gesture is ongoing, cancel all DManip Gestures | ||
// otherwise, send Touch to DManip gestures | ||
for (int i = 0; i < dManipGestureCount; i++) { | ||
UIGestureRecognizer* dManipGesture = dManipRecognizers[i]; | ||
UIGestureRecognizer* dManipGesture = dManipRecognizers[i]; | ||
if (gestureOnGoing) { | ||
[dManipGesture _cancelIfActive]; | ||
if (DEBUG_GESTURES) { | ||
|
@@ -527,9 +528,7 @@ - (UITouchPhase)_processPointerEvent:(WUXIPointerRoutedEventArgs*)pointerEventAr | |
if (!touchPoint.touch->_view) { | ||
// Ignore if the pointer isn't captured | ||
if (DEBUG_TOUCHES_LIGHT) { | ||
TraceVerbose(TAG, | ||
L"View for touch is nil!, ignoring touch for touchPhase %d.", | ||
touchPhase); | ||
TraceVerbose(TAG, L"View for touch is nil!, ignoring touch for touchPhase %d.", touchPhase); | ||
} | ||
} else if (touchPhase != UITouchPhaseBegan && ![touchPoint.touch->_view->priv->currentTouches containsObject:touchPoint.touch]) { | ||
// Ignore if the pointer isn't captured | ||
|
@@ -2252,12 +2251,16 @@ - (CGPoint)convertPoint:(CGPoint)pos fromView:(UIView*)fromView { | |
*/ | ||
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context { | ||
UIGraphicsPushContext(context); | ||
_CGContextPushBeginDraw(context); | ||
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. This should really go into CALayer display, which displays a layer for one frame. #Resolved 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. Also into UIGraphicsPushContext() and PopContext(). #Resolved 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. I had the same idea, but it ended up regressing XAMLCatalog (Custom text view would not update at all). In reply to: 96086902 [](ancestors = 96086902) 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. Contexts that go onto the UIGraphics context stack cannot actually be safely assumed to only need their results after PopContext(). In reply to: 96087015 [](ancestors = 96087015) 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. Fair enough. We should still do this in CALayer display. #Resolved 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. Er, that is, putting it into [CALayer display] broke things. I could go investigate why if you'd like, but I'm not sure how fruitful that'd be - we'd probably have to keep this out of CALayer display anyway. In reply to: 96095561 [](ancestors = 96095561) |
||
|
||
auto popEnd = wil::ScopeExit([context]() { | ||
_CGContextPopEndDraw(context); | ||
UIGraphicsPopContext(); | ||
}); | ||
|
||
CGRect bounds; | ||
bounds = CGContextGetClipBoundingBox(context); | ||
[self drawRect:bounds]; | ||
|
||
UIGraphicsPopContext(); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,11 @@ COREGRAPHICS_EXPORT bool CGContextIsPointInPath(CGContextRef c, bool eoFill, flo | |
|
||
COREGRAPHICS_EXPORT void CGContextDrawGlyphRun(CGContextRef ctx, const DWRITE_GLYPH_RUN* glyphRun); | ||
|
||
COREGRAPHICS_EXPORT void _CGContextPushBeginDraw(CGContextRef ctx); | ||
COREGRAPHICS_EXPORT void _CGContextPopEndDraw(CGContextRef ctx); | ||
COREGRAPHICS_EXPORT void _CGContextSafeInnerBeginDraw(CGContextRef ctx); | ||
COREGRAPHICS_EXPORT void _CGContextSafeInnerEndDraw(CGContextRef ctx); | ||
|
||
// TODO 1077:: Remove once D2D render target is implemented | ||
COREGRAPHICS_EXPORT void _CGContextSetScaleFactor(CGContextRef ctx, float scale); | ||
|
||
|
@@ -57,6 +62,9 @@ class __CGContext : private objc_object { | |
float scale; | ||
CGContextImpl* _backing; | ||
|
||
// Reduces the number of BeginDraw() and EndDraw() calls needed, by counting in a stack-like manner | ||
uint32_t _beginEndDrawDepth = 0; | ||
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. Should we have a mutex for updating this? #Resolved 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. |
||
|
||
__CGContext(CGImageRef pDest); | ||
~__CGContext(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -874,7 +874,7 @@ - (void)viewDidLoad { | |
textEdit.autoresizingMask = infoLabel.autoresizingMask = focusButton.autoresizingMask = | ||
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; | ||
|
||
infoLabel.text = @"Click the control to gain focus. Use the keyboard to type and caret nagivate. Hold shift to update the " | ||
infoLabel.text = @"Click the control to gain focus. Use the keyboard to type and caret navigate. Hold shift to update the " | ||
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. +1 #Closed |
||
@"selection. Right click or Ctrl+C or V to copy and paste."; | ||
infoLabel.numberOfLines = 0; | ||
infoLabel.textAlignment = NSTextAlignmentCenter; | ||
|
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.
Where are these two used, and what is their purpose? #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.
Not used in this commit, but are needed for CGD2D. it seemed vaguely more appropriate to add them now than to add them when merging to CGD2D, but i don't feel strongly about this.
As an example, CGD2D has __CGContext::DrawToCommandList - it switches render targets in the middle and switches back at the end. Retargeting is illegal if in the middle of a Begin/EndDraw pair, so we need an alternate mechanism to force an EndDraw so we can retarget, then BeginDraw again. (I made a mistake by putting the second command in the body of this function though, oops) According to @DHowett-MSFT, shadows and transparency layers also require a retarget.
In reply to: 96086173 [](ancestors = 96086173)