Confirmed users, Bureaucrats and Sysops emeriti
1,680
edits
No edit summary |
|||
Line 92: | Line 92: | ||
In 64-bit, the QuickDraw drawing model does not exist, so CoreGraphics is the default drawing model. | In 64-bit, the QuickDraw drawing model does not exist, so CoreGraphics is the default drawing model. | ||
The CoreGraphics drawing model | == The CoreGraphics drawing model == | ||
If a plugin sets the drawing model to NPDrawingModelCoreGraphics, then the meanings of some of the NPAPI data structures change: | If a plugin sets the drawing model to NPDrawingModelCoreGraphics, then the meanings of some of the NPAPI data structures change: | ||
Line 136: | Line 136: | ||
static CGContextRef beginQDPluginUpdate(NPWindow *window) | static CGContextRef beginQDPluginUpdate(NPWindow *window) | ||
{ | { | ||
// window->window is an NPPort* since the browser is using QuickDraw | |||
NP_Port *npPort = ((NP_Port *)window->window); | |||
// Get the CGContext for the port | |||
CGContextRef cgContext; | |||
QDBeginCGContext(npPort->port, &cgContext); | |||
CGContextSaveGState(cgContext); | |||
// Set the CG clip path to the port's clip region -- QDBeginCGContext() | |||
// does not automatically respect the QuickDraw port's clip region. | |||
RgnHandle clipRegion = NewRgn(); | |||
GetPortClipRegion(npPort->port, clipRegion); | |||
Rect portBounds; | |||
GetPortBounds(npPort->port, &portBounds); | |||
ClipCGContextToRegion(cgContext, &portBounds, clipRegion); | |||
DisposeRgn(clipRegion); | |||
// Flip the CG context vertically -- its origin is at the lower left, | |||
// but QuickDraw's origin is at the upper left. | |||
CGContextTranslateCTM(cgContext, 0.0, portBounds.bottom - portBounds.top); | |||
CGContextScaleCTM(cgContext, 1.0, -1.0); | |||
return cgContext; | |||
}<br> | }<br> | ||
static void endQDPluginUpdate(NPWindow *window, CGContextRef cgContext) | static void endQDPluginUpdate(NPWindow *window, CGContextRef cgContext) | ||
{ | { | ||
// Restore state (it was saved in beginQDPluginUpdate()) | |||
CGContextRestoreGState(cgContext); | |||
// If we had to prepare the CGContext for use in a QuickDraw-only browser, | |||
// restore its state and notify QD that the CG drawing sequence is over. | |||
CGContextFlush(cgContext); | |||
QDEndCGContext(((NP_Port *)window->window)->port, &cgContext); | |||
} | } | ||