This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +22
-16
lines changed
Expand file tree Collapse file tree 4 files changed +22
-16
lines changed Original file line number Diff line number Diff line change 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-
2519namespace flutter {
2620
2721typedef 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
Original file line number Diff line number Diff line change 1414
1515namespace flutter {
1616
17+ // Must be kept in sync with painting.dart.
18+ enum ColorSpace {
19+ kSRGB ,
20+ kExtendedSRGB ,
21+ };
22+
1723class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
1824 DEFINE_WRAPPERTYPEINFO ();
1925 FML_FRIEND_MAKE_REF_COUNTED (CanvasImage);
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ namespace flutter {
1717
1818class 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.
You can’t perform that action at this time.
0 commit comments