summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb/video_layer.swift
Commit message (Collapse)AuthorAgeFilesLines
* cocoa-cb: generalisation of backend independent partsder richter2020-08-221-323/+0
| | | | | | | | | | | | | move all backend independent code parts in their own folder and files, to simplify adding new backends. the goal is to only extend one class and add the backend dependent parts there. usually only the (un)init, config and related parts need to be implemented per backend. furthermore all needed windowing and related events are propagated and can be overwritten. the other backend dependent part is usually the surface for rendering, for example the opengl oder metal layer. in the best case a new backend can be added with only a few hundred lines.
* cocoa-cb: add support for forcing the dedicated GPU for renderingder richter2020-01-261-2/+9
| | | | | | | | this deprecates the old cocoa backend only option and moves it to the general macos ones. add support for the new option in the cocoa-cb layer creation and use the new option in the olde cocoa backend. Fixes #7272
* cocoa-cb: remove get_property_* usages and split up mpv helperder richter2019-10-061-27/+26
| | | | | | | | | | all the get_property_* usages were removed because in some circumstances they can lead to deadlocks. they were replaced by accessing the vo and mp_vo_opts structs directly, like on other vos. additionally the mpv helper was split into a mpv and libmpv helper, to differentiate between private and public APIs and for future changes like a macOS vulkan context for vo=gpu.
* cocoa-cb: add support for 10bit opengl renderingder richter2019-09-261-19/+38
| | | | | | | this will request a 16bit half-float framebuffer instead if a 8bit integer framebuffer. Fixes #3613
* cocoa-cb: remove an unused variableder richter2019-09-021-1/+0
|
* cocoa-cb: remove all force unwrappings of optionalsder richter2019-04-251-94/+113
| | | | | | the force unwrapping of optionals caused many unpredictable segfaults instead of gracefully exiting or falling back. besides that, it is bad practice and the code is a lot more stable now.
* cocoa-cb: simplify CGL pixel format creationAkemi2019-04-021-57/+75
| | | | | | | | | | | | | | | i found the old pixel format creation a bit too messy. pixel format attribute arrays and look ups were all over the place, the actual logic what kind of format was created was inscrutable, the software pixel format was hardcoded and no probing was done. i split the attributes into mandatory and optional ones, one mandatory for a hardware and software pixel format each, and moved those to the top of the class. that way new attributes can be easily added to either the mandatory or optional attributes and they don't mess up the actual pixel creation logic any more. furthermore both hardware and software pixel formats are being probed the same way now. to minimise code duplications the probing was moved into its own function.
* cocoa-cb: synchronise the flush with the renderAkemi2019-04-021-3/+2
| | | | | | | this could lead to a crash on deinit when flush was called while the opengl state was cleaned up. Fixes #6323
* cocoa-cb: add logging for CGL pixel format attributesAkemi2018-11-131-0/+19
| | | | | | | | depending on the capabilities of the system and testing of various attributes the resulting CGL pixel format can change. due to that probing it can be helpful to know which pixel format is used to create the CGL context. added some verbose logging that outputs final pixel format.
* cocoa-cb: use libmpv's advanced rendering control and timingAkemi2018-11-131-27/+13
| | | | | | | | this adds support for GPU rendered screenshots, DR (theoretically) and possible other advanced functions in the future that need to be executed from the rendering thread. additionally frames that would be off screen or not be displayed when on screen are being dropped now.
* cocoa-cb: add Apple Software Renderer supportAkemi2018-09-301-2/+27
| | | | | | by default the pixel format creation falls back to software renderer when everything fails. this is mostly needed for VMs. additionally one can directly request an sw renderer or exclude it entirely.
* cocoa-cb: fix building with Swift 4.2coverity_scanAkemi2018-06-121-1/+1
| | | | | | | | | init is a reserved keyword and Swift 4.2 got a bit stricter about using it. this could be fixed by adding apostrophes around init but makes the code uglier. hence i just renamed init to initialized and for consistency uninit to uninitialized. Fixes #5899
* cocoa-cb: remove pre-allocation of window, view and layerAkemi2018-06-121-18/+12
| | | | | | | | | | | the pre-allocation was needed because the layer allocated a opengl context async itself and we couldn't influence that. so we had to start the core after the context was actually allocated. furthermore a window, view and layer hierarchy had to be created so the layer would create a context. now, instead of relying on the layer to create a context we do this manually and re-use that context later when the layer wants to create one async itself.
* cocoa-cb: render on a dedicated dispatch queueAkemi2018-03-251-22/+29
| | | | | | | | | | | we rendered on the displaylink thread which wasn't the best idea. if rendering took too long or was blocking it also blocked the displaylink callback. when that happened new vsyncs were reported delayed or not at all. consequently the mpv_render_context_report_swap function wasn't called consistently and that could cause bad video playback. so the rendering is moved to a dedicated dispatch queue. furthermore the update callback starts a layer update directly instead of the displaylink callback, making the rendering a bit more consistent.
* cocoa-cb: fix crash with forced iGPU on some multi GPU systemsAkemi2018-03-141-3/+5
| | | | | | | | | | | | | there were actually a few small problems. the fatalError() function wasn't supposed to be called there and caused an "Illegal instruction". this was replaced by a print and exit() call. the second problem was that cocoa returns a kCGLBadPixelFormat instead of a kCGLBadAttribute error, which broke our check, immediately exited our loop and no working pixel format was ever created. the third problem was that macOS 10.12 didn't return any errors but also didn't return a pixel format, that also broke our check. now the code checks for both cases. Fixes #5631
* cocoa-cb: change handling of window aspect ratio changesAkemi2018-03-041-15/+8
| | | | | | | | | | | | i tried being smart and handle aspect ratio differences manually via atomic drawing and resizing to aspect fitted frames. there were a few issues with that. like unexpected visibility of certain System GUI elements on entering fullscreen or visually dropped frames due to the atomic drawing. now we rely on system mechanics to keep the proper aspect ratio of our layer, the recommended way. as a side effect it also fixes a segfault. Fixes #5581
* cocoa-cb: use new libmpv API instead of opengl-cbAkemi2018-03-041-7/+7
| | | | | a new replacement API was introduced with b037121 and the old one was deprecated. porting cocoa-cb to the new API.
* cocoa-cb: fix stretched gl surface on window aspect ratio changeAkemi2018-02-281-2/+33
| | | | | | | | when resizing async it's possible that the layer, and the underlying gl surface, is stretched on an aspect ratio change. to prevent that we do an atomic resize (resize and draw at the same time). usually max one unique frame should be dropped but it's possible, depending on the performance, that more are dropped.
* cocoa-cb: fix wrong drawing size on resizeAkemi2018-02-251-17/+12
| | | | | | on live resize, eg async resize, the layer's bounds size is not in sync with the actual surface size. this led to a wrongly sized frame and a perceived flicker. get and use the actual surface size instead.
* cocoa-cb: fix hwdec when drawing off-screenAkemi2018-02-171-0/+1
| | | | | | | | | drawing off-screen failed because we didn't have a valid context. the problem is we force off-screen drawing because the CAOpenGLLayer refuses to draw anything while being off-screen. set the current context before starting to draw anything off-screen. Fixes #5530
* cocoa-cb: initial implementation via opengl-cb APIAkemi2018-02-121-0/+210
this is meant to replace the old and not properly working vo_gpu/opengl cocoa backend in the future. the problems are various shortcomings of Apple's opengl implementation and buggy behaviour in certain circumstances that couldn't be properly worked around. there are also certain regressions on newer macOS versions from 10.11 onwards. - awful opengl performance with a none layer backed context - huge amount of dropped frames with an early context flush - flickering of system elements like the dock or volume indicator - double buffering not properly working with a none layer backed context - bad performance in fullscreen because of system optimisations all the problems were caused by using a normal opengl context, that seems somewhat abandoned by apple, and are fixed by using a layer backed opengl context instead. problems that couldn't be fixed could be properly worked around. this has all features our old backend has sans the wid embedding, the possibility to disable the automatic GPU switching and taking screenshots of the window content. the first was deemed unnecessary by me for now, since i just use the libmpv API that others can use anyway. second is technically not possible atm because we have to pre-allocate our opengl context at a time the config isn't read yet, so we can't get the needed property. third one is a bit tricky because of deadlocking and it needed to be in sync, hopefully i can work around that in the future. this also has at least one additional feature or eye-candy. a properly working fullscreen animation with the native fs. also since this is a direct port of the old backend of the parts that could be used, though with adaptions and improvements, this looks a lot cleaner and easier to understand. some credit goes to @pigoz for the initial swift build support which i could improve upon. Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739, #2392, #2217