Skip to content

Commit 821e791

Browse files
authored
Merge branch 'master' into fix/CupertinoSliverNavigationBar-collapse-animation-infinite-loop
2 parents c182ec0 + 389f10e commit 821e791

11 files changed

+58
-7
lines changed

engine/src/flutter/impeller/renderer/backend/gles/reactor_gles.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ HandleGLES ReactorGLES::CreateHandle(HandleType type, GLuint external_handle) {
233233
}
234234

235235
void ReactorGLES::CollectHandle(HandleGLES handle) {
236+
if (handle.IsDead()) {
237+
return;
238+
}
236239
if (handle.untracked_id_.has_value()) {
237240
LiveHandle live_handle(GLStorage{.integer = handle.untracked_id_.value()});
238241
live_handle.pending_collection = true;

engine/src/flutter/impeller/renderer/backend/gles/test/texture_gles_unittests.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "flutter/impeller/renderer/backend/gles/texture_gles.h"
88
#include "flutter/testing/testing.h"
99
#include "gtest/gtest.h"
10+
#include "impeller/base/validation.h"
1011
#include "impeller/core/formats.h"
1112
#include "impeller/core/texture_descriptor.h"
1213
#include "impeller/renderer/backend/gles/handle_gles.h"
@@ -93,4 +94,26 @@ TEST_P(TextureGLESTest, Binds2DTexture) {
9394
}
9495
}
9596

97+
TEST_P(TextureGLESTest, Leak) {
98+
TextureDescriptor desc;
99+
desc.storage_mode = StorageMode::kDevicePrivate;
100+
desc.size = {100, 100};
101+
desc.format = PixelFormat::kR8G8B8A8UNormInt;
102+
desc.type = TextureType::kTexture2D;
103+
desc.sample_count = SampleCount::kCount1;
104+
105+
auto texture = GetContext()->GetResourceAllocator()->CreateTexture(desc);
106+
107+
ASSERT_TRUE(texture);
108+
109+
std::optional<GLuint> handle = TextureGLES::Cast(*texture).GetGLHandle();
110+
EXPECT_TRUE(handle.has_value());
111+
112+
TextureGLES::Cast(*texture).Leak();
113+
114+
ScopedValidationDisable disable_validation;
115+
handle = TextureGLES::Cast(*texture).GetGLHandle();
116+
EXPECT_FALSE(handle.has_value());
117+
}
118+
96119
} // namespace impeller::testing

engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "impeller/core/formats.h"
1717
#include "impeller/core/texture_descriptor.h"
1818
#include "impeller/renderer/backend/gles/formats_gles.h"
19+
#include "impeller/renderer/backend/gles/handle_gles.h"
1920

2021
namespace impeller {
2122

@@ -229,6 +230,10 @@ TextureGLES::~TextureGLES() {
229230
}
230231
}
231232

233+
void TextureGLES::Leak() {
234+
handle_ = HandleGLES::DeadHandle();
235+
}
236+
232237
// |Texture|
233238
bool TextureGLES::IsValid() const {
234239
return is_valid_;

engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class TextureGLES final : public Texture,
102102

103103
bool IsWrapped() const;
104104

105+
/// @brief Reset the internal texture state so that the reactor will not free
106+
/// the associated handle.
107+
void Leak();
108+
105109
std::optional<GLuint> GetFBO() const;
106110

107111
//----------------------------------------------------------------------------

engine/src/flutter/shell/platform/android/android_context_dynamic_impeller.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class AndroidContextDynamicImpeller : public AndroidContext {
3030
// |AndroidContext|
3131
bool IsValid() const override { return true; }
3232

33+
// |AndroidContext|
34+
bool IsDynamicSelection() const override { return true; }
35+
3336
// |AndroidContext|
3437
AndroidRenderingAPI RenderingApi() const override;
3538

engine/src/flutter/shell/platform/android/context/android_context.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,8 @@ std::shared_ptr<impeller::Context> AndroidContext::GetImpellerContext() const {
5050
return impeller_context_;
5151
}
5252

53+
bool AndroidContext::IsDynamicSelection() const {
54+
return false;
55+
}
56+
5357
} // namespace flutter

engine/src/flutter/shell/platform/android/context/android_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class AndroidContext {
3939

4040
virtual AndroidRenderingAPI RenderingApi() const;
4141

42+
virtual bool IsDynamicSelection() const;
43+
4244
virtual bool IsValid() const;
4345

4446
//----------------------------------------------------------------------------

engine/src/flutter/shell/platform/android/platform_view_android.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ AndroidSurfaceFactoryImpl::AndroidSurfaceFactoryImpl(
7878
AndroidSurfaceFactoryImpl::~AndroidSurfaceFactoryImpl() = default;
7979

8080
std::unique_ptr<AndroidSurface> AndroidSurfaceFactoryImpl::CreateSurface() {
81+
if (android_context_->IsDynamicSelection()) {
82+
auto cast_ptr = std::static_pointer_cast<AndroidContextDynamicImpeller>(
83+
android_context_);
84+
return std::make_unique<AndroidSurfaceDynamicImpeller>(cast_ptr);
85+
}
8186
switch (android_context_->RenderingApi()) {
8287
#if !SLIMPELLER
8388
case AndroidRenderingAPI::kSoftware:

engine/src/flutter/shell/platform/android/surface_texture_external_texture_gl_impeller.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ void SurfaceTextureExternalTextureGLImpeller::ProcessFrame(
5555

5656
void SurfaceTextureExternalTextureGLImpeller::Detach() {
5757
SurfaceTextureExternalTexture::Detach();
58+
// Detach will collect the texture handle.
59+
// See also: https://github.com/flutter/flutter/issues/152459
60+
texture_->Leak();
5861
texture_.reset();
5962
}
6063

engine/src/flutter/shell/platform/android/surface_texture_external_texture_gl_skia.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ void SurfaceTextureExternalTextureGLSkia::ProcessFrame(PaintContext& context,
5252

5353
void SurfaceTextureExternalTextureGLSkia::Detach() {
5454
SurfaceTextureExternalTexture::Detach();
55-
if (texture_name_ != 0) {
56-
glDeleteTextures(1, &texture_name_);
57-
texture_name_ = 0;
58-
}
55+
// Detach will collect the texture handle.
56+
// See also: https://github.com/flutter/flutter/issues/152459
57+
texture_name_ = 0;
5958
}
6059

6160
} // namespace flutter

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy