Skip to content

Commit 92f4245

Browse files
authored
Add ORBLayer and ORBDevice support (#18)
1 parent 07af6b0 commit 92f4245

19 files changed

Lines changed: 423 additions & 9 deletions

File tree

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// ORBDevice.mm
3+
// OpenRenderBox
4+
5+
#include <OpenRenderBoxObjC/Device/ORBDevice.h>
6+
7+
#if ORB_OBJC_FOUNDATION
8+
9+
#include <Foundation/Foundation.h>
10+
11+
@implementation ORBDevice
12+
13+
+ (id)sharedDefaultDevice {
14+
// TODO
15+
return nil;
16+
}
17+
18+
+ (id)allDevices {
19+
// TODO
20+
return nil;
21+
}
22+
23+
+ (BOOL)isSupported {
24+
id device = [self sharedDefaultDevice];
25+
return device != nil;
26+
}
27+
28+
- (instancetype)initWithDevice:(id<MTLDevice>)device {
29+
self = [super init];
30+
if (self) {
31+
// TODO
32+
}
33+
return self;
34+
}
35+
36+
@end
37+
38+
#endif /* ORB_OBJC_FOUNDATION */
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// ORBLayer.m
3+
// OpenRenderBox
4+
5+
#include <OpenRenderBoxObjC/Render/ORBLayer.h>
6+
7+
#if ORB_OBJC_FOUNDATION
8+
9+
@implementation ORBLayer
10+
11+
// TODO
12+
13+
@end
14+
15+
#endif /* ORB_OBJC_FOUNDATION */

Sources/OpenRenderBoxCxx/include/OpenRenderBox/ORBBase.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060
#define ORB_EXPORT CF_EXPORT
6161
#define ORB_BRIDGED_TYPE CF_BRIDGED_TYPE
6262

63-
#if ORB_TARGET_OS_DARWIN && __ORBJC__
64-
#define ORB_ORBJC_FOUNDATION 1
63+
#if ORB_TARGET_OS_DARWIN && __OBJC__
64+
#define ORB_OBJC_FOUNDATION 1
6565
#else
66-
#define ORB_ORBJC_FOUNDATION 0
67-
#endif /* TARGET_OS_DARWIN && __ORBJC__ */
66+
#define ORB_OBJC_FOUNDATION 0
67+
#endif /* TARGET_OS_DARWIN && __OBJC__ */
6868

6969
#if !ORB_TRRET_OS_DARWIN
7070
#include "CFCGTypes.h"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// ORBColor.h
3+
// OpenRenderBox
4+
5+
#pragma once
6+
7+
#include <OpenRenderBox/ORBBase.h>
8+
9+
ORB_ASSUME_NONNULL_BEGIN
10+
11+
ORB_EXTERN_C_BEGIN
12+
13+
typedef struct ORBColor {
14+
float red;
15+
float green;
16+
float blue;
17+
float alpha;
18+
} ORBColor;
19+
20+
ORB_EXTERN_C_END
21+
22+
ORB_ASSUME_NONNULL_END
23+

Sources/OpenRenderBoxCxx/include/OpenRenderBox/OpenRenderBox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <OpenRenderBox/ORBBase.h>
2+
#include <OpenRenderBox/ORBColor.h>
23
#include <OpenRenderBox/ORBPath.h>
34
#include <OpenRenderBox/ORBPathCallbacks.h>
45
#include <OpenRenderBox/ORBPathStorage.h>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// ORBDevice.hpp
3+
// OpenRenderBoxCxx
4+
5+
namespace ORB {
6+
7+
// WIP
8+
class Device {
9+
10+
};
11+
}

Sources/OpenRenderBoxCxx/include/OpenRenderBoxCxx/Util/assert.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ namespace ORB {
1010
void precondition_failure(const char *format, ...) __cold __dead2;
1111
void non_fatal_precondition_failure(const char *format, ...);
1212
} /* ORB */
13-

Sources/OpenRenderBoxCxx/include/OpenRenderBoxCxx/Util/log.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ os_log_t error_log();
2020
ORB_ASSUME_NONNULL_END
2121

2222
#endif /* ORB_TARGET_OS_DARWIN */
23-
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// ORBDevice.h
3+
// OpenRenderBox
4+
5+
#pragma once
6+
7+
#include <OpenRenderBox/ORBBase.h>
8+
9+
#if ORB_OBJC_FOUNDATION
10+
11+
#include <Foundation/Foundation.h>
12+
#include <Metal/Metal.h>
13+
#include <OpenRenderBoxObjC/Render/ORBImageRenderer.h>
14+
#include <dispatch/dispatch.h>
15+
16+
@protocol MTLCaptureScope, MTLDevice, OS_dispatch_queue;
17+
18+
ORB_ASSUME_NONNULL_BEGIN
19+
20+
@interface ORBDevice: NSObject <ORBImageRenderer>
21+
22+
@property (readonly, nonatomic) id<MTLDevice> device;
23+
@property (readonly, nonatomic) NSObject<OS_dispatch_queue> *queue;
24+
@property (readonly, nonatomic, nullable) id<MTLCaptureScope> captureScope;
25+
@property NSUInteger GPUPriority;
26+
@property NSUInteger backgroundGPUPriority;
27+
28+
/* class methods */
29+
+ (nullable instancetype)sharedDefaultDevice;
30+
+ (NSArray<ORBDevice *> *)allDevices;
31+
+ (BOOL)isSupported;
32+
+ (void)setAllowsRenderingInBackground:(BOOL)background;
33+
+ (BOOL)allowsRenderingInBackground;
34+
+ (NSUInteger)defaultBackgroundGPUPriority;
35+
+ (NSUInteger)defaultGPUPriority;
36+
+ (BOOL)isRunningInBackground;
37+
+ (void)setDefaultBackgroundGPUPriority:(NSUInteger)gpupriority;
38+
+ (void)setDefaultGPUPriority:(NSUInteger)gpupriority;
39+
+ (nullable instancetype)sharedDevice:(id<MTLDevice>)device;
40+
+ (nullable instancetype)sharedDeviceForDisplay:(unsigned int)display;
41+
42+
/* instance methods */
43+
- (void)dealloc;
44+
- (instancetype)initWithDevice:(id<MTLDevice>)device;
45+
- (nullable CGImageRef)renderImageInRect:(CGRect)rect options:(nullable id)options renderer:(nullable id /* block */)renderer;
46+
- (void)collectResources;
47+
- (void)compileShader:(id)shader completionQueue:(nullable id)queue handler:(nullable id /* block */)handler;
48+
- (BOOL)compileShader:(id)shader error:(id _Nullable * _Nullable)error;
49+
- (nullable id)pipelineDescriptions:(nullable id)descriptions extraColorFormats:(nullable id)formats;
50+
- (void)renderImageInRect:(CGRect)rect options:(nullable id)options renderer:(nullable id /* block */)renderer completionQueue:(nullable id)queue handler:(nullable id /* block */)handler;
51+
52+
@end
53+
54+
ORB_ASSUME_NONNULL_END
55+
56+
#endif /* ORB_OBJC_FOUNDATION */

0 commit comments

Comments
 (0)