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 1 commit
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
Prev Previous commit
Next Next commit
jonah feedback
  • Loading branch information
gaaclarke committed Oct 12, 2023
commit 50b344bbc6279949d7ca1ca052856e651d75fcf9
17 changes: 16 additions & 1 deletion fml/status_or.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@

namespace fml {

/// TODO(): Replace with absl::StatusOr.
// TODO(https://github.com/flutter/flutter/issues/134741): Replace with
// absl::StatusOr.
/// Represents a union type of an object of type `T` and an fml::Status.
///
/// This is often used as a replacement for C++ exceptions where a function that
/// could fail may return an error or a result. These are typically used for
/// errors that are meant to be recovered from. If there is no recovery
/// available `FML_CHECK` is more appropriate.
///
/// Example:
/// StatusOr<int> div(int n, int d) {
/// if (d == 0) {
/// return Status(StatusCode::kFailedPrecondition, "div by zero");
/// }
/// return n / d;
/// }
template <typename T>
class StatusOr {
public:
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1941,7 +1941,7 @@ base class _Image extends NativeFieldWrapperClass1 {
if (encoded != null) {
completer.complete(encoded.buffer.asByteData());
} else {
completer.completeError(Exception(error ?? 'unknown error'));
completer.completeError(Exception(error ?? 'Unknown exception.'));
}
});
if (syncError != null) {
Expand Down
6 changes: 1 addition & 5 deletions lib/ui/painting/image_encoding_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void DoConvertImageToRasterImpeller(
fml::SyncSwitch::Handlers()
.SetIfTrue([&encode_task] {
encode_task(
fml::Status(fml::StatusCode::kUnavailable, "gpu unavailable"));
fml::Status(fml::StatusCode::kUnavailable, "GPU unavailable."));
})
.SetIfFalse([&dl_image, &encode_task, &impeller_context] {
ImageEncodingImpeller::ConvertDlImageToSkImage(
Expand All @@ -82,14 +82,12 @@ void ImageEncodingImpeller::ConvertDlImageToSkImage(
auto texture = dl_image->impeller_texture();

if (impeller_context == nullptr) {
FML_LOG(ERROR) << "Impeller context was null.";
encode_task(fml::Status(fml::StatusCode::kFailedPrecondition,
"Impeller context was null."));
return;
}

if (texture == nullptr) {
FML_LOG(ERROR) << "Image was null.";
encode_task(
fml::Status(fml::StatusCode::kFailedPrecondition, "Image was null."));
return;
Expand All @@ -99,14 +97,12 @@ void ImageEncodingImpeller::ConvertDlImageToSkImage(
auto color_type = ToSkColorType(texture->GetTextureDescriptor().format);

if (dimensions.isEmpty()) {
FML_LOG(ERROR) << "Image dimensions were empty.";
encode_task(fml::Status(fml::StatusCode::kFailedPrecondition,
"Image dimensions were empty."));
return;
}

if (!color_type.has_value()) {
FML_LOG(ERROR) << "Failed to get color type from pixel format.";
encode_task(fml::Status(fml::StatusCode::kUnimplemented,
"Failed to get color type from pixel format."));
return;
Expand Down