Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@chinmaygarde
Copy link
Member

@chinmaygarde chinmaygarde commented Nov 26, 2019

The converters are still in a separate target that must be included manually. This allows targets that depend on FML but not Dart runtime not have to depend on the runtime.

Adds a test that includes this target and tests image decompression from assets. There is also a test for the standalone DartConvertor in shell_unittests but not in fml_unittests be cause FML unit-tests cannot yet launch a VM. I will work on adding fixtures for those.

A potential future improvement could be that we start using typed data buffer on mapping that are given to us so that there are no copies.

DestroyShell(std::move(shell));
}

static bool MemsetPatternSetOrCheck(uint8_t* buffer,
Copy link
Member

Choose a reason for hiding this comment

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

Add a short doc comment, since it's a utility. Particularly, document that if set_or_checkis true, you set, otherwise you check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Made the bool an enum.

uint8_t* start = buffer;
uint8_t* p = buffer;

while ((start + size) - p >= 4) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Pretty obvious what this is, but maybe pattern and a constexpr size_t pattern_len = 4;?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


uint8_t* buffer = static_cast<uint8_t*>(::malloc(buffer_size));
ASSERT_NE(buffer, nullptr);
ASSERT_TRUE(MemsetPatternSetOrCheck(buffer, buffer_size, true /* set */));
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if you should just chuck in an two-valued enum instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


fml::UniqueFD OpenFixture(std::string fixture_name);

std::unique_ptr<fml::Mapping> OpenFixtureAsMapping(std::string fixture_name);
Copy link
Member

Choose a reason for hiding this comment

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

Consider documenting this (and the surrounding prototypes while you're in here).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

return nullptr;
}

auto mapping_buffer = ::malloc(length);
Copy link
Member

Choose a reason for hiding this comment

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

For a zero-length list this can return null, in which case we'll handle as an OOM below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Good catch. Returns a valid zero sized mapping now.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

lgtm with minor nits.

Copy link
Member Author

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Addressed all comments. PTAL.

DestroyShell(std::move(shell));
}

static bool MemsetPatternSetOrCheck(uint8_t* buffer,
Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Made the bool an enum.

uint8_t* start = buffer;
uint8_t* p = buffer;

while ((start + size) - p >= 4) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


uint8_t* buffer = static_cast<uint8_t*>(::malloc(buffer_size));
ASSERT_NE(buffer, nullptr);
ASSERT_TRUE(MemsetPatternSetOrCheck(buffer, buffer_size, true /* set */));
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


fml::UniqueFD OpenFixture(std::string fixture_name);

std::unique_ptr<fml::Mapping> OpenFixtureAsMapping(std::string fixture_name);
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

return nullptr;
}

auto mapping_buffer = ::malloc(length);
Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Good catch. Returns a valid zero sized mapping now.

The converters are still in a separate target that must be included manually. This allows targets that depend on FML but not Dart runtime not have to depend on the runtime.

Adds a test that includes this target and tests image decompression from assets. There is also a test for the standalone DartConvertor in shell_unittests but not in fml_unittests be cause FML uni-tests cannot yet launch a VM. I will work on adding fixtures for those.
@cbracken
Copy link
Member

LGTM stamp from a Japanese personal seal

@chinmaygarde chinmaygarde merged commit ca68af2 into flutter:master Nov 26, 2019
@chinmaygarde chinmaygarde deleted the fml_dart_converter branch November 26, 2019 21:34
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 27, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 27, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 27, 2019
auto-submit bot pushed a commit that referenced this pull request Nov 22, 2023
This is more-or-less a revert of #14011

This code never ended up being used outside of tests, and it's not how we handle asset loading at this point anyway.

I was hopeful we could kill off all runtime dependencies on Dart in `FML` when looking at this, but it looks like trace_event.h still wants to import dart_api_tools.h for some Dart enum types. This may or may not matter if we ever want to build FML for web/wasm. /cc @eyebrowsoffire. If we really need to do that, we can refactor the trace event stuff so that it has a web and Dart implementation that's selected at build time.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants