Skip to content

Commit 21eb223

Browse files
authored
chore(⚠️): Fix some clang warnings (#2798)
1 parent 4073bb4 commit 21eb223

16 files changed

+52
-46
lines changed

externals/depot_tools

Submodule depot_tools updated from beb48f1 to 728e704

packages/skia/android/cpp/jni/include/JniSkiaBaseView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class JniSkiaBaseView {
2020
public:
2121
JniSkiaBaseView(jni::alias_ref<JniSkiaManager::javaobject> skiaManager,
2222
std::shared_ptr<RNSkBaseAndroidView> skiaView)
23-
: _manager(skiaManager->cthis()), _skiaAndroidView(skiaView) {}
23+
: _manager(skiaManager->cthis()), _skiaAndroidView(std::move(skiaView)) {}
2424

25-
~JniSkiaBaseView() {}
25+
~JniSkiaBaseView() = default;
2626

2727
std::shared_ptr<RNSkManager> getSkiaManager() {
2828
return _manager->getSkiaManager();

packages/skia/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ GrBackendFormat GetGLBackendFormat(GrDirectContext *dContext,
4141
bool requireKnownFormat) {
4242
GrBackendApi backend = dContext->backend();
4343
if (backend != GrBackendApi::kOpenGL) {
44-
return GrBackendFormat();
44+
return {};
4545
}
4646
switch (bufferFormat) {
4747
// TODO: find out if we can detect, which graphic buffers support
@@ -63,7 +63,7 @@ GrBackendFormat GetGLBackendFormat(GrDirectContext *dContext,
6363
#endif
6464
default:
6565
if (requireKnownFormat) {
66-
return GrBackendFormat();
66+
return {};
6767
} else {
6868
return GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL);
6969
}
@@ -110,12 +110,12 @@ void GLTextureHelper::rebind(GrDirectContext *dContext) {
110110
}
111111

112112
void delete_gl_texture(void *context) {
113-
GLTextureHelper *cleanupHelper = static_cast<GLTextureHelper *>(context);
113+
auto cleanupHelper = static_cast<GLTextureHelper *>(context);
114114
delete cleanupHelper;
115115
}
116116

117117
void update_gl_texture(void *context, GrDirectContext *dContext) {
118-
GLTextureHelper *cleanupHelper = static_cast<GLTextureHelper *>(context);
118+
auto cleanupHelper = static_cast<GLTextureHelper *>(context);
119119
cleanupHelper->rebind(dContext);
120120
}
121121

@@ -127,13 +127,13 @@ static GrBackendTexture make_gl_backend_texture(
127127
while (GL_NO_ERROR != glGetError()) {
128128
} // clear GL errors
129129

130-
EGLGetNativeClientBufferANDROIDProc eglGetNativeClientBufferANDROID =
130+
auto eglGetNativeClientBufferANDROID =
131131
(EGLGetNativeClientBufferANDROIDProc)eglGetProcAddress(
132132
"eglGetNativeClientBufferANDROID");
133133
if (!eglGetNativeClientBufferANDROID) {
134134
RNSkLogger::logToConsole(
135135
"Failed to get the eglGetNativeClientBufferAndroid proc");
136-
return GrBackendTexture();
136+
return {};
137137
}
138138

139139
EGLClientBuffer clientBuffer =
@@ -149,14 +149,14 @@ static GrBackendTexture make_gl_backend_texture(
149149
if (EGL_NO_IMAGE_KHR == image) {
150150
SkDebugf("Could not create EGL image, err = (%#x)",
151151
static_cast<int>(eglGetError()));
152-
return GrBackendTexture();
152+
return {};
153153
}
154154

155155
GrGLuint texID;
156156
glGenTextures(1, &texID);
157157
if (!texID) {
158158
eglDestroyImageKHR(display, image);
159-
return GrBackendTexture();
159+
return {};
160160
}
161161

162162
GrGLuint target = isRenderable ? GR_GL_TEXTURE_2D : GR_GL_TEXTURE_EXTERNAL;
@@ -167,15 +167,15 @@ static GrBackendTexture make_gl_backend_texture(
167167
SkDebugf("glBindTexture failed (%#x)", static_cast<int>(status));
168168
glDeleteTextures(1, &texID);
169169
eglDestroyImageKHR(display, image);
170-
return GrBackendTexture();
170+
return {};
171171
}
172172
glEGLImageTargetTexture2DOES(target, image);
173173
if ((status = glGetError()) != GL_NO_ERROR) {
174174
SkDebugf("glEGLImageTargetTexture2DOES failed (%#x)",
175175
static_cast<int>(status));
176176
glDeleteTextures(1, &texID);
177177
eglDestroyImageKHR(display, image);
178-
return GrBackendTexture();
178+
return {};
179179
}
180180
dContext->resetContext(kTextureBinding_GrGLBackendState);
181181

@@ -223,16 +223,16 @@ MakeGLBackendTexture(GrDirectContext *dContext, AHardwareBuffer *hardwareBuffer,
223223
bool isProtectedContent,
224224
const GrBackendFormat &backendFormat, bool isRenderable) {
225225
SkASSERT(dContext);
226-
if (!dContext || dContext->abandoned()) {
227-
return GrBackendTexture();
226+
if (dContext->abandoned()) {
227+
return {};
228228
}
229229

230230
if (GrBackendApi::kOpenGL != dContext->backend()) {
231-
return GrBackendTexture();
231+
return {};
232232
}
233233

234234
if (isProtectedContent && !can_import_protected_content(dContext)) {
235-
return GrBackendTexture();
235+
return {};
236236
}
237237

238238
return make_gl_backend_texture(

packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class MainThreadDispatcher {
88
private:
9-
ALooper *mainLooper;
10-
int messagePipe[2];
9+
ALooper *mainLooper = nullptr;
10+
int messagePipe[2] = { -1, -1 };
1111
std::queue<std::function<void()>> taskQueue;
1212
std::mutex queueMutex;
1313

packages/skia/android/cpp/rnskia-android/OpenGLContext.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,23 @@ class OpenGLContext {
117117
// GR_GL_TEXTURE_2D
118118
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
119119
format = GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL);
120+
break;
120121
case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
121122
format = GrBackendFormats::MakeGL(GR_GL_RGBA16F, GR_GL_TEXTURE_EXTERNAL);
123+
break;
122124
case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
123-
format = GrBackendFormats::MakeGL(GR_GL_RGB565, GR_GL_TEXTURE_EXTERNAL);
125+
GrBackendFormats::MakeGL(GR_GL_RGB565, GR_GL_TEXTURE_EXTERNAL);
126+
break;
124127
case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
125128
format = GrBackendFormats::MakeGL(GR_GL_RGB10_A2, GR_GL_TEXTURE_EXTERNAL);
129+
break;
126130
case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
127131
format = GrBackendFormats::MakeGL(GR_GL_RGB8, GR_GL_TEXTURE_EXTERNAL);
132+
break;
128133
#if __ANDROID_API__ >= 33
129134
case AHARDWAREBUFFER_FORMAT_R8_UNORM:
130135
format = GrBackendFormats::MakeGL(GR_GL_R8, GR_GL_TEXTURE_EXTERNAL);
136+
break;
131137
#endif
132138
default:
133139
if (requireKnownFormat) {
@@ -136,10 +142,11 @@ class OpenGLContext {
136142
format = GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL);
137143
}
138144
}
139-
145+
auto width = static_cast<int>(description.width);
146+
auto height = static_cast<int>(description.height);
140147
auto backendTex = MakeGLBackendTexture(
141148
_directContext.get(), const_cast<AHardwareBuffer *>(hardwareBuffer),
142-
description.width, description.height, &deleteImageProc,
149+
width, height, &deleteImageProc,
143150
&updateImageProc, &deleteImageCtx, false, format, false);
144151
if (!backendTex.isValid()) {
145152
RNSkLogger::logToConsole(
@@ -159,8 +166,7 @@ class OpenGLContext {
159166
}
160167

161168
// TODO: remove width, height
162-
std::unique_ptr<WindowContext> MakeWindow(ANativeWindow *window, int width,
163-
int height) {
169+
std::unique_ptr<WindowContext> MakeWindow(ANativeWindow *window) {
164170
auto display = OpenGLSharedContext::getInstance().getDisplay();
165171
return std::make_unique<OpenGLWindowContext>(
166172
_directContext.get(), display, _glContext.get(), window,

packages/skia/android/cpp/rnskia-android/OpenGLWindowContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class OpenGLWindowContext : public WindowContext {
4242
_glSurface = display->makeWindowSurface(config, _window);
4343
}
4444

45-
~OpenGLWindowContext() {
45+
~OpenGLWindowContext() override {
4646
_skSurface = nullptr;
4747
_glSurface = nullptr;
4848
ANativeWindow_release(_window);

packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext {
3333
RNSkAndroidPlatformContext(
3434
JniPlatformContext *jniPlatformContext,
3535
std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker)
36-
: RNSkPlatformContext(jsCallInvoker,
36+
: RNSkPlatformContext(std::move(jsCallInvoker),
3737
jniPlatformContext->getPixelDensity()),
3838
_jniPlatformContext(jniPlatformContext) {}
3939

40-
~RNSkAndroidPlatformContext() {}
40+
~RNSkAndroidPlatformContext() override = default;
4141

4242
void performStreamOperation(
4343
const std::string &sourceUri,
@@ -63,7 +63,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext {
6363
return DawnContext::getInstance().MakeWindow(surface, width, height);
6464
#else
6565
auto aWindow = reinterpret_cast<ANativeWindow *>(surface);
66-
return OpenGLContext::getInstance().MakeWindow(aWindow, width, height);
66+
return OpenGLContext::getInstance().MakeWindow(aWindow);
6767
#endif
6868
}
6969

@@ -87,7 +87,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext {
8787

8888
OpenGLContext::getInstance().makeCurrent();
8989
if (glIsTexture(textureInfo.fID) == GL_FALSE) {
90-
throw new std::runtime_error("Invalid textureInfo");
90+
throw std::runtime_error("Invalid textureInfo");
9191
}
9292

9393
GrBackendTexture backendTexture = GrBackendTextures::MakeGL(
@@ -107,7 +107,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext {
107107

108108
void releaseNativeBuffer(uint64_t pointer) override {
109109
#if __ANDROID_API__ >= 26
110-
AHardwareBuffer *buffer = reinterpret_cast<AHardwareBuffer *>(pointer);
110+
auto *buffer = reinterpret_cast<AHardwareBuffer *>(pointer);
111111
AHardwareBuffer_release(buffer);
112112
#endif
113113
}
@@ -185,7 +185,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext {
185185
return getTextureInfo(texture);
186186
}
187187

188-
static const TextureInfo getTextureInfo(const GrBackendTexture &texture) {
188+
static TextureInfo getTextureInfo(const GrBackendTexture &texture) {
189189
if (!texture.isValid()) {
190190
throw std::runtime_error("invalid backend texture");
191191
}

packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RNSkAndroidVideo::RNSkAndroidVideo(jni::global_ref<jobject> jniVideo)
3535
#endif
3636
}
3737

38-
RNSkAndroidVideo::~RNSkAndroidVideo() {}
38+
RNSkAndroidVideo::~RNSkAndroidVideo() = default;
3939

4040
sk_sp<SkImage> RNSkAndroidVideo::nextImage(double *timeStamp) {
4141
#if __ANDROID_API__ >= 26

packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RNSkAndroidVideo : public RNSkVideo {
2626

2727
public:
2828
explicit RNSkAndroidVideo(jni::global_ref<jobject> jniVideo);
29-
~RNSkAndroidVideo();
29+
~RNSkAndroidVideo() override;
3030
sk_sp<SkImage> nextImage(double *timeStamp = nullptr) override;
3131
double duration() override;
3232
double framerate() override;

packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ namespace RNSkia {
2626
RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(
2727
std::function<void()> requestRedraw,
2828
std::shared_ptr<RNSkia::RNSkPlatformContext> platformContext)
29-
: RNSkCanvasProvider(requestRedraw), _platformContext(platformContext) {}
29+
: RNSkCanvasProvider(std::move(requestRedraw)), _platformContext(std::move(platformContext)) {}
3030

31-
RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() {}
31+
RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() = default;
3232

3333
float RNSkOpenGLCanvasProvider::getScaledWidth() {
3434
if (_surfaceHolder) {
@@ -110,7 +110,7 @@ void RNSkOpenGLCanvasProvider::surfaceAvailable(jobject jSurfaceTexture,
110110
_surfaceHolder = DawnContext::getInstance().MakeWindow(window, width, height);
111111
#else
112112
_surfaceHolder =
113-
OpenGLContext::getInstance().MakeWindow(window, width, height);
113+
OpenGLContext::getInstance().MakeWindow(window);
114114
#endif
115115

116116
// Post redraw request to ensure we paint in the next draw cycle.

0 commit comments

Comments
 (0)