diff --git a/externals/depot_tools b/externals/depot_tools index beb48f193f..728e704add 160000 --- a/externals/depot_tools +++ b/externals/depot_tools @@ -1 +1 @@ -Subproject commit beb48f193f4d5e095c9f09411ae35a4980bd5897 +Subproject commit 728e704add46ccc31607fc2265e8ef518b9650fe diff --git a/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h b/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h index eaf6691054..11ea168b39 100644 --- a/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h +++ b/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h @@ -20,9 +20,9 @@ class JniSkiaBaseView { public: JniSkiaBaseView(jni::alias_ref skiaManager, std::shared_ptr skiaView) - : _manager(skiaManager->cthis()), _skiaAndroidView(skiaView) {} + : _manager(skiaManager->cthis()), _skiaAndroidView(std::move(skiaView)) {} - ~JniSkiaBaseView() {} + ~JniSkiaBaseView() = default; std::shared_ptr getSkiaManager() { return _manager->getSkiaManager(); diff --git a/packages/skia/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp b/packages/skia/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp index 8f2d7c998d..bc061caf07 100644 --- a/packages/skia/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +++ b/packages/skia/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp @@ -41,7 +41,7 @@ GrBackendFormat GetGLBackendFormat(GrDirectContext *dContext, bool requireKnownFormat) { GrBackendApi backend = dContext->backend(); if (backend != GrBackendApi::kOpenGL) { - return GrBackendFormat(); + return {}; } switch (bufferFormat) { // TODO: find out if we can detect, which graphic buffers support @@ -63,7 +63,7 @@ GrBackendFormat GetGLBackendFormat(GrDirectContext *dContext, #endif default: if (requireKnownFormat) { - return GrBackendFormat(); + return {}; } else { return GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL); } @@ -110,12 +110,12 @@ void GLTextureHelper::rebind(GrDirectContext *dContext) { } void delete_gl_texture(void *context) { - GLTextureHelper *cleanupHelper = static_cast(context); + auto cleanupHelper = static_cast(context); delete cleanupHelper; } void update_gl_texture(void *context, GrDirectContext *dContext) { - GLTextureHelper *cleanupHelper = static_cast(context); + auto cleanupHelper = static_cast(context); cleanupHelper->rebind(dContext); } @@ -127,13 +127,13 @@ static GrBackendTexture make_gl_backend_texture( while (GL_NO_ERROR != glGetError()) { } // clear GL errors - EGLGetNativeClientBufferANDROIDProc eglGetNativeClientBufferANDROID = + auto eglGetNativeClientBufferANDROID = (EGLGetNativeClientBufferANDROIDProc)eglGetProcAddress( "eglGetNativeClientBufferANDROID"); if (!eglGetNativeClientBufferANDROID) { RNSkLogger::logToConsole( "Failed to get the eglGetNativeClientBufferAndroid proc"); - return GrBackendTexture(); + return {}; } EGLClientBuffer clientBuffer = @@ -149,14 +149,14 @@ static GrBackendTexture make_gl_backend_texture( if (EGL_NO_IMAGE_KHR == image) { SkDebugf("Could not create EGL image, err = (%#x)", static_cast(eglGetError())); - return GrBackendTexture(); + return {}; } GrGLuint texID; glGenTextures(1, &texID); if (!texID) { eglDestroyImageKHR(display, image); - return GrBackendTexture(); + return {}; } GrGLuint target = isRenderable ? GR_GL_TEXTURE_2D : GR_GL_TEXTURE_EXTERNAL; @@ -167,7 +167,7 @@ static GrBackendTexture make_gl_backend_texture( SkDebugf("glBindTexture failed (%#x)", static_cast(status)); glDeleteTextures(1, &texID); eglDestroyImageKHR(display, image); - return GrBackendTexture(); + return {}; } glEGLImageTargetTexture2DOES(target, image); if ((status = glGetError()) != GL_NO_ERROR) { @@ -175,7 +175,7 @@ static GrBackendTexture make_gl_backend_texture( static_cast(status)); glDeleteTextures(1, &texID); eglDestroyImageKHR(display, image); - return GrBackendTexture(); + return {}; } dContext->resetContext(kTextureBinding_GrGLBackendState); @@ -223,16 +223,16 @@ MakeGLBackendTexture(GrDirectContext *dContext, AHardwareBuffer *hardwareBuffer, bool isProtectedContent, const GrBackendFormat &backendFormat, bool isRenderable) { SkASSERT(dContext); - if (!dContext || dContext->abandoned()) { - return GrBackendTexture(); + if (dContext->abandoned()) { + return {}; } if (GrBackendApi::kOpenGL != dContext->backend()) { - return GrBackendTexture(); + return {}; } if (isProtectedContent && !can_import_protected_content(dContext)) { - return GrBackendTexture(); + return {}; } return make_gl_backend_texture( diff --git a/packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h b/packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h index 4a33906ee9..ad91cfdc09 100644 --- a/packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h +++ b/packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h @@ -6,8 +6,8 @@ class MainThreadDispatcher { private: - ALooper *mainLooper; - int messagePipe[2]; + ALooper *mainLooper = nullptr; + int messagePipe[2] = { -1, -1 }; std::queue> taskQueue; std::mutex queueMutex; diff --git a/packages/skia/android/cpp/rnskia-android/OpenGLContext.h b/packages/skia/android/cpp/rnskia-android/OpenGLContext.h index f08b879e02..17159a9246 100644 --- a/packages/skia/android/cpp/rnskia-android/OpenGLContext.h +++ b/packages/skia/android/cpp/rnskia-android/OpenGLContext.h @@ -117,17 +117,23 @@ class OpenGLContext { // GR_GL_TEXTURE_2D case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM: format = GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL); + break; case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT: format = GrBackendFormats::MakeGL(GR_GL_RGBA16F, GR_GL_TEXTURE_EXTERNAL); + break; case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM: - format = GrBackendFormats::MakeGL(GR_GL_RGB565, GR_GL_TEXTURE_EXTERNAL); + GrBackendFormats::MakeGL(GR_GL_RGB565, GR_GL_TEXTURE_EXTERNAL); + break; case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM: format = GrBackendFormats::MakeGL(GR_GL_RGB10_A2, GR_GL_TEXTURE_EXTERNAL); + break; case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM: format = GrBackendFormats::MakeGL(GR_GL_RGB8, GR_GL_TEXTURE_EXTERNAL); + break; #if __ANDROID_API__ >= 33 case AHARDWAREBUFFER_FORMAT_R8_UNORM: format = GrBackendFormats::MakeGL(GR_GL_R8, GR_GL_TEXTURE_EXTERNAL); + break; #endif default: if (requireKnownFormat) { @@ -136,10 +142,11 @@ class OpenGLContext { format = GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL); } } - + auto width = static_cast(description.width); + auto height = static_cast(description.height); auto backendTex = MakeGLBackendTexture( _directContext.get(), const_cast(hardwareBuffer), - description.width, description.height, &deleteImageProc, + width, height, &deleteImageProc, &updateImageProc, &deleteImageCtx, false, format, false); if (!backendTex.isValid()) { RNSkLogger::logToConsole( @@ -159,8 +166,7 @@ class OpenGLContext { } // TODO: remove width, height - std::unique_ptr MakeWindow(ANativeWindow *window, int width, - int height) { + std::unique_ptr MakeWindow(ANativeWindow *window) { auto display = OpenGLSharedContext::getInstance().getDisplay(); return std::make_unique( _directContext.get(), display, _glContext.get(), window, diff --git a/packages/skia/android/cpp/rnskia-android/OpenGLWindowContext.h b/packages/skia/android/cpp/rnskia-android/OpenGLWindowContext.h index 223648d1ed..7c69468c76 100644 --- a/packages/skia/android/cpp/rnskia-android/OpenGLWindowContext.h +++ b/packages/skia/android/cpp/rnskia-android/OpenGLWindowContext.h @@ -42,7 +42,7 @@ class OpenGLWindowContext : public WindowContext { _glSurface = display->makeWindowSurface(config, _window); } - ~OpenGLWindowContext() { + ~OpenGLWindowContext() override { _skSurface = nullptr; _glSurface = nullptr; ANativeWindow_release(_window); diff --git a/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h b/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h index 360c1520f2..ccefa47fac 100644 --- a/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +++ b/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h @@ -33,11 +33,11 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { RNSkAndroidPlatformContext( JniPlatformContext *jniPlatformContext, std::shared_ptr jsCallInvoker) - : RNSkPlatformContext(jsCallInvoker, + : RNSkPlatformContext(std::move(jsCallInvoker), jniPlatformContext->getPixelDensity()), _jniPlatformContext(jniPlatformContext) {} - ~RNSkAndroidPlatformContext() {} + ~RNSkAndroidPlatformContext() override = default; void performStreamOperation( const std::string &sourceUri, @@ -63,7 +63,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { return DawnContext::getInstance().MakeWindow(surface, width, height); #else auto aWindow = reinterpret_cast(surface); - return OpenGLContext::getInstance().MakeWindow(aWindow, width, height); + return OpenGLContext::getInstance().MakeWindow(aWindow); #endif } @@ -87,7 +87,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { OpenGLContext::getInstance().makeCurrent(); if (glIsTexture(textureInfo.fID) == GL_FALSE) { - throw new std::runtime_error("Invalid textureInfo"); + throw std::runtime_error("Invalid textureInfo"); } GrBackendTexture backendTexture = GrBackendTextures::MakeGL( @@ -107,7 +107,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { void releaseNativeBuffer(uint64_t pointer) override { #if __ANDROID_API__ >= 26 - AHardwareBuffer *buffer = reinterpret_cast(pointer); + auto *buffer = reinterpret_cast(pointer); AHardwareBuffer_release(buffer); #endif } @@ -185,7 +185,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { return getTextureInfo(texture); } - static const TextureInfo getTextureInfo(const GrBackendTexture &texture) { + static TextureInfo getTextureInfo(const GrBackendTexture &texture) { if (!texture.isValid()) { throw std::runtime_error("invalid backend texture"); } diff --git a/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.cpp b/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.cpp index 0edafa3ca3..c0867479cf 100644 --- a/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +++ b/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.cpp @@ -35,7 +35,7 @@ RNSkAndroidVideo::RNSkAndroidVideo(jni::global_ref jniVideo) #endif } -RNSkAndroidVideo::~RNSkAndroidVideo() {} +RNSkAndroidVideo::~RNSkAndroidVideo() = default; sk_sp RNSkAndroidVideo::nextImage(double *timeStamp) { #if __ANDROID_API__ >= 26 diff --git a/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.h b/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.h index 4198d667f4..e6cea1455d 100644 --- a/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.h +++ b/packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.h @@ -26,7 +26,7 @@ class RNSkAndroidVideo : public RNSkVideo { public: explicit RNSkAndroidVideo(jni::global_ref jniVideo); - ~RNSkAndroidVideo(); + ~RNSkAndroidVideo() override; sk_sp nextImage(double *timeStamp = nullptr) override; double duration() override; double framerate() override; diff --git a/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp b/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp index 361bdc2997..f75d48024d 100644 --- a/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +++ b/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp @@ -26,9 +26,9 @@ namespace RNSkia { RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider( std::function requestRedraw, std::shared_ptr platformContext) - : RNSkCanvasProvider(requestRedraw), _platformContext(platformContext) {} + : RNSkCanvasProvider(std::move(requestRedraw)), _platformContext(std::move(platformContext)) {} -RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() {} +RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() = default; float RNSkOpenGLCanvasProvider::getScaledWidth() { if (_surfaceHolder) { @@ -110,7 +110,7 @@ void RNSkOpenGLCanvasProvider::surfaceAvailable(jobject jSurfaceTexture, _surfaceHolder = DawnContext::getInstance().MakeWindow(window, width, height); #else _surfaceHolder = - OpenGLContext::getInstance().MakeWindow(window, width, height); + OpenGLContext::getInstance().MakeWindow(window); #endif // Post redraw request to ensure we paint in the next draw cycle. diff --git a/packages/skia/cpp/api/JsiSkApi.h b/packages/skia/cpp/api/JsiSkApi.h index 170f26ba2d..2e1363f564 100644 --- a/packages/skia/cpp/api/JsiSkApi.h +++ b/packages/skia/cpp/api/JsiSkApi.h @@ -64,7 +64,7 @@ class JsiSkApi : public JsiSkHostObject { * and provide functions for accessing and creating the Skia wrapper objects * @param context Platform context */ - JsiSkApi(jsi::Runtime &runtime, std::shared_ptr context) + explicit JsiSkApi(const std::shared_ptr &context) : JsiSkHostObject(context) { // We create the system font manager eagerly since it has proven to be too // slow to do it on demand diff --git a/packages/skia/cpp/api/JsiSkCanvas.h b/packages/skia/cpp/api/JsiSkCanvas.h index 394e2b9274..3e72d7d7e2 100644 --- a/packages/skia/cpp/api/JsiSkCanvas.h +++ b/packages/skia/cpp/api/JsiSkCanvas.h @@ -83,7 +83,7 @@ class JsiSkCanvas : public JsiSkHostObject { auto src = JsiSkRect::fromValue(runtime, arguments[1]); auto dest = JsiSkRect::fromValue(runtime, arguments[2]); auto paint = JsiSkPaint::fromValue(runtime, arguments[3]); - auto fastSample = count < 5 ? false : arguments[4].getBool(); + auto fastSample = count >= 5 && arguments[4].getBool(); _canvas->drawImageRect(image, *src, *dest, SkSamplingOptions(), paint.get(), fastSample ? SkCanvas::kFast_SrcRectConstraint : SkCanvas::kStrict_SrcRectConstraint); diff --git a/packages/skia/cpp/api/JsiSkColor.h b/packages/skia/cpp/api/JsiSkColor.h index 89115d8354..5b4ed2176a 100644 --- a/packages/skia/cpp/api/JsiSkColor.h +++ b/packages/skia/cpp/api/JsiSkColor.h @@ -24,7 +24,7 @@ class JsiSkColor : public RNJsi::JsiHostObject { public: JsiSkColor() : JsiHostObject() {} - ~JsiSkColor() {} + ~JsiSkColor() override = default; static jsi::Object toValue(jsi::Runtime &runtime, SkColor color) { auto result = runtime.global() @@ -63,7 +63,7 @@ class JsiSkColor : public RNJsi::JsiHostObject { * @return A function for creating a new host object wrapper for the SkColor * class */ - static const jsi::HostFunctionType createCtor() { + static jsi::HostFunctionType createCtor() { return JSI_HOST_FUNCTION_LAMBDA { if (arguments[0].isNumber()) { return JsiSkColor::toValue(runtime, arguments[0].getNumber()); diff --git a/packages/skia/cpp/api/third_party/CSSColorParser.h b/packages/skia/cpp/api/third_party/CSSColorParser.h index 03b2186b42..9ae24a5d5c 100644 --- a/packages/skia/cpp/api/third_party/CSSColorParser.h +++ b/packages/skia/cpp/api/third_party/CSSColorParser.h @@ -34,7 +34,7 @@ namespace CSSColorParser { struct Color { - inline Color() {} + inline Color() = default; inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_) : r(r_), g(g_), b(b_), a(a_ > 1 ? 1 : a_ < 0 ? 0 diff --git a/packages/skia/cpp/api/third_party/base64.cpp b/packages/skia/cpp/api/third_party/base64.cpp index 0ae30c61cf..ac02ac2c91 100644 --- a/packages/skia/cpp/api/third_party/base64.cpp +++ b/packages/skia/cpp/api/third_party/base64.cpp @@ -26,8 +26,8 @@ namespace RNSkia { Base64::Error Base64::Decode(const void *srcv, size_t srcLength, void *dstv, size_t *dstLength) { - const unsigned char *src = static_cast(srcv); - unsigned char *dst = static_cast(dstv); + auto *src = static_cast(srcv); + auto *dst = static_cast(dstv); int i = 0; bool padTwo = false; @@ -112,8 +112,8 @@ Base64::Error Base64::Decode(const void *srcv, size_t srcLength, void *dstv, } size_t Base64::Encode(const void *srcv, size_t length, void *dstv) { - const unsigned char *src = static_cast(srcv); - unsigned char *dst = static_cast(dstv); + auto *src = static_cast(srcv); + auto *dst = static_cast(dstv); const char *encode = kDefaultEncode; if (dst) { diff --git a/packages/skia/cpp/rnskia/RNSkManager.cpp b/packages/skia/cpp/rnskia/RNSkManager.cpp index cb56782e4d..57bf9f6cca 100644 --- a/packages/skia/cpp/rnskia/RNSkManager.cpp +++ b/packages/skia/cpp/rnskia/RNSkManager.cpp @@ -69,7 +69,7 @@ void RNSkManager::installBindings() { // Create the API objects and install it on the global object in the // provided runtime. - auto skiaApi = std::make_shared(*_jsRuntime, _platformContext); + auto skiaApi = std::make_shared(_platformContext); _jsRuntime->global().setProperty( *_jsRuntime, "SkiaApi", jsi::Object::createFromHostObject(*_jsRuntime, std::move(skiaApi)));