-
Notifications
You must be signed in to change notification settings - Fork 804
Fix some rendering issues that were causing #2095. #2117
Changes from all commits
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 |
|---|---|---|
|
|
@@ -427,14 +427,20 @@ - (void)renderInContext:(CGContextRef)ctx { | |
| [priv->delegate drawLayer:self inContext:ctx]; | ||
| } | ||
| } else { | ||
| CGRect rect; | ||
|
|
||
| rect.origin.x = 0; | ||
| rect.origin.y = priv->bounds.size.height * priv->contentsScale; | ||
| rect.size.width = priv->bounds.size.width * priv->contentsScale; | ||
| rect.size.height = -priv->bounds.size.height * priv->contentsScale; | ||
|
|
||
| _CGContextDrawImageRect(ctx, priv->contents, rect, destRect); | ||
| // If the layer has cached contents, blit them directly. | ||
|
|
||
| // Since the layer was rendered in Quartz referential (ULO) AND the current context | ||
| // is assumed to be Quartz referential (ULO), BUT the layer's cached contents | ||
| // were captured in a CGImage (CGImage referential, LLO), we have to flip | ||
| // the context again before we render it. | ||
|
|
||
| // |1 0 0| is the transformation matrix for flipping a rect anchored at 0,0 about its Y midpoint. | ||
| // |0 -1 0| | ||
| // |0 h 1| | ||
| CGContextSaveGState(ctx); | ||
| CGContextConcatCTM(ctx, CGAffineTransformMake(1, 0, 0, -1, 0, destRect.size.height)); | ||
|
Contributor
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.
mind adding a comment calling out why this this transform is needed so that other people without the context can understand the reasoning behind. Thx!
Author
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. @yiyang-msft done |
||
| CGContextDrawImage(ctx, destRect, priv->contents); | ||
| CGContextRestoreGState(ctx); | ||
| } | ||
|
|
||
| // Draw sublayers | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,8 +491,8 @@ - (void)drawAtPoint:(CGPoint)point blendMode:(CGBlendMode)mode alpha:(float)alph | |
|
|
||
| CGRect pos; | ||
| pos.origin = point; | ||
| pos.size.width = (img_height / _scale); | ||
| pos.size.height = (img_width / _scale); | ||
| pos.size.height = (img_height / _scale); | ||
| pos.size.width = (img_width / _scale); | ||
|
Author
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. @aballway might like this
Contributor
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.
Contributor
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: position is a very silly name for a rect 😝
Author
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: oh well :) |
||
|
|
||
| // |1 0 0| is the transformation matrix for flipping a rect about its Y midpoint m. (m = (y + h/2)) | ||
| // |0 -1 0| | ||
|
|
||
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.
is saving/popping g-state relatively free? we should be able to get away with just reverting the CTM if not.
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.
It's very cheap.