Flutter Engine
The Flutter Engine
image_external_texture.h
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#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_
6#define FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_
7
8#include "flutter/common/graphics/texture.h"
9#include "flutter/fml/logging.h"
10#include "flutter/shell/platform/android/image_lru.h"
11#include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
12#include "flutter/shell/platform/android/platform_view_android_jni_impl.h"
13
15#include <android/hardware_buffer_jni.h>
16
17namespace flutter {
18
19// External texture peered to a sequence of android.hardware.HardwareBuffers.
20//
22 public:
23 explicit ImageExternalTexture(
24 int64_t id,
25 const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
26 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade);
27
28 virtual ~ImageExternalTexture() = default;
29
30 // |flutter::Texture|.
31 void Paint(PaintContext& context,
32 const SkRect& bounds,
33 bool freeze,
34 const DlImageSampling sampling) override;
35
36 // |flutter::Texture|.
37 void MarkNewFrameAvailable() override;
38
39 // |flutter::Texture|
40 void OnTextureUnregistered() override;
41
42 // |flutter::ContextListener|
43 void OnGrContextCreated() override;
44
45 // |flutter::ContextListener|
46 void OnGrContextDestroyed() override;
47
48 protected:
49 virtual void Attach(PaintContext& context) = 0;
50 virtual void Detach() = 0;
51 virtual void ProcessFrame(PaintContext& context, const SkRect& bounds) = 0;
52
56 void CloseHardwareBuffer(const fml::jni::JavaRef<jobject>& hardware_buffer);
58 const fml::jni::JavaRef<jobject>& hardware_buffer);
59
61 std::shared_ptr<PlatformViewAndroidJNI> jni_facade_;
62
63 enum class AttachmentState { kUninitialized, kAttached, kDetached };
67
69};
70
71} // namespace flutter
72
73#endif // FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_
struct AHardwareBuffer AHardwareBuffer
FML_DISALLOW_COPY_AND_ASSIGN(ImageExternalTexture)
virtual ~ImageExternalTexture()=default
AHardwareBuffer * AHardwareBufferFor(const fml::jni::JavaRef< jobject > &hardware_buffer)
JavaLocalRef HardwareBufferFor(const fml::jni::JavaRef< jobject > &image)
virtual void ProcessFrame(PaintContext &context, const SkRect &bounds)=0
void CloseHardwareBuffer(const fml::jni::JavaRef< jobject > &hardware_buffer)
sk_sp< flutter::DlImage > dl_image_
void CloseImage(const fml::jni::JavaRef< jobject > &image)
virtual void Attach(PaintContext &context)=0
std::shared_ptr< PlatformViewAndroidJNI > jni_facade_
ImageExternalTexture(int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &image_texture_entry, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
void Paint(PaintContext &context, const SkRect &bounds, bool freeze, const DlImageSampling sampling) override
fml::jni::ScopedJavaGlobalRef< jobject > image_texture_entry_
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions sampling
Definition: SkRecords.h:337
std::nullptr_t JavaLocalRef