Skip to content

Commit 4192f83

Browse files
chore(🍏): Rename references from "ios" to "apple" (#3033)
* move `ios/RNSkia-iOS/*` to `apple/*` * update podspec * rename `RNSkiOSPlatformContext` to `RNSkApplePlatformContext` * rename `RNSkiOSVideo` to `RNSkAppleVideo` * rename `RnSkiOSView` to `RNSkAppleView` --------- Co-authored-by: William Candillon <[email protected]>
1 parent 861b8c7 commit 4192f83

30 files changed

+64
-357
lines changed

packages/skia/ios/RNSkia-iOS/MetalContext.h renamed to packages/skia/apple/MetalContext.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
#import <include/gpu/ganesh/mtl/GrMtlDirectContext.h>
1515
#import <include/gpu/ganesh/mtl/SkSurfaceMetal.h>
1616

17-
// namespace RNSkia {
18-
// class RNSkiOSPlatformContext;
19-
// }
20-
2117
class MetalSharedContext {
2218
public:
2319
static MetalSharedContext &getInstance() {
@@ -126,7 +122,6 @@ class MetalContext {
126122
GrDirectContext *getDirectContext() { return _directContext.get(); }
127123

128124
private:
129-
// friend class RNSkia::RNSkiOSPlatformContext;
130125
id<MTLCommandQueue> _commandQueue = nullptr;
131126
sk_sp<GrDirectContext> _directContext = nullptr;
132127

packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.h renamed to packages/skia/apple/RNSkApplePlatformContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class CallInvoker;
1818

1919
namespace RNSkia {
2020

21-
class RNSkiOSPlatformContext : public RNSkPlatformContext {
21+
class RNSkApplePlatformContext : public RNSkPlatformContext {
2222
public:
23-
RNSkiOSPlatformContext(
23+
RNSkApplePlatformContext(
2424
RCTBridge *bridge,
2525
std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker)
2626
: RNSkPlatformContext(jsCallInvoker, [[UIScreen mainScreen] scale]) {
@@ -30,7 +30,7 @@ class RNSkiOSPlatformContext : public RNSkPlatformContext {
3030
[[ViewScreenshotService alloc] initWithUiManager:bridge.uiManager];
3131
}
3232

33-
~RNSkiOSPlatformContext() = default;
33+
~RNSkApplePlatformContext() = default;
3434

3535
void runOnMainThread(std::function<void()>) override;
3636

packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm renamed to packages/skia/apple/RNSkApplePlatformContext.mm

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "RNSkiOSPlatformContext.h"
1+
#import "RNSkApplePlatformContext.h"
22

33
#import <CoreMedia/CMSampleBuffer.h>
44
#include <Metal/Metal.h>
@@ -11,7 +11,7 @@
1111
#else
1212
#include "MetalContext.h"
1313
#endif
14-
#include "RNSkiOSVideo.h"
14+
#include "RNSkAppleVideo.h"
1515

1616
#pragma clang diagnostic push
1717
#pragma clang diagnostic ignored "-Wdocumentation"
@@ -26,7 +26,7 @@
2626

2727
namespace RNSkia {
2828

29-
void RNSkiOSPlatformContext::performStreamOperation(
29+
void RNSkApplePlatformContext::performStreamOperation(
3030
const std::string &sourceUri,
3131
const std::function<void(std::unique_ptr<SkStreamAsset>)> &op) {
3232

@@ -64,14 +64,14 @@
6464
std::thread(loader).detach();
6565
}
6666

67-
void RNSkiOSPlatformContext::releaseNativeBuffer(uint64_t pointer) {
67+
void RNSkApplePlatformContext::releaseNativeBuffer(uint64_t pointer) {
6868
CVPixelBufferRef pixelBuffer = reinterpret_cast<CVPixelBufferRef>(pointer);
6969
if (pixelBuffer) {
7070
CFRelease(pixelBuffer);
7171
}
7272
}
7373

74-
uint64_t RNSkiOSPlatformContext::makeNativeBuffer(sk_sp<SkImage> image) {
74+
uint64_t RNSkApplePlatformContext::makeNativeBuffer(sk_sp<SkImage> image) {
7575
// 0. If Image is not in BGRA, convert to BGRA as only BGRA is supported.
7676
if (image->colorType() != kBGRA_8888_SkColorType) {
7777
#if defined(SK_GRAPHITE)
@@ -156,7 +156,7 @@
156156
return reinterpret_cast<uint64_t>(pixelBuffer);
157157
}
158158

159-
const TextureInfo RNSkiOSPlatformContext::getTexture(sk_sp<SkImage> image) {
159+
const TextureInfo RNSkApplePlatformContext::getTexture(sk_sp<SkImage> image) {
160160
GrBackendTexture texture;
161161
TextureInfo result;
162162
if (!SkImages::GetBackendTextureFromImage(image, &texture, true)) {
@@ -173,7 +173,7 @@
173173
return result;
174174
}
175175

176-
const TextureInfo RNSkiOSPlatformContext::getTexture(sk_sp<SkSurface> surface) {
176+
const TextureInfo RNSkApplePlatformContext::getTexture(sk_sp<SkSurface> surface) {
177177
GrBackendTexture texture = SkSurfaces::GetBackendTexture(
178178
surface.get(), SkSurfaces::BackendHandleAccess::kFlushRead);
179179
TextureInfo result;
@@ -189,12 +189,12 @@
189189
}
190190

191191
std::shared_ptr<RNSkVideo>
192-
RNSkiOSPlatformContext::createVideo(const std::string &url) {
193-
return std::make_shared<RNSkiOSVideo>(url, this);
192+
RNSkApplePlatformContext::createVideo(const std::string &url) {
193+
return std::make_shared<RNSkAppleVideo>(url, this);
194194
}
195195

196196
std::shared_ptr<WindowContext>
197-
RNSkiOSPlatformContext::makeContextFromNativeSurface(void *surface, int width,
197+
RNSkApplePlatformContext::makeContextFromNativeSurface(void *surface, int width,
198198
int height) {
199199
#if defined(SK_GRAPHITE)
200200
return DawnContext::getInstance().MakeWindow(surface, width, height);
@@ -204,11 +204,11 @@
204204
#endif
205205
}
206206

207-
void RNSkiOSPlatformContext::raiseError(const std::exception &err) {
207+
void RNSkApplePlatformContext::raiseError(const std::exception &err) {
208208
RCTFatal(RCTErrorWithMessage([NSString stringWithUTF8String:err.what()]));
209209
}
210210

211-
sk_sp<SkSurface> RNSkiOSPlatformContext::makeOffscreenSurface(int width,
211+
sk_sp<SkSurface> RNSkApplePlatformContext::makeOffscreenSurface(int width,
212212
int height) {
213213
#if defined(SK_GRAPHITE)
214214
return DawnContext::getInstance().MakeOffscreen(width, height);
@@ -217,15 +217,15 @@
217217
#endif
218218
}
219219

220-
sk_sp<SkImage> RNSkiOSPlatformContext::makeImageFromNativeBuffer(void *buffer) {
220+
sk_sp<SkImage> RNSkApplePlatformContext::makeImageFromNativeBuffer(void *buffer) {
221221
#if defined(SK_GRAPHITE)
222222
return DawnContext::getInstance().MakeImageFromBuffer(buffer);
223223
#else
224224
return MetalContext::getInstance().MakeImageFromBuffer(buffer);
225225
#endif
226226
}
227227

228-
sk_sp<SkImage> RNSkiOSPlatformContext::makeImageFromNativeTexture(
228+
sk_sp<SkImage> RNSkApplePlatformContext::makeImageFromNativeTexture(
229229
const TextureInfo &texInfo, int width, int height, bool mipMapped) {
230230
id<MTLTexture> mtlTexture = (__bridge id<MTLTexture>)(texInfo.mtlTexture);
231231

@@ -246,7 +246,7 @@
246246
kPremul_SkAlphaType, nullptr);
247247
}
248248

249-
SkColorType RNSkiOSPlatformContext::mtlPixelFormatToSkColorType(
249+
SkColorType RNSkApplePlatformContext::mtlPixelFormatToSkColorType(
250250
MTLPixelFormat pixelFormat) {
251251
switch (pixelFormat) {
252252
case MTLPixelFormatRGBA8Unorm:
@@ -279,23 +279,23 @@
279279
}
280280

281281
#if !defined(SK_GRAPHITE)
282-
GrDirectContext *RNSkiOSPlatformContext::getDirectContext() {
282+
GrDirectContext *RNSkApplePlatformContext::getDirectContext() {
283283
return MetalContext::getInstance().getDirectContext();
284284
}
285285
#endif
286286

287-
sk_sp<SkFontMgr> RNSkiOSPlatformContext::createFontMgr() {
287+
sk_sp<SkFontMgr> RNSkApplePlatformContext::createFontMgr() {
288288
return SkFontMgr_New_CoreText(nullptr);
289289
}
290290

291-
void RNSkiOSPlatformContext::runOnMainThread(std::function<void()> func) {
291+
void RNSkApplePlatformContext::runOnMainThread(std::function<void()> func) {
292292
dispatch_async(dispatch_get_main_queue(), ^{
293293
func();
294294
});
295295
}
296296

297297
sk_sp<SkImage>
298-
RNSkiOSPlatformContext::takeScreenshotFromViewTag(size_t viewTag) {
298+
RNSkApplePlatformContext::takeScreenshotFromViewTag(size_t viewTag) {
299299
return [_screenshotService
300300
screenshotOfViewWithTag:[NSNumber numberWithLong:viewTag]];
301301
}

packages/skia/ios/RNSkia-iOS/RNSkiOSVideo.h renamed to packages/skia/apple/RNSkAppleVideo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace RNSkia {
2020

21-
class RNSkiOSVideo : public RNSkVideo {
21+
class RNSkAppleVideo : public RNSkVideo {
2222
private:
2323
std::string _url;
2424
AVPlayer *_player = nullptr;
@@ -35,8 +35,8 @@ class RNSkiOSVideo : public RNSkVideo {
3535
NSDictionary *getOutputSettings();
3636

3737
public:
38-
RNSkiOSVideo(std::string url, RNSkPlatformContext *context);
39-
~RNSkiOSVideo();
38+
RNSkAppleVideo(std::string url, RNSkPlatformContext *context);
39+
~RNSkAppleVideo();
4040
sk_sp<SkImage> nextImage(double *timeStamp = nullptr) override;
4141
double duration() override;
4242
double framerate() override;

packages/skia/ios/RNSkia-iOS/RNSkiOSVideo.mm renamed to packages/skia/apple/RNSkAppleVideo.mm

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88

99
#pragma clang diagnostic pop
1010

11-
#include "RNSkiOSVideo.h"
11+
#include "RNSkAppleVideo.h"
1212
#include <AVFoundation/AVFoundation.h>
1313
#include <CoreVideo/CoreVideo.h>
1414

1515
namespace RNSkia {
1616

17-
RNSkiOSVideo::RNSkiOSVideo(std::string url, RNSkPlatformContext *context)
17+
RNSkAppleVideo::RNSkAppleVideo(std::string url, RNSkPlatformContext *context)
1818
: _url(std::move(url)), _context(context) {
1919
setupPlayer();
2020
}
2121

22-
RNSkiOSVideo::~RNSkiOSVideo() {
22+
RNSkAppleVideo::~RNSkAppleVideo() {
2323
if (_player) {
2424
[_player pause];
2525
}
2626
}
2727

28-
void RNSkiOSVideo::setupPlayer() {
28+
void RNSkAppleVideo::setupPlayer() {
2929
NSURL *videoURL = [NSURL URLWithString:@(_url.c_str())];
3030
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:videoURL];
3131
_player = [AVPlayer playerWithPlayerItem:playerItem];
@@ -53,7 +53,7 @@
5353
play();
5454
}
5555

56-
sk_sp<SkImage> RNSkiOSVideo::nextImage(double *timeStamp) {
56+
sk_sp<SkImage> RNSkAppleVideo::nextImage(double *timeStamp) {
5757
CMTime currentTime = [_player currentTime];
5858
CVPixelBufferRef pixelBuffer =
5959
[_videoOutput copyPixelBufferForItemTime:currentTime
@@ -73,14 +73,14 @@
7373
return skImage;
7474
}
7575

76-
NSDictionary *RNSkiOSVideo::getOutputSettings() {
76+
NSDictionary *RNSkAppleVideo::getOutputSettings() {
7777
return @{
7878
(id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA),
7979
(id)kCVPixelBufferMetalCompatibilityKey : @YES
8080
};
8181
}
8282

83-
float RNSkiOSVideo::getRotationInDegrees() {
83+
float RNSkAppleVideo::getRotationInDegrees() {
8484
CGFloat rotationAngle = 0.0;
8585
auto transform = _preferredTransform;
8686
// Determine the rotation angle in radians
@@ -97,7 +97,7 @@
9797
return rotationAngle;
9898
}
9999

100-
void RNSkiOSVideo::seek(double timeInMilliseconds) {
100+
void RNSkAppleVideo::seek(double timeInMilliseconds) {
101101
CMTime seekTime =
102102
CMTimeMakeWithSeconds(timeInMilliseconds / 1000.0, NSEC_PER_SEC);
103103
[_player seekToTime:seekTime
@@ -110,28 +110,28 @@
110110
}];
111111
}
112112

113-
void RNSkiOSVideo::play() {
113+
void RNSkAppleVideo::play() {
114114
if (_player) {
115115
[_player play];
116116
_isPlaying = true;
117117
}
118118
}
119119

120-
void RNSkiOSVideo::pause() {
120+
void RNSkAppleVideo::pause() {
121121
if (_player) {
122122
[_player pause];
123123
_isPlaying = false;
124124
}
125125
}
126126

127-
double RNSkiOSVideo::duration() { return _duration; }
127+
double RNSkAppleVideo::duration() { return _duration; }
128128

129-
double RNSkiOSVideo::framerate() { return _framerate; }
129+
double RNSkAppleVideo::framerate() { return _framerate; }
130130

131-
SkISize RNSkiOSVideo::getSize() {
131+
SkISize RNSkAppleVideo::getSize() {
132132
return SkISize::Make(_videoWidth, _videoHeight);
133133
}
134134

135-
void RNSkiOSVideo::setVolume(float volume) { _player.volume = volume; }
135+
void RNSkAppleVideo::setVolume(float volume) { _player.volume = volume; }
136136

137137
} // namespace RNSkia

packages/skia/ios/RNSkia-iOS/RNSkiOSView.h renamed to packages/skia/apple/RNSkAppleView.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
#import "RNSkMetalCanvasProvider.h"
66
#import "RNSkView.h"
7-
#import "RNSkiOSPlatformContext.h"
7+
#import "RNSkApplePlatformContext.h"
88

9-
class RNSkBaseiOSView {
9+
class RNSkBaseAppleView {
1010
public:
1111
virtual CALayer *getLayer() = 0;
1212
virtual void setSize(int width, int height) = 0;
1313
virtual std::shared_ptr<RNSkia::RNSkView> getDrawView() = 0;
1414
};
1515

16-
template <class T> class RNSkiOSView : public RNSkBaseiOSView, public T {
16+
template <class T> class RNSkAppleView : public RNSkBaseAppleView, public T {
1717
public:
18-
RNSkiOSView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
18+
RNSkAppleView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
1919
: T(context,
2020
std::make_shared<RNSkMetalCanvasProvider>(
2121
std::bind(&RNSkia::RNSkView::requestRedraw, this), context)) {}

packages/skia/ios/RNSkia-iOS/RNSkiOSView.mm renamed to packages/skia/apple/RNSkAppleView.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
#import "RNSkMetalCanvasProvider.h"
44
#import "RNSkView.h"
5-
#import "RNSkiOSPlatformContext.h"
5+
#import "RNSkApplePlatformContext.h"
66

7-
class RNSkBaseiOSView {
7+
class RNSkBaseAppleView {
88
public:
99
virtual CALayer *getLayer() = 0;
1010
virtual void setSize(int width, int height) = 0;
1111
virtual std::shared_ptr<RNSkia::RNSkView> getDrawView() = 0;
1212
};
1313

14-
template <class T> class RNSkiOSView : public RNSkBaseiOSView, public T {
14+
template <class T> class RNSkAppleView : public RNSkBaseAppleView, public T {
1515
public:
16-
RNSkiOSView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
16+
RNSkAppleView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
1717
: T(context,
1818
std::make_shared<RNSkMetalCanvasProvider>(
1919
std::bind(&RNSkia::RNSkView::requestRedraw, this), context)) {}

0 commit comments

Comments
 (0)