From 3401111d672eaed516a78dcd2eb2aae36427bf76 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Sat, 30 Nov 2024 18:24:41 +0100 Subject: [PATCH] =?UTF-8?q?fix(=F0=9F=A4=96):=20fix=20bug=20with=20default?= =?UTF-8?q?=20clear=20color=20on=20Android=20offscreen=20surfaces=20(#2781?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit offscreen surfaces showed that they were using the fill color of the parent context unless overridden. This fixes that. --- .../android/cpp/rnskia-android/OpenGLContext.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/skia/android/cpp/rnskia-android/OpenGLContext.h b/packages/skia/android/cpp/rnskia-android/OpenGLContext.h index 08206d0b9f..8f1d7156c1 100644 --- a/packages/skia/android/cpp/rnskia-android/OpenGLContext.h +++ b/packages/skia/android/cpp/rnskia-android/OpenGLContext.h @@ -26,8 +26,8 @@ class OpenGLSharedContext { return instance; } - gl::Display* getDisplay() { return _glDisplay.get(); } - gl::Context* getContext() { return _glContext.get(); } + gl::Display *getDisplay() { return _glDisplay.get(); } + gl::Context *getContext() { return _glContext.get(); } private: std::unique_ptr _glDisplay; @@ -63,8 +63,11 @@ class OpenGLContext { } // Create texture + auto GL_RGBA8 = 0x8058; + auto format = GrBackendFormats::MakeGL(GL_RGBA8, GL_TEXTURE_2D); auto texture = _directContext->createBackendTexture( - width, height, colorType, skgpu::Mipmapped::kNo, GrRenderable::kYes); + width, height, format, SkColors::kTransparent, skgpu::Mipmapped::kNo, + GrRenderable::kYes); if (!texture.isValid()) { RNSkLogger::logToConsole("couldn't create offscreen texture %dx%d", width, @@ -153,8 +156,8 @@ class OpenGLContext { std::unique_ptr MakeWindow(ANativeWindow *window, int width, int height) { auto display = OpenGLSharedContext::getInstance().getDisplay(); - return std::make_unique( - _directContext.get(), display, _glContext.get(), window); + return std::make_unique(_directContext.get(), display, + _glContext.get(), window); } GrDirectContext *getDirectContext() { return _directContext.get(); } @@ -180,4 +183,4 @@ class OpenGLContext { } }; -} // namespace RNSkia \ No newline at end of file +} // namespace RNSkia