src/render/metal/SDL_render_metal.m
changeset 12320 758d4e1222a7
parent 12179 c06be57c5a01
child 12322 b5074e5aaa49
equal deleted inserted replaced
12319:06e89f1159f9 12320:758d4e1222a7
   750 }
   750 }
   751 
   751 
   752 static void
   752 static void
   753 METAL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
   753 METAL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
   754 {
   754 {
   755     if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
       
   756         METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
       
   757         data.mtllayer.drawableSize = CGSizeMake(event->data1, event->data2);
       
   758     }
       
   759 
       
   760     if (event->event == SDL_WINDOWEVENT_SHOWN ||
   755     if (event->event == SDL_WINDOWEVENT_SHOWN ||
   761         event->event == SDL_WINDOWEVENT_HIDDEN) {
   756         event->event == SDL_WINDOWEVENT_HIDDEN) {
   762         // !!! FIXME: write me
   757         // !!! FIXME: write me
   763     }
   758     }
   764 }
   759 }
   846         mtltexdesc.pixelFormat = MTLPixelFormatR8Unorm;
   841         mtltexdesc.pixelFormat = MTLPixelFormatR8Unorm;
   847         mtltexdesc.width = (texture->w + 1) / 2;
   842         mtltexdesc.width = (texture->w + 1) / 2;
   848         mtltexdesc.height = (texture->h + 1) / 2;
   843         mtltexdesc.height = (texture->h + 1) / 2;
   849         mtltexdesc.textureType = MTLTextureType2DArray;
   844         mtltexdesc.textureType = MTLTextureType2DArray;
   850         mtltexdesc.arrayLength = 2;
   845         mtltexdesc.arrayLength = 2;
   851         mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
       
   852     } else if (nv12) {
   846     } else if (nv12) {
   853         mtltexdesc.pixelFormat = MTLPixelFormatRG8Unorm;
   847         mtltexdesc.pixelFormat = MTLPixelFormatRG8Unorm;
   854         mtltexdesc.width = (texture->w + 1) / 2;
   848         mtltexdesc.width = (texture->w + 1) / 2;
   855         mtltexdesc.height = (texture->h + 1) / 2;
   849         mtltexdesc.height = (texture->h + 1) / 2;
       
   850     }
       
   851 
       
   852     if (yuv || nv12) {
   856         mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
   853         mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
       
   854         if (mtltexture_uv == nil) {
       
   855 #if !__has_feature(objc_arc)
       
   856             [mtltexture release];
       
   857 #endif
       
   858             return SDL_SetError("Texture allocation failed");
       
   859         }
   857     }
   860     }
   858 
   861 
   859     METAL_TextureData *texturedata = [[METAL_TextureData alloc] init];
   862     METAL_TextureData *texturedata = [[METAL_TextureData alloc] init];
   860     if (texture->scaleMode == SDL_ScaleModeNearest) {
   863     if (texture->scaleMode == SDL_ScaleModeNearest) {
   861         texturedata.mtlsampler = data.mtlsamplernearest;
   864         texturedata.mtlsampler = data.mtlsamplernearest;