WWDC2004 Session 219

Transcript

Kind: captions
Language: en
ladies and gentlemen please welcome
courts engineering manager Haroun shake
[Applause]
today everyone welcome to the last day
of WWDC it's almost over we've got a
really important session for you today
and it's really going to be important if
you're using quick draw on Mac os10 so
if you haven't heard already let me go
to right to the point we are officially
deprecating quick draw and we are
replacing it with quartz 2d now
quick-draw has served us quite well for
the last 20 plus years it has been
instrumental in the GUI revolution of in
the 80s it was really innovative for its
time it introduced many interesting
ideas and features such as regent
patterns we introduced pics with it with
the display manager we introduced
seamless multi-monitor support and with
color quick draw we actually introduced
a seamless transition to color one of
the other important things with the
quick-draw was that was fast and
efficient but unfortunately it is no
longer a competitive 2d graphics API and
our applications our users expect a
really rich graphics API on the platform
and to some of the things that are
missing from it are Bezier curve support
alpha support built-in color management
we've got color swing but it's not built
in it's not thread-safe some of the
limits some of the assumptions that
quick draw was built on or some of the
design goals that roseville times are
now starting to show up as limitations
in your application so you've got it's
limited to the coordinate system is
limited to 16-bit integers the
resolution itself is limited to 72 DPI
and going forward with resolution in
independence in the future that's going
to become a real bottleneck for us
and one of the signs that it is no
longer competitive is you notice that
applications are using quick-draw as
nothing more than a blit engine because
they've got their own graphics engine
doing their own rendering and at the end
of it they just end up using quick draw
for for bleeding to the screen in our
development of Mac OS 10 and bringing
quick-draw allergy mac OS n since Jaguar
Panther we've noticed you know we will
be fixing bugs inside of a quick draw
for a particular application but just
fixing that one that one bug would end
up breaking potentially other
applications so we recognize that
quick-draw has now become fragile and
for us maintaining binary compatibility
with your applications has become quite
a bit of a challenge so even it even
though bug fixing is a problem for us
you know we can't really add some of the
features that I talked about earlier on
the previous slide into quick-draw to be
really can't extend it anymore and we've
decided we're no longer going to be
working on it we may fix a bug here
there but there's no active adult and on
it in terms of adding new features to it
it's no longer freeze your proof
implying that it will will no longer
integrate it with new features in the
system it will continue to function the
way it is as you've expected to but it
will not be integrated with the rest of
the new innovative technologies on the
converse side you've got courts 2d where
it is a very rich graphics API is based
on an industry proven imaging model by
design it is actually resolution and
device independent and we've got
built-in support for alpha alpha
channels on images and for rector are
about transparency support and alpha
there also it is designed to be
thread-safe it has a really rich feature
set I left many of those things and if
you finished any of the courts to these
sessions this year or in price of ewps
you know what I'm talking about and it
also has a you know a floating point
coordinate system
it integrates very well with other
technologies for example we've got
colors ink color stinks color management
built into court city and this year with
core image we've you can actually take
advantage of courage with quartz 2d it
directly integrated with that new
technology courts to D is also now you
know hardware accelerated through quartz
extreme and all of these points come up
with one conclusion is this is the API
that you want to be using if you want to
be future compatible so I just want to
show you this graph you may have seen it
in the previous video VDC but the
concept here I just want to get one
major point out of this the numbers are
not necessarily accurate but they are
there to give you a particular point and
that is you want to be on the court
curve and not on the quick draw a curve
you know quick draw is deprecated you
want you want to showcase your
application on Mac OS 10 by taking
advantage of quarks and that's really
where you where if you don't your
competitor probably both so what does it
mean for you the deprecation concept it
means that we will maintain binary
compatibility so they're not actually
removing the quick-draw library from the
platform in Tiger yet I'm not sure when
we'll make that decision but it
definitely not for tiger if you are
building for Tiger as your build target
you'll start getting warning that's just
to help you to know which API seemed to
move off of and at some future stage we
will also consider removing the header
so you won't be actually be able to
build using the quick-draw headers now
what is being deprecated it's the
headers that I list here the main
important one is really quick taught at
H all of the api's in them are being
deprecated at pubs at previous wbcs
we've actually talked about you know
adopting course in your carbon
application and we've talked about a
peaceful meal or incremental
which unit eight pieces out of your
rendering and replace quick draw calls
with clear Co graphics or current court
CD called but going forward that's no
longer an optimal solution and so this
year we're actually asking you to fully
adopt court study and you want to
leverage that in all aspects of your
graphics usage be it for display
printing metafile generation PDF
generation many of your many
applications out there are architected
on courts are architected on quick draw
and some of the limitations instead of
quick draw are also may also show up in
your architecture so what we would like
you to do is if that is the case think
of the new features that the courts
provide or of course 2d provides Andrey
architect your application with that
with course CD in mind take some time in
nearing the design cycle for the next
version of your application and really
understand what you need to do because
it's not a necessarily an easy
transition and to that end we're also
moving all of our internal code over to
courts already now as I mentioned
earlier poor CD is being a hardware
accelerated through quartz extreme but
quick-draw is not being a hardware
accelerated in Tiger the main point here
is if you end up using quick draw in
your application that window where you
end up using and drawing too with quick
draw it will no longer be accelerated
and the reason for that is quick draw of
not being accelerated has to draw
through the CPU and for us what that
means is you have to pull the window
backing store back from the we ramp over
to system memory you start drawing into
it through a quick draw we don't want to
go ping pong back and forth accelerate
decelerate accelerate decelerate so our
policy is that as soon as you do end up
using quick draw we will decelerate you
because just that ping pong in itself is
actually going to be much more of a
performance issue than the any hardware
acceleration that you might benefit from
so quartz extreme courts 2d is
accelerated through quartz extreme and
you want to enable it it's currently not
enabled in your build at wwc enable it
through quartz debug it's a familiar
tool for those who are already working
with quartz or not in general it also
has out also two other performance
features that you can use to the
determine where what are the bottlenecks
in your application but enable it
through quartz debug and there's another
feature in here which is the show
windowless that will list all the
accelerators all the windows in the
system and those windows which are
accelerated will be color coded as green
you can find out whether your window is
I sleeping accelerator or not where it
is in terms of what the windows server
thinks it is doing or what the windows
server or the courts compositor has
decided that it that it whether it's on
a graphics card in terms of doing it
being accelerated or not now as you
start making the transition you will you
know you'll come to the conclusion that
these are two different imaging model if
you haven't already quick-dry
fundamentally pixel-based whereas court
sudi was designed to be resolution and
device independent so as a result quick
courts to d is not going to be a
superset of quick draw so there are
going to be features in quick-draw and
primarily those are pixel-based
manipulation using you know utilities
that are not going to be provided
through court study and we've
consciously left those out because we
cannot put those features and not break
the resolution to device independent
design of course city in some cases we
may add similar features for example the
transfer modes and click draw we've got
PDF blend modes inside of course city
they don't match one to one but there
you could probably use some of them if
necessary you may want to also
re-evaluate your users you used to job
those AP is a perfect example that comes
out is you know XR drawing yes we've got
a transfer mode for it but if you look
at mac OS and you know
many applications can get away without
XR drawing and you want to revalue it
and think differently in terms of how
you want to use that API that you're
used to but how you could do that
equivalent thing in course 2d and so in
some of those cases we've decided that
oh F is no law going to go no longer
going to be providing those api's and as
a recipient level service we realize the
transition is not easy so we've done
quite a bit of thing for tiger
specifically we've added many new API is
in Tiger in the course to the API and
those were focused primarily for people
who are going to be moving over from
court from Creek Georgia Court City a
common complaint has been the
documentation so we've improved the
documentation significantly we've got
the drawing with courts GD document
we've got the reference document those
have been updated plus we've got the new
document which is the transitioning to
courts 2d it's a new series of articles
you should have access to them already
there'll be many more coming it's going
to mimic the contents of this session
and we're go into more detail about some
of the problems that you will run into
win in this transition we've got new
sample code will have more sample code
available maybe even Technos depending
on what problem people come up with and
what the solutions are we've got a court
step mailing list if you're not on it
it's a great list to beyond because
you've got other carbon developers and
other courts ed developers who can help
answer questions and we've also got some
of the engineers on our team that are
helping out with those questions also
and right after the session we've got
the graphics and media lab where you can
drop by until 5pm today and we will be
there to answer questions for you so
we'll do the Q&A and then but after that
we can also move to the graphics and
media lab and focus in on specific
questions that you may have and finally
we actually need your feedback we've
tried hard to make this transition easy
or you know fill in some of the holes
but as you move your application over
and you recognize problems in your
applications are you missing a
functionality let us know that many ways
that you can do that and I listed so you
know the mailing list contact those bill
this at the end but let us know but it's
really good opportunity for you to try
it out and help help us easier
transition there are a few other
technologies that are being deprecated
that we're not going to be talking about
in this session but I wanted to list
them here the display manager and draw
sprockets are being deprecated also and
for those but those two technologies
what you want to do is use the court
display services those technologies were
actually built on top of the courts
display services so now you should
actually go directly to that it's a
better API for you to be using and
protects is also being deprecated but it
was discussed in another session earlier
this week so we won't talk about it and
from this point i'll actually like to
bring up justin moore are quick to our
experts we can actually help you see the
common problems and help you move over
to court CD so there you go Thank You
haroon they deprecated my nickname but
it's okay I actually like it feels like
a promotion I still should let you know
that we are I come from we say Clark so
don't laugh if my pronunciation of
quartz is not as you hear it all over
the place from now on each time you read
about hear about learn about quartz you
will think of me and the very I say
Clark
you know I had to learn these new words
this year deprecated looked it up in the
dictionary comes from Latin Dupree curry
and it means toward off by prayer I'm
not making this up you can google it for
yourself so can you picture her own and
Peter Graff Ernie no praying to defend
themselves against the evil of quick
draw talking about evil you are
wonderful audience you fit you're the
perfect audience for this afternoon you
are I assume you are carbon developer so
you can relate to the clothes in the
title I assume you know quick draw so I
don't have to explain anything about it
anymore I assume you know enough about
quarks that I don't have to explain much
about it either and of course you want
to transition your graphics programming
to court yeah okay I know their days
there is some obstacle to overcome you
need to let loose of some sentimental
attachment and I know what I am talking
about have been sentimentally attached
for 21 years see over the last weeks or
so sometimes I felt like standing out
there on the corner the answer mariani
in the morning watching all the fellow
Apple employees thrive by to work and I
was there with my big sign that read
hunk if you like quick draw well with
the exception of tools we bodies from
the quicktime group nobody hung
so I brought my own honking device click
draw click drop Friday afternoon after
all huh I don't have a musical
instrument for quartz quartz quartz
doesn't need it would have to be
something big you know shiny and blend
it I'm thinking of a trombone no way I
could fit it in my cargo pants Clark has
something else quartz has tailwind and
there's somebody who likes to ride a
bicycle I can tell you that Palin is a
very good thing all of us know however
that in order to take advantage of
tailwind you need to go in the right
direction so i invite you to come along
with me and we make a big turn and we
turn into the right direction we go to
transition they told me it would work
yeah we are going to talk about how to
transition to two clubs take the first
three bullet items as introduction as
things we need to think about before we
even get started and then thinking about
the program here i thought i would
isolate two concepts that need more
discussion in depth region handles and
copy bit then I regroup some more issues
and concerns at the end think about
pictures versus PDF or performance or
this color space thing and everything
that's new there and i even have
examples intimos why don't we start with
sample code i happen to know that some
of you have already asked for it during
this week i am happy to introduce carbon
sketch many of you may remember from
three or four years ago carbon draw
which was the first proof of concept you
actually can call
quartz api's from a cup a carbon
application this time it's the real
thing there is no quick draw at all it
can be done you don't use X or fourth
track selection and matching answer
whatever you use overlay windows hit
this thing there is no point in region
we don't need it there other ways around
it and the sample code shows it we have
copy pasting PDF data the generic color
space usage and some more and it's
available I didn't find it today this
morning yet but it should come up
anytime real soon and it's there to grow
I think I want to demo it now
so it's your regular drawing application
nothing spectacular you draw a line move
them around now each time you do hit
testing you use a 1 pixel bitmap context
that you transform appropriately you can
scale the drawing and hit testing also
works in this case way what's going on
behind the scenes is there is one
generic transform that transforms from
documents coordinates in the list of
shape to the window content now I'm
emphasizing this because if ever you get
your hands on the carpet it's uploaded
this might not work I fixed the bug just
over last weekend and I will later come
back remind me to talk about this bug
it's helpful and of course you do set
fill colors or whatever no I meant full
blue and I mentioned before that it does
have that take advantage of built-in
color matching if don't know if you can
see this if you look closely this
digital kilometer tells us that the real
color I'm pointing it here is not the
blue that we set it has got an
additional red component in there I
don't know why the color thing people
can explain you but that's just a
demonstration that color matching works
is there is alive and of course on top
of it color matching wouldn't make much
sense without calibrating to begin with
and with projectors and so on it's just
something to point out I said we have
copy and paste before we can say that
the PDF file that's no big surprise
and I have prepared a PDF file here in
preview and preview can copy PDF
contents into carbon sketch maybe not
don't know how we made it work just
before okay what if I open this PDF we
just created now it's in preview and I
close carbon sketch a new window and
here i ask preview to copy this stuff
into oh here we go so this should have
worked before this is one of those
miracles in demos I don't know oh
actually I do I think now I know copy
paste in case you want to know too there
are two different copies of preview on
this machine and the copy that works
best for this demo is the one from
Panther so I'm back in carbon sketch I
can do whatever I want like our quick
draw rounded rectangle let's make it
half cents parents or so and now I go
back and say I want to copy this whole
page in my carbon sketch thing and if
this is the right copy of preview then I
can say new from clipboard and here it
is I have a new PDF that tells our
drawing edit don't know what I forgot
now to show about this carbon sketch
thing the interesting part for you
should be I'm in the following you
referring to it and inviting you to take
the code the source code copy paste from
there those things that you better copy
paste from somewhere where they already
work and then play around and make
experiences with
getting some experience with quads
drawing yourself so we can go on with
the slides now we get into the need
haroon has already pointed out all the
differences I don't need to repeat all
the details but in this slide you should
start with reading the last line the
last line says don't try to translate
the usual quick-draw idioms that we got
used to over so many years into God's as
is because the differences are just too
big now you look over the rest of the
slide and you see that I repeated a line
save and restore graphic state this
comes twice it comes next to the changes
of coordinate systems and the current
transformation matrix and it comes to
clipping and it would have to do with
all other calls that you make in course
to change the behavior of the stroking
and filling operations the colors and
many other settings and details in
crypto we had the model that this state
was mainly preserved in the graph port
we could have accesses and then get and
set the values in course the model is
different everything is combined in this
opaque graphic state which you can push
and pull back you save it on the stack
and you restore it from the stack this
makes for a nice bracketing thinking in
all your drawing and after the first
couple hours and you get used to it you
really like it it's a much better
approach to keep your drawing code GREEN
and we have to come back to that more
often now coordinates the ctm the
current information matrix n transforms
this year of the next slide i remember
when i encountered quick-draw and the
first time saw coordinate system we are
by default the vertical coordinates went
top down
I found it odd I took me a while to get
used to it I didn't really like it of
course all of us we learned very rapidly
that this was the convenient way of
addressing pixels in in the window it's
natural it follows the order in memory
and it has so many other benefits
because we are used for resizing windows
to resize from the bottom right and the
top left the content stays anchored to
the top left so this was the right thing
and over the years we got completely
brainwashed into believing that
coordinate system have to go vertically
top down well now they are again back up
in quotes by default but there is this
general model whereby the ctm can be
changed to whatever you want not that
you will get everything right right the
way it often requires an experimentation
or or some additional thinking but it
gives you the power to for example flip
the current system and shifted such that
you can continue working as you did in
your mental model of the grid
coordinates and H I've use they do have
their origin at the top left they have
set up the CG context that you get back
in your drawer control events such that
you can just use this I've had good
reasons to set it up that way still it's
one of those obstacles on the way to
transition to quartz and I should point
this out that you should not be
surprised to spend some extra time just
figuring out where the coordinates go
and converting back and forth between a
window position that vertically you have
to count from top down in the crypt
remodel or the HIV model and that in the
default course models you have to
introduce the height of the window the
current height so you can subtract it
and get the distance from the bottom and
this is a joke math is hard math is not
hard
it's just hard to get everything right
when you use this transport I refer to
it when I showed you the heat testing in
carbon sketch and I said about this bug
I didn't notice because I hadn't tested
his testing under scaling up or when I
tested it it just happened to work by
accident and then I noticed that it
didn't work and it tracked it down to
the following there is a 1 pixel bitmap
context which I set up and once you
click in the window at some point I move
it to this point and then I redraw the
whole content of the window and check
whether this point in this bitmap
context has been touched we are easy i
set it to zero before and afterwards if
it has been touched it from 20 anymore
well the problem was I applied and in
order to talk in the content of course I
always have to concatenate this generic
affine transform that converts from the
document document the document
coordinates to the window content
coordinates depending on the position of
the scroll bars and so on the tricky
part was I got the order wrong I apply
distance form and shift is a bitmap
context where it belongs where this is
the wrong order first I have to ship
there and then apply transform it
doesn't matter if you don't scale but as
soon as you scale the transforms are not
it depends on the order so this is just
an example of the type of apps that you
are likely to encounter this is a very
generic slide just to tell you in order
to get started the CG context is more or
less something in parallel to a graph
port we need something to draw into all
the nearly all the costs ap is take a CG
context this first parameter and the
question is where do we get it from in
our first examples of experimentation
with it well you have learned over this
week and for two years already
the direction for carbon developers in
the H I toolbox is to adopt the H I've
you architecture and there you draw in
this cave and control draw events and
the event record brings you the CG
context ready set up clips with the
chords as you like it and so on so
that's the most convenient solution the
most convenient answer to the question
for everybody else in the meantime you
have the window port coming back from
get window port and you fill it in to
the QT begins each context call and this
gives you the CG context as you have
always had this context each time you
make this call is a default context it's
a fresh reset context as if you created
it from scratch new but of course now
that we promise not to use any quick
draw in our window drawing we do it just
once at the beginning and then green is
always our context I mentioned the
bitmap context in the content in the
case of using a 1 pixel wide bitmap
context for this hit testing business
and we created PDF data in carbon sketch
so we need to create a PDF context the
equivalent in quick draw balls to call
open picture then do some drawing that
gets recorded and say close picture to
get back the picture handle and well in
quartz which are straw into a PDF
context and for printing well this
bracket of begin CG context and entity
context works David Kellen here has done
everything that needed to be done for
that but preferably it's better to let
the printing system know right away that
we only use quad drawing and up to Tiger
it was a little bit i found this
unintuitive how to do it i couldn't
figure it out by myself had to go back
to david and ask him and so entire we
get something that's much more clean and
intuitive and before tire you go to
carbon sketch and copy pasted out there
for you printing
so the first major chapter what do we do
with all those region handles you have
heard probably some references to region
handles being bad in the H I toolbox
presentations already one thing is a
given there are no region handles in
quartz regions in crypto are being used
either as very general shapes that can
be drawn and filled and painted and what
have you or they are used as masks for
example as last parameter in a cup of
its called a mask region handle when
moving to quartz these two different
usages are being addressed by different
ways the generic shape very naturally
inquire is described by its contours so
a path and for mask quartz has the alpha
channel the question is how do we put
this in I will come back to that and the
other bullet points are going to have
their own slides as well so we just flip
over the major the first time a quick
tour developer encounters regions
probably is to clip as a clip region set
the clip to something and in quick draws
these functions clip to the rectangle or
set eclipse of course replace whatever
was there as previous clip in the port
whereas in quartz the corresponding
called CG context clip that takes
implicitly the current path intersects
with whatever the previous clip was the
first time I learned about this from my
new co-workers when I joined the group I
said I don't like this well I'll of
course it's easy to get used to it and
again once more GG context safety say
then you clip to what you need and you
come back with the closing bracket
restore
state and so you're always in a clean
situation still in the first hours of
experimentation with quartz drawing if
you are like me sometimes you're drawing
don't show up the first reason is you've
got the coordinates wrong the second
reason could be that you clipped and
that your drawing is away from what you
want to clip out and then as I was
wondering how can i debug this how can I
determine if this is the case and there
is this call that I just wanted to point
out TG context get clip bounding box
this helps in most cases because there
is no way to get the current clip back
as a at a path and value-added here's
another hint i discovered this only
during development of carbon sketch I
needed to clip the drawing to the
portion of the window content outside of
other controls the scroll bars and this
pop up for the scale so as it was
nothing easier than that you just take
the past for the whole window content
rectangle and then you subtract the past
for that describes the contour of the
scroll bars and the pop-up problem is
the CG context flip uses the winding
number rule to determine what's inside
and outside of the area which means as
the little arrows should indicate the
rectangles that gets subtracted from the
area should have the opposite
orientation in the contour now that's a
little annoying when you have to write
the code because you have to write at
least four lines instead of just one
line to add the rectangle to the path
unfortunately then I learned that there
was the city context even odd clip and
so now you can just add the rectangles
as their come and the even-odd rule that
the right things and you can clip as you
want here's another subject if you never
bothered about understanding really
what's happened
and begin updates and end updates when
you redraw your window in response to an
update event you don't have to listen
now and come back for the next slide the
story is that originally in the mac in
this toolbox there was this concept of
invalidating little regions in the area
that needed updating and by the time you
got called with an update event you
didn't have to bother clipping your
drawing to whatever needed to be redrawn
it happens behind the scenes
automatically the H I tool box set keeps
track of whatever needs to be redrawn it
keeps track of the update region and the
strictest begin updates used the visual
region this region in the graph port to
achieve this because with those
obviously has a clipped to all this now
if you carry this model over just to fix
the ideas assume the window content is
mirrored in a G word and what you are
doing is you update the little areas in
the G word as the need comes up to in
your application and then each time you
need to refresh every so often you just
blast with a big cop if it's the whole G
word onto the screen and you rely on the
benefits that automatically this big
copy base operation is clipped out to
what really needs to be transferred if
you would do this in the same way with
quartz then you might have a bad
experience performance-wise because this
begin update mechanism Clause doesn't
know anything about it there is no
reason in the port and it just doesn't
come in so each time you would redraw
the whole content and that's not what
you want well of course h i use they are
they address this as soon as you adopt a
chive used again you don't have to worry
about anything at all anymore in this
matter and in other cases it's one of
those examples where we need to rethink
the approach and replace the existing
code
the existing model by some optimizations
for this purpose now we come to regions
as mass here is the traditional clicked
role model to create a mask you copy
bits into a 1 bit off screen and if you
are not happy with the very colors get
maps to black or white you put in a
search proc and you get precisely the
region that you want to obtain as a mask
when you call bitmap to region that's
not how how you can do it in in Carson
to begin with masks are by by design
meant to be in the Alpha Channel so how
do you get this mask bits into the Alpha
Channel it all depends of course on what
your specific application and your
specific goals and needs are there if
it's something that you can do ahead of
time and then store the proposition is
just do it once and for all keep their
alpha mask up to date is what you want
and you have a picture that you can use
as is and no need for mask region
handles at all anymore the other
proposal is to tinker around with the
pixels directly in a bitmap context the
bitmap context gives you the base
address gives you the robots and you can
basically work with it as you are used
to with the pixels in a keyword in a
pixmap this is not really a satisfactory
answer either I know and that's why for
tiger the API has been extended within
this perspective and now you can call GG
image creators mask and TG context flip
to mask in both cases the mask is a deep
mask so this should help hip testing I
mentioned it several times already
asking quick-draw booths set up the
region where it wants the point to
compare against if it's contained or not
but the trick is drawing the content and
clipping it to the point where you want
to check whether this point gets drawn
has been around since the beginning of
crypto it was one of the
first trick that I learned in back in 84
so it's still good and as long as in
Quark's we don't have the cg pass
contains point for a geometric solution
in some accompanying utility functions
there to make this useful really and
it's there starting with Tiger only you
would have to look at the way carbon
sketch does hit testing now would be a
good time for a breaker we are switching
to a new chapter but Travis is scared so
I better continue you're going to copied
it I think some of you came to us long
ago already when quick-draw and quartz
we are opposed and compared and when we
were invited to embrace quarks and one
of the first reactions worse what do I
do with all my copy of its called there
is no copy of it in words really there
is CG context or image and it will have
to do that's all we've got originally
the general functionality is not there
and for good reasons again if you think
about the fundamental differences in the
imaging model so the first comment is
maybe you don't need so many copy bits
calls anymore to begin with for one very
awesome the usage of copyrights out from
off-screen keywords and so on was to
work around the fact on system 9 on pre
system 10 that windows were not buffered
and we just wanted to avoid flickering
we wanted to composite things one by one
before they could be brought to the
screen whereas now with more experience
about how everything works on 10 in many
cases we have still code that is not
necessary we can use the compositing
feature in the windows to our advantage
and throw away much code and many chivos
image repsol so they stay around if you
leave them around and if you learn about
the rules of using them they are much
more convenient you don't have to set up
and juggle around with so many Austrians
in general anymore but in principle it's
through the tandem or 4G word with the
copy bit in terms of a cached content to
be brought to display corresponds to a
CG bitmap context and the corresponding
CG context raw image there's a link in
between you need to set up a data
provider for the image it's not really
as easy as it could be it takes probably
more than half an hour to really learn
it how to use it the first time and
there are still some restrictions we
should never forget that here the source
pixels of an image ref are immutable you
cannot change them once you have this
you can but you might not be happy with
the result and there are some other
missing conveniences at least up to
tiger now we can create an image with a
sub rectangle and if you have been on
tuesday at the session where all the new
quartz features have been introduced and
this is just a way of repeating it and
hammering it in the image can be created
directly from the bitmap context no
intermediate tinkering around with data
providers anymore and for tiger because
of the motivation and the needs that
came up with hardware acceleration a new
concept the CG layer rest that is
particularly favorable to cash drawing
that then gets brought to the screen the
missing transfer modes haroon has
mentioned it we don't have a precise
equivalent for the arithmetic on
thermals and everything but there are
new features new facilities new
possibilities in the PDF blend mode
again starting with tiger
and also because going forward and
inviting all you carbon developers to
transition to quarks we are going to
cooperate much closer with a chai
toolbox and make all this blend together
and one of the functions that's there
for example is a chive you create
off-screen image in many cases you need
to have your view and keep the content
as is in an image ready so there it is
oh yeah progressing nicely pics click
the head pics clarks has PDF it really
doesn't make sense to hang on to the
pics when you move your drawing to class
and as I brought up here in the second
bullet point we need to start supporting
copy and paste only the PDF format
really captures the all the details all
the penis of quarks drawing there is as
being the caulk you depict raw to cg
context it draws a pict into cg context
whatever the cg context is well this
code has to convert her to translate
from the quick draw drawing model into
the PDF drawing model and that's
potentially a lot of work which means it
might be a performance problem if you
call this many times with many pictures
and so on in this case the workaround we
recommend is well just throw it into a
PDF context hang on to the PF PDF data
and use those from then on and one step
further if you have hundreds of pictures
I know it's a not trivial but consider
moving them over in the same process in
particular if you know that as in the
last line that the picture that came out
compressed from Photoshop actually just
a wrapper around jpg data
that get decompressed by quick time
through a good time opcode think about
all the machinery that has to be put in
place to get through it really doesn't
make sense anymore when you approach the
clouds API where you have CG image
create with JPEG data provider right
away so just keep them the traffic data
themselves before there is this line
that says some pictures on convert well
of course we know they don't print well
either there are some of them are still
around and you need to convert them
anyway probably the trick is to just
draw them into a fixed map and then
create a new picture that's just playing
pixels so back to the copy paste
business I hate bringing up source code
on a slide this is just a list of some
of the calls they're all a little bit
lengthy and swelling you have to set up
the PDF context to draw your content
that had to go on the pace poured into
it to capture the PDF data and then you
can bring them up and the other comment
is there is this comdata will be dot PDF
literal finally entire beget to symbolic
constant for that not too early in the
universal types and pasting is a little
bit longer to than this just singly
called the recommendation is that's why
it's there carbon sketch look at it and
go through and probably you can copy
paste the last of the source code but
please start adopting copying and
pasting PDF data we need to get there
another chapter in the story of
transition into quartz is color spaces
you start coding with the quartz AP I
don't know yet how many calls at the end
which causes the end what they have to
do you set the bitmap context and you
look through the parameters that you
need to provide and suddenly you need to
provide a color space we didn't have
color spaces in quick-draw we don't know
what it is so we looked at the file
colorstay
start age and we search for a way to get
the color space to plug it in as
parameter and my first solution was to
just grab the CG color space create
device rgd because it was the simplest
one and it sounded plausible enough that
that's what I wanted and then comes one
day David Goldman again and says oh
don't do that i will show you i will
give you all the code that's how you
have to do it to use generic RGB color
and remember when i showed you the blue
pixel that actually by the time it got
to the screen was slightly modified with
some other components added in to do the
right color matching you get it for free
and because in such an application we
would copy paste content with colors or
save to a PDF file we are really
interested in getting the correct colors
all over the place so that's the model
that's the recommendation unfortunately
again we had to wait until tie you to
get the real easy call that gives us
this generic color space before it's
required several lines of code which I
haven't brought up here no point I
invite you to look at it in carbon
sketch and to just copy pasted out again
and then you get the generic color space
for all your RGB knees yeah there's this
last point and we have had some
discussions about this of course colors
color matching takes CPU cycles and
there are situations when you cannot
afford it or when you really are hurting
because of this fact in some extreme
cases you only go to display your only
have some specific needs we are not
really perfectly well prepared for the
situation and that's why we promised the
tech notes sometime soon that addresses
all these questions to bring in this new
concept of color spaces probably I
should have also pointed out that as
it's written on the slide for tiger the
behaviors
to change the behavior of device RGB the
device RGB colour space so you will
you're going to get different behavior
between content and tiger if you already
use the device RGB colour space in from
tigon it's likely to be color matched so
in summary there is stuff that gets left
on the way during this transition those
in famous crypto transfer modes all 173
of them or I don't know how many well we
cannot pixel by pixel reproduce
everything that quick tour days it just
doesn't make sense time goes on and as
you can see on the user interface of Mac
OS 10 all those applications that don't
use any quick draw you can live without
those it looks different we have new
ways of selecting of track selecting
something by using a grayish transparent
overlay window for example if you like
that and if not in carbon sketch I still
use the marching and frame for drag
selection with ola windows it's really
nice how you can achieve effects which
would have been extremely difficult to
reproduce in crypto if you remember
playing around in carbon sketching
creating objects and resizing them and
so on it looks it looks pretty good by
taking advantage of overlay windows
which you could consider the even stack
for special purposes and special needs
and using transparency when you're
drawing into the overlay Venus which you
can still compared with what's
underneath and then we have this PDF
blend modes I haven't looked closest and
myself yet to see what we can do the
possibilities are richer than whatever
we had known in crypto the graph hood
has this bottleneck prox
tip and every quick tour developer was
proud when he first hooked in there and
a chief special effects and we got used
to it they are not there anymore they
are no bottlenecks in court in Tiger we
have this new feature of being able to
scan and get called back for each up
code in a content stream a PDF content
stream this is in its not equivalent
it's much richer it depends all on what
you try to achieve when you hooked in
the bottlenecks in most cases you don't
need to the begin with anymore in the
quad drawing model but if you really
want to get very close control of
everything that's going on drawing wise
in your application that's the way to go
and as haroon pointed out some pieces
they are lost forever in exchange I
thought I should point out how much you
win again so that's a little bit of
propaganda thing that just right after
the downer of what you are losing theirs
there is so much more excitement in this
new graphics model you can do things
that it would have been extremely
difficult to achieve them in quicker and
you can see how often we refer to Tiger
with new API is that are there to make
the transition easy and comfortable we
have finally a lot of new documentation
we have the new sample code more is to
come and I'm personally ambitious to
make carbon sketch into something that
should respond to all your questions so
bring the feedback bring the request
bring their it isn't criticisms
performance of course has been an issue
from the beginning if you set out and
set up a benchmark and you compare the
working of certain operations in quick
draw against those in course you will
find
today cases where quartz is slower and
sometimes quite substantially on the
other hand if you measure your time in
your application percentage-wise of the
whole processing time which percentage
is used for drawing for display and
which percentage is used for everything
else in the system and if it turns out
that you spend about ten percent of your
processor time in drawing then you can
put it in perspective it's in many cases
where you think it's the performance is
a problem it actually isn't and then
there are cases where it is and i will
come back to that in a couple minutes so
the message here which we repeat quick
draw is an obstacle against hardware
acceleration and we want to take
advantage of it in the future as it
comes so quick tour really doesn't isn't
a good citizen any more on on the system
and then there are some other
recommendations I don't even need to
comment on them you know i just copied
them over from the documentation that we
have about performance and the concept
of cg layers in particular bears
repeating it's something new and we want
to just emphasize it that for the future
that's really something to look at yeah
here's the time when I come back to the
performance question can be flipped to
the demo machine please
I think most of you have seen it already
over this week and I am entitled to show
it once more one last time some of you
may remember who has been here two years
ago that I showed it two years ago these
are these are 88,000 line segments they
come from jean-paul Dumond developer of
CAD program and he had trouble on Mac
os10 with quid pro because quick the
line drawing was so much slower than a
mac OS 9 so two years ago for Jaguar I
compared what you can do and explain
what you can do to make it competitive
with mac OS 9 and I was proud of it and
nowadays it's just pathetic if you flip
to software rendering in quartz yeah you
might ask why didn't I showbox than two
years ago already well because years ago
that two years ago it wasn't so fast it
was still slower than crypto and this is
only progress that has been made within
quartz in software rendering and you
probably have seen the hardware
rendering case and it becomes it's not
even funny I mentioned some other things
again I think two years ago I had
something similar to this and the reason
was again a comparison this mac OS 9
what's going on the way it's set up and
it's not meant to be something for the
real world it was just a very specific
limited test case there are so many off
screens in a row in an array if you want
and then I'm cycling through and from
each one I do a copy of it in order to
show that each time is different each of
the off screens head has this rings
outset the way I am set this up these
are install a timer and measure the time
that's used for actual drawing and then
everything else
so here in this case drawing time in the
system is seven and a half percent with
quartz what if I do click draw its seven
point seven percent and of course it
will would fluctuate if we would repeat
so this is nearly the same it's
practically the same why because this is
just copy paste song Victor and on the
quad side it's just cg context raw image
because I set up this image reps with
the pixels from the off-screen G word
now copy will sing quick draw as often
as it can just passes the job off to co
graphics and it ends up precisely in the
same code so no wonder they are about
the same performance then I tried to
bump up the percentage of drawing time
each frame I just repeat it I repeat it
to saturate the machine such that it
gets more work to do and you notice it
gets already slower it's already
suffering a little bit the priorities in
scheduling kick in and I could bring it
up to about ninety percent and then the
system refuses to let me take more CPU
so I get 16 repetitions for frame
drawing time between fifty and sixty
percent if now I flip to quartz
55-percent the behavior is not always
reproducible what I meant to show us
that in many cases and maybe i just went
too fast it turns out that drawing time
in quartz becomes more favorable as you
put more load in the machine well as it
happens it's just no so spectacular
anymore now here in this case which
means i don't have to explain it to
comment about it
and then comes another case again which
is purely artificial it goes back to
this idea that you do a big copy bit
from your off-screen but you clip out
only little areas but i'm doing here is
it's the same model as in the bullseye
before but i'm clipping each one to the
nine little rectangles and in between
each frame i change the content of these
nine little rectangles the idea is that
you say you have some window content
that reflects some some hardware input
and in real time and you want to display
how it changes so that's what how you
would do it in good draw you have this
off-screen you wiggle around whatever
needs to be updated you do one big cup
of it's called to bring it back on
screen and same thing I wanted to see
how this compares with using quartz and
crystal and it turns out that quad looks
a little bit unfavorable in comparison
to quit drop and maybe this was the case
which I remembered we're bumping up the
repetitions suddenly made quartz look
much better see quad takes nine percent
drawing time by 16 repetitions put the
take nearly twice as much
so he can comment about what's going on
and how come that as soon as you put
more loads more graphics load on the
system quartz starts looking better the
previous example problem was just too
trivial there was much to be gained and
here it turns out that internally the
architecture of course the way it's
designed and implemented it's just so
much more advanced than quick-draw bitch
is tied to a design that had to match
that correspond to Hardware reality of
more than 20 years ago I think I should
stop at this time let's go back to the
slides once more please I come to the
conclusion of course it's not reveal of
course it will take work and we need to
learn something new and we need to
rethink certain things I feel it's a
good thing I feel rejuvenated since I
started learning something new maybe
this can entice some of you as well and
above all it's really the right thing to
do think about the tailwind it's good
karma trust me and I'm repeating about
haroon offered we are here to help in
particular myself who has a background
and developer technical support long ago
I just cannot help it so see you in the
lab afterwards I will be there together
with the other members of the group and
we want to help you bring you over to
court Travis Browne is the man to talk
to with everything bring all your
feedback all your requests as I
mentioned we are proud of all the new
documentation we have now you will find
everything down from the reference
library graphics and imaging there is
sample code and unfortunately i don't
have the precise path to carbon sketch
but carbon States is not alone and we
are working on making it richer and we
have the quad step mailing