Skip to content

Instantly share code, notes, and snippets.

@jonahwilliams
Created September 14, 2023 16:35
Show Gist options
  • Save jonahwilliams/be57fdf0bdff9ee1a0018adf30fc5214 to your computer and use it in GitHub Desktop.
Save jonahwilliams/be57fdf0bdff9ee1a0018adf30fc5214 to your computer and use it in GitHub Desktop.
diff.diff
diff --git a/impeller/aiks/aiks_playground.cc b/impeller/aiks/aiks_playground.cc
index 3f31c658da..c958250213 100644
--- a/impeller/aiks/aiks_playground.cc
+++ b/impeller/aiks/aiks_playground.cc
@@ -52,4 +52,9 @@ bool AiksPlayground::OpenPlaygroundHere(AiksPlaygroundCallback callback) {
});
}
+void AiksPlayground::TearDown() {
+ inspector_.Reset();
+ PlaygroundTest::TearDown();
+}
+
} // namespace impeller
diff --git a/impeller/aiks/aiks_playground.h b/impeller/aiks/aiks_playground.h
index d33a15b07f..c1734b297c 100644
--- a/impeller/aiks/aiks_playground.h
+++ b/impeller/aiks/aiks_playground.h
@@ -29,6 +29,8 @@ class AiksPlayground : public PlaygroundTest {
bool OpenPlaygroundHere(AiksPlaygroundCallback callback);
+ void TearDown() override;
+
private:
std::shared_ptr<TypographerContext> typographer_context_;
AiksInspector inspector_;
diff --git a/impeller/aiks/aiks_playground_inspector.cc b/impeller/aiks/aiks_playground_inspector.cc
index 0f8721358d..f456cacb5a 100644
--- a/impeller/aiks/aiks_playground_inspector.cc
+++ b/impeller/aiks/aiks_playground_inspector.cc
@@ -22,6 +22,12 @@ static const std::initializer_list<std::string> kSupportedDocuments = {
AiksInspector::AiksInspector() = default;
+void AiksInspector::Reset() {
+ hovered_element_ = nullptr;
+ selected_element_ = nullptr;
+ last_picture_ = std::nullopt;
+}
+
const std::optional<Picture>& AiksInspector::RenderInspector(
AiksContext& aiks_context,
const std::function<std::optional<Picture>()>& picture_callback) {
diff --git a/impeller/aiks/aiks_playground_inspector.h b/impeller/aiks/aiks_playground_inspector.h
index 95b1e07778..be8de45e9a 100644
--- a/impeller/aiks/aiks_playground_inspector.h
+++ b/impeller/aiks/aiks_playground_inspector.h
@@ -21,6 +21,10 @@ class AiksInspector {
AiksContext& aiks_context,
const std::function<std::optional<Picture>()>& picture_callback);
+ /// @brief Clear the last captured state, preventing resource leaks across
+ /// tests.
+ void Reset();
+
private:
void RenderCapture(CaptureContext& capture_context);
void RenderCaptureElement(CaptureElement& element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment