Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/licenses_golden/excluded_files
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
../../../flutter/impeller/playground
../../../flutter/impeller/renderer/backend/gles/buffer_bindings_gles_unittests.cc
../../../flutter/impeller/renderer/backend/gles/test
../../../flutter/impeller/renderer/backend/gles/unique_handle_gles_unittests.cc
../../../flutter/impeller/renderer/backend/metal/allocator_mtl_unittests.mm
../../../flutter/impeller/renderer/backend/metal/texture_mtl_unittests.mm
../../../flutter/impeller/renderer/backend/vulkan/allocator_vk_unittests.cc
Expand Down
1 change: 1 addition & 0 deletions impeller/renderer/backend/gles/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impeller_component("gles_unittests") {
"test/specialization_constants_unittests.cc",
"test/surface_gles_unittests.cc",
"test/texture_gles_unittests.cc",
"unique_handle_gles_unittests.cc",
]
deps = [
":gles",
Expand Down
3 changes: 2 additions & 1 deletion impeller/renderer/backend/gles/pipeline_library_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ std::shared_ptr<PipelineGLES> PipelineLibraryGLES::CreatePipeline(
desc, //
has_cached_program
? std::move(cached_program)
: std::make_shared<UniqueHandleGLES>(reactor, HandleType::kProgram)));
: std::make_shared<UniqueHandleGLES>(UniqueHandleGLES::MakeUntracked(
reactor, HandleType::kProgram))));
Comment on lines +215 to +216
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't come up with a test for this, but it will have coverage in in every opengles golden and devicelab test.


auto program = reactor->GetGLHandle(pipeline->GetProgramHandle());

Expand Down
8 changes: 8 additions & 0 deletions impeller/renderer/backend/gles/unique_handle_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ UniqueHandleGLES::UniqueHandleGLES(ReactorGLES::Ref reactor, HandleType type)
}
}

// static
UniqueHandleGLES UniqueHandleGLES::MakeUntracked(ReactorGLES::Ref reactor,
HandleType type) {
FML_DCHECK(reactor);
HandleGLES handle = reactor->CreateUntrackedHandle(type);
return UniqueHandleGLES(std::move(reactor), handle);
}

UniqueHandleGLES::UniqueHandleGLES(ReactorGLES::Ref reactor, HandleGLES handle)
: reactor_(std::move(reactor)), handle_(handle) {}

Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/backend/gles/unique_handle_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class UniqueHandleGLES {
public:
UniqueHandleGLES(ReactorGLES::Ref reactor, HandleType type);

static UniqueHandleGLES MakeUntracked(ReactorGLES::Ref reactor,
HandleType type);

UniqueHandleGLES(ReactorGLES::Ref reactor, HandleGLES handle);

~UniqueHandleGLES();
Expand Down
42 changes: 42 additions & 0 deletions impeller/renderer/backend/gles/unique_handle_gles_unittests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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/testing/testing.h" // IWYU pragma: keep
#include "gtest/gtest.h"
#include "impeller/renderer/backend/gles/reactor_gles.h"
#include "impeller/renderer/backend/gles/test/mock_gles.h"
#include "impeller/renderer/backend/gles/unique_handle_gles.h"

namespace impeller {
namespace testing {

namespace {
class TestWorker : public ReactorGLES::Worker {
public:
bool CanReactorReactOnCurrentThreadNow(
const ReactorGLES& reactor) const override {
return true;
}
};
} // namespace

TEST(UniqueHandleGLES, MakeUntracked) {
auto mock_gles = MockGLES::Init();
ProcTableGLES::Resolver resolver = kMockResolverGLES;
auto proc_table = std::make_unique<ProcTableGLES>(resolver);
auto worker = std::make_shared<TestWorker>();
auto reactor = std::make_shared<ReactorGLES>(std::move(proc_table));
reactor->AddWorker(worker);

mock_gles->GetCapturedCalls();
UniqueHandleGLES handle =
UniqueHandleGLES::MakeUntracked(reactor, HandleType::kTexture);
EXPECT_FALSE(handle.Get().IsDead());
std::vector<std::string> calls = mock_gles->GetCapturedCalls();
EXPECT_TRUE(std::find(calls.begin(), calls.end(), "glGenTextures") !=
calls.end());
}

} // namespace testing
} // namespace impeller