-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(🤖): fix minor threading issue on Android (#2725)
The main goal of this PR is to refactor the platforms-specific Skia code in a way that will make the Graphite migration smoother. It also fixes a minor issue on Android where one onscreen contextes could created in many threads instead of only once. This issue is most likely not affecting any users.
- Loading branch information
1 parent
ce475ac
commit 569acc9
Showing
23 changed files
with
318 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include "SkiaOpenGLSurfaceFactory.h" | ||
#include "WindowContext.h" | ||
|
||
#include "include/core/SkSurface.h" | ||
|
||
class OpenGLContext { | ||
public: | ||
OpenGLContext(const OpenGLContext &) = delete; | ||
OpenGLContext &operator=(const OpenGLContext &) = delete; | ||
|
||
static OpenGLContext &getInstance() { | ||
static thread_local OpenGLContext instance; | ||
return instance; | ||
} | ||
|
||
sk_sp<SkSurface> MakeOffscreen(int width, int height) { | ||
return RNSkia::SkiaOpenGLSurfaceFactory::makeOffscreenSurface( | ||
&_context, width, height); | ||
} | ||
|
||
sk_sp<SkImage> MakeImageFromBuffer(void *buffer) { | ||
return RNSkia::SkiaOpenGLSurfaceFactory::makeImageFromHardwareBuffer( | ||
&_context, buffer); | ||
} | ||
|
||
std::unique_ptr<RNSkia::WindowContext> MakeWindow(ANativeWindow *window, | ||
int width, int height) { | ||
return RNSkia::SkiaOpenGLSurfaceFactory::makeContext(&_context, window, | ||
width, height); | ||
} | ||
|
||
private: | ||
RNSkia::SkiaOpenGLContext _context; | ||
|
||
OpenGLContext() { | ||
RNSkia::SkiaOpenGLHelper::createSkiaDirectContextIfNecessary(&_context); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.