Path: blob/master/thirdparty/metal-cpp/QuartzCore/CAMetalLayer.hpp
21059 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// QuartzCore/CAMetalDrawable.hpp3//4// Copyright 2020-2024 Apple Inc.5//6// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.17//18//-------------------------------------------------------------------------------------------------------------------------------------------------------------1920#pragma once2122//-------------------------------------------------------------------------------------------------------------------------------------------------------------2324#include "../Metal/MTLPixelFormat.hpp"25#include "../Metal/MTLTexture.hpp"26#include "../Metal/MTLResidencySet.hpp"27#include "../Foundation/NSTypes.hpp"28#include <CoreGraphics/CGGeometry.h>29#include <CoreGraphics/CGColorSpace.h>3031#include "CADefines.hpp"32#include "CAMetalDrawable.hpp"33#include "CAPrivate.hpp"3435//-------------------------------------------------------------------------------------------------------------------------------------------------------------3637namespace CA38{3940class MetalLayer : public NS::Referencing<MetalLayer>41{42public:43static class MetalLayer* layer();4445MTL::Device* device() const;46void setDevice(MTL::Device* device);4748MTL::PixelFormat pixelFormat() const;49void setPixelFormat(MTL::PixelFormat pixelFormat);5051bool framebufferOnly() const;52void setFramebufferOnly(bool framebufferOnly);5354CGSize drawableSize() const;55void setDrawableSize(CGSize drawableSize);5657class MetalDrawable* nextDrawable();5859NS::UInteger maximumDrawableCount() const;60void setMaximumDrawableCount(NS::UInteger maximumDrawableCount);6162bool displaySyncEnabled() const;63void setDisplaySyncEnabled(bool displaySyncEnabled);6465CGColorSpaceRef colorspace() const;66void setColorspace(CGColorSpaceRef colorspace);6768bool allowsNextDrawableTimeout() const;69void setAllowsNextDrawableTimeout(bool allowsNextDrawableTimeout);7071MTL::ResidencySet* residencySet() const;72};73} // namespace CA7475//-------------------------------------------------------------------------------------------------------------------------------------------------------------76_CA_INLINE CA::MetalLayer* CA::MetalLayer::layer()77{78return Object::sendMessage<CA::MetalLayer*>(_CA_PRIVATE_CLS(CAMetalLayer), _CA_PRIVATE_SEL(layer));79}80//-------------------------------------------------------------------------------------------------------------------------------------------------------------8182//-------------------------------------------------------------------------------------------------------------------------------------------------------------8384_CA_INLINE MTL::Device* CA::MetalLayer::device() const85{86return Object::sendMessage<MTL::Device*>(this, _CA_PRIVATE_SEL(device));87}88//-------------------------------------------------------------------------------------------------------------------------------------------------------------8990_CA_INLINE void CA::MetalLayer::setDevice(MTL::Device* device)91{92return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setDevice_), device);93}9495//-------------------------------------------------------------------------------------------------------------------------------------------------------------9697_CA_INLINE MTL::PixelFormat CA::MetalLayer::pixelFormat() const98{99return Object::sendMessage<MTL::PixelFormat>(this,100_CA_PRIVATE_SEL(pixelFormat));101}102103//-------------------------------------------------------------------------------------------------------------------------------------------------------------104105_CA_INLINE void CA::MetalLayer::setPixelFormat(MTL::PixelFormat pixelFormat)106{107return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setPixelFormat_),108pixelFormat);109}110111//-------------------------------------------------------------------------------------------------------------------------------------------------------------112113_CA_INLINE bool CA::MetalLayer::framebufferOnly() const114{115return Object::sendMessage<bool>(this, _CA_PRIVATE_SEL(framebufferOnly));116}117118//-------------------------------------------------------------------------------------------------------------------------------------------------------------119120_CA_INLINE void CA::MetalLayer::setFramebufferOnly(bool framebufferOnly)121{122return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setFramebufferOnly_),123framebufferOnly);124}125126//-------------------------------------------------------------------------------------------------------------------------------------------------------------127128_CA_INLINE CGSize CA::MetalLayer::drawableSize() const129{130return Object::sendMessage<CGSize>(this, _CA_PRIVATE_SEL(drawableSize));131}132133//-------------------------------------------------------------------------------------------------------------------------------------------------------------134135_CA_INLINE void CA::MetalLayer::setDrawableSize(CGSize drawableSize)136{137return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setDrawableSize_),138drawableSize);139}140141//-------------------------------------------------------------------------------------------------------------------------------------------------------------142143_CA_INLINE CA::MetalDrawable* CA::MetalLayer::nextDrawable()144{145return Object::sendMessage<MetalDrawable*>(this,146_CA_PRIVATE_SEL(nextDrawable));147}148149//-------------------------------------------------------------------------------------------------------------------------------------------------------------150151_CA_INLINE NS::UInteger CA::MetalLayer::maximumDrawableCount() const152{153return Object::sendMessage<NS::UInteger>(this,154_CA_PRIVATE_SEL(maximumDrawableCount));155}156157//-------------------------------------------------------------------------------------------------------------------------------------------------------------158159_CA_INLINE void CA::MetalLayer::setMaximumDrawableCount(NS::UInteger maximumDrawableCount)160{161return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setMaximumDrawableCount_),162maximumDrawableCount);163}164165//-------------------------------------------------------------------------------------------------------------------------------------------------------------166167_CA_INLINE bool CA::MetalLayer::displaySyncEnabled() const168{169return Object::sendMessage<bool>(this, _CA_PRIVATE_SEL(displaySyncEnabled));170}171172//-------------------------------------------------------------------------------------------------------------------------------------------------------------173174_CA_INLINE void CA::MetalLayer::setDisplaySyncEnabled(bool displaySyncEnabled)175{176return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setDisplaySyncEnabled_),177displaySyncEnabled);178}179180//-------------------------------------------------------------------------------------------------------------------------------------------------------------181182_CA_INLINE CGColorSpaceRef CA::MetalLayer::colorspace() const183{184return Object::sendMessage<CGColorSpaceRef>(this, _CA_PRIVATE_SEL(colorspace));185}186187//-------------------------------------------------------------------------------------------------------------------------------------------------------------188189_CA_INLINE void CA::MetalLayer::setColorspace(CGColorSpaceRef colorspace)190{191return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setColorspace_),192colorspace);193}194195//-------------------------------------------------------------------------------------------------------------------------------------------------------------196197_CA_INLINE bool CA::MetalLayer::allowsNextDrawableTimeout() const198{199return Object::sendMessage<bool>(this, _CA_PRIVATE_SEL(allowsNextDrawableTimeout));200}201202//-------------------------------------------------------------------------------------------------------------------------------------------------------------203204_CA_INLINE void CA::MetalLayer::setAllowsNextDrawableTimeout(bool allowsNextDrawableTimeout)205{206return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setAllowsNextDrawableTimeout_),207allowsNextDrawableTimeout);208}209210//-------------------------------------------------------------------------------------------------------------------------------------------------------------211212_CA_INLINE MTL::ResidencySet* CA::MetalLayer::residencySet() const213{214return Object::sendMessage<MTL::ResidencySet*>(this, _CA_PRIVATE_SEL(residencySet) );215}216217218