This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Flutter External Texture Based On OpenGL Texture Underlying Share Context #11819
Closed
kaisa695275735
wants to merge
27
commits into
flutter:master
from
kaisa695275735:external_texture_new
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
55933e2
Flutter External Texture Based On Share Texture
kaisa695275735 b5b19c7
code format
kaisa695275735 c3c0dfd
Merge branch 'external_texture_merge_master' into external_texture_new
kaisa695275735 8c2beb2
Add testing code for new external texture
kaisa695275735 618094a
Code format
kaisa695275735 adb2f13
Merge branch 'external_texture_new_bkp4' into external_texture_new
kaisa695275735 0052f47
iOS update texture id
kaisa695275735 6dfa303
Code format
kaisa695275735 9471f5c
Merge branch 'upstream_master' into external_texture_new
kaisa695275735 7e297d8
Code format
kaisa695275735 3e4196d
Merge branch 'origin_master' into external_texture_new
kaisa695275735 f964c8a
Code format
kaisa695275735 1a2be7a
Codereview
kaisa695275735 6da0037
Code format
kaisa695275735 464de18
Hard code remove
kaisa695275735 6190ac2
Merge branch 'origin_master' into external_texture_new
kaisa695275735 87bd692
code format
kaisa695275735 a1ef963
Merge compile error modify
kaisa695275735 7675cdc
Delete unused code
kaisa695275735 0c9a675
Check SKImage null
kaisa695275735 78089db
Add texture_id == 0 debug log
kaisa695275735 17185dc
Move docstring to header file
kaisa695275735 2310264
Merge branch 'external_texture_backup' into external_texture_new
kaisa695275735 ebba66c
Merge branch 'master' into external_texture_new
kaisa695275735 3073e06
code format
kaisa695275735 37feaa4
Merge branch 'external_texture_bkp3' into external_texture_new
kaisa695275735 ada6565
doc string
kaisa695275735 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
shell/platform/android/android_external_texture_gl_share_context.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/platform/android/android_external_texture_gl_share_context.h" | ||
|
||
#include <GLES/glext.h> | ||
|
||
#include "flutter/shell/platform/android/platform_view_android_jni.h" | ||
#include "third_party/skia/include/gpu/GrBackendSurface.h" | ||
|
||
#include "flutter/fml/trace_event.h" | ||
|
||
namespace flutter { | ||
AndroidExternalTextureShareContext::AndroidExternalTextureShareContext( | ||
int64_t id, | ||
int64_t shareTextureID) | ||
: Texture(id), texture_id_(shareTextureID) {} | ||
|
||
AndroidExternalTextureShareContext::~AndroidExternalTextureShareContext() {} | ||
|
||
void AndroidExternalTextureShareContext::OnGrContextCreated() {} | ||
|
||
void AndroidExternalTextureShareContext::MarkNewFrameAvailable() {} | ||
|
||
void AndroidExternalTextureShareContext::Paint(SkCanvas& canvas, | ||
const SkRect& bounds, | ||
bool freeze, | ||
GrContext* context) { | ||
GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_id_, | ||
GL_RGBA8_OES}; | ||
|
||
textureInfo.fTarget = GL_TEXTURE_2D; | ||
|
||
GrBackendTexture backendTexture(bounds.width(), bounds.height(), | ||
GrMipMapped::kNo, textureInfo); | ||
sk_sp<SkImage> image = SkImage::MakeFromTexture( | ||
canvas.getGrContext(), backendTexture, kTopLeft_GrSurfaceOrigin, | ||
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); | ||
FML_DCHECK(image) << "Failed to create SkImage from Texture."; | ||
if (image) { | ||
canvas.drawImage(image, bounds.x(), bounds.y()); | ||
} | ||
} | ||
|
||
void AndroidExternalTextureShareContext::OnGrContextDestroyed() {} | ||
} // namespace flutter |
46 changes: 46 additions & 0 deletions
46
shell/platform/android/android_external_texture_gl_share_context.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_SHARE_CONTEXT_H_ | ||
#define FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_SHARE_CONTEXT_H_ | ||
|
||
#include <GLES/gl.h> | ||
#include "flutter/flow/texture.h" | ||
#include "flutter/fml/platform/android/jni_weak_ref.h" | ||
|
||
namespace flutter { | ||
|
||
// This is another solution for Flutter's ExternalTexture. | ||
// The original ExternalTexture uses SurfaceTexture to update the frame data | ||
// that native video object produces to an OpenGL texture. In this scheme, we | ||
// directly pass an OpenGL texture ID to the ExternalTexture object, and avoid | ||
// the performance consumption of data writing to SurfaceTexture | ||
class AndroidExternalTextureShareContext : public flutter::Texture { | ||
kaisa695275735 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public: | ||
AndroidExternalTextureShareContext(int64_t id, int64_t shareTextureID); | ||
|
||
~AndroidExternalTextureShareContext() override; | ||
|
||
void Paint(SkCanvas& canvas, | ||
const SkRect& bounds, | ||
bool freeze, | ||
GrContext* context) override; | ||
|
||
void OnGrContextCreated() override; | ||
|
||
void OnGrContextDestroyed() override; | ||
|
||
void MarkNewFrameAvailable() override; | ||
|
||
private: | ||
fml::jni::JavaObjectWeakGlobalRef surface_texture_; | ||
|
||
GLuint texture_id_ = 0; | ||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(AndroidExternalTextureShareContext); | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_GL_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.