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

+2-2
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

+14-14
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

+2-2
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

+11-5
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

+1-1
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

+6-6
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

+1-1
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

+1-1
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

+3-3
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.

packages/skia/cpp/api/JsiSkApi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class JsiSkApi : public JsiSkHostObject {
6464
* and provide functions for accessing and creating the Skia wrapper objects
6565
* @param context Platform context
6666
*/
67-
JsiSkApi(jsi::Runtime &runtime, std::shared_ptr<RNSkPlatformContext> context)
67+
explicit JsiSkApi(const std::shared_ptr<RNSkPlatformContext> &context)
6868
: JsiSkHostObject(context) {
6969
// We create the system font manager eagerly since it has proven to be too
7070
// slow to do it on demand

packages/skia/cpp/api/JsiSkCanvas.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class JsiSkCanvas : public JsiSkHostObject {
8383
auto src = JsiSkRect::fromValue(runtime, arguments[1]);
8484
auto dest = JsiSkRect::fromValue(runtime, arguments[2]);
8585
auto paint = JsiSkPaint::fromValue(runtime, arguments[3]);
86-
auto fastSample = count < 5 ? false : arguments[4].getBool();
86+
auto fastSample = count >= 5 && arguments[4].getBool();
8787
_canvas->drawImageRect(image, *src, *dest, SkSamplingOptions(), paint.get(),
8888
fastSample ? SkCanvas::kFast_SrcRectConstraint
8989
: SkCanvas::kStrict_SrcRectConstraint);

packages/skia/cpp/api/JsiSkColor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class JsiSkColor : public RNJsi::JsiHostObject {
2424
public:
2525
JsiSkColor() : JsiHostObject() {}
2626

27-
~JsiSkColor() {}
27+
~JsiSkColor() override = default;
2828

2929
static jsi::Object toValue(jsi::Runtime &runtime, SkColor color) {
3030
auto result = runtime.global()
@@ -63,7 +63,7 @@ class JsiSkColor : public RNJsi::JsiHostObject {
6363
* @return A function for creating a new host object wrapper for the SkColor
6464
* class
6565
*/
66-
static const jsi::HostFunctionType createCtor() {
66+
static jsi::HostFunctionType createCtor() {
6767
return JSI_HOST_FUNCTION_LAMBDA {
6868
if (arguments[0].isNumber()) {
6969
return JsiSkColor::toValue(runtime, arguments[0].getNumber());

packages/skia/cpp/api/third_party/CSSColorParser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
namespace CSSColorParser {
3535

3636
struct Color {
37-
inline Color() {}
37+
inline Color() = default;
3838
inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_)
3939
: r(r_), g(g_), b(b_), a(a_ > 1 ? 1
4040
: a_ < 0 ? 0

packages/skia/cpp/api/third_party/base64.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ namespace RNSkia {
2626

2727
Base64::Error Base64::Decode(const void *srcv, size_t srcLength, void *dstv,
2828
size_t *dstLength) {
29-
const unsigned char *src = static_cast<const unsigned char *>(srcv);
30-
unsigned char *dst = static_cast<unsigned char *>(dstv);
29+
auto *src = static_cast<const unsigned char *>(srcv);
30+
auto *dst = static_cast<unsigned char *>(dstv);
3131

3232
int i = 0;
3333
bool padTwo = false;
@@ -112,8 +112,8 @@ Base64::Error Base64::Decode(const void *srcv, size_t srcLength, void *dstv,
112112
}
113113

114114
size_t Base64::Encode(const void *srcv, size_t length, void *dstv) {
115-
const unsigned char *src = static_cast<const unsigned char *>(srcv);
116-
unsigned char *dst = static_cast<unsigned char *>(dstv);
115+
auto *src = static_cast<const unsigned char *>(srcv);
116+
auto *dst = static_cast<unsigned char *>(dstv);
117117

118118
const char *encode = kDefaultEncode;
119119
if (dst) {

packages/skia/cpp/rnskia/RNSkManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void RNSkManager::installBindings() {
6969
// Create the API objects and install it on the global object in the
7070
// provided runtime.
7171

72-
auto skiaApi = std::make_shared<JsiSkApi>(*_jsRuntime, _platformContext);
72+
auto skiaApi = std::make_shared<JsiSkApi>(_platformContext);
7373
_jsRuntime->global().setProperty(
7474
*_jsRuntime, "SkiaApi",
7575
jsi::Object::createFromHostObject(*_jsRuntime, std::move(skiaApi)));

0 commit comments

Comments
 (0)