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

Commit 992fb70

Browse files
committed
fixed fuchsia by moving impeller logic into an impeller compiled file
1 parent 21dc06b commit 992fb70

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

lib/ui/painting/image.cc

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@
88
#include <limits>
99

1010
#if IMPELLER_SUPPORTS_RENDERING
11-
#include "flutter/impeller/renderer/texture.h"
11+
#include "flutter/lib/ui/painting/image_encoding_impeller.h"
1212
#endif
1313
#include "flutter/lib/ui/painting/image_encoding.h"
1414
#include "third_party/tonic/converter/dart_converter.h"
1515
#include "third_party/tonic/dart_args.h"
1616
#include "third_party/tonic/dart_binding_macros.h"
1717
#include "third_party/tonic/dart_library_natives.h"
1818

19-
// Must be kept in sync with painting.dart.
20-
enum ColorSpace {
21-
kSRGB,
22-
kExtendedSRGB,
23-
};
24-
2519
namespace flutter {
2620

2721
typedef CanvasImage Image;
@@ -49,15 +43,7 @@ int CanvasImage::colorSpace() {
4943
return ColorSpace::kSRGB;
5044
} else if (image_->impeller_texture()) {
5145
#if IMPELLER_SUPPORTS_RENDERING
52-
const impeller::TextureDescriptor& desc =
53-
image_->impeller_texture()->GetTextureDescriptor();
54-
switch (desc.format) {
55-
case impeller::PixelFormat::kB10G10R10XR: // intentional_fallthrough
56-
case impeller::PixelFormat::kR16G16B16A16Float:
57-
return ColorSpace::kExtendedSRGB;
58-
default:
59-
return ColorSpace::kSRGB;
60-
}
46+
return ImageEncodingImpeller::GetColorSpace(image_->impeller_texture());
6147
#endif // IMPELLER_SUPPORTS_RENDERING
6248
}
6349

lib/ui/painting/image.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
namespace flutter {
1616

17+
// Must be kept in sync with painting.dart.
18+
enum ColorSpace {
19+
kSRGB,
20+
kExtendedSRGB,
21+
};
22+
1723
class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
1824
DEFINE_WRAPPERTYPEINFO();
1925
FML_FRIEND_MAKE_REF_COUNTED(CanvasImage);

lib/ui/painting/image_encoding_impeller.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,16 @@ void ImageEncodingImpeller::ConvertImageToRaster(
163163
});
164164
}
165165

166+
int ImageEncodingImpeller::GetColorSpace(
167+
const std::shared_ptr<impeller::Texture>& texture) {
168+
const impeller::TextureDescriptor& desc = texture->GetTextureDescriptor();
169+
switch (desc.format) {
170+
case impeller::PixelFormat::kB10G10R10XR: // intentional_fallthrough
171+
case impeller::PixelFormat::kR16G16B16A16Float:
172+
return ColorSpace::kExtendedSRGB;
173+
default:
174+
return ColorSpace::kSRGB;
175+
}
176+
}
177+
166178
} // namespace flutter

lib/ui/painting/image_encoding_impeller.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace flutter {
1717

1818
class ImageEncodingImpeller {
1919
public:
20+
static int GetColorSpace(const std::shared_ptr<impeller::Texture>& texture);
21+
2022
/// Converts a DlImage to a SkImage.
2123
/// This should be called from the thread that corresponds to
2224
/// `dl_image->owning_context()` when gpu access is guaranteed.

0 commit comments

Comments
 (0)