Drawable size of MTKView

I have a MTKView as a document view of NSScrollView. Whenever i check the drawable size of this metal view , i am getting twice the size of the metal view. For a metal view of size 1000x1000, drawable size is 2000x2000. Why it is so? What is exactly the so called 'Drawable'.? Thanks in advance.

Answered by Graphics and Games Engineer in 743657022

The drawable is a texture (aka surface) provided by CoreAnimation which can be rendered to by Metal and displayed in a view. (You can render to an offscreen texture by creating your own texture with the Metal API).

The size of a view's frame is in points not pixels. With a retina display there can be many pixels per points. The idea of points is mostly a concept to simplify UI design and the ratio of pixels to points can change from device to device depending on the display resolution and size. By default, the MTLView's drawable is 1 screen pixel per 1 drawable pixel so there is no scaling of your drawable when it's presented on screen However, if you want to render at a lower resolution and let CoreAnimation scale up your drawable, you can increate the view's contentScaleFactor or you can just set your own drawableSize.

Accepted Answer

The drawable is a texture (aka surface) provided by CoreAnimation which can be rendered to by Metal and displayed in a view. (You can render to an offscreen texture by creating your own texture with the Metal API).

The size of a view's frame is in points not pixels. With a retina display there can be many pixels per points. The idea of points is mostly a concept to simplify UI design and the ratio of pixels to points can change from device to device depending on the display resolution and size. By default, the MTLView's drawable is 1 screen pixel per 1 drawable pixel so there is no scaling of your drawable when it's presented on screen However, if you want to render at a lower resolution and let CoreAnimation scale up your drawable, you can increate the view's contentScaleFactor or you can just set your own drawableSize.

Drawable size of MTKView
 
 
Q