Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
surface_texture_external_texture_gl.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
5#include "flutter/shell/platform/android/surface_texture_external_texture_gl.h"
6
7#include <utility>
8
9#include "flutter/display_list/effects/dl_color_source.h"
21
22namespace flutter {
23
25 int64_t id,
26 const fml::jni::ScopedJavaGlobalRef<jobject>& surface_texture,
27 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
28 : SurfaceTextureExternalTexture(id, surface_texture, jni_facade) {}
29
31 if (texture_name_ != 0) {
32 glDeleteTextures(1, &texture_name_);
33 }
34}
35
37 const SkRect& bounds) {
39 // Generate the texture handle.
40 glGenTextures(1, &texture_name_);
41 Attach(texture_name_);
42 }
44
45 // Updates the texture contents and transformation matrix.
46 Update();
47
48 // Create a
49 GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_,
50 GL_RGBA8_OES};
51 auto backendTexture =
52 GrBackendTextures::MakeGL(1, 1, skgpu::Mipmapped::kNo, textureInfo);
54 context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin,
56}
57
60 if (texture_name_ != 0) {
61 glDeleteTextures(1, &texture_name_);
62 texture_name_ = 0;
63 }
64}
65
68 const std::shared_ptr<impeller::ContextGLES>& context,
69 int64_t id,
70 const fml::jni::ScopedJavaGlobalRef<jobject>& surface_texture,
71 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
72 : SurfaceTextureExternalTexture(id, surface_texture, jni_facade),
73 impeller_context_(context) {}
74
77
79 PaintContext& context,
80 const SkRect& bounds) {
82 // Generate the texture handle.
85 desc.storage_mode = impeller::StorageMode::kDevicePrivate;
87 desc.size = {static_cast<int>(bounds.width()),
88 static_cast<int>(bounds.height())};
89 desc.mip_count = 1;
90 texture_ = std::make_shared<impeller::TextureGLES>(
91 impeller_context_->GetReactor(), desc,
93 texture_->SetCoordinateSystem(
95 auto maybe_handle = texture_->GetGLHandle();
96 if (!maybe_handle.has_value()) {
97 FML_LOG(ERROR) << "Could not get GL handle from impeller::TextureGLES!";
98 return;
99 }
100 Attach(maybe_handle.value());
101 }
103
104 // Updates the texture contents and transformation matrix.
105 Update();
106
108}
109
114
115} // namespace flutter
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
static sk_sp< DlImage > Make(const SkImage *image)
Definition dl_image.cc:11
SurfaceTextureExternalTextureGL(int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
virtual void ProcessFrame(PaintContext &context, const SkRect &bounds) override
SurfaceTextureExternalTextureImpellerGL(const std::shared_ptr< impeller::ContextGLES > &context, int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
virtual void ProcessFrame(PaintContext &context, const SkRect &bounds) override
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
#define FML_LOG(severity)
Definition logging.h:82
#define FML_CHECK(condition)
Definition logging.h:85
SK_API GrBackendTexture MakeGL(int width, int height, skgpu::Mipmapped, const GrGLTextureInfo &glInfo, std::string_view label={})
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
GrDirectContext * gr_context
Definition texture.h:43
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
const uintptr_t id
#define ERROR(message)