/* * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, Hardware * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "gtest/gtest.h" #ifdef RS_ENABLE_GPU #include "image_source.h" #include "pixel_map.h" #endif #include "draw/brush.h" #include "effect/color_space.h" #include "drawing/engine_adapter/impl_factory.h" #include "image/bitmap.h" #include "image/gpu_context.h" #include "image/image.h" #include "image/yuv_info.h" #include "image/picture.h" #include "render_context/render_context.h" #include "utils/matrix.h" #include "utils/size.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { namespace Drawing { class ImageTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; }; void ImageTest::SetUpTestCase() {} void ImageTest::TearDownTestCase() {} void ImageTest::SetUp() {} void ImageTest::TearDown() {} // jpg static unsigned char g_testJpgBuffer[] = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x04, 0x04, 0x03, 0x05, 0x07, 0x06, 0x07, 0x07, 0x07, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0b, 0x09, 0x08, 0x08, 0x0a, 0x08, 0x07, 0x07, 0x0a, 0x0d, 0x0a, 0x0a, 0x0b, 0x0c, 0x0c, 0x0c, 0x0c, 0x07, 0x09, 0x0e, 0x0f, 0x0d, 0x0c, 0x0e, 0x0b, 0x0c, 0x0c, 0x0c, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x06, 0x03, 0x03, 0x06, 0x0c, 0x08, 0x07, 0x08, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0xe2, 0x01, 0xd8, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xfd, 0x10, 0xa2, 0x8a, 0x2b, 0xfc, 0x63, 0x3f, 0xaa, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28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x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x0f, 0xff, 0xd9 }; static unsigned int g_testJpgLength = 2431; /** * @tc.name: CreateAndDestroy001 * @tc.desc: * @tc.type: FUNC * @tc.require:AR000GGNV3 * @tc.author: */ HWTEST_F(ImageTest, CreateAndDestroy001, TestSize.Level1) { // The best way to create Image. std::unique_ptr image = std::make_unique(); ASSERT_TRUE(image != nullptr); } /** * @tc.name: BuildFromBitmap001 * @tc.desc: * @tc.type: FUNC * @tc.require:AR000GGNV3 * @tc.author: */ HWTEST_F(ImageTest, BuildFromBitmap001, TestSize.Level1) { std::unique_ptr image = std::make_unique(); ASSERT_TRUE(image != nullptr); Bitmap bitmap; image->BuildFromBitmap(bitmap); } /** * @tc.name: ImageGetWidthTest001 * @tc.desc: * @tc.type: FUNC * @tc.require:AR000GGNV3 * @tc.author: */ HWTEST_F(ImageTest, ImageGetWidthTest001, TestSize.Level1) { Bitmap bitmap; BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; bitmap.Build(10, 10, bitmapFormat); Image image; ASSERT_EQ(0, image.GetWidth()); image.BuildFromBitmap(bitmap); ASSERT_EQ(10, image.GetWidth()); } /** * @tc.name: ImageGetWidthTest002 * @tc.desc: * @tc.type: FUNC * @tc.require:AR000GGNV3 * @tc.author: */ HWTEST_F(ImageTest, ImageGetWidthTest002, TestSize.Level1) { Bitmap bitmap; BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; bitmap.Build(15, 15, bitmapFormat); Image image; ASSERT_EQ(0, image.GetWidth()); image.BuildFromBitmap(bitmap); ASSERT_EQ(15, image.GetWidth()); } /** * @tc.name: ImageGetHeightTest001 * @tc.desc: * @tc.type: FUNC * @tc.require:AR000GGNV3 * @tc.author: */ HWTEST_F(ImageTest, ImageGetHeightTest001, TestSize.Level1) { Bitmap bitmap; BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; bitmap.Build(10, 10, bitmapFormat); Image image; image.BuildFromBitmap(bitmap); ASSERT_EQ(10, image.GetHeight()); } /** * @tc.name: ImageGetHeightTest002 * @tc.desc: * @tc.type: FUNC * @tc.require:AR000GGNV3 * @tc.author: */ HWTEST_F(ImageTest, ImageGetHeightTest002, TestSize.Level1) { Bitmap bitmap; BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; bitmap.Build(15, 15, bitmapFormat); Image image; image.BuildFromBitmap(bitmap); ASSERT_EQ(15, image.GetHeight()); } /** * @tc.name: ImageGetUniqueIDTest001 * @tc.desc: test for geting the unique Id of Image. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, ImageGetUniqueIDTest001, TestSize.Level1) { // GetUniqueID will change all the time Image image; ASSERT_EQ(0, image.GetUniqueID()); } /** * @tc.name: ReadPixelsTest001 * @tc.desc: test for Coping a Rect of pixels from Image to Bitmap. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, ReadPixelsTest001, TestSize.Level1) { Bitmap bitmap; Image image; int x = 0; int y = 0; EXPECT_FALSE(image.ReadPixels(bitmap, x, y)); } /** * @tc.name: ReadPixelsTest002 * @tc.desc: test for Coping a Rect of pixels from Image to Bitmap. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, ReadPixelsTest002, TestSize.Level1) { Bitmap bitmap; BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; bitmap.Build(15, 15, bitmapFormat); Image image; image.BuildFromBitmap(bitmap); int x = 0; int y = 0; EXPECT_TRUE(image.ReadPixels(bitmap, x, y)); } /** * @tc.name: IsTextureBackedTest001 * @tc.desc: test for IsTextureBacked function. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, IsTextureBackedTest001, TestSize.Level1) { Bitmap bitmap; BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; bitmap.Build(15, 15, bitmapFormat); Image image; image.BuildFromBitmap(bitmap); EXPECT_FALSE(image.IsTextureBacked()); } #ifdef RS_ENABLE_GPU /** * @tc.name: BuildFromCompressedTest001 * @tc.desc: test for creating a GPU-backed Image from compressed data. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, BuildFromCompressedTest001, TestSize.Level1) { GPUContext gpuContext; const std::shared_ptr data = nullptr; std::unique_ptr image = std::make_unique(); ASSERT_TRUE(image != nullptr); image->BuildFromCompressed(gpuContext, data, 15, 15, CompressedType::ASTC_RGBA8_4x4); } /** * @tc.name: BuildFromCompressedTest002 * @tc.desc: test for creating a GPU-backed Image from compressed data. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, BuildFromCompressedTest002, TestSize.Level1) { GPUContext gpuContext; std::shared_ptr data = std::make_shared(); ASSERT_TRUE(data != nullptr); std::unique_ptr image = std::make_unique(); ASSERT_TRUE(image != nullptr); image->BuildFromCompressed(gpuContext, data, 15, 15, CompressedType::ASTC_RGBA8_4x4); } /** * @tc.name: BuildFromCompressedTest003 * @tc.desc: test for creating a GPU-backed Image from compressed data. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, BuildFromCompressedTest003, TestSize.Level1) { GPUContext gpuContext; std::shared_ptr data = std::make_shared(); ASSERT_TRUE(data != nullptr); std::unique_ptr image = std::make_unique(); ASSERT_TRUE(image != nullptr); image->BuildFromCompressed(gpuContext, data, 15, 15, CompressedType::ETC2_RGB8_UNORM); } /** * @tc.name: BuildFromBitmapTest001 * @tc.desc: test for creating Image from Bitmap. Image is uploaded to GPU back-end using context. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, BuildFromBitmapTest001, TestSize.Level1) { GPUContext gpuContext; Bitmap bitmap; BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; bitmap.Build(15, 15, bitmapFormat); std::unique_ptr image = std::make_unique(); ASSERT_TRUE(image != nullptr); image->BuildFromBitmap(gpuContext, bitmap); } /** * @tc.name: BuildFromTextureTest001 * @tc.desc: test for creating Image from GPU texture associated with context. * @tc.type: FUNC * @tc.require: I70OWN */ HWTEST_F(ImageTest, BuildFromTextureTest001, TestSize.Level1) { GPUContext gpuContext; TextureInfo info; info.SetWidth(10); BitmapFormat bitmapFormat { COLORTYPE_UNKNOWN, ALPHATYPE_UNKNOWN }; auto colorSpace = std::make_shared(ColorSpace::ColorSpaceType::NO_TYPE); std::unique_ptr image = std::make_unique(); ASSERT_TRUE(image != nullptr); image->BuildFromTexture(gpuContext, info, TextureOrigin::TOP_LEFT, bitmapFormat, nullptr); bitmapFormat = { COLORTYPE_ALPHA_8, ALPHATYPE_OPAQUE }; image->BuildFromTexture(gpuContext, info, TextureOrigin::TOP_LEFT, bitmapFormat, colorSpace); bitmapFormat = { COLORTYPE_RGB_565, ALPHATYPE_PREMUL }; image->BuildFromTexture(gpuContext, info, TextureOrigin::BOTTOM_LEFT, bitmapFormat, colorSpace); bitmapFormat = { COLORTYPE_ARGB_4444, ALPHATYPE_UNPREMUL }; image->BuildFromTexture(gpuContext, info, TextureOrigin::BOTTOM_LEFT, bitmapFormat, colorSpace); bitmapFormat.colorType = COLORTYPE_RGBA_8888; bitmapFormat.alphaType = static_cast(-1); image->BuildFromTexture(gpuContext, info, TextureOrigin::BOTTOM_LEFT, bitmapFormat, colorSpace); bitmapFormat.colorType = COLORTYPE_BGRA_8888; image->BuildFromTexture(gpuContext, info, TextureOrigin::BOTTOM_LEFT, bitmapFormat, colorSpace); bitmapFormat.colorType = COLORTYPE_N32; image->BuildFromTexture(gpuContext, info, TextureOrigin::BOTTOM_LEFT, bitmapFormat, colorSpace); bitmapFormat.colorType = static_cast(-1); image->BuildFromTexture(gpuContext, info, static_cast(-1), bitmapFormat, colorSpace); } /** * @tc.name: SerializeAndDeserializeTest001 * @tc.desc: test for serialize and deserialize Image. * @tc.type: FUNC * @tc.require: I782P9 */ HWTEST_F(ImageTest, SerializeAndDeserializeTest001, TestSize.Level1) { auto image = std::make_shared(); auto data = image->Serialize(); #ifdef ROSEN_OHOS ASSERT_TRUE(data == nullptr); EXPECT_FALSE(image->Deserialize(data)); BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE }; auto bitmap = std::make_shared(); EXPECT_TRUE(bitmap->Build(10, 10, bitmapFormat)); image->BuildFromBitmap(*bitmap); data = image->Serialize(); ASSERT_TRUE(data != nullptr); EXPECT_TRUE(image->Deserialize(data)); #else ASSERT_TRUE(data == nullptr); EXPECT_FALSE(image->Deserialize(data)); #endif } /** * @tc.name: MakeFromYUVAPixmapsTest001 * @tc.desc: test for MakeFromYUVAPixmapsTest failed with nullptr gpuContext. * @tc.type: FUNC * @tc.require: I782P9 */ HWTEST_F(ImageTest, MakeFromYUVAPixmapsTest001, TestSize.Level1) { GPUContext gpuContext; YUVInfo info(100, 100, YUVInfo::PlaneConfig::Y_UV, YUVInfo::SubSampling::K420, YUVInfo::YUVColorSpace::JPEG_FULL_YUVCOLORSPACE, YUVInfo::YUVDataType::UNORM_8); auto image = Image::MakeFromYUVAPixmaps(gpuContext, info, nullptr); EXPECT_TRUE(image == nullptr); } /** * @tc.name: MakeFromYUVAPixmapsTest002 * @tc.desc: test for MakeFromYUVAPixmapsTest failed with nullptr memory. * @tc.type: FUNC * @tc.require: I782P9 */ HWTEST_F(ImageTest, MakeFromYUVAPixmapsTest002, TestSize.Level1) { auto renderContext = std::make_shared(); renderContext->InitializeEglContext(); renderContext->SetUpGpuContext(); auto gpuContext = renderContext->GetSharedDrGPUContext(); ASSERT_NE(gpuContext, nullptr); YUVInfo info(100, 100, YUVInfo::PlaneConfig::Y_UV, YUVInfo::SubSampling::K420, YUVInfo::YUVColorSpace::JPEG_FULL_YUVCOLORSPACE, YUVInfo::YUVDataType::UNORM_8); auto image = Image::MakeFromYUVAPixmaps(*gpuContext, info, nullptr); EXPECT_TRUE(image == nullptr); gpuContext = nullptr; } /** * @tc.name: MakeFromYUVAPixmapsTest003 * @tc.desc: test for MakeFromYUVAPixmapsTest success for YUV NV21. * @tc.type: FUNC * @tc.require: I782P9 */ HWTEST_F(ImageTest, MakeFromYUVAPixmapsTest003, TestSize.Level1) { auto renderContext = std::make_shared(); renderContext->InitializeEglContext(); renderContext->SetUpGpuContext(); auto gpuContext = renderContext->GetSharedDrGPUContext(); ASSERT_NE(gpuContext, nullptr); size_t bufferSize = g_testJpgLength; uint8_t *buffer = g_testJpgBuffer; uint32_t errorCode = 0; Media::SourceOptions opts; opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = Media::ImageSource::CreateImageSource(buffer, bufferSize, opts, errorCode); ASSERT_NE(imageSource.get(), nullptr); Media::DecodeOptions decodeOpts; decodeOpts.desiredPixelFormat = Media::PixelFormat::NV21; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); ASSERT_NE(pixelMap.get(), nullptr); YUVInfo info(300, 300, YUVInfo::PlaneConfig::Y_VU, YUVInfo::SubSampling::K420, YUVInfo::YUVColorSpace::JPEG_FULL_YUVCOLORSPACE, YUVInfo::YUVDataType::UNORM_8); auto image = Image::MakeFromYUVAPixmaps(*gpuContext, info, const_cast(reinterpret_cast(pixelMap->GetPixels()))); EXPECT_TRUE(image != nullptr); gpuContext = nullptr; } /** * @tc.name: MakeFromYUVAPixmapsTest004 * @tc.desc: test for MakeFromYUVAPixmapsTest success for YUV NV12. * @tc.type: FUNC * @tc.require: I782P9 */ HWTEST_F(ImageTest, MakeFromYUVAPixmapsTest004, TestSize.Level1) { auto renderContext = std::make_shared(); renderContext->InitializeEglContext(); renderContext->SetUpGpuContext(); auto gpuContext = renderContext->GetSharedDrGPUContext(); ASSERT_NE(gpuContext, nullptr); size_t bufferSize = g_testJpgLength; uint8_t *buffer = g_testJpgBuffer; uint32_t errorCode = 0; Media::SourceOptions opts; opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = Media::ImageSource::CreateImageSource(buffer, bufferSize, opts, errorCode); ASSERT_NE(imageSource.get(), nullptr); Media::DecodeOptions decodeOpts; decodeOpts.desiredPixelFormat = Media::PixelFormat::NV12; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); ASSERT_NE(pixelMap.get(), nullptr); YUVInfo info(300, 300, YUVInfo::PlaneConfig::Y_UV, YUVInfo::SubSampling::K420, YUVInfo::YUVColorSpace::JPEG_FULL_YUVCOLORSPACE, YUVInfo::YUVDataType::UNORM_8); auto image = Image::MakeFromYUVAPixmaps(*gpuContext, info, const_cast(reinterpret_cast(pixelMap->GetPixels()))); EXPECT_TRUE(image != nullptr); gpuContext = nullptr; } /** * @tc.name: MakeFromYUVAPixmapsTest005 * @tc.desc: test for MakeFromYUVAPixmapsTest success for YUV YCBCR_P010. * @tc.type: FUNC * @tc.require: I782P9 */ HWTEST_F(ImageTest, MakeFromYUVAPixmapsTest005, TestSize.Level1) { auto renderContext = std::make_shared(); renderContext->InitializeEglContext(); renderContext->SetUpGpuContext(); auto gpuContext = renderContext->GetSharedDrGPUContext(); ASSERT_NE(gpuContext, nullptr); size_t bufferSize = g_testJpgLength; uint8_t *buffer = g_testJpgBuffer; uint32_t errorCode = 0; Media::SourceOptions opts; opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = Media::ImageSource::CreateImageSource(buffer, bufferSize, opts, errorCode); ASSERT_NE(imageSource.get(), nullptr); Media::DecodeOptions decodeOpts; decodeOpts.desiredPixelFormat = Media::PixelFormat::YCBCR_P010; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); ASSERT_NE(pixelMap.get(), nullptr); YUVInfo info(300, 300, YUVInfo::PlaneConfig::Y_UV, YUVInfo::SubSampling::K420, YUVInfo::YUVColorSpace::BT2020_10BIT_LIMITED_YUVCOLORSPACE, YUVInfo::YUVDataType::UNORM_16); auto image = Image::MakeFromYUVAPixmaps(*gpuContext, info, const_cast(reinterpret_cast(pixelMap->GetPixels()))); EXPECT_TRUE(image != nullptr); gpuContext = nullptr; } /** * @tc.name: MakeFromYUVAPixmapsTest006 * @tc.desc: test for MakeFromYUVAPixmapsTest success for YUV YCRCB_P010. * @tc.type: FUNC * @tc.require: I782P9 */ HWTEST_F(ImageTest, MakeFromYUVAPixmapsTest006, TestSize.Level1) { auto renderContext = std::make_shared(); renderContext->InitializeEglContext(); renderContext->SetUpGpuContext(); auto gpuContext = renderContext->GetSharedDrGPUContext(); ASSERT_NE(gpuContext, nullptr); size_t bufferSize = g_testJpgLength; uint8_t *buffer = g_testJpgBuffer; uint32_t errorCode = 0; Media::SourceOptions opts; opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = Media::ImageSource::CreateImageSource(buffer, bufferSize, opts, errorCode); ASSERT_NE(imageSource.get(), nullptr); Media::DecodeOptions decodeOpts; decodeOpts.desiredPixelFormat = Media::PixelFormat::YCRCB_P010; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); ASSERT_NE(pixelMap.get(), nullptr); YUVInfo info(300, 300, YUVInfo::PlaneConfig::Y_VU, YUVInfo::SubSampling::K420, YUVInfo::YUVColorSpace::BT2020_10BIT_LIMITED_YUVCOLORSPACE, YUVInfo::YUVDataType::UNORM_16); auto image = Image::MakeFromYUVAPixmaps(*gpuContext, info, const_cast(reinterpret_cast(pixelMap->GetPixels()))); EXPECT_TRUE(image != nullptr); gpuContext = nullptr; } #endif } // namespace Drawing } // namespace Rosen } // namespace OHOS