-
Notifications
You must be signed in to change notification settings - Fork 806
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
Implement drawing CGPaths through CGContext #1307
Changes from 1 commit
d43b075
5f79b50
5eab616
24f5707
34bd6d5
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
#import <CoreGraphics/CGGradient.h> | ||
#import "CGColorSpaceInternal.h" | ||
#import "CGContextInternal.h" | ||
#import "CGPathInternal.h" | ||
|
||
#import <CFCppBase.h> | ||
|
||
|
@@ -1646,7 +1647,8 @@ void CGContextFillRects(CGContextRef context, const CGRect* rects, size_t count) | |
*/ | ||
void CGContextDrawPath(CGContextRef context, CGPathDrawingMode mode) { | ||
NOISY_RETURN_IF_NULL(context); | ||
UNIMPLEMENTED(); | ||
|
||
__CGContextDrawGeometry(context, _getAndClosePathGeometry(context->Path()), mode); | ||
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.
Otherwise, 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.
We may need to invert the user transform on this draw, because otherwise we could apply a double-transformed path. #WontFix 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 made a note of this. We'll explore this more with the affine transform work item. In reply to: 86265029 [](ancestors = 86265029) |
||
context->ClearPath(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ | |
#import "LoggingNative.h" | ||
#import <CGGraphicBufferImage.h> | ||
|
||
#import "D2DWrapper.h" | ||
|
||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-register" | ||
|
||
|
@@ -155,8 +157,7 @@ | |
if (_renderTarget == nullptr) { | ||
BYTE* imageData = static_cast<BYTE*>(LockImageData()); | ||
ComPtr<IWICBitmap> wicBitmap = Make<CGIWICBitmap>(this, SurfaceFormat()); | ||
ComPtr<ID2D1Factory> d2dFactory; | ||
THROW_IF_FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory), &d2dFactory)); | ||
ComPtr<ID2D1Factory> d2dFactory = _GetD2DFactoryInstance(); | ||
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 might be going cross-module soon; perhaps it should be named _CGGetD2DFactory(), and have the signature
|
||
ComPtr<ID2D1RenderTarget> renderTarget; | ||
THROW_IF_FAILED(d2dFactory->CreateWicBitmapRenderTarget(wicBitmap.Get(), D2D1::RenderTargetProperties(), &renderTarget)); | ||
_renderTarget = renderTarget.Detach(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,10 @@ | |
#include "CoreGraphics/CGContext.h" | ||
#include "CoreGraphics/CGPath.h" | ||
|
||
#include <COMIncludes.h> | ||
#include <d2d1.h> | ||
#include <COMIncludes_End.h> | ||
|
||
const int kCGPathMaxPointCount = 3; | ||
|
||
struct CGPathElementInternal : CGPathElement { | ||
|
@@ -51,4 +55,6 @@ struct CGPathElementInternal : CGPathElement { | |
}; | ||
typedef struct CGPathElementInternal CGPathElementInternal; | ||
|
||
ID2D1Geometry* _getAndClosePathGeometry(CGPathRef path); | ||
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.
extra nit: _CGPathGetAndClosePathGeometry(...) ? #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. please something more like:
In reply to: 86264580 [](ancestors = 86264580) |
||
|
||
#endif |
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.
:-( super sad at the inconsistencies here. I thought the decision was to be error returning out to the public layer at which point a decision would be made on the correct course of action. This still seems internal as it returns a D2D object.
Additionally, returning a Com object with a raw * usually speaks to a problematic design pattern. This is because it requires the "unjacketing" of the ComObject to return it to the caller without a clear communication on transfer/sharing of ownership which is by definition occuring by handing it out. #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.
The render target generators in CGImage and friends are going away (and are only being updated as necessary as part of this PR); ideally, yes, we'd fix everything all at once. There's little point when it's gonna be turfed. :)
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 code has gone away, i'll be sending out the PR soon.
Actually this whole file is gone.
In reply to: 86612430 [](ancestors = 86612430)
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.
We should sync up.
In reply to: 86614591 [](ancestors = 86614591,86612430)