CALayer scale transform

2008-06-11 Thread Brian Christensen
Is it expected behavior that when applying a CATransform3DMakeScale()  
transform to a CALayer the layer's current bitmap information is what  
gets scaled (using some type of filter) rather than asking the layer  
to actually redraw itself into the, presumably, freshly transformed  
context? Currently applying a scale transform appears to result in  
unacceptable pixelation.


Here is an example:

_textLayer = [[CATextLayer alloc] init];

[_textLayer setFrame:CGRectMake( 300.0, 300.0, 1000.0, 36.0 )];
[_textLayer setString:@Hello world];
[_textLayer setTransform:CATransform3DMakeScale( 1.5, 1.5, 1.0 )];

This will scale the text up to 1.5x its size, but the result is  
essentially useless. It becomes even more pronounced if I set the  
minification/magnification filters to nil:


[_textLayer setMinificationFilter:nil];
[_textLayer setMagnificationFilter:nil];

I can't seem to find anything in the documentation on this behavior.  
The relevant sections discuss it as transforming a layer's geometry.  
Maybe I'm not understanding something fundamental, but I would have  
figured that a geometry transform wouldn't simply stretch the existing  
device pixel based bitmap content using minification/magnification  
filters to fit into the newly scaled unit size (at least, from my  
understanding, this certainly isn't how a transform applied to the  
drawing context would cause regular Cocoa drawing to behave). I can  
understand this being done if the layer content is a bitmap image to  
begin with, but I certainly wouldn't expect this to be the case for  
text.


Can anyone shed any light on this?

/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CALayer scale transform

2008-06-11 Thread David Duncan

On Jun 11, 2008, at 8:56 AM, Brian Christensen wrote:

Is it expected behavior that when applying a  
CATransform3DMakeScale() transform to a CALayer the layer's current  
bitmap information is what gets scaled (using some type of filter)  
rather than asking the layer to actually redraw itself into the,  
presumably, freshly transformed context? Currently applying a scale  
transform appears to result in unacceptable pixelation.


This is expected behavior.

I can't seem to find anything in the documentation on this behavior.  
The relevant sections discuss it as transforming a layer's  
geometry. Maybe I'm not understanding something fundamental, but I  
would have figured that a geometry transform wouldn't simply stretch  
the existing device pixel based bitmap content using minification/ 
magnification filters to fit into the newly scaled unit size (at  
least, from my understanding, this certainly isn't how a transform  
applied to the drawing context would cause regular Cocoa drawing to  
behave). I can understand this being done if the layer content is a  
bitmap image to begin with, but I certainly wouldn't expect this to  
be the case for text.



Effectively a CALayer represents a texture with the layer's contents  
on the video card. As the docs say, transforms only affect geometry.  
The texture does not include geometry, thus the current content is  
scaled rather than being re-rendered. At even moderate zoom factors  
scaling the content could cause issues with maximum texture sizes on  
the video card your running on.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer scale transform

2008-06-11 Thread Brian Christensen

On Jun 11, 2008, at 12:37 , David Duncan wrote:

Effectively a CALayer represents a texture with the layer's contents  
on the video card. As the docs say, transforms only affect geometry.  
The texture does not include geometry, thus the current content is  
scaled rather than being re-rendered. At even moderate zoom factors  
scaling the content could cause issues with maximum texture sizes on  
the video card your running on.


I see. Thanks for the explanation. My solution will then be to simply  
maintain my own scaleFactor and apply that to my drawing calculations  
in place of a transformation (or in the case of a text layer, simply  
fontSize * scaleFactor).


/brian



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CALayer scale transform

2008-06-11 Thread Jens Alfke


On 11 Jun '08, at 9:37 AM, David Duncan wrote:

Effectively a CALayer represents a texture with the layer's contents  
on the video card. As the docs say, transforms only affect geometry.  
The texture does not include geometry, thus the current content is  
scaled rather than being re-rendered. At even moderate zoom factors  
scaling the content could cause issues with maximum texture sizes on  
the video card your running on.


Are all layers treated as bitmap textures, even solid ones? For  
instance, if I create a 1024x1024 layer as a background and just set  
its background color to blue, does that allocate a megapixel's worth  
of VRAM? What about if I add a border or round corners?


I've wondered about this with the Grid class in GeekGameBoard, which  
is used to represent things like chess or Go boards. Is it better to  
use one big layer with a custom drawing proc that draws the squares,  
or 64 (or 324) smaller layers?


(I've seen some bad CA performance problems on, um, systems with less- 
capable graphics hardware than the average Mac, which make me wonder  
if I need to rethink some of the design.)


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: CALayer scale transform

2008-06-11 Thread John Harper


On Jun 11, 2008, at 12:39 PM, Jens Alfke wrote:

Are all layers treated as bitmap textures, even solid ones? For  
instance, if I create a 1024x1024 layer as a background and just set  
its background color to blue, does that allocate a megapixel's worth  
of VRAM? What about if I add a border or round corners?


Layers only use textures / VRAM for the images or drawn content you  
provide. None of the other features (background color, border color)  
use any texture memory. (Colors that are patterns allocate a texture  
for the single image cell in the pattern, but not for the layer size.)




I've wondered about this with the Grid class in GeekGameBoard, which  
is used to represent things like chess or Go boards. Is it better to  
use one big layer with a custom drawing proc that draws the squares,  
or 64 (or 324) smaller layers?


For small checks a single layer with a pattern-based background color  
would be best. For large checks multiple layers may be more efficient.  
The best way to investigate this kind of thing is via the OpenGL  
Driver Monitor application, you can use it to display the amount of  
free VRAM over time,


John


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]