35 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
36 std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
37 impeller_entity_shaders_length),
38 std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
39 impeller_modern_shaders_length),
40 std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
41 impeller_framebuffer_blend_shaders_length),
43 auto sync_switch = std::make_shared<fml::SyncSwitch>(
false);
98 const size_t width = 100;
105 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
106 GrDirectContext* grContext = darwinContextMetal.
mainContext.get();
107 sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
110 MTLTextureDescriptor* textureDescriptor = [[MTLTextureDescriptor alloc] init];
111 textureDescriptor.pixelFormat = MTLPixelFormatBGRA8Unorm;
112 textureDescriptor.width =
width;
113 textureDescriptor.height =
height;
114 textureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
115 id<MTLTexture> mtlTexture =
116 [darwinContextMetal.device newTextureWithDescriptor:textureDescriptor];
117 std::vector<FlutterMetalTextureHandle> textures = {
124 EXPECT_TRUE(w ==
width);
127 auto texture = std::make_unique<FlutterMetalExternalTexture>();
133 texture->textures = textures.data();
138 std::unique_ptr<flutter::Texture>
texture =
145 .gr_context = grContext,
147 texture->Paint(context, bounds,
false, sampling);
149 ASSERT_TRUE(mtlTexture != nil);
151 gpuSurface->makeImageSnapshot();
156 const size_t width = 100;
157 const size_t height = 100;
163 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
164 GrDirectContext* grContext = darwinContextMetal.
mainContext.get();
165 sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
171 pixelFormatType:kCVPixelFormatType_32BGRA];
174 darwinMetalContext:darwinContextMetal];
179 EXPECT_TRUE(w ==
width);
182 auto texture = std::make_unique<FlutterMetalExternalTexture>();
185 EXPECT_TRUE(
texture->num_textures == 1);
186 EXPECT_TRUE(
texture->textures !=
nullptr);
192 std::unique_ptr<flutter::Texture>
texture =
199 .gr_context = grContext,
201 texture->Paint(context, bounds,
false, sampling);
203 gpuSurface->makeImageSnapshot();
208 const size_t width = 100;
209 const size_t height = 100;
215 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
216 GrDirectContext* grContext = darwinContextMetal.
mainContext.get();
217 sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
223 pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange];
226 darwinMetalContext:darwinContextMetal];
231 EXPECT_TRUE(w ==
width);
234 auto texture = std::make_unique<FlutterMetalExternalTexture>();
237 EXPECT_TRUE(
texture->num_textures == 2);
238 EXPECT_TRUE(
texture->textures !=
nullptr);
240 EXPECT_TRUE(
texture->yuv_color_space ==
246 std::unique_ptr<flutter::Texture>
texture =
253 .gr_context = grContext,
255 texture->Paint(context, bounds,
false, sampling);
257 gpuSurface->makeImageSnapshot();
262 const size_t width = 100;
263 const size_t height = 100;
269 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
270 GrDirectContext* grContext = darwinContextMetal.
mainContext.get();
271 sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
277 pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange];
280 darwinMetalContext:darwinContextMetal];
285 EXPECT_TRUE(w ==
width);
288 auto texture = std::make_unique<FlutterMetalExternalTexture>();
291 EXPECT_TRUE(
texture->num_textures == 2);
292 EXPECT_TRUE(
texture->textures !=
nullptr);
294 EXPECT_TRUE(
texture->yuv_color_space ==
300 std::unique_ptr<flutter::Texture>
texture =
307 .gr_context = grContext,
309 texture->Paint(context, bounds,
false, sampling);
311 gpuSurface->makeImageSnapshot();
316 const size_t width = 100;
317 const size_t height = 100;
323 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
324 GrDirectContext* grContext = darwinContextMetal.
mainContext.get();
325 sk_sp<SkSurface> gpuSurface(SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info));
331 pixelFormatType:kCVPixelFormatType_420YpCbCr8PlanarFullRange];
334 darwinMetalContext:darwinContextMetal];
339 EXPECT_TRUE(w ==
width);
342 auto texture = std::make_unique<FlutterMetalExternalTexture>();
343 EXPECT_FALSE([textureHolder populateTexture:
texture.get()]);
348 std::unique_ptr<flutter::Texture>
texture =
355 .gr_context = grContext,
357 texture->Paint(context, bounds,
false, sampling);
362 const size_t width = 100;
363 const size_t height = 100;
367 auto device = ::MTLCreateSystemDefaultDevice();
370 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
373 MTLTextureDescriptor* textureDescriptor = [[MTLTextureDescriptor alloc] init];
374 textureDescriptor.pixelFormat = MTLPixelFormatBGRA8Unorm;
375 textureDescriptor.width =
width;
376 textureDescriptor.height =
height;
377 textureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
378 id<MTLTexture> mtlTexture = [device newTextureWithDescriptor:textureDescriptor];
379 std::vector<FlutterMetalTextureHandle> textures = {
386 EXPECT_TRUE(w ==
width);
389 auto texture = std::make_unique<FlutterMetalExternalTexture>();
395 texture->textures = textures.data();
400 std::unique_ptr<flutter::Texture>
texture =
407 .
canvas = &builder, .gr_context =
nullptr, .aiks_context = &aiks_context};
408 texture->Paint(context, bounds,
false, sampling);
410 ASSERT_TRUE(mtlTexture != nil);
415 const size_t width = 100;
416 const size_t height = 100;
423 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
429 pixelFormatType:kCVPixelFormatType_32BGRA];
432 darwinMetalContext:darwinContextMetal];
437 EXPECT_TRUE(w ==
width);
440 auto texture = std::make_unique<FlutterMetalExternalTexture>();
443 EXPECT_TRUE(
texture->num_textures == 1);
444 EXPECT_TRUE(
texture->textures !=
nullptr);
450 std::unique_ptr<flutter::Texture>
texture =
458 .gr_context =
nullptr,
459 .aiks_context = &aiks_context,
461 texture->Paint(context, bounds,
false, sampling);
466 const size_t width = 100;
467 const size_t height = 100;
474 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
480 pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange];
483 darwinMetalContext:darwinContextMetal];
488 EXPECT_TRUE(w ==
width);
491 auto texture = std::make_unique<FlutterMetalExternalTexture>();
494 EXPECT_TRUE(
texture->num_textures == 2);
495 EXPECT_TRUE(
texture->textures !=
nullptr);
497 EXPECT_TRUE(
texture->yuv_color_space ==
503 std::unique_ptr<flutter::Texture>
texture =
510 .
canvas = &builder, .gr_context =
nullptr, .aiks_context = &aiks_context};
511 texture->Paint(context, bounds,
false, sampling);
516 const size_t width = 100;
517 const size_t height = 100;
524 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
530 pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange];
533 darwinMetalContext:darwinContextMetal];
538 EXPECT_TRUE(w ==
width);
541 auto texture = std::make_unique<FlutterMetalExternalTexture>();
544 EXPECT_TRUE(
texture->num_textures == 2);
545 EXPECT_TRUE(
texture->textures !=
nullptr);
547 EXPECT_TRUE(
texture->yuv_color_space ==
553 std::unique_ptr<flutter::Texture>
texture =
560 .
canvas = &builder, .gr_context =
nullptr, .aiks_context = &aiks_context};
561 texture->Paint(context, bounds,
false, sampling);
566 const size_t width = 100;
567 const size_t height = 100;
574 SkImageInfo info = SkImageInfo::MakeN32Premul(
width,
height);
580 pixelFormatType:kCVPixelFormatType_420YpCbCr8PlanarFullRange];
583 darwinMetalContext:darwinContextMetal];
588 EXPECT_TRUE(w ==
width);
591 auto texture = std::make_unique<FlutterMetalExternalTexture>();
592 EXPECT_FALSE([textureHolder populateTexture:
texture.get()]);
597 std::unique_ptr<flutter::Texture>
texture =
604 .
canvas = &builder, .gr_context =
nullptr, .aiks_context = &aiks_context};
605 texture->Paint(context, bounds,
false, sampling);
static std::shared_ptr< impeller::ContextMTL > CreateImpellerContext()
static std::shared_ptr< ContextMTL > Create(const Flags &flags, const std::vector< std::string > &shader_library_paths, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)
BOOL populateTexture:(nonnull FlutterMetalExternalTexture *metalTexture)