WWDC2001 Session 508

Transcript

Kind: captions
Language: en
please welcome John Berkey Java classes
team technical lead hi everybody
so I'm going to talk a lot of things
today let me grab my little clicker
we're going to divide the talk into
three sections and as I work it there's
me and so our three sections are we do a
features overview of what Mac Mac os10
job is about the Java 2d and things like
that that's I think important because we
got a mix crowd here I think tips and
techniques for how to make your apps
high quality high speed and including
some of the things that are different
about our platform which is why they're
really important and also our update
which is coming up in the exciting new
technology that's part of the update and
then we'll go to Q&A at the end so first
of all can I have a show of hands for
Java developers everybody's devil
developer good and so how about show
hand so people who are Mac os10 people
who just Java I heard about Java couple
so cool partisan crowd so great so this
is jarred gem ski and he'll be assisting
me today so my co-host in Java finally
we have Java - it's been a long time
coming
we've worked really hard and Suns been
really great to work with and we finally
have Java - and as you guys know I'm a
big part of it as Java 2d Java graphics
from sort of the Mac os10 perspective I
like to look at it is just like quartz
it's PDF rendering it's you know general
shapes a lot of different things that
PDF has and because we are on top of
quartz we can actually generate PDF -
we'll talk more about that little while
also we're an object API on top of
quartz I just want to point it out
because I think we have some really good
advantages a really good one to punch
because we have quartz which is our OS
graphic system and we have Java 2d which
is a great object wrapper and I think
together they work really well I'll go
into that too and also this is actually
really important again your part is in
but you know the way we build these
things is we use the other API is to
build the nice API as far as I'm
concerned and so what'd you guys get
which is just great is you get the same
API with just a few lines of code you
can render it a screen render the off
screen you can render the printers I
think that's really great I was a Java
developer for a long time before as long
as any whatever it's three years right
before I came to Apple and that was one
of the best things I thought about Java
was that just you whip out a few lines
of code and you can render almost
anywhere so I really like that so to the
features what I'm going to do is first
just cover a sort of each of these real
quick and then we'll go to the Java 2d
demo and just point them out it's we
wanted to sort of cover that because
some of these technologies still pretty
new it's just good to do a quick summary
so general paths and shapes a quick way
to say that is that basically any shape
you can do with bezzie a pass and
quadratics you can do with the general
path API and that goes from lines and
rectangles all the way up to the kind of
things you'll see in the Java 2d demo so
that means for the first time in Java we
can do all the things we need to do to
do professional applications then we can
take those shapes whatever from
rectangles all the way up
and we can fill them with whatever we
want what I like about Suns api's is
what they tend to do is define a nice
real open easy to customize API and then
they tend to have an example or two that
is the common use so in the case of
custom fills we have textures and
gradients and they've defined these
forests and they work just great and we
actually as a team try to optimize those
cases so that you can get the best
performance using the built-in ones
because we can guess a lot better about
how things work so then on top of that
we have completely custom fills you can
actually define your own paint actually
it's called in Java 2d and do whatever
you want for your pain so that's really
nice you supply you know some maybe
there's some new way to do filling that
we don't know about yet you can do
whatever you want there but textures and
gradients work just great custom strokes
so same kind of idea Hearst is really
good I think is you can define you can
Stroke a arbitrary line or curve with
any shape you want you basically you can
be called back and you can say hey this
is the shape I want you to spray all
over my line however they also have
basic stroke which is one of these ones
they have built in and that lets you do
dashes and line widths etcetera so
custom compositing same kind of idea you
define the blit so it's like having copy
bits for all s old mac guys and but you
can do whatever you want so that's great
and it's all I'm Java so that's great
too because you don't have to deal with
all the kind of things you were into
when you run off the end of your blitter
etc so it's nice you know of course it
doesn't work the least to get an
exception instead of a crash so and then
also this is another one of these that
has one built in it's got alpha
compositing built in and of course with
the different engines that we use to
implement this that operation is
built-in so we'll get more into what I
mean by that a minute but the main thing
is is that you got custom compositing
you can define to do whatever you want
to do when you've lit and you've read
alpha compositing built in reported f
compositing rules which is what court
supports natively and of course it's
completely portable code you guys know
that Partizan
so we'll do a quick overview of the Java
2d demo this is the Sun demo I just
wanted to do a quick overview of the
features or do you want to start oh you
got great so here's some we're just
going to do a few of the panels most
people have seen this but we're just
going to point out a few things so
you'll see in this one this is the
stroking stuff we're talking about the
last slide
they call it lines here in the nurse
that you can do dashes that's all basic
strokes from the top right you can do
the different types of caps you can
build that thing that the arrows are
thick lines with different kinds of caps
they're just giving good examples of
different car things you can do you can
switch it
so here's arcs and curves and the most
interesting one is where the cursor is
that's a Bezier animation and what's
interesting is there's a gradient fill
once you click on that and make that the
big boy
and then yeah stop it for a sec and then
switch the draw choice - yeah there's a
blue - dude well that's cool - do blue -
that we had for a draw choice I just
want to see the dashing so you saw a
texture and a - stroke so that's pretty
cool
you define the shape and then you said
how to fill it how to stroke it and the
stroke really is in a way both a
geometry because you can do dashes and
things like that and a fill for that
geometry so that's pretty flexible and
all of the object API of course so go to
the next one I forget which we had sure
so this is a good one - I think they do
a good job of making them informative
and playful so the guy in the top left
is actually an animated gif that's why
he marches and so that's cool it's built
into the images if you draw any animated
gif you can put it into an image icon
etc they'll animate just kind of cool
but anyway once you yank those sliders
on the top right one there's some
built-in image operations - and they do
different kinds of operations on the
images you can do color mixtures and
some other things and so that's pretty
cool there's several built-in you can
define your own again - that's Britney
and then of course sort of I guess
that's some kind of sheer filter warp
image but it's doing some kind of shear
transfer matrix you know I think we had
one more right I'm just trying to stay
like scale lots of cover so we're just
gonna do a quick overview so here
there's another pretty big part of Java
2d and of course ports once you mess
with the scale shear and rotate and it
was all obvious if I'm just pointed out
so there's the scale of course this year
in the rotate these are all built in
they're all standard a standard PDF kind
of language there's a transform matrix
an affine transform three by two
just like in quartz just like instead of
other things it's great it's standard
because it's object API with garbage
collected objects you don't have to
worry about kind of things they have to
worry about the native API so I like
that
so also good news for us Mac os10 guys
the quartz engine does really well
against the other platforms and this
kind of stuff we've measured a lot
against Windows machines for these kinds
of Bezier animations and things and at
the high end we do really well with this
engine so really happy with that because
they did a lot of great work they're a
lot more knowledgeable than we are about
graphics and we were able to take the
Sun inch and put it aside and hook up to
the quartz engine instead and it was
really great so what you can yeah we can
go back to slides so um let me just
click over here yes so back to the Mac
os10 bonuses or so I started to cover
its courts it's not a ported used every
once in a while engine which as good as
x engine is that is what it is they
avoid using it whenever they can whereas
in courts actually it's the OS graphic
system so we have a lot greater fidelity
a lot more resources behind it and
that's really great for us Java guys
because as I said the smart guy is
working that in a graph a Nino's group
and they do all the hard work there so a
couple of things that I think are great
for us Java guys though is there's no
Rockport's function calling the other
ways to use courts always involve
calling C API s-- and pointers so we get
to avoid that we get the same fidelity
and all the same access to everything
and on top of it we get things like
compositing and strokes we get custom
things built in a Java that aren't
available in either API is that's that's
pretty cool so it's a real good one two
of the built-in apple technologies and
Java 2d printed PDF comes for free
that's pretty cool even if you don't
hook it up in some way in your app every
time you print as I'm sure most of you
noticed there's always that preview to
PDF in fact that's always generated so
there's always PDF there it's pretty
cool and then we'll go into more macro
stem bonuses in the third section
so this next section is on performance
its tips and techniques you can do and
there's some buddies that are really
important some of these are more nuanced
II but I think they're all worth
mentioning so the four major areas are
image creation that's actually one the
most important rendering hints double
buffering and live window resizing
so image creation the key high-level
message here is you want to use pretty
compatible image or the 1:1 create image
I'm going to show that in code in just a
sec but I also want to mention that
there's a whole pile of image types that
are really cool that we have now but the
fact is is we will optimize first for
the ones that are native on our platform
and so these aren't going to be
optimized for a first and importantly
there's sort of a little thing that all
of us do right is we we set up our app
and getting close to shipping and then
we want to squeeze a little extra
performance out of our app so usually
what I do is I rig up my performance
analysis tools either just timing or
some tool hopefully like we now we have
optimized in our platform and then I
look and see well where's my soft spots
right so um when I find something that
just feels slow I go work on it so one
of the things that people will do is
they'll go in here and say hey I'm gonna
Windows machine so BGR must be really
fast and sometimes it will be our
platform it won't be and I would really
prefer if you always called Crate
compatible image because we're working
really hard to figure out based on
what's going on underneath you to give
you the right stuff and if you're going
to do image manipulation via the pixels
directly I can totally understand where
you want to grab an a RGB or something
like that to make it simple the good
news is that one in particular is
actually a native image format anyway so
it'll be fast but if you're not doing
direct image manipulation it's best not
to guess just we're trying our best to
pick the right one so I think I said
that enough so I already do if we go to
demo 3
so we'll just do some little code
snippets let me just this is jbuilder
see just
there we go so I made the text a little
big so I'm not quite used to this way of
looking at code pretty clean yeah okay
so you see the F bad here this is the
tempting thing to do because the other
temptation of course this new API is
cool right so I want to use the new
stuff I don't use the old stuff but this
is the thing that well actually this
guess would be pretty good as I said
before I'd rather you didn't even hear
that it's better to do one of these two
things create image is actually the
easiest to use if you're in any
component you can always call create
image a lot of us spend all of our time
paying from components anyway but it's
also possible with this new API I'm just
gonna slide this over a little bit with
pretty compatible image what's
interesting about this is is that
graphics configurations are one of the
Sun objects that are available from any
graphics device you can print from
excuse me render to including printers
screens and off screens so wherever you
are you can always ask for the graphics
configuration you can always then ask it
for compatible image so again the idea
there is again it's a great hint for us
that's great that they built this into
the API because you've asked a
configuration that you're rendering to
for compatible image we can always make
a really good guess of what the best
thing is to do compatible will sometimes
mean faster sometimes it'll be higher
quality just depends so that's for us to
try to figure out
so that's it I don't think I need to run
the thing now I'll run it once each way
you see it everything works the same
this particular demo is meant to be
simple and not beautiful so excuse me
for my graphics very nice so the green
box is rendered I'll show you that in
the code see how we're we're filling
erect with green here and then we filter
the main screen with black and then we
draw the image to the main screen
typical double buffer only meant for
double for demo purposes we'll get into
why we shouldn't double buffer a minute
so just to be clear we can make bad true
I feel guilty even doing that and run so
now we're doing this we're making an
image again except that instead of
guessing we're being being maybe too
clever for ourselves and we're making
the image ourselves looks exactly the
same there should be but maybe too much
information so again just to reinforce
it's best to call create image or get
graphics configuration and create
compatible image so back to slides
that was the code so rendering hints
these are interesting and this is more
of a new once but as we move forward
we'll be taking advantage of these more
and more there hints and actually
they're in Sun abt which is one of those
interesting things about their api's but
their hints so we can't ignore them and
do sometimes but they are useful the
first and the last are for Speed
basically you can say speed or quality
or you can say default or I think
they're maybe don't care but the main
thing is is if you leave it alone we'll
figure try to figure it out if you
specify we may make a choice based in
your hand the next two the second third
anti anti-aliasing and text
anti-aliasing are hints but we actually
do use these right now as you guys know
we have really cool anti-aliasing on ten
including built-in to the quartz engine
primitive anti-aliasing will do our best
job to give you that and the defaults on
ten is anti aliasing on that's different
than our Windows or on Solaris that's
because here at Apple we like smooth
graphics so you can turn those on and
off by using those and we'll go to code
in just a sec but first all the scrubber
these real fast
fractional metrics is a hint that you
can specify if you want us to depending
on the situation try to render text with
sub pixel positioning for the glyphs so
that means we'll try to do a better job
of bringing the cliff's closer together
again that's quartz technology that we
sit on top of but that's what that hands
for and the next three are for
controlling when we render images
there's different things that rendering
systems will do to again make it look
really good versus going faster those
three hints will let you hint us to do
either one or the other speed or quality
so if we go back to demo three
okay so let me get organized so what we
did here was sorry it just indenting is
a little weird what we did here was we
just drew two lines and I just wanted to
show you the anti-aliasing can't four
primitives I'm just gonna run that it's
gonna build it I love the speed here
this is what we use every day because
the productivity so anyway so there's
one line that's anti-alias in one line
that's not I just want to show how that
hint worked and so I'll flip the thing
off we'll see it the other way and then
I'll just delve into the hints here
while I'm here because JBL that provides
a good assist for this particular thing
so I'll flip this off oops oops I think
I do bugged stopped it
okay so here's running and so now
they're both Antilles so that's great so
the hint actually does work but what I
want to show you which is this is a
great feature of JBL they're not giving
it a blow demo but it's just perfect for
this so so let's say I want to do a
different can't I'm just gonna copy this
and oops so be there in a sec so I'm
just gonna hit dot here so here's all
the Sun hands right here and so you know
here's the different keys so we got you
know color rendering default quality
speed as I mentioned before dithering
sectional metrics interpolation for this
is when we lit images how we do the
pixel smoothing so there's a rendering
quality speed stroke it's a whole bunch
of them so that's really cool though
easy way to demo the hints to show you
that there are quite a lot of them
ignore most of now but we will be I am
as we go as I said we definitely do the
anti-aliasing one so I'm going to put
that back in and then do all this grab
all this
so again just like it the other one did
gonna and pick a key that goes with it
just to be real clear because this line
of code is pretty long all this comes
down to is key value pair there's the
key and here's the value the Sun hand
stuffs a little bit weird and that it
makes you just get key thing but the
main thing is is that you know you've
got your key there Ann Taylor saying and
then you you're saying off so great so
hope that was cool
so I can go back to slides
so there's rendering it's
again anti-aliasing and text
anti-aliasing I should just point this
out I'm some of the old one o applets
like though there's an old clock as a
second hand that sweeps does the erase
with white or draw myself again with
white to erase on tend s cube that
leaves a blur trail and that's because
10 anti-aliasing is I'm gonna default
wearing other platforms it isn't and
when you do erase with white on top of
an of let's say a draw with black let's
say of an anti aliased line you don't
get coverage over all the pixels so it
doesn't just stamp it all out so because
of that you'll leave trails if you use
that technique the graphic systems are
pretty fast today so we get more into
that a minute as I was saying but so I
would recommend not using that technique
for rendering anymore that was something
we did in the old days so so double
buffering this is important we mentioned
this last year and but I want to
emphasize it because there's another
trick that we were able to do under the
covers that again we'll talk about in
the third section that became possibly
because of this so the deal is is that
on Mac OS 10 double buffering is taken
care of by the operating system as you
guys know swing is double buffered as
well what we do to swing is we rip up
rip out it's double buffering and we
make it draw directly to our OS double
buffer instead so as far as swing is
concerned is drawing directly to screen
your code will still look like it's
drawing double buffered because we
manipulated this the swing state so that
it says what it does which is that it is
double buffered even though the double
buffering is implemented differently
underneath then we tell the internals of
the swing code that were single buffers
that if they don't create images
everywhere not a big deal from your
level and the jck also agrees that we're
a double buffer like we're supposed to
be so that's good everything works the
same the difference is though is because
it's an OS double buffer we get two
things the first thing we get is that
the quartz engine does dirtiness for
dirty region detections detection excuse
me so that means is that when you're
rendering disparate parts in the screen
we won't just flush the whole thing to
the screen will actually flush minimal
sub sections as
you draw so that's much better and that
way you're not just pumping the bus with
a bunch of data so as I said we take
care of swing a lot of people did double
buffering in Java out of Swing it's
really important that you examine your
code and get rid of that because your
triple buffered right now that's a
memory thing which as all of us know
memories the biggest thing to deal with
in Java we don't want to be any bigger
than we have to be and especially with a
real virtual machine underneath us in a
real virtual memory system underneath
that memory can be kind of a sketchy
thing when you're always going to have
the right amount what you don't want to
do is triple buffer for performance and
then use all that extra resources and
end up hit in the disk so that's bad so
that's cool I'm not good at this
I think it turned around so anyway next
thing is light wintry sizing we have
that on as a feature for 10:00 it's as
much a feature for you guys as a feature
for us we do our job in our apps and in
our services to make this as easy as
possible but certainly it's true that if
your main panel takes six seconds to
render it's not gonna be live so I'm
just pointing this out because it's
different than other platforms of course
if you're doing a big complicated scene
like maybe a terrain render or something
you can do a simple quick pass or you
can keep the thing from last time and
stretch it or something there's a lot of
games you can play but certainly the Mac
OS users are gonna be interested in
having that actually be live they're
actually going to pull it and because it
doesn't do the wireframe stuff you're
actually gonna your apps gonna feel
funny there's on nine right it's not
live so it doesn't matter if you take it
matters but it matters less because you
pull it and when you release it redraws
so now you're yours to be constraining
your users window resizing so a few more
this came up in our list I want to point
out all graphics objects are created
equal
every graphics object is the same class
in the system there are all 2d objects
doesn't matter where you get them they
have different different implementation
plugins underneath that's all invisible
to you and there's really no way for you
to affect that so every graphics object
can be cast into a graphics 2d again
that came up in the list that's why I'm
mentioning it also the more complicated
the clip the slower the graphic speed
that'll become really apparent in a sec
but I hope it makes sense actually just
to be real clear the other UI frameworks
always use the painters algorithm which
is the drama guys who are my parents
first draw the children last so they
don't have to deal with clipped
rendering and swing does that as well
swing is like power plant mac app and
cocoa they all do the same thing they
use the painters algorithm a DBT for
reasons long complicated reasons some of
which I agree with some of which I don't
has thread-safe
pree clipped rendering so you can
actually just to be real clear you can
stick to heavyweight buttons in a parent
view and make three threads and have
them all render and new the children in
the parent all at the same time and will
clip it all for you and make everything
work it won't always be fast though so
it's better to watch the clip don't draw
through too much clip watch out for
Timmy repaints - no that's obvious but
we all know of many examples where we're
paying way more than we need to
and especially with double buffering
because there's not as much flicker you
tend to maybe miss them so certainly we
have that's one of things that we're
always working on - so so last thing of
course is profile then cash the
expensive stuff find metrics is one of
those ones that's been around for a
while if you have one of those
complicated views I don't recommend
double buffering but I could imagine in
some read cases you would do that just
because you've got one piece of thing
that you just want to render for an
example maybe you want to do a really
beautiful icon that has a piece of
artwork and maybe some tags on top so
like what mail does they put that stamp
on top with a little 5 or whatever mail
messages you have maybe you want to do
that and then throw that into an image
because you just don't want to have that
code execute that's one way to save
yourself from some computational time so
those are all things you can do
so this is the third section so that's
it for our tips and techniques for now
this is really exciting this is our new
update and it's momentarily available as
a dr release DP release Developer
Preview and we're really excited about
this we've been working really hard this
fall excuse me this spring seems like
your goes by really quick I guess this
spring and and a lot of this stuff that
we really wanted to get into Mac os10
final has been made in here and we're
really excited about it three things
cutting-edge technology which you'll see
in a sec much better correctness we've
been working very hard with our partners
to iron out our wrinkles that we have in
Mac OS 10 final and then performance
performance has been a big deal the
update is live now yay
[Applause]
so that's great to hear
so this is some of the things that we
concentrate on the update heavyweight a
DBT was a big thing that we had an issue
with I feel for Mac os10 final
specifically properly rendering deep
hierarchies of heavyweight AWT panels
etc with card layouts etc we worked
really hard to get those bugs ironed out
and I think you'll be pretty happy with
how far we've come
swing we've made a lot of progress Liane
Rucker is a person who is a Sun employee
who works on our campus and bleeds the
rainbow colors to think more than we do
and she's been working very very hard at
making our aqua look and feel really
amazing so that's really great you'll
see some of the results of that in a
little bit printing works much better
all the image formats will be supported
when we ship we made some progress in
there this update they're not all in
they will be in when we ship those are
those ones I was mentioning earlier
we'll get to those real soon and we've
wiped out a whole bunch of bugs we're
really interested in your feedback on
this release because we're gonna push
real hard to get the rest of the mail so
more on the update no here we go the
demo so what we're gonna show you here
is a side-by-side before he starts it
we've been working really hard to
Hardware accelerate Java graphics so
what you'll see is a before and after of
the hardware acceleration so dry once
you do the software first and we just
did some I just picked an image off my
disk but what we did here this is
important is as we'll talk about more in
a minute we've picked the primitives
that are used a lot in new wise here for
our testing and this is actually a
result of a piece of code that we had
for doing profiling so we did as you may
be able to see in the screen we did
images rectangles lines and glyphs
glyphs being text those are the four
most important things in the UI so
what we're what's important to me and
those of us who can work on my hardness
is that this is actually what's
important for UI rendering so now we can
do the hardware so so 10 times faster in
text lines I'm not even sure what that
ends up being that's looks like a
hundred times faster for rectangles
we're talking ten times images we're
talking more like it's a big number to
two hundred probably that's possible
because of the stuff we'll talk about a
minute and it'll become more apparent
over where that performance comes from
so when I hit the hardware one one more
time just case they missed it great okay
cool so let's go back to slides right
yeah better slice some we'll talk about
how we did that and why it cetera so
first of all here's the other number
that's interesting this is the caffeine
mark for Mac OS 10 we went from being
kind of slow to pretty competitive and
this is really exciting
we're the only platform with hardware
accelerated swing that's because of the
double buffering thing I talked about
earlier the reason why is that because
we removed the double buffer from swings
code where they actually allocate an
image and then render to it and we use
the OS then over the summer in the fall
in the spring took us a while to get
this all worked out we switched to a
hardware buffer so our hardware pen can
render and do the back buffer so you get
the advantage of a double buffer where
you don't get to flicker all that stuff
but you also get the advantage of
hardware pen so
who worked very closely with Peter
Griffin who knows courts team on this
they were very very helpful and in fact
we went to SIGGRAPH than last year and
started talking about this over
interesting New Orleans drinks and he
had a base plan then and started talking
about the house to do this and then we
started designing an architecture that
would handle the kind of things we need
to do here
so of course double buffering as I
mentioned so this is what we've done
this is sort of the details all
primitives are hardware accelerated but
that means there's lines rectangles
ovals recent event all those things that
you do there are the methods hanging off
the graphics object they're all hardware
accelerated 95% of all text rendering
was hard work celebrated and I'll talk
more about that in a minute
I say 95 because we will back down on
either hard ligature cases for
nationalised text or very large fonts
that's because we build Hardware caches
envy RAM for our glyphs and so we don't
want to build hardware caches with fonts
that are this big right that would be a
really big hardware cache so we've
backed down in those cases and general
path tessellation is being done right
now that's really cool because
especially for political shapes and then
moving towards the general path cases
we'll be able to Hardware accelerate
those too so that's I'm really excited
about that because I think it'd be great
if we had the the Java 2d API and all
the power gives you in terms of being
able to specify really great things
visually and actually have that Hardware
celebrated that would be a sort of a
first-in object api's so and then
hardware double buffering as I mentioned
when the fourth one is very important
this is actually our biggest sweet spot
we uh play upload all static images and
even have image dirtiness detection in
there so as long as you don't grab the
pixels directly we will we can tell if
you rendered to an image recently and we
will only upload on demand as you've
dirtied the pixels so lets us do is keep
our bus traffic to a minimum and draw
basically blit images from vram to view
that's what the cards are really good at
so you get optimal performance that's
why we get 200 400 times you'll see some
more demos in a sec difference in
artwork rendering that's really
important because although it does make
good demos it also speeds up your UI and
I know some of you probably saw the J
builder before and after where he showed
that he could slide the slider back and
forth what was cool about that was that
the way swing implements the slider is
actually repaints the entire view on
each side of the slider so when we
accelerate that and it's that much
different that means we basically
accelerated the whole UI by that amount
so it's not some simple blip it's not
like a scrolling operation and that's
because when you have separators like
that they could choose to scale their
content based on size they don't have to
slide it out of the way so that's really
important we may go over that again in a
minute too so the reason why we did this
we took careful measurement profiling
typical apps with our profiling tools
last summer and we built prototypes in
the summer and basically posts the new
orlean sig graph we built prototypes
with the guys on the quartz team and
then based on that information took some
other easy wins and try to find out if
we could actually do this that point we
are connected the graphics subsystem so
that we could plug in separate engines
and I'll get into that in a sec and then
started profiling our UI rendering
system because if you want to seriously
render UI you have to let it have access
to the hardware pen as well
so we'll get that too in a sec - we did
a project plan in fall so here's the new
Java 2d implementation the main things
to notice are there's sort of two things
I want to talk about here first is that
from your java app you basically talk to
sort of the graphic system you've always
dealt with but then what we do
underneath is we plug in different pens
based on what surface you're rendering -
so we've got a printer pen on one side
we've got the hardware pen the other
Bringer pen generates PDF Hardware pen
generates calls to the hardware cards
and then the guys in the middle do the
stuff that actually very similar to the
printer pen that they generate PDF like
stuff and renders do those surfaces
that's very important because we manage
the graphic state separately from the
actual rendering so that we can switch
pens on the fly and that we can pick the
right tool for the job and then the
middle section is very important too as
I was mentioning static images are
cached in hardware and glyphs are as
well because lifts are really images
right what we do is we we pre render our
text using quartz into a hardware cache
and then we use the engine to blit it to
the screen on demand so it's in effect
another hardware cache just like an
image and we try to manage that as well
as we can so your images are hot so that
your UI renders quick and then the
primitives as quickly as possible in the
screen case get to the hardware pen and
execute card calls so that's that if you
have questions about that we can talk
about that in QA
so this is the second part of the piece
and after we built the first part we ran
into a lot of profiling with really fast
custom views I'll call them like the
views that you guys were working on
right not the buttons not the slider is
not the white and white stripes but your
code was actually wearing them really
fast now we could render you know lots
and lots of polygons per second but
without this work we couldn't render our
UI fast enough to keep up so within the
spring remodulate our GUI rendering
subsystem to use a hardware pen for 85
to 95 percent of all aakula can feel and
our peers through the hardware pen as
well so that we can sell our UI i'm
leanne rucker again is checked in
thousands and thousands of lines of code
in this area it's pretty amazing and so
now we have two tools we can use for
rendering our UI carbon in our
lightweight renderer that uses our
hardware pen
so this is where I my other tips and
techniques thing which is great for a
lot of reasons I know it's always been
true in the past that a DBT was the
fastest way to do stuff on your
platforms but as of now a Mac os10 swing
will always be the fastest GUI framework
to use for Java it will always be faster
than a WT the reason why is because we
put a hardware surface across the entire
window and render with the hardware pen
basically always if swing is active we
will turn our hardware pen off very
quickly if a DBT is active only real
simple hierarchies will work that gets
back to the clipping thing we follow up
very quickly if the clip gets
complicated because Hardware surfaces
are rectangular so we're sort of that's
just how it is
I think the good news is that swing is
really fast and it's very competitive
with any other swing of implementation
anywhere the bad news is that a DBT
won't be accelerated that way it's just
not much we can do there so that's
pretty important certain will always
work best first because again the
rendering path is very simple it's
painter algorithm like the other your
wife frameworks and the state is much
easier to manage it's a much richer UI
framework so there are some serious
advantages to using it over a bt I think
you guys all know that but what's cool
is now it's actually the faster one too
so and they used the same rendering
layer for the widgets as a DBT does so
in almost all cases you'll be calling
the same rendering code anyway so
there's not really much point to using
the peers so I'm just get show an
example of that
yes it is ok so this is a little sneak
preview of what will happen next this is
a piece of code and it's a swing yet
that I built and jbuilder using their
wizards and I'm just gonna cheat and
just go like this you think you can see
my cursor I'm gonna take this J panel
make into a panel and I'm gonna run
did I hit right yeah the image will take
a set it's a this images 11 megabytes
uncompressed and so if you how many of
you recognize this image but one of the
hardware acceleration talks was using
this yesterday so we thought it'd be
cool to use it too anyway this is with a
heavyweight peer sitting in the middle
so you know it feels kind of fast maybe
it's so hard to know what these kind of
demos and so you see the before and
after so what I'll do is stop it and
you'll see what it's supposed to be
doing so now I'm gonna go back here and
all this do one do yep just sec where'd
that go
so again all I did here was I just made
it back in a swing panel so that means
it'll be a normal swing set up the frame
that contains it as a jframe it's a
swing frame in this image panel which is
real simple piece of code is a J panel
so that's normal swing so now you'll see
how it's supposed to work
oops so this is what your expects
and this is what you saw yesterday at
the hardware acceleration demo big image
took a sec to load you see the CPU it's
busy boy it'll be a sec here
I guess
there goes so a little bit better so I
know that's sort of cheating because I
took a swing up and made it into an ad
BT up and then turn it back so that's
obviously if you have a TB TF so you
have a lot more work to do
but the point is there is light at the
end of the tunnel you do get speed out
of it in addition to all the additional
functionality so I think that's pretty
good reason to think about it anyway
back to slides oh whoops
how did I do that
okay so actually we're gonna go over our
next demo come on Scott and forgot this
is the surprise demo which is why I was
surprised - so this is what happened
yesterday we saw the hardwork
celebration demo and we thought it was
really cool
they showed that 11 megabyte 2500 or so
by 1500 pixel image that's what we're
just rendering that fast being rendered
very fast by hardware so we thought
really cool we'll do that too so we
rigged that up and then about 10:30 last
night which is why we look a little
tired we thought well geez actually we
have a 1.7 gigahertz p4 in our office so
why not see how fast it does that the
same thing so this isn't a benchmark
this is just we had a machine and we
said well let's rig it up so Scott's on
a Dell 1.7 gigahertz oh yeah can we
switch to the demo machines the split
will go back to them and so Scott's on a
1.7 gigahertz you got Mike you can talk
about
256k of RAM and upfront is the mic
working number three okay well why don't
you it's Michael go okay great so here
we've got approximately one six nine
five megahertz on this guy and we just
got this on like Friday so yeah that's
the reason why don't you think to it
this is doc its NVIDIA GeForce -
something like that yeah
and Gerard has we didn't think it'd be
fair to take our top of the line so we
took Gerard's office machine so my
apologies that his office and machine
isn't the top of the line but anyway
it's a what's the megahertz in this drug
450 megahertz so four hundred fifty
megahertz g4 with 256 megabytes of
memory and again with the same kind of
code I just showed you and so we'll do a
little bake-off here which one are we
doing first okay okay bet you count off
okay on three one two three
[Music]
we're getting I'm getting about blazing
seven point three seven point seven
frames per second he's never 305 go
ahead dry I'm waiting around 300 frames
per second
well 400 you I do your other all right
we can add to the rotation or stop and
go let's stop that that's the rotation
we said it and let's turn on zooming one
two three
it's not really fair so what this
demonstrates is that there's an
architectural performance issue here
because we use a static image VRAM
upload we can actually deal with very
large images very effectively there's
very little bus traffic going on and
because the hardware cards do this kind
of operation natively we take advantage
of them the other implementations may do
that someday but we're doing it now John
yeah we have one more thing one day you
go ahead sorry to surprise
we developed this actually on John's
power book and Gerard wanted to show you
guys this is because you know we're
running on this really cool machine I
think it has like a video card but
that's the rage 128 mobility and you can
see the the frame rate is almost
identical what can you monitor the frame
rate is almost 500 frames per second and
this is really early what we're getting
out of this thing right it's not
dependent on having its you can you see
it no it's it's the same demo
so this is architectural performance as
I said our software's built differently
it's optimized because of the engines we
have underneath us on Mac OS 10 and
because of that optimization we make it
a fair race our CPU and our graphics
card work really well together and
that's just how it goes on that coast
and so that's it for the demos and just
want to close with the slide so sort of
three things the promise of Java and Mac
OS 10 of course you just saw performance
we have an object framework access to
courts that's really cool you've got
easy objects to use to a great courts
API
you've got swing which is a very rich
cross-platform UI framework code runs
anywhere so we'll go to Q&A we'll take
any questions oh here's our roadmap
sorry I'm so we have two more things in
Java Scott Co batch has given a great
job security talk tomorrow I think
that'll be really interesting and then
we've got our feedback form so you can
ask us about all those things you're
still interested in
[Applause]
you