Skip to content

Commit 3401111

Browse files
authored
fix(🤖): fix bug with default clear color on Android offscreen surfaces (#2781)
offscreen surfaces showed that they were using the fill color of the parent context unless overridden. This fixes that.
1 parent 88dec7f commit 3401111

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class OpenGLSharedContext {
2626
return instance;
2727
}
2828

29-
gl::Display* getDisplay() { return _glDisplay.get(); }
30-
gl::Context* getContext() { return _glContext.get(); }
29+
gl::Display *getDisplay() { return _glDisplay.get(); }
30+
gl::Context *getContext() { return _glContext.get(); }
3131

3232
private:
3333
std::unique_ptr<gl::Display> _glDisplay;
@@ -63,8 +63,11 @@ class OpenGLContext {
6363
}
6464

6565
// Create texture
66+
auto GL_RGBA8 = 0x8058;
67+
auto format = GrBackendFormats::MakeGL(GL_RGBA8, GL_TEXTURE_2D);
6668
auto texture = _directContext->createBackendTexture(
67-
width, height, colorType, skgpu::Mipmapped::kNo, GrRenderable::kYes);
69+
width, height, format, SkColors::kTransparent, skgpu::Mipmapped::kNo,
70+
GrRenderable::kYes);
6871

6972
if (!texture.isValid()) {
7073
RNSkLogger::logToConsole("couldn't create offscreen texture %dx%d", width,
@@ -153,8 +156,8 @@ class OpenGLContext {
153156
std::unique_ptr<WindowContext> MakeWindow(ANativeWindow *window, int width,
154157
int height) {
155158
auto display = OpenGLSharedContext::getInstance().getDisplay();
156-
return std::make_unique<OpenGLWindowContext>(
157-
_directContext.get(), display, _glContext.get(), window);
159+
return std::make_unique<OpenGLWindowContext>(_directContext.get(), display,
160+
_glContext.get(), window);
158161
}
159162

160163
GrDirectContext *getDirectContext() { return _directContext.get(); }
@@ -180,4 +183,4 @@ class OpenGLContext {
180183
}
181184
};
182185

183-
} // namespace RNSkia
186+
} // namespace RNSkia

0 commit comments

Comments
 (0)