CAMetalLayer.hpp
1 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 // 3 // QuartzCore/CAMetalDrawable.hpp 4 // 5 // Copyright 2020-2024 Apple Inc. 6 // 7 // Licensed under the Apache License, Version 2.0 (the "License"); 8 // you may not use this file except in compliance with the License. 9 // You may obtain a copy of the License at 10 // 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // 13 // Unless required by applicable law or agreed to in writing, software 14 // distributed under the License is distributed on an "AS IS" BASIS, 15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 // See the License for the specific language governing permissions and 17 // limitations under the License. 18 // 19 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 21 #pragma once 22 23 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 25 #include "../Metal/MTLPixelFormat.hpp" 26 #include "../Metal/MTLTexture.hpp" 27 #include <CoreGraphics/CGGeometry.h> 28 29 #include "CADefines.hpp" 30 #include "CAMetalDrawable.hpp" 31 #include "CAPrivate.hpp" 32 33 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 34 35 namespace CA 36 { 37 38 class MetalLayer : public NS::Referencing<MetalLayer> 39 { 40 public: 41 static class MetalLayer* layer(); 42 43 MTL::Device* device() const; 44 void setDevice(MTL::Device* device); 45 46 MTL::PixelFormat pixelFormat() const; 47 void setPixelFormat(MTL::PixelFormat pixelFormat); 48 49 bool framebufferOnly() const; 50 void setFramebufferOnly(bool framebufferOnly); 51 52 CGSize drawableSize() const; 53 void setDrawableSize(CGSize drawableSize); 54 55 class MetalDrawable* nextDrawable(); 56 }; 57 } // namespace CA 58 59 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 60 _CA_INLINE CA::MetalLayer* CA::MetalLayer::layer() 61 { 62 return Object::sendMessage<CA::MetalLayer*>(_CA_PRIVATE_CLS(CAMetalLayer), _CA_PRIVATE_SEL(layer)); 63 } 64 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 65 66 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 67 68 _CA_INLINE MTL::Device* CA::MetalLayer::device() const 69 { 70 return Object::sendMessage<MTL::Device*>(this, _CA_PRIVATE_SEL(device)); 71 } 72 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 73 74 _CA_INLINE void CA::MetalLayer::setDevice(MTL::Device* device) 75 { 76 return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setDevice_), device); 77 } 78 79 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 80 81 _CA_INLINE MTL::PixelFormat CA::MetalLayer::pixelFormat() const 82 { 83 return Object::sendMessage<MTL::PixelFormat>(this, 84 _CA_PRIVATE_SEL(pixelFormat)); 85 } 86 87 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 88 89 _CA_INLINE void CA::MetalLayer::setPixelFormat(MTL::PixelFormat pixelFormat) 90 { 91 return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setPixelFormat_), 92 pixelFormat); 93 } 94 95 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 96 97 _CA_INLINE bool CA::MetalLayer::framebufferOnly() const 98 { 99 return Object::sendMessage<bool>(this, _CA_PRIVATE_SEL(framebufferOnly)); 100 } 101 102 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 103 104 _CA_INLINE void CA::MetalLayer::setFramebufferOnly(bool framebufferOnly) 105 { 106 return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setFramebufferOnly_), 107 framebufferOnly); 108 } 109 110 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 111 112 _CA_INLINE CGSize CA::MetalLayer::drawableSize() const 113 { 114 return Object::sendMessage<CGSize>(this, _CA_PRIVATE_SEL(drawableSize)); 115 } 116 117 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 118 119 _CA_INLINE void CA::MetalLayer::setDrawableSize(CGSize drawableSize) 120 { 121 return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setDrawableSize_), 122 drawableSize); 123 } 124 125 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 126 127 _CA_INLINE CA::MetalDrawable* CA::MetalLayer::nextDrawable() 128 { 129 return Object::sendMessage<MetalDrawable*>(this, 130 _CA_PRIVATE_SEL(nextDrawable)); 131 }