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

[macOS] Allocate textures as unique_ptr earlier #47786

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,14 @@ - (CVPixelBufferRef)pixelBuffer {
EXPECT_TRUE(w == width);
EXPECT_TRUE(h == height);

FlutterMetalExternalTexture* texture = new FlutterMetalExternalTexture();
auto texture = std::make_unique<FlutterMetalExternalTexture>();
texture->struct_size = sizeof(FlutterMetalExternalTexture);
texture->num_textures = 1;
texture->height = h;
texture->width = w;
texture->pixel_format = FlutterMetalExternalTexturePixelFormat::kRGBA;
texture->textures = textures.data();

return std::unique_ptr<FlutterMetalExternalTexture>(texture);
return texture;
};

// Render the texture.
Expand Down Expand Up @@ -164,14 +163,13 @@ - (CVPixelBufferRef)pixelBuffer {
EXPECT_TRUE(w == width);
EXPECT_TRUE(h == height);

FlutterMetalExternalTexture* texture = new FlutterMetalExternalTexture();
[textureHolder populateTexture:texture];
auto texture = std::make_unique<FlutterMetalExternalTexture>();
[textureHolder populateTexture:texture.get()];

EXPECT_TRUE(texture->num_textures == 1);
EXPECT_TRUE(texture->textures != nullptr);
EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kRGBA);

return std::unique_ptr<FlutterMetalExternalTexture>(texture);
return texture;
};

// Render the texture.
Expand Down Expand Up @@ -217,16 +215,15 @@ - (CVPixelBufferRef)pixelBuffer {
EXPECT_TRUE(w == width);
EXPECT_TRUE(h == height);

FlutterMetalExternalTexture* texture = new FlutterMetalExternalTexture();
[textureHolder populateTexture:texture];
auto texture = std::make_unique<FlutterMetalExternalTexture>();
[textureHolder populateTexture:texture.get()];

EXPECT_TRUE(texture->num_textures == 2);
EXPECT_TRUE(texture->textures != nullptr);
EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kYUVA);
EXPECT_TRUE(texture->yuv_color_space ==
FlutterMetalExternalTextureYUVColorSpace::kBT601LimitedRange);

return std::unique_ptr<FlutterMetalExternalTexture>(texture);
return texture;
};

// Render the texture.
Expand Down Expand Up @@ -272,16 +269,15 @@ - (CVPixelBufferRef)pixelBuffer {
EXPECT_TRUE(w == width);
EXPECT_TRUE(h == height);

FlutterMetalExternalTexture* texture = new FlutterMetalExternalTexture();
[textureHolder populateTexture:texture];
auto texture = std::make_unique<FlutterMetalExternalTexture>();
[textureHolder populateTexture:texture.get()];

EXPECT_TRUE(texture->num_textures == 2);
EXPECT_TRUE(texture->textures != nullptr);
EXPECT_TRUE(texture->pixel_format == FlutterMetalExternalTexturePixelFormat::kYUVA);
EXPECT_TRUE(texture->yuv_color_space ==
FlutterMetalExternalTextureYUVColorSpace::kBT601FullRange);

return std::unique_ptr<FlutterMetalExternalTexture>(texture);
return texture;
};

// Render the texture.
Expand Down