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 8
8
#include < limits>
9
9
10
10
#if IMPELLER_SUPPORTS_RENDERING
11
- #include " flutter/impeller/renderer/texture .h"
11
+ #include " flutter/lib/ui/painting/image_encoding_impeller .h"
12
12
#endif
13
13
#include " flutter/lib/ui/painting/image_encoding.h"
14
14
#include " third_party/tonic/converter/dart_converter.h"
15
15
#include " third_party/tonic/dart_args.h"
16
16
#include " third_party/tonic/dart_binding_macros.h"
17
17
#include " third_party/tonic/dart_library_natives.h"
18
18
19
- // Must be kept in sync with painting.dart.
20
- enum ColorSpace {
21
- kSRGB ,
22
- kExtendedSRGB ,
23
- };
24
-
25
19
namespace flutter {
26
20
27
21
typedef CanvasImage Image;
@@ -49,15 +43,7 @@ int CanvasImage::colorSpace() {
49
43
return ColorSpace::kSRGB ;
50
44
} else if (image_->impeller_texture ()) {
51
45
#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 ());
61
47
#endif // IMPELLER_SUPPORTS_RENDERING
62
48
}
63
49
Original file line number Diff line number Diff line change 14
14
15
15
namespace flutter {
16
16
17
+ // Must be kept in sync with painting.dart.
18
+ enum ColorSpace {
19
+ kSRGB ,
20
+ kExtendedSRGB ,
21
+ };
22
+
17
23
class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
18
24
DEFINE_WRAPPERTYPEINFO ();
19
25
FML_FRIEND_MAKE_REF_COUNTED (CanvasImage);
Original file line number Diff line number Diff line change @@ -163,4 +163,16 @@ void ImageEncodingImpeller::ConvertImageToRaster(
163
163
});
164
164
}
165
165
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
+
166
178
} // namespace flutter
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ namespace flutter {
17
17
18
18
class ImageEncodingImpeller {
19
19
public:
20
+ static int GetColorSpace (const std::shared_ptr<impeller::Texture>& texture);
21
+
20
22
// / Converts a DlImage to a SkImage.
21
23
// / This should be called from the thread that corresponds to
22
24
// / `dl_image->owning_context()` when gpu access is guaranteed.
You can’t perform that action at this time.
0 commit comments