• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hardware-accelerated scaling on iOS without OpenGL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hardware-accelerated scaling on iOS without OpenGL


  • Subject: Re: Hardware-accelerated scaling on iOS without OpenGL
  • From: David Duncan <email@hidden>
  • Date: Fri, 25 Nov 2016 13:21:52 -0500

The transform is a reasonable way to go. You can also change the contentMode to get scaling for free. Fundamentally this all ends up as a texture draw on the GPU so how you get the geometry for the draw there is nearly irrelevant.

The major performance gain from OpenGL (or Metal) in this case is that you can avoid an additional buffer copy and composite on the way to the display in many circumstances. This may not be significant in your case however.

--
David Duncan @ My iPhone

> On Nov 25, 2016, at 11:38 AM, Andreas Falkenhahn <email@hidden> wrote:
>
>> On 25.11.2016 at 16:29 David Duncan wrote:
>>
>> The fastest method without OpenGL is to work with CGImage directly
>> and assign the image as the contents of a CALayer.
>
>> This will engage CoreAnimation to use the hardware to scale the
>> image, but is still not quite as fast as OpenGL for the same task.
>
>> Roughly you'll want to look at CGImageCreate and
>> CGDataProviderCreate (there are a number of variants of the latter).
>
> Thanks, I've just tried this and the performance seems reasonably well.
> I don't know how fast direct OpenGL would be but it looks like the
> CALayer approach is already sufficiently fast enough.
>
> But just to make sure I implemented this in the right way: Assigning the
> image as the contents of my view's CALayer means that I shouldn't draw
> in drawRect() at all but just do the following whenever I need to draw
> a new frame:
>
>    myImage = CGImageCreate(...);
>    view.layer.contents = (id) myImage;
>    CGImageRelease(myImage);
>
> Is that right? I have to create a new CGImageRef for every frame I draw
> because CGImages are immutable objects, right?
>
> And to scale the whole shebang from 320x240 to full screen I just set
>
>    view.transform = CGAffineTransformScale(CGAffineTransformIdentity, scalex, scaley);
>
> Or is there a better way to force a view into full screen by scaling?
>
> --
> Best regards,
> Andreas Falkenhahn                            mailto:email@hidden
>

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


References: 
 >Hardware-accelerated scaling on iOS without OpenGL (From: Andreas Falkenhahn <email@hidden>)
 >Re: Hardware-accelerated scaling on iOS without OpenGL (From: David Duncan <email@hidden>)
 >Re: Hardware-accelerated scaling on iOS without OpenGL (From: Andreas Falkenhahn <email@hidden>)

  • Prev by Date: Re: Hardware-accelerated scaling on iOS without OpenGL
  • Next by Date: How to detect rotation in progress in viewDidLayoutSubview
  • Previous by thread: Re: Hardware-accelerated scaling on iOS without OpenGL
  • Next by thread: How to detect rotation in progress in viewDidLayoutSubview
  • Index(es):
    • Date
    • Thread