Flutter Engine
 
Loading...
Searching...
No Matches
surface_texture_external_texture_gl_impeller.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8
9namespace flutter {
10
13 const std::shared_ptr<impeller::ContextGLES>& context,
14 int64_t id,
15 const fml::jni::ScopedJavaGlobalRef<jobject>& surface_texture,
16 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
17 : SurfaceTextureExternalTexture(id, surface_texture, jni_facade),
18 impeller_context_(context) {}
19
22
23void SurfaceTextureExternalTextureGLImpeller::ProcessFrame(
24 PaintContext& context,
25 const SkRect& bounds) {
27 // Generate the texture handle.
32 desc.size = {1, 1};
33 desc.mip_count = 1;
34 texture_ = std::make_shared<impeller::TextureGLES>(
35 impeller_context_->GetReactor(), desc);
36 // The contents will be initialized later in the call to `Attach` instead of
37 // by Impeller.
38 texture_->MarkContentsInitialized();
39 texture_->SetCoordinateSystem(
41 auto maybe_handle = texture_->GetGLHandle();
42 if (!maybe_handle.has_value()) {
43 FML_LOG(ERROR) << "Could not get GL handle from impeller::TextureGLES!";
44 return;
45 }
46 Attach(maybe_handle.value());
47 }
49
50 // Updates the texture contents and transformation matrix.
51 Update();
52
54}
55
56void SurfaceTextureExternalTextureGLImpeller::Detach() {
58 // Detach will collect the texture handle.
59 // See also: https://github.com/flutter/flutter/issues/152459
60 texture_->Leak();
61 texture_.reset();
62}
63
64} // namespace flutter
SurfaceTextureExternalTextureGLImpeller(const std::shared_ptr< impeller::ContextGLES > &context, int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
Instances of external textures peered to android.graphics.SurfaceTexture.
void Attach(int gl_tex_id)
Attaches the given OpenGL texture handle to the surface texture via a bind operation.
virtual void Detach()
Provides an opportunity for the subclasses to sever the connection between the OpenGL texture resourc...
void Update()
Update the surface texture contents and transformation matrix.
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
#define FML_LOG(severity)
Definition logging.h:101
#define FML_CHECK(condition)
Definition logging.h:104
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
const uintptr_t id