12#include "third_party/skia/include/core/SkAlphaType.h"
13#include "third_party/skia/include/core/SkColorSpace.h"
14#include "third_party/skia/include/core/SkColorType.h"
15#include "third_party/skia/include/core/SkImage.h"
22 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
24 jni_facade_(jni_facade),
25 surface_texture_(surface_texture),
26 transform_(SkMatrix::I()) {}
30void SurfaceTextureExternalTexture::OnGrContextCreated() {
34void SurfaceTextureExternalTexture::MarkNewFrameAvailable() {
38void SurfaceTextureExternalTexture::Paint(PaintContext& context,
45 const bool should_process_frame =
47 if (should_process_frame) {
57 <<
"No DlImage available for SurfaceTextureExternalTexture to paint.";
85 <<
"Invalid (not invertable) SurfaceTexture transformation matrix";
95 context.
canvas->
Scale(bounds.width(), -bounds.height());
102 paintWithShader = *context.
paint;
108void SurfaceTextureExternalTexture::OnGrContextDestroyed() {
115void SurfaceTextureExternalTexture::OnTextureUnregistered() {}
137 transform_ =
jni_facade_->SurfaceTextureGetTransformMatrix(
virtual void DrawRect(const DlRect &rect, const DlPaint &paint)=0
virtual void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr)=0
virtual void Translate(DlScalar tx, DlScalar ty)=0
virtual void Scale(DlScalar sx, DlScalar sy)=0
static std::shared_ptr< DlColorSource > MakeImage(const sk_sp< const DlImage > &image, DlTileMode horizontal_tile_mode, DlTileMode vertical_tile_mode, DlImageSampling sampling=DlImageSampling::kLinear, const DlMatrix *matrix=nullptr)
DlPaint & setColorSource(std::nullptr_t source)
SurfaceTextureExternalTexture(int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
virtual void DrawFrame(PaintContext &context, const SkRect &bounds, const DlImageSampling sampling) const
~SurfaceTextureExternalTexture() override
sk_sp< flutter::DlImage > dl_image_
fml::jni::ScopedJavaGlobalRef< jobject > surface_texture_
void Attach(int gl_tex_id)
Attaches the given OpenGL texture handle to the surface texture via a bind operation.
std::shared_ptr< PlatformViewAndroidJNI > jni_facade_
virtual void ProcessFrame(PaintContext &context, const SkRect &bounds)=0
Subclasses override this method to bind the OpenGL texture resource represented by this surface textu...
const SkM44 & GetCurrentUVTransformation() const
Get the transformation that should be applied to the UV texture coordinates when sampling from this t...
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.
#define FML_LOG(severity)
DlMatrix ToDlMatrix(const SkMatrix &matrix)
const SkRect & ToSkRect(const DlRect &rect)
static constexpr TRect MakeWH(Type width, Type height)