TweetFollow Us on Twitter

June 1994 - Graphical Truffles

Graphical Truffles

The Debugging Version of QuickDraw GX

Pete ("Luke") Alexander

By now, many of you have installed one of the beta versions of QuickDraw GX onto your Macintosh -- and possibly by the time you read this, QuickDraw GX Software Developer's Kit version 1.0 will be available from APDA. Maybe you've played with the various sample applications and are now ready to work on your first QuickDraw GX application. Perhaps you've even read my article in develop; Issue 15, "Getting Started With QuickDraw GX." In this column, I'll talk about something I referred to briefly in that article: the two versions of QuickDraw GX's combined graphics and layout portions, and how to take advantage of the debugging version during the development of your QuickDraw GX-based application. Along the way I'll update you on a few changes since I wrote the article.

THE EXTENSIONS OF QUICKDRAW GX
The QuickDraw GX system extension comes in two flavors: a nondebugging and a debugging version. When you run the QuickDraw GX installer script, the nondebugging version is installed, including the complete QuickDraw GX system. The nondebugging version is lean and mean, so it's significantly faster than the debugging version; it performs quite a bit less error checking than the debugging version.

The debugging version of the extension provides extensive error checking and other debugging amenities. When developing a QuickDraw GX application, you should use this version to shake out the bugs. The debugging extension is in the DEBUG Init folder and is named "GXGraphics (debug)" in version 1.0 (it used to be named aSecretGraphics.debug); just drag it into your System Folder and reboot. As your system starts up you'll see the debugging extension's icon displayed before the QuickDraw GX icon.

An explanation of what's really going on here may help clarify things (and it has changed): There are actually three extensions within the QuickDraw GX extension -- one for graphics and layout, one for printing, and one for the Finder printing extension. The QuickDraw GX extension knows, if "GXGraphics (debug)" has already loaded, to use that extension instead of the nondebugging version of the graphics and layout extension. (Note that since the debugging extension must load before the nondebugging version, you should not change the debugging extension's name.)

THE ADVANTAGES OF THE DEBUGGING VERSION DURING DEVELOPMENT
Let's look at some differences between the two extensions, and specifically how to take advantage of the debugging version during the development of your QuickDraw GX application.

Notices, warnings, and errors. With the debugging version of the extension, you can get three types of information about drawing problems: notices, warnings, and errors. For a complete list of these, look at the graphics errors.h interface file. The many notices, warnings, and errors defined between #ifdef debugging and #endif in that file are available only with the debugging version. You'll need to #define debugging in your application to take advantage of them. (Make sure debugging is not defined when you build your final version.)

With the nondebugging version, notices aren't available at all, and the list of errors and warnings you need to respond to in your application consists only of those relatively few that lie outside #ifdef debugging and #endif in the graphics errors.h file. Your application must be set up to handle these errors and warnings, which in general indicate that the QuickDraw GX system could not honor your application's request. For example:

shape_is_nil
size_of_path_exceeds_implementation_limit
picture_index_out_of_range

The debugging version checks for errors that you're likely to run into while developing your application, such as passing a negative pen size to GXSetShapePen or a curve to GXGetGlyphMetrics. The nondebugging version doesn't check for these types of errors; it assumes you've already shaken them out of the code.

Validation routines. The GXSetValidation and GXValidateShape routines are available only in the debugging version. These routines allow your application to tell whether it's passing valid parameters into a QuickDraw GX function, to validate the contents of all QuickDraw GX objects (such as a shape, style, and ink) before their use, and to validate the QuickDraw GX memory your application is using.

Speed optimizations. The nondebugging version has optimizations for speed built in -- not only fewer error checks but also inline functions. The debugging version doesn't optimize for speed. This shouldn't have any impact on your application development except that there's not a one-to-one correspondence between stack crawls using the debugging and nondebugging versions. A performance analysis of your QuickDraw GX application should only be donewithout the "GXGraphics (debug)" file in your Extensions folder.

GraphicsBug. The GraphicsBug debugging tool allows you to explore the contents of any QuickDraw GX object to make sure it contains the correct information. Another change from before is that GraphicsBug is available in both the debugging and nondebugging versions. This ability to spy on an object's contents is important to your application development because otherwise you could only access information in objects by making API calls, which would be very tedious during debugging.

There's a slight advantage when using GraphicsBug with the debugging version: heaps are listed by name rather than by hex address in the Heaps menu.

Memory. The debugging version's memory blocks in the QuickDraw GX heap are a bit bigger to help detect errors when your application writes over the end of a block: all the blocks end with the same signature, 'grfx'.

Special MacsBug messages. The debugging version generates MacsBug messages that are intended solely for the consumption of the Apple engineers in unusual circumstances. (One of my favorites is "Curious if this ever happens.") If we did our jobs right, you should never see one of these messages. In case you do, however, we're really interested in hearing what caused you to receive it; please let us know at AppleLink APPLE.BUGS.

CLEANING UP
You should design your application to take advantage of the extensive capabilities of the debugging extension, but turn those capabilities off when you create your final shipping application, to improve its performance. For example, calling GXValidateShape with the nondebugging extension installed will only result in a jump and return (that is, it will be a no-op). This is a wonderful method for testing the QuickDraw GX dispatcher, but it doesn't help the performance of your application.

In the final compile of your shipping application, you'll most likely want to remove all calls to validation routines, posting of notices, and extra warnings and errors available only in the debugging version. One approach would be to have various compilation flags associated with pairs of #ifdef and #endif to turn these features on and off.

For more information, see my article in Issue 15 if you haven't already -- or just dig into the QuickDraw GX documentation. Enjoy your journey into the QuickDraw GX world!

RELATED READING

  • "Getting Started With QuickDraw GX" by Pete ("Luke") Alexander, develop  Issue 15.
  • "Print Hints: Looking Ahead to QuickDraw GX" by Pete ("Luke") Alexander, develop  Issue 13.

PETE ("LUKE") ALEXANDER has been providing developer support for QuickDraw GX ever since it was way up in the air. He's happy it's making its final approach, and he's hoping it lands smack dab in the middle of your software. As a glider pilot, Luke knows how important control is -- and with QuickDraw GX, you'll be able to maneuver your software into spaces you never thought possible. Since QuickDraw GX can help you do lots of great graphics stunts that you used to have to ask him about, Luke is about to soar off into the wild blue yonder and do some stunts of his own. Soon he'll be ready for the preflight check that will launch his sabbatical faster than QuickDraw GX handles two-byte text. For many weeks he'll be thinking about nothing but white sand beaches, white puffy clouds, and white-capped mountains. He'll lie on his back and watch the sway of the trees until they stop reminding him of the swashes of L's. So if you see him somewhere in Montana, Utah, Nevada, California, or Idaho, be sure to say hello -- but try not to use any words that have a G and an X in them. *

Thanks to Hugo Ayala, Cary Clark, and Herb Derby for reviewing this column. *

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »
Explore some of BBCs' most iconic s...
Despite your personal opinion on the BBC at a managerial level, it is undeniable that it has overseen some fantastic British shows in the past, and now thanks to a partnership with Roblox, players will be able to interact with some of these... | Read more »
Play Together teams up with Sanrio to br...
I was quite surprised to learn that the massive social network game Play Together had never collaborated with the globally popular Sanrio IP, it seems like the perfect team. Well, this glaring omission has now been rectified, as that instantly... | Read more »
Dark and Darker Mobile gets a new teaser...
Bluehole Studio and KRAFTON have released a new teaser trailer for their upcoming loot extravaganza Dark and Darker Mobile. Alongside this look into the underside of treasure hunting, we have received a few pieces of information about gameplay... | Read more »

Price Scanner via MacPrices.net

14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more
Roundup of Verizon’s April Apple iPhone Promo...
Verizon is offering a number of iPhone deals for the month of April. Switch, and open a new of service, and you can qualify for a free iPhone 15 or heavy monthly discounts on other models: – 128GB... Read more
B&H has 16-inch MacBook Pros on sale for...
Apple 16″ MacBook Pros with M3 Pro and M3 Max CPUs are in stock and on sale today for $200-$300 off MSRP at B&H Photo. Their prices are among the lowest currently available for these models. B... Read more
Updated Mac Desktop Price Trackers
Our Apple award-winning Mac desktop price trackers are the best place to look for the lowest prices and latest sales on all the latest computers. Scan our price trackers for the latest information on... Read more
9th-generation iPads on sale for $80 off MSRP...
Best Buy has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80 off MSRP on their online store for a limited time. Prices start at only $249. Sale prices for online orders only, in-store prices... Read more
15-inch M3 MacBook Airs on sale for $100 off...
Best Buy has Apple 15″ MacBook Airs with M3 CPUs on sale for $100 off MSRP on their online store. Prices valid for online orders only, in-store prices may vary. Order online and choose free shipping... Read more

Jobs Board

Sublease Associate Optometrist- *Apple* Val...
Sublease Associate Optometrist- Apple Valley, CA- Target Optical Date: Mar 22, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92307 **Requisition Read more
Early Preschool Teacher - Glenda Drive/ *Appl...
Early Preschool Teacher - Glenda Drive/ Apple ValleyTeacher Share by Email Share on LinkedIn Share on Twitter Read more
Retail Assistant Manager- *Apple* Blossom Ma...
Retail Assistant Manager- APPLE BLOSSOM MALL Brand: Bath & Body Works Location: Winchester, VA, US Location Type: On-site Job ID: 04225 Job Area: Store: Management Read more
Housekeeper, *Apple* Valley Village - Cassi...
Apple Valley Village Health Care Center, a senior care campus, is hiring a Part-Time Housekeeper to join our team! We will train you for this position! In this role, Read more
Sonographer - *Apple* Hill Imaging Center -...
Sonographer - Apple Hill Imaging Center - Evenings Location: York Hospital, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now See Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.