16#include "include/core/SkPaint.h"
17#include "third_party/skia/include/core/SkAlphaType.h"
18#include "third_party/skia/include/core/SkColorSpace.h"
19#include "third_party/skia/include/core/SkColorType.h"
20#include "third_party/skia/include/core/SkImage.h"
21#include "third_party/skia/include/core/SkSize.h"
22#include "third_party/skia/include/gpu/ganesh/GrBackendSurface.h"
23#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
24#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
25#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
26#include "third_party/skia/include/gpu/ganesh/gl/GrGLTypes.h"
31 int64_t texture_identifier,
40void EmbedderExternalTextureGL::Paint(
PaintContext& context,
44 if (last_image_ ==
nullptr) {
53 DlCanvas* canvas = context.
canvas;
54 const DlPaint* paint = context.paint;
58 if (bounds != image_bounds) {
59 canvas->DrawImageRect(last_image_, image_bounds, bounds, sampling, paint);
61 canvas->DrawImage(last_image_, bounds.
GetOrigin(), sampling, paint);
66sk_sp<DlImage> EmbedderExternalTextureGL::ResolveTexture(
68 GrDirectContext* context,
70 const SkISize&
size) {
78sk_sp<DlImage> EmbedderExternalTextureGL::ResolveTextureSkia(
80 GrDirectContext* context,
81 const SkISize&
size) {
82 context->flushAndSubmit();
83 context->resetContext(kAll_GrBackendState);
84 std::unique_ptr<FlutterOpenGLTexture>
texture =
102 auto gr_backend_texture = GrBackendTextures::MakeGL(
103 width,
height, skgpu::Mipmapped::kNo, gr_texture_info);
104 SkImages::TextureReleaseProc release_proc =
texture->destruction_callback;
106 SkImages::BorrowTextureFrom(context,
108 kTopLeft_GrSurfaceOrigin,
109 kRGBA_8888_SkColorType,
120 release_proc(
texture->user_data);
122 FML_LOG(ERROR) <<
"Could not create external texture->";
130sk_sp<DlImage> EmbedderExternalTextureGL::ResolveTextureImpeller(
133 const SkISize&
size) {
134 std::unique_ptr<FlutterOpenGLTexture>
texture =
148 std::shared_ptr<impeller::TextureGLES>
image =
154 if (
texture->destruction_callback) {
157 FML_LOG(ERROR) <<
"Could not create external texture";
160 if (
texture->destruction_callback &&
161 !context.
GetReactor()->RegisterCleanupCallback(
165 FML_LOG(ERROR) <<
"Could not register destruction callback";
173void EmbedderExternalTextureGL::OnGrContextCreated() {}
176void EmbedderExternalTextureGL::OnGrContextDestroyed() {}
179void EmbedderExternalTextureGL::MarkNewFrameAvailable() {
180 last_image_ =
nullptr;
184void EmbedderExternalTextureGL::OnTextureUnregistered() {}
static sk_sp< DlImage > Make(const SkImage *image)
~EmbedderExternalTextureGL()
EmbedderExternalTextureGL(int64_t texture_identifier, const ExternalTextureCallback &callback)
std::function< std::unique_ptr< FlutterOpenGLTexture >(int64_t, size_t, size_t)> ExternalTextureCallback
std::shared_ptr< Context > GetContext() const
static ContextGLES & Cast(Context &base)
const std::shared_ptr< ReactorGLES > & GetReactor() const
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
static std::shared_ptr< TextureGLES > WrapTexture(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, HandleGLES external_handle)
Create a texture by wrapping an external OpenGL texture handle. Ownership of the texture handle is as...
FlutterVulkanImage * image
FlutterDesktopBinaryReply callback
#define FML_LOG(severity)
#define FML_DCHECK(condition)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
impeller::AiksContext * aiks_context
GrDirectContext * gr_context
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
static constexpr std::enable_if_t< std::is_floating_point_v< FT >, TRect > Make(const TRect< U > &rect)
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
constexpr TPoint< Type > GetOrigin() const
Returns the upper left corner of the rectangle as specified by the left/top or x/y values when it was...
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...