forked from firka/flutter
Fix wrong context when use platfromview (flutter/engine#30184)
This commit is contained in:
@@ -67,7 +67,7 @@ std::unique_ptr<GLContextResult> IOSContextGL::MakeCurrent() {
|
||||
std::unique_ptr<Texture> IOSContextGL::CreateExternalTexture(
|
||||
int64_t texture_id,
|
||||
fml::scoped_nsobject<NSObject<FlutterTexture>> texture) {
|
||||
return std::make_unique<IOSExternalTextureGL>(texture_id, std::move(texture));
|
||||
return std::make_unique<IOSExternalTextureGL>(texture_id, std::move(texture), context_);
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -14,7 +14,9 @@ namespace flutter {
|
||||
|
||||
class IOSExternalTextureGL final : public Texture {
|
||||
public:
|
||||
IOSExternalTextureGL(int64_t textureId, NSObject<FlutterTexture>* externalTexture);
|
||||
IOSExternalTextureGL(int64_t textureId,
|
||||
NSObject<FlutterTexture>* externalTexture,
|
||||
fml::scoped_nsobject<EAGLContext> context);
|
||||
|
||||
// |Texture|
|
||||
~IOSExternalTextureGL() override;
|
||||
@@ -28,6 +30,7 @@ class IOSExternalTextureGL final : public Texture {
|
||||
OSType pixel_format_ = 0;
|
||||
fml::CFRef<CVOpenGLESTextureRef> y_texture_ref_;
|
||||
fml::CFRef<CVOpenGLESTextureRef> uv_texture_ref_;
|
||||
fml::scoped_nsobject<EAGLContext> context_;
|
||||
|
||||
// |Texture|
|
||||
void Paint(SkCanvas& canvas,
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
namespace flutter {
|
||||
|
||||
IOSExternalTextureGL::IOSExternalTextureGL(int64_t textureId,
|
||||
NSObject<FlutterTexture>* externalTexture)
|
||||
NSObject<FlutterTexture>* externalTexture,
|
||||
fml::scoped_nsobject<EAGLContext> context)
|
||||
: Texture(textureId),
|
||||
external_texture_(fml::scoped_nsobject<NSObject<FlutterTexture>>([externalTexture retain])) {
|
||||
external_texture_(fml::scoped_nsobject<NSObject<FlutterTexture>>([externalTexture retain])),
|
||||
context_(context) {
|
||||
FML_DCHECK(external_texture_);
|
||||
}
|
||||
|
||||
@@ -29,8 +31,8 @@ IOSExternalTextureGL::~IOSExternalTextureGL() = default;
|
||||
void IOSExternalTextureGL::EnsureTextureCacheExists() {
|
||||
if (!cache_ref_) {
|
||||
CVOpenGLESTextureCacheRef cache;
|
||||
CVReturn err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL,
|
||||
[EAGLContext currentContext], NULL, &cache);
|
||||
CVReturn err =
|
||||
CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL, context_.get(), NULL, &cache);
|
||||
if (err == noErr) {
|
||||
cache_ref_.Reset(cache);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user