NPAPI:CoreGraphicsDrawing: Difference between revisions

Line 137: Line 137:
  {
  {
     // window->window is an NPPort* since the browser is using QuickDraw
     // window->window is an NPPort* since the browser is using QuickDraw
     NP_Port *npPort = ((NP_Port *)window->window);  
     NP_Port *npPort = ((NP_Port *)window->window);<br>
     // Get the CGContext for the port
     // Get the CGContext for the port
     CGContextRef cgContext;
     CGContextRef cgContext;
     QDBeginCGContext(npPort->port, &cgContext);
     QDBeginCGContext(npPort->port, &cgContext);
     CGContextSaveGState(cgContext);
     CGContextSaveGState(cgContext);<br>
     // Set the CG clip path to the port's clip region -- QDBeginCGContext()
     // Set the CG clip path to the port's clip region -- QDBeginCGContext()
     // does not automatically respect the QuickDraw port's clip region.
     // does not automatically respect the QuickDraw port's clip region.
Line 149: Line 149:
     GetPortBounds(npPort->port, &portBounds);
     GetPortBounds(npPort->port, &portBounds);
     ClipCGContextToRegion(cgContext, &portBounds, clipRegion);
     ClipCGContextToRegion(cgContext, &portBounds, clipRegion);
     DisposeRgn(clipRegion);
     DisposeRgn(clipRegion);<br>
     // Flip the CG context vertically -- its origin is at the lower left,
     // Flip the CG context vertically -- its origin is at the lower left,
     // but QuickDraw's origin is at the upper left.
     // but QuickDraw's origin is at the upper left.
     CGContextTranslateCTM(cgContext, 0.0, portBounds.bottom - portBounds.top);
     CGContextTranslateCTM(cgContext, 0.0, portBounds.bottom - portBounds.top);
     CGContextScaleCTM(cgContext, 1.0, -1.0);
     CGContextScaleCTM(cgContext, 1.0, -1.0);<br>
     return cgContext;
     return cgContext;
  }<br>
  }<br>
Line 159: Line 159:
  {
  {
     // Restore state (it was saved in beginQDPluginUpdate())
     // Restore state (it was saved in beginQDPluginUpdate())
     CGContextRestoreGState(cgContext);
     CGContextRestoreGState(cgContext);<br>
     // If we had to prepare the CGContext for use in a QuickDraw-only browser,
     // 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.
     // restore its state and notify QD that the CG drawing sequence is over.
Confirmed users, Bureaucrats and Sysops emeriti
1,680

edits