87 lines
2.8 KiB
C++
87 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
//! \file
|
|
|
|
#ifndef TNT_FILAMENT_BACKEND_PLATFORM_H
|
|
#define TNT_FILAMENT_BACKEND_PLATFORM_H
|
|
|
|
#include <backend/DriverEnums.h>
|
|
|
|
#include <utils/compiler.h>
|
|
|
|
namespace filament::backend {
|
|
|
|
class Driver;
|
|
|
|
/**
|
|
* Platform is an interface that abstracts how the backend (also referred to as Driver) is
|
|
* created. The backend provides several common Platform concrete implementations, which are
|
|
* selected automatically. It is possible however to provide a custom Platform when creating
|
|
* the filament Engine.
|
|
*/
|
|
class UTILS_PUBLIC Platform {
|
|
public:
|
|
struct SwapChain {};
|
|
struct Fence {};
|
|
struct Stream {};
|
|
|
|
struct DriverConfig {
|
|
/*
|
|
* size of handle arena in bytes. Setting to 0 indicates default value is to be used.
|
|
* Driver clamps to valid values.
|
|
*/
|
|
size_t handleArenaSize = 0;
|
|
};
|
|
|
|
virtual ~Platform() noexcept;
|
|
|
|
/**
|
|
* Queries the underlying OS version.
|
|
* @return The OS version.
|
|
*/
|
|
virtual int getOSVersion() const noexcept = 0;
|
|
|
|
/**
|
|
* Creates and initializes the low-level API (e.g. an OpenGL context or Vulkan instance),
|
|
* then creates the concrete Driver.
|
|
* The caller takes ownership of the returned Driver* and must destroy it with delete.
|
|
*
|
|
* @param sharedContext an optional shared context. This is not meaningful with all graphic
|
|
* APIs and platforms.
|
|
* For EGL platforms, this is an EGLContext.
|
|
*
|
|
* @param driverConfig specifies driver initialization parameters
|
|
*
|
|
* @return nullptr on failure, or a pointer to the newly created driver.
|
|
*/
|
|
virtual backend::Driver* createDriver(void* sharedContext,
|
|
const DriverConfig& driverConfig) noexcept = 0;
|
|
|
|
/**
|
|
* Processes the platform's event queue when called from its primary event-handling thread.
|
|
*
|
|
* Internally, Filament might need to call this when waiting on a fence. It is only implemented
|
|
* on platforms that need it, such as macOS + OpenGL. Returns false if this is not the main
|
|
* thread, or if the platform does not need to perform any special processing.
|
|
*/
|
|
virtual bool pumpEvents() noexcept;
|
|
};
|
|
|
|
} // namespace filament
|
|
|
|
#endif // TNT_FILAMENT_BACKEND_PLATFORM_H
|