mirror of
https://gitee.com/openharmony/multimedia_image_framework
synced 2024-11-23 23:20:09 +00:00
Merge remote-tracking branch 'origin/master' into surface2
Change-Id: Ie7ac8c15da1068e82eaf8fb2dc21ff5f9e46d7d7
This commit is contained in:
commit
9c4e6df905
@ -244,7 +244,7 @@ unique_ptr<ImageSource> ImageSource::CreateImageSource(const std::string &pathNa
|
||||
streamPtr = FileSourceStream::CreateSourceStream(pathName);
|
||||
}
|
||||
if (streamPtr == nullptr) {
|
||||
HiLog::Error(LABEL, "[ImageSource]failed to create file path source stream.");
|
||||
HiLog::Error(LABEL, "[ImageSource]failed to create file path source stream. pathName=%s", pathName.c_str());
|
||||
}
|
||||
return streamPtr;
|
||||
}, opts, errorCode, "CreateImageSource by path");
|
||||
@ -533,7 +533,9 @@ unique_ptr<PixelMap> ImageSource::CreatePixelMapExtended(uint32_t index,
|
||||
if (!context.ifPartialOutput) {
|
||||
NotifyDecodeEvent(decodeListeners_, DecodeEvent::EVENT_COMPLETE_DECODE, nullptr);
|
||||
}
|
||||
HiLog::Info(LABEL, "ImageSource::CreatePixelMapExtended success");
|
||||
HiLog::Info(LABEL, "ImageSource::CreatePixelMapExtended success, desiredSize: (%{public}d, %{public}d),"
|
||||
"imageSize: (%{public}d, %{public}d)", opts.desiredSize.width, opts.desiredSize.height, info.size.width,
|
||||
info.size.height);
|
||||
return pixelMap;
|
||||
}
|
||||
|
||||
@ -1136,7 +1138,7 @@ uint32_t ImageSource::GetData(ImagePlugin::DataStreamBuffer &outData, size_t siz
|
||||
return ERR_IMAGE_INVALID_PARAMETER;
|
||||
}
|
||||
if (!sourceStreamPtr_->Peek(size, outData)) {
|
||||
HiLog::Error(LABEL, "[ImageSource]stream peek the data fail.");
|
||||
HiLog::Error(LABEL, "[ImageSource]stream peek the data fail, desiredSize:%{public}zu", size);
|
||||
return ERR_IMAGE_SOURCE_DATA;
|
||||
}
|
||||
if (outData.inputStreamBuffer == nullptr || outData.dataSize < size) {
|
||||
|
@ -1402,6 +1402,17 @@ bool PixelMap::WritePixels(const uint32_t &color)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PixelMap::IsStrideAlignment()
|
||||
{
|
||||
HiLog::Error(LABEL, "IsStrideAlignment error ");
|
||||
if (allocatorType_ == AllocatorType::DMA_ALLOC) {
|
||||
HiLog::Error(LABEL, "SetPixelsAddr error allocatorType_ %{public}d ", allocatorType_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
HiLog::Error(LABEL, "IsStrideAlignment error ");
|
||||
}
|
||||
|
||||
AllocatorType PixelMap::GetAllocatorType()
|
||||
{
|
||||
return allocatorType_;
|
||||
|
48
frameworks/innerkitsimpl/egl_image/BUILD.gn
Normal file
48
frameworks/innerkitsimpl/egl_image/BUILD.gn
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright (C) 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, software
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/multimedia/image_framework/ide/image_decode_config.gni")
|
||||
|
||||
config("egl_image_public_config") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("egl_image") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
|
||||
public_configs = [ ":egl_image_public_config" ]
|
||||
sources = [
|
||||
"src/pixel_map_from_surface.cpp",
|
||||
"src/render_context.cpp",
|
||||
]
|
||||
|
||||
deps = [ "$image_subsystem/interfaces/innerkits:image_native" ]
|
||||
deps += skia_platform
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"graphic_2d:libgl",
|
||||
"graphic_surface:surface",
|
||||
"graphic_surface:sync_fence",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
]
|
||||
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "image_framework"
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 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, software
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_INNERKITSIMPL_EGL_IMAGE_INCLUDE_PIXELMAP_FROM_SURFACE_H
|
||||
#define FRAMEWORKS_INNERKITSIMPL_EGL_IMAGE_INCLUDE_PIXELMAP_FROM_SURFACE_H
|
||||
|
||||
#include "render_context.h"
|
||||
|
||||
#include "pixel_map.h"
|
||||
#include "surface_buffer.h"
|
||||
#include "surface_utils.h"
|
||||
#include "window.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Media {
|
||||
// we use this helper to make pixelmap from a surface, and will construct this object
|
||||
// in every PixelMap::CreateFromSurface() call.
|
||||
class PixelMapFromSurface {
|
||||
public:
|
||||
PixelMapFromSurface();
|
||||
~PixelMapFromSurface() noexcept;
|
||||
|
||||
std::unique_ptr<PixelMap> Create(uint64_t surfaceId, const Rect &srcRect);
|
||||
|
||||
// disallow copy and move
|
||||
PixelMapFromSurface(const PixelMapFromSurface &) = delete;
|
||||
void operator=(const PixelMapFromSurface &) = delete;
|
||||
PixelMapFromSurface(const PixelMapFromSurface &&) = delete;
|
||||
void operator=(const PixelMapFromSurface &&) = delete;
|
||||
|
||||
private:
|
||||
bool GetNativeWindowBufferFromSurface(const sptr<Surface> &surface);
|
||||
bool CreateEGLImage();
|
||||
bool DrawImage(const Rect &srcRect);
|
||||
void Clear() noexcept;
|
||||
|
||||
sptr<SurfaceBuffer> surfaceBuffer_;
|
||||
OHNativeWindowBuffer *nativeWindowBuffer_ = nullptr;
|
||||
std::unique_ptr<RenderContext> renderContext_;
|
||||
GLuint texId_ = 0U;
|
||||
EGLImageKHR eglImage_ = EGL_NO_IMAGE_KHR;
|
||||
sk_sp<SkSurface> targetSurface_; // a tmp surface(renderTarget) to draw surfacebuffer and get the result.
|
||||
};
|
||||
|
||||
std::unique_ptr<PixelMap> CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect);
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FRAMEWORKS_INNERKITSIMPL_EGL_IMAGE_INCLUDE_PIXELMAP_FROM_SURFACE_H
|
78
frameworks/innerkitsimpl/egl_image/include/render_context.h
Normal file
78
frameworks/innerkitsimpl/egl_image/include/render_context.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 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, software
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_INNERKITSIMPL_EGL_IMAGE_INCLUDE_RENDER_CONTEXT_H
|
||||
#define FRAMEWORKS_INNERKITSIMPL_EGL_IMAGE_INCLUDE_RENDER_CONTEXT_H
|
||||
|
||||
#ifndef EGL_EGLEXT_PROTOTYPES
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
#endif // EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include "EGL/egl.h"
|
||||
#include "EGL/eglext.h"
|
||||
#include "GLES/gl.h"
|
||||
#include "GLES/glext.h"
|
||||
#include "GLES3/gl32.h"
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "include/gpu/gl/GrGLInterface.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Media {
|
||||
class RenderContext {
|
||||
public:
|
||||
RenderContext();
|
||||
~RenderContext() noexcept;
|
||||
|
||||
// disallow copy and move
|
||||
RenderContext(const RenderContext &) = delete;
|
||||
void operator=(const RenderContext &) = delete;
|
||||
RenderContext(const RenderContext &&) = delete;
|
||||
void operator=(const RenderContext &&) = delete;
|
||||
|
||||
bool Init();
|
||||
|
||||
void MakeCurrent(EGLSurface surface) const;
|
||||
|
||||
sk_sp<GrDirectContext> GetGrContext() const
|
||||
{
|
||||
return grContext_;
|
||||
}
|
||||
|
||||
EGLDisplay GetEGLDisplay() const
|
||||
{
|
||||
return eglDisplay_;
|
||||
}
|
||||
|
||||
public:
|
||||
void Clear() noexcept;
|
||||
bool CreatePbufferSurface();
|
||||
bool InitEGLContext();
|
||||
bool InitGrContext();
|
||||
|
||||
EGLDisplay eglDisplay_ = EGL_NO_DISPLAY;
|
||||
EGLConfig config_ = NULL;
|
||||
EGLContext eglContext_ = EGL_NO_CONTEXT;
|
||||
EGLSurface pbufferSurface_ = EGL_NO_SURFACE;
|
||||
sk_sp<GrDirectContext> grContext_;
|
||||
};
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
#endif // FRAMEWORKS_INNERKITSIMPL_EGL_IMAGE_INCLUDE_RENDER_CONTEXT_H
|
@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (C) 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, software
|
||||
* 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 "pixel_map_from_surface.h"
|
||||
|
||||
#include "sync_fence.h"
|
||||
#include "hilog/log.h"
|
||||
#include "log_tags.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Media {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelMap" };
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
PixelMapFromSurface::PixelMapFromSurface()
|
||||
{}
|
||||
|
||||
PixelMapFromSurface::~PixelMapFromSurface() noexcept
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void PixelMapFromSurface::Clear() noexcept
|
||||
{
|
||||
if (eglImage_ != EGL_NO_IMAGE_KHR) {
|
||||
if (renderContext_ != nullptr) {
|
||||
eglDestroyImageKHR(renderContext_->GetEGLDisplay(), eglImage_);
|
||||
} else {
|
||||
auto disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
eglDestroyImageKHR(disp, eglImage_);
|
||||
}
|
||||
eglImage_ = EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
|
||||
if (texId_ != 0U) {
|
||||
glDeleteTextures(1, &texId_);
|
||||
texId_ = 0U;
|
||||
}
|
||||
|
||||
surfaceBuffer_ = nullptr;
|
||||
if (nativeWindowBuffer_ != nullptr) {
|
||||
DestroyNativeWindowBuffer(nativeWindowBuffer_);
|
||||
nativeWindowBuffer_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool PixelMapFromSurface::GetNativeWindowBufferFromSurface(const sptr<Surface> &surface)
|
||||
{
|
||||
// private func, surface is not nullptr.
|
||||
sptr<SyncFence> fence;
|
||||
// a 4 * 4 idetity matrix
|
||||
float matrix[16] = {
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
};
|
||||
int ret = surface->GetLastFlushedBuffer(surfaceBuffer_, fence, matrix);
|
||||
if (ret != OHOS::GSERROR_OK || surfaceBuffer_ == nullptr) {
|
||||
Clear();
|
||||
HiLog::Error(LABEL,
|
||||
"CreatePixelMapFromSurface: GetLastFlushedBuffer from nativeWindow failed, err: %{public}d",
|
||||
ret);
|
||||
return false;
|
||||
}
|
||||
if (fence != nullptr) {
|
||||
fence->Wait(3000); // wait at most 3000ms
|
||||
}
|
||||
nativeWindowBuffer_ = CreateNativeWindowBufferFromSurfaceBuffer(&surfaceBuffer_);
|
||||
return nativeWindowBuffer_ != nullptr;
|
||||
}
|
||||
|
||||
bool PixelMapFromSurface::CreateEGLImage()
|
||||
{
|
||||
EGLint attrs[] = {
|
||||
EGL_IMAGE_PRESERVED,
|
||||
EGL_TRUE,
|
||||
EGL_NONE,
|
||||
};
|
||||
eglImage_ = eglCreateImageKHR(
|
||||
renderContext_->GetEGLDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_OHOS,
|
||||
nativeWindowBuffer_, attrs);
|
||||
if (eglImage_ == EGL_NO_IMAGE_KHR) {
|
||||
Clear();
|
||||
HiLog::Error(LABEL, "%{public}s create egl image fail %{public}d", __func__, eglGetError());
|
||||
return false;
|
||||
}
|
||||
glGenTextures(1, &texId_);
|
||||
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texId_);
|
||||
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
static auto glEGLImageTargetTexture2DOESFunc = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(
|
||||
eglGetProcAddress("glEGLImageTargetTexture2DOES"));
|
||||
if (glEGLImageTargetTexture2DOESFunc == nullptr) {
|
||||
Clear();
|
||||
HiLog::Error(LABEL, "%{public}s glEGLImageTargetTexture2DOES func not found: %{public}d",
|
||||
__func__, eglGetError());
|
||||
return false;
|
||||
}
|
||||
glEGLImageTargetTexture2DOESFunc(GL_TEXTURE_EXTERNAL_OES, static_cast<GLeglImageOES>(eglImage_));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PixelMapFromSurface::DrawImage(const Rect &srcRect)
|
||||
{
|
||||
GraphicPixelFormat pixelFormat = static_cast<GraphicPixelFormat>(surfaceBuffer_->GetFormat());
|
||||
SkColorType colorType = kRGBA_8888_SkColorType;
|
||||
GLuint glType = GL_RGBA8;
|
||||
int bufferWidth = surfaceBuffer_->GetWidth();
|
||||
int bufferHeight = surfaceBuffer_->GetHeight();
|
||||
if (pixelFormat == GRAPHIC_PIXEL_FMT_BGRA_8888) {
|
||||
colorType = kBGRA_8888_SkColorType;
|
||||
} else if (pixelFormat == GRAPHIC_PIXEL_FMT_YCBCR_P010 || pixelFormat == GRAPHIC_PIXEL_FMT_YCRCB_P010) {
|
||||
colorType = kRGBA_1010102_SkColorType;
|
||||
glType = GL_RGB10_A2;
|
||||
}
|
||||
GrGLTextureInfo grExternalTextureInfo = { GL_TEXTURE_EXTERNAL_OES, texId_, static_cast<GrGLenum>(glType) };
|
||||
auto backendTexturePtr =
|
||||
std::make_shared<GrBackendTexture>(bufferWidth, bufferHeight, GrMipMapped::kNo, grExternalTextureInfo);
|
||||
auto image = SkImage::MakeFromTexture(renderContext_->GetGrContext().get(), *backendTexturePtr,
|
||||
kTopLeft_GrSurfaceOrigin, colorType, kPremul_SkAlphaType, nullptr);
|
||||
if (image == nullptr) {
|
||||
Clear();
|
||||
HiLog::Error(LABEL, "%{public}s create SkImage failed.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto imageInfo = SkImageInfo::Make(srcRect.width, srcRect.height, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
targetSurface_ = SkSurface::MakeRenderTarget(renderContext_->GetGrContext().get(), SkBudgeted::kYes,
|
||||
imageInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr);
|
||||
if (targetSurface_ == nullptr) {
|
||||
Clear();
|
||||
HiLog::Error(LABEL, "%{public}s SkSurface::MakeRenderTarget failed.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
SkCanvas* canvas = targetSurface_->getCanvas();
|
||||
SkPaint paint;
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
SkSamplingOptions sampling(SkFilterMode::kNearest);
|
||||
canvas->drawImageRect(image,
|
||||
SkRect::MakeXYWH(srcRect.left, srcRect.top, srcRect.width, srcRect.height),
|
||||
SkRect::MakeWH(srcRect.width, srcRect.height),
|
||||
sampling, &paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<PixelMap> PixelMapFromSurface::Create(uint64_t surfaceId, const Rect &srcRect)
|
||||
{
|
||||
Clear();
|
||||
sptr<Surface> surface = SurfaceUtils::GetInstance()->GetSurface(surfaceId);
|
||||
if (surface == nullptr) {
|
||||
HiLog::Error(LABEL,
|
||||
"CreatePixelMapFromSurface: can't find surface for surfaceId: {public}%" PRIu64 ".", surfaceId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!GetNativeWindowBufferFromSurface(surface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// init renderContext to do some format convertion if necessary.
|
||||
renderContext_ = std::make_unique<RenderContext>();
|
||||
if (!renderContext_->Init()) {
|
||||
Clear();
|
||||
HiLog::Error(LABEL, "CreatePixelMapFromSurface: init renderContext failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!CreateEGLImage()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!DrawImage(srcRect)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InitializationOptions options;
|
||||
options.size.width = srcRect.width;
|
||||
options.size.height = srcRect.height;
|
||||
options.srcPixelFormat = PixelFormat::RGBA_8888;
|
||||
options.pixelFormat = PixelFormat::RGBA_8888;
|
||||
auto pixelMap = PixelMap::Create(options);
|
||||
auto imageInfo = SkImageInfo::Make(srcRect.width, srcRect.height, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
SkPixmap skPixmap(imageInfo, pixelMap->GetPixel(0, 0), pixelMap->GetRowBytes());
|
||||
targetSurface_->readPixels(skPixmap, 0, 0);
|
||||
return pixelMap;
|
||||
}
|
||||
|
||||
std::unique_ptr<PixelMap> CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect)
|
||||
{
|
||||
auto helper = std::make_unique<PixelMapFromSurface>();
|
||||
return helper->Create(surfaceId, srcRect);
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
166
frameworks/innerkitsimpl/egl_image/src/render_context.cpp
Normal file
166
frameworks/innerkitsimpl/egl_image/src/render_context.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (C) 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, software
|
||||
* 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 "render_context.h"
|
||||
|
||||
#include "hilog/log.h"
|
||||
#include "log_tags.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Media {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelMap" };
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
RenderContext::RenderContext()
|
||||
{}
|
||||
|
||||
RenderContext::~RenderContext() noexcept
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool RenderContext::Init()
|
||||
{
|
||||
if (!InitEGLContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!InitGrContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderContext::InitEGLContext()
|
||||
{
|
||||
eglDisplay_ = eglGetPlatformDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, nullptr);
|
||||
if (eglDisplay_ == EGL_NO_DISPLAY) {
|
||||
HiLog::Error(LABEL, "RenderContext::Init: eglGetDisplay error: ");
|
||||
return false;
|
||||
}
|
||||
|
||||
EGLint major = 0;
|
||||
EGLint minor = 0;
|
||||
if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) {
|
||||
HiLog::Error(LABEL, "Failed to initialize EGLDisplay");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
|
||||
HiLog::Error(LABEL, "Failed to bind OpenGL ES API");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int ret;
|
||||
EGLint count;
|
||||
EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE };
|
||||
|
||||
ret = eglChooseConfig(eglDisplay_, configAttribs, &config_, 1, &count);
|
||||
if (!(ret && static_cast<unsigned int>(count) >= 1)) {
|
||||
HiLog::Error(LABEL, "Failed to eglChooseConfig");
|
||||
return false;
|
||||
}
|
||||
|
||||
static const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
||||
eglContext_ = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, contextAttribs);
|
||||
if (eglContext_ == EGL_NO_CONTEXT) {
|
||||
HiLog::Error(LABEL, "Failed to create egl context %{public}x", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CreatePbufferSurface()) {
|
||||
return false;
|
||||
}
|
||||
MakeCurrent(pbufferSurface_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderContext::CreatePbufferSurface()
|
||||
{
|
||||
if (pbufferSurface_ == EGL_NO_SURFACE) {
|
||||
EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
|
||||
pbufferSurface_ = eglCreatePbufferSurface(eglDisplay_, config_, attribs);
|
||||
if (pbufferSurface_ == EGL_NO_SURFACE) {
|
||||
HiLog::Error(
|
||||
LABEL,
|
||||
"RenderContext::CreatePbufferSurface failed, error is %{public}x",
|
||||
eglGetError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderContext::MakeCurrent(EGLSurface surface) const
|
||||
{
|
||||
EGLSurface currSurface = surface;
|
||||
if (currSurface == EGL_NO_SURFACE) {
|
||||
currSurface = pbufferSurface_;
|
||||
}
|
||||
|
||||
if (eglMakeCurrent(eglDisplay_, currSurface, currSurface, eglContext_) != EGL_TRUE) {
|
||||
EGLint surfaceId = -1;
|
||||
eglQuerySurface(eglDisplay_, surface, EGL_CONFIG_ID, &surfaceId);
|
||||
HiLog::Error(
|
||||
LABEL,
|
||||
"RenderContext::MakeCurrent failed for eglSurface %{public}d, error is %{public}x",
|
||||
surfaceId,
|
||||
eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderContext::InitGrContext()
|
||||
{
|
||||
sk_sp<const GrGLInterface> glInterface(GrGLCreateNativeInterface());
|
||||
if (glInterface == nullptr) {
|
||||
HiLog::Error(LABEL, "SetUpGrContext failed to make native interface");
|
||||
return false;
|
||||
}
|
||||
|
||||
GrContextOptions options;
|
||||
options.fGpuPathRenderers &= ~GpuPathRenderers::kCoverageCounting;
|
||||
options.fPreferExternalImagesOverES3 = true;
|
||||
options.fDisableDistanceFieldPaths = true;
|
||||
grContext_ = GrDirectContext::MakeGL(std::move(glInterface), options);
|
||||
return grContext_ != nullptr;
|
||||
}
|
||||
|
||||
void RenderContext::Clear() noexcept
|
||||
{
|
||||
if (eglDisplay_ == EGL_NO_DISPLAY) {
|
||||
return;
|
||||
}
|
||||
|
||||
grContext_ = nullptr;
|
||||
|
||||
if (pbufferSurface_ != EGL_NO_SURFACE) {
|
||||
EGLBoolean ret = eglDestroySurface(eglDisplay_, pbufferSurface_);
|
||||
if (ret != EGL_TRUE) {
|
||||
HiLog::Error(LABEL, "RenderContext::Clear() failed to destroy pbuffer surface, error is %{public}x.",
|
||||
eglGetError());
|
||||
}
|
||||
pbufferSurface_ = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
(void)eglDestroyContext(eglDisplay_, eglContext_);
|
||||
(void)eglTerminate(eglDisplay_);
|
||||
eglContext_ = EGL_NO_CONTEXT;
|
||||
eglDisplay_ = EGL_NO_DISPLAY;
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
@ -151,7 +151,7 @@ bool FileSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData)
|
||||
return false;
|
||||
}
|
||||
if (!GetData(desiredSize, outData)) {
|
||||
HiLog::Info(LABEL, "[FileSourceStream]peek dataStreamBuffer fail.");
|
||||
HiLog::Info(LABEL, "[FileSourceStream]peek dataStreamBuffer fail, desiredSize:%{public}zu", desiredSize);
|
||||
return false;
|
||||
}
|
||||
int ret = fseek(filePtr_, fileOffset_, SEEK_SET);
|
||||
|
@ -237,6 +237,35 @@ ohos_unittest("jpegutilstest") {
|
||||
resource_config_file = "$image_subsystem/test/resource/image/ohos_test.xml"
|
||||
}
|
||||
|
||||
ohos_unittest("exifmakernotetest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
include_dirs = [
|
||||
"$image_subsystem/frameworks/innerkitsimpl/converter/include",
|
||||
"$image_subsystem/frameworks/innerkitsimpl/utils/include",
|
||||
"$image_subsystem/interfaces/innerkits/include",
|
||||
"$image_subsystem/plugins/common/libs/image/libjpegplugin/include",
|
||||
"$image_subsystem/plugins/manager/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
]
|
||||
cflags = [ "-DIMAGE_COLORSPACE_FLAG" ]
|
||||
sources = [ "$image_subsystem/frameworks/innerkitsimpl/test/unittest/exif_maker_note_test.cpp" ]
|
||||
deps = [
|
||||
"$image_subsystem/frameworks/innerkitsimpl/utils:image_utils",
|
||||
"$image_subsystem/interfaces/innerkits:image_native",
|
||||
"$image_subsystem/plugins/common/libs/image/libjpegplugin:jpegplugin",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
||||
resource_config_file = "$image_subsystem/test/resource/image/ohos_test.xml"
|
||||
}
|
||||
|
||||
ohos_unittest("format_agent_plugin_src_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
@ -997,6 +1026,7 @@ ohos_unittest("jpeg_hw_decoder_test") {
|
||||
|
||||
include_dirs = [
|
||||
"${image_subsystem}/frameworks/innerkitsimpl/test/unittest/jpeg_hw_decode/common/",
|
||||
"${image_subsystem}/frameworks/innerkitsimpl/utils/include/",
|
||||
"${image_subsystem}/plugins/common/libs/image/libextplugin/include/",
|
||||
"${image_subsystem}/plugins/manager/include/",
|
||||
"${image_subsystem}/interfaces/innerkits/include/",
|
||||
@ -1009,6 +1039,7 @@ ohos_unittest("jpeg_hw_decoder_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils",
|
||||
"${image_subsystem}/interfaces/innerkits:image_native",
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//third_party/skia:skia_ohos",
|
||||
@ -1035,6 +1066,49 @@ ohos_unittest("jpeg_hw_decoder_test") {
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("pixelastctest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
cflags = [
|
||||
"-DIMAGE_DEBUG_FLAG",
|
||||
"-DIMAGE_COLORSPACE_FLAG",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"${image_subsystem}/frameworks/innerkitsimpl/converter/include",
|
||||
"${image_subsystem}/frameworks/innerkitsimpl/utils/include",
|
||||
"${image_subsystem}/interfaces/innerkits/include",
|
||||
"$graphic_subsystem/utils/color_manager/export",
|
||||
"${image_subsystem}/../../../foundation/multimedia/utils/include",
|
||||
"${image_subsystem}/../../../third_party/googletest/googletest/include",
|
||||
"${image_subsystem}/../../../commonlibrary/c_utils/base/include",
|
||||
"${image_subsystem}/plugins/manager/include",
|
||||
]
|
||||
sources = [ "$image_subsystem/frameworks/innerkitsimpl/test/unittest/pixel_astc_test.cpp" ]
|
||||
|
||||
deps = [
|
||||
"$graphic_subsystem/utils/color_manager:color_manager",
|
||||
"${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils",
|
||||
"${image_subsystem}/interfaces/innerkits:image_native",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
if (purgeable_ashmem_enable && defined(global_parts_info) &&
|
||||
defined(global_parts_info.resourceschedule_memmgr_plugin)) {
|
||||
defines = [ "IMAGE_PURGEABLE_PIXELMAP" ]
|
||||
external_deps += [ "memmgr_plugin:libpurgeablemem_plugin" ]
|
||||
}
|
||||
|
||||
resource_config_file = "$image_subsystem/test/resource/image/ohos_test.xml"
|
||||
}
|
||||
|
||||
################################################
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
@ -1044,6 +1118,7 @@ group("unittest") {
|
||||
":colorconvertertest",
|
||||
":convertertest",
|
||||
":creatortest",
|
||||
":exifmakernotetest",
|
||||
":format_agent_plugin_src_test",
|
||||
":formatagentplugintest",
|
||||
":gstpluginfwtest",
|
||||
@ -1056,6 +1131,7 @@ group("unittest") {
|
||||
":jpegdecoderextest",
|
||||
":jpegutilstest",
|
||||
":napitest",
|
||||
":pixelastctest",
|
||||
":pixelconvertadaptertest",
|
||||
":pixelmaptest",
|
||||
":pluginlibjpegtest",
|
||||
|
291
frameworks/innerkitsimpl/test/unittest/exif_maker_note_test.cpp
Normal file
291
frameworks/innerkitsimpl/test/unittest/exif_maker_note_test.cpp
Normal file
@ -0,0 +1,291 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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, software
|
||||
* 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.
|
||||
*/
|
||||
#define private public
|
||||
#include <gtest/gtest.h>
|
||||
#include <memory>
|
||||
#include <fcntl.h>
|
||||
#include "exif_maker_note.h"
|
||||
#include "securec.h"
|
||||
#include "string_ex.h"
|
||||
#include "hilog/log.h"
|
||||
#include "log_tags.h"
|
||||
#include "media_errors.h"
|
||||
#include "exif_info.h"
|
||||
#include "jpeg_decoder.h"
|
||||
#include "jpeg_encoder.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::Media;
|
||||
using namespace OHOS::HiviewDFX;
|
||||
namespace OHOS {
|
||||
namespace ImagePlugin {
|
||||
constexpr unsigned char EXIF_HEADER[] = {'E', 'x', 'i', 'f', '\0', '\0'};
|
||||
constexpr unsigned char EXIF_TAIL[] = {'e', 'x', 'p', 'o', 'r', 't', 's', 'c', 't', 'e', 's', 't', '\0'};
|
||||
constexpr unsigned char EXIF_TCL[] = {'f', 'd', 'e', 'b'};
|
||||
constexpr unsigned char EXIF_TCB[] = {'f', 'd'};
|
||||
class ExifMakerNoteTest : public testing::Test {
|
||||
public:
|
||||
ExifMakerNoteTest() {}
|
||||
~ExifMakerNoteTest() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.name: CopyItemTest0001
|
||||
* @tc.desc: Test of CopyItem
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, CopyItemTest001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: CopyItemTest001 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
ExifMakerNote::ExifItem item;
|
||||
item.ifd = 1;
|
||||
ExifMakerNote->CopyItem(item);
|
||||
ASSERT_EQ(item.ifd, 1);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: CopyItemTest0001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetValueTest001
|
||||
* @tc.desc: Test of GetValue
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, GetValueTest001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest001 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
std::string value = "111";
|
||||
ExifByteOrder order = ExifByteOrder::EXIF_BYTE_ORDER_INTEL;
|
||||
bool mock = true;
|
||||
bool ret = ExifMakerNote->GetValue(value, order, mock);
|
||||
ASSERT_EQ(ret, true);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetValueTest002
|
||||
* @tc.desc: Test of GetValue
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, GetValueTest002, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest002 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
std::string value = "111";
|
||||
ExifData *exifData = nullptr;
|
||||
bool mock = true;
|
||||
bool ret = ExifMakerNote->GetValue(value, exifData, mock);
|
||||
ASSERT_EQ(ret, true);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest002 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DumpTest001
|
||||
* @tc.desc: Test of Dump
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, DumpTest001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: DumpTest001 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
std::string info = "nihao";
|
||||
ExifByteOrder order = ExifByteOrder::EXIF_BYTE_ORDER_INTEL;
|
||||
ExifMakerNote::ExifItem item;
|
||||
item.tag =2;
|
||||
ExifMakerNote->Dump(info, order);
|
||||
ASSERT_EQ(item.tag, 2);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: DumpTest001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetValueTest003
|
||||
* @tc.desc: Test of GetValue
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, GetValueTest003, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest003 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
std::string value = "111";
|
||||
ExifByteOrder order = ExifByteOrder::EXIF_BYTE_ORDER_INTEL;
|
||||
ExifMakerNote::ExifItem item;
|
||||
bool mock = true;
|
||||
bool ret = ExifMakerNote->GetValue(value, order, item, mock);
|
||||
ASSERT_EQ(ret, true);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest003 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetValueTest004
|
||||
* @tc.desc: Test of GetValue
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, GetValueTest004, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest004 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
std::string value = "111";
|
||||
ExifData *exifData = nullptr;
|
||||
ExifMakerNote::ExifItem item;
|
||||
bool mock = true;
|
||||
bool ret = ExifMakerNote->GetValue(value, exifData, item, mock);
|
||||
ASSERT_EQ(ret, true);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest004 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetValueTest005
|
||||
* @tc.desc: Test of GetValue
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, GetValueTest005, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest005 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
std::string value = "111";
|
||||
ExifContent *exifContent = nullptr;
|
||||
ExifMakerNote::ExifItem item;
|
||||
bool mock = true;
|
||||
bool ret = ExifMakerNote->GetValue(value, exifContent, item, mock);
|
||||
ASSERT_EQ(ret, true);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: GetValueTest005 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DumpTest002
|
||||
* @tc.desc: Test of Dump
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, DumpTest002, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: DumpTest002 start";
|
||||
auto ExifMakerNote = std::make_shared<ExifMakerNote::ExifItem>();
|
||||
std::string info = "infomation";
|
||||
ExifMakerNote::ExifItem item;
|
||||
item.ifd = 1;
|
||||
ExifByteOrder order = ExifByteOrder::EXIF_BYTE_ORDER_INTEL;
|
||||
ExifMakerNote->Dump(info, item, order);
|
||||
ASSERT_EQ(item.ifd, 1);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: DumpTest002 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ParserTest001
|
||||
* @tc.desc: Test of Parser
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, ParserTest001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: ParserTest001 start";
|
||||
ExifMakerNote exifMakerNote;
|
||||
ExifData *exif = nullptr;
|
||||
unsigned char* data = nullptr;
|
||||
uint32_t size = 11;
|
||||
uint32_t ret = exifMakerNote.Parser(exif, data, size);
|
||||
ASSERT_EQ(ret, Media::SUCCESS);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: ParserTest001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FindExifLocationTest001
|
||||
* @tc.desc: Test of FindExifLocation
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, FindExifLocationTest001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindExifLocationTest001 start";
|
||||
ExifMakerNote exifMakerNote;
|
||||
const unsigned char *data = nullptr;
|
||||
uint32_t size = 3;
|
||||
const unsigned char *&newData = data;
|
||||
uint32_t newSize = 7;
|
||||
bool result = exifMakerNote.FindExifLocation(data, size, newData, newSize);
|
||||
ASSERT_EQ(result, false);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindExifLocationTest001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FindExifLocationTest002
|
||||
* @tc.desc: Test of FindExifLocation
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, FindExifLocationTest002, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindExifLocationTest002 start";
|
||||
ExifMakerNote exifMakerNote;
|
||||
const unsigned char *data = EXIF_HEADER;
|
||||
uint32_t size = 6;
|
||||
const unsigned char *&newData = data;
|
||||
uint32_t newSize = 7;
|
||||
bool result = exifMakerNote.FindExifLocation(data, size, newData, newSize);
|
||||
ASSERT_EQ(result, false);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindExifLocationTest002 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FindExifLocationTest003
|
||||
* @tc.desc: Test of FindExifLocation
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, FindExifLocationTest003, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindExifLocationTest003 start";
|
||||
ExifMakerNote exifMakerNote;
|
||||
const unsigned char *data = EXIF_TAIL;
|
||||
uint32_t size = 13;
|
||||
const unsigned char *&newData = data;
|
||||
uint32_t newSize = 7;
|
||||
bool result = exifMakerNote.FindExifLocation(data, size, newData, newSize);
|
||||
ASSERT_EQ(result, false);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindExifLocationTest003 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FindJpegAPP1Test001
|
||||
* @tc.desc: Test of FindJpegAPP1
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, FindJpegAPP1Test001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindJpegAPP1Test001 start";
|
||||
ExifMakerNote exifMakerNote;
|
||||
const unsigned char *data = EXIF_TCL;
|
||||
uint32_t size = 4;
|
||||
const unsigned char *&newData = data;
|
||||
uint32_t newSize = 7;
|
||||
bool result = exifMakerNote.FindJpegAPP1(data, size, newData, newSize);
|
||||
ASSERT_EQ(result, false);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindJpegAPP1Test001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FindJpegAPP1Test002
|
||||
* @tc.desc: Test of FindJpegAPP1
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ExifMakerNoteTest, FindJpegAPP1Test002, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindJpegAPP1Test002 start";
|
||||
ExifMakerNote exifMakerNote;
|
||||
const unsigned char *data = EXIF_TCB;
|
||||
uint32_t size = 2;
|
||||
const unsigned char *&newData = data;
|
||||
uint32_t newSize = 7;
|
||||
bool result = exifMakerNote.FindJpegAPP1(data, size, newData, newSize);
|
||||
ASSERT_EQ(result, false);
|
||||
GTEST_LOG_(INFO) << "ExifMakerNoteTest: FindJpegAPP1Test002 end";
|
||||
}
|
||||
}
|
||||
}
|
@ -392,10 +392,10 @@ HWTEST_F(ImagePixelMapTest, ImagePixelMap007, TestSize.Level3)
|
||||
info.size.height = 500 * 1024;
|
||||
info.pixelFormat = PixelFormat::ARGB_8888;
|
||||
info.colorSpace = ColorSpace::SRGB;
|
||||
EXPECT_EQ(pixelMap.SetImageInfo(info), ERR_IMAGE_TOO_LARGE);
|
||||
EXPECT_EQ(pixelMap.GetHeight(), 0);
|
||||
EXPECT_EQ(pixelMap.GetWidth(), 0);
|
||||
EXPECT_EQ(pixelMap.GetByteCount(), 0);
|
||||
EXPECT_EQ(pixelMap.SetImageInfo(info), SUCCESS);
|
||||
EXPECT_EQ(pixelMap.GetHeight(), info.size.width);
|
||||
EXPECT_EQ(pixelMap.GetWidth(), info.size.width);
|
||||
EXPECT_NE(pixelMap.GetByteCount(), 0);
|
||||
uint8_t *data = const_cast<uint8_t *>(pixelMap.GetPixels());
|
||||
EXPECT_EQ(data, nullptr);
|
||||
GTEST_LOG_(INFO) << "ImagePixelMapTest: ImagePixelMap007 end";
|
||||
|
@ -80,7 +80,7 @@ HWTEST_F(ImageReceiverManagerTest, ImageReceiverManager003, TestSize.Level3)
|
||||
RECEIVER_TEST_HEIGHT, RECEIVER_TEST_FORMAT, RECEIVER_TEST_CAPACITY);
|
||||
ImageReceiverManager& imageReceiverManager = ImageReceiverManager::getInstance();
|
||||
std::string receiverKey = imageReceiverManager.SaveImageReceiver(iva);
|
||||
ASSERT_EQ(receiverKey, "2");
|
||||
ASSERT_EQ(receiverKey, "1");
|
||||
auto surface = imageReceiverManager.getSurfaceByKeyId("");
|
||||
bool result = (surface == nullptr);
|
||||
ASSERT_EQ(result, true);
|
||||
|
@ -319,14 +319,13 @@ HWTEST_F(ImageReceiverTest, ImageReceiver0016, TestSize.Level3)
|
||||
HWTEST_F(ImageReceiverTest, ImageReceiver0017, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ImageReceiverTest: ImageReceiver0017 start";
|
||||
ImageReceiverManager& imageReceiverManager = ImageReceiverManager::getInstance();
|
||||
std::shared_ptr<ImageReceiver> imageReceiver1 = imageReceiverManager.getImageReceiverByKeyId("1");
|
||||
std::shared_ptr<ImageReceiver> imageReceiver1 = nullptr;
|
||||
int32_t width = 640;
|
||||
int32_t height = 480;
|
||||
int32_t format = 4;
|
||||
int32_t capicity = 8;
|
||||
imageReceiver1->CreateImageReceiver(width, height, format, capicity);
|
||||
ASSERT_EQ(imageReceiver1, nullptr);
|
||||
ASSERT_NE(imageReceiver1, nullptr);
|
||||
GTEST_LOG_(INFO) << "ImageReceiverTest: ImageReceiver0017 end";
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "hardware/jpeg_hw_decoder.h"
|
||||
#include "mock_jpeg_hw_decode_flow.h"
|
||||
#include "image_system_properties.h"
|
||||
|
||||
namespace OHOS::Media {
|
||||
using namespace testing::ext;
|
||||
@ -26,42 +27,9 @@ class JpegHwDecoderTest : public testing::Test {
|
||||
public:
|
||||
static constexpr char JPEG_FORMAT[] = "image/jpeg";
|
||||
static constexpr char HEIF_FORMAT[] = "image/heif";
|
||||
static constexpr char TEST_JPEG_IMG[] = "/data/local/tmp/image/test_hw.jpg";
|
||||
static constexpr char TEST_JPEG_IMG[] = "/data/local/tmp/image/test_hw1.jpg";
|
||||
};
|
||||
|
||||
HWTEST_F(JpegHwDecoderTest, supported_img_inner_size, TestSize.Level1)
|
||||
{
|
||||
JpegHardwareDecoder testObj;
|
||||
PlSize srcImgSize = {
|
||||
.width = 2736,
|
||||
.height = 3648
|
||||
};
|
||||
bool ret = testObj.IsHardwareDecodeSupported(JPEG_FORMAT, srcImgSize);
|
||||
ASSERT_TRUE(ret);
|
||||
}
|
||||
|
||||
HWTEST_F(JpegHwDecoderTest, supported_img_lower_bound_size, TestSize.Level1)
|
||||
{
|
||||
JpegHardwareDecoder testObj;
|
||||
PlSize srcImgSize = {
|
||||
.width = 512,
|
||||
.height = 512
|
||||
};
|
||||
bool ret = testObj.IsHardwareDecodeSupported(JPEG_FORMAT, srcImgSize);
|
||||
ASSERT_TRUE(ret);
|
||||
}
|
||||
|
||||
HWTEST_F(JpegHwDecoderTest, supported_img_upper_bound_size, TestSize.Level1)
|
||||
{
|
||||
JpegHardwareDecoder testObj;
|
||||
PlSize srcImgSize = {
|
||||
.width = 8192,
|
||||
.height = 8192
|
||||
};
|
||||
bool ret = testObj.IsHardwareDecodeSupported(JPEG_FORMAT, srcImgSize);
|
||||
ASSERT_TRUE(ret);
|
||||
}
|
||||
|
||||
HWTEST_F(JpegHwDecoderTest, unsupported_img_empty_format, TestSize.Level1)
|
||||
{
|
||||
JpegHardwareDecoder testObj;
|
||||
@ -88,7 +56,7 @@ HWTEST_F(JpegHwDecoderTest, unsupported_img_size_too_small, TestSize.Level1)
|
||||
{
|
||||
JpegHardwareDecoder testObj;
|
||||
PlSize srcImgSize = {
|
||||
.width = 511,
|
||||
.width = 140,
|
||||
.height = 512
|
||||
};
|
||||
bool ret = testObj.IsHardwareDecodeSupported(JPEG_FORMAT, srcImgSize);
|
||||
@ -109,12 +77,15 @@ HWTEST_F(JpegHwDecoderTest, unsupported_img_size_too_big, TestSize.Level1)
|
||||
HWTEST_F(JpegHwDecoderTest, decode_ok, TestSize.Level1)
|
||||
{
|
||||
CommandOpt opt;
|
||||
opt.width = 3456;
|
||||
opt.height = 4608;
|
||||
opt.width = 1280;
|
||||
opt.height = 768;
|
||||
opt.sampleSize = 1;
|
||||
opt.inputFile = TEST_JPEG_IMG;
|
||||
JpegHwDecoderFlow demo;
|
||||
bool ret = demo.Run(opt, false);
|
||||
bool ret = true;
|
||||
if (ImageSystemProperties::GetHardWareDecodeEnabled()) {
|
||||
ret = demo.Run(opt, false);
|
||||
}
|
||||
ASSERT_TRUE(ret);
|
||||
}
|
||||
} // namespace OHOS::Media
|
@ -41,10 +41,10 @@ HWTEST_F(NinePathListenerTest, ReadChunk001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "NinePathListenerTest: ReadChunk001 start";
|
||||
ImagePlugin::NinePatchListener ninepath;
|
||||
const std::string tag = "";
|
||||
const std::string tag = "npTc";
|
||||
void *data = nullptr;
|
||||
ASSERT_EQ(data, nullptr);
|
||||
size_t length = 1;
|
||||
size_t length = 88;
|
||||
bool readck = ninepath.ReadChunk(tag, data, length);
|
||||
ASSERT_EQ(readck, true);
|
||||
GTEST_LOG_(INFO) << "NinePathListenerTest: ReadChunk001 end";
|
||||
@ -79,10 +79,6 @@ HWTEST_F(NinePathListenerTest, ReadChunk002, TestSize.Level3)
|
||||
const std::string tag = "npTc";
|
||||
int *p = new int;
|
||||
int32_t length = 33;
|
||||
ImagePlugin::PngNinePatchRes att;
|
||||
att.numXDivs = 0;
|
||||
att.numYDivs = 0;
|
||||
att.numColors = 0;
|
||||
bool ret = ninepath.ReadChunk(tag, static_cast<void *>(p), length);
|
||||
ASSERT_EQ(ret, false);
|
||||
delete p;
|
||||
@ -106,7 +102,7 @@ HWTEST_F(NinePathListenerTest, Scale002, TestSize.Level3)
|
||||
int32_t scaledHeight = 4;
|
||||
ninepath.Scale(scaleX, scaleY, scaledWidth, scaledHeight);
|
||||
delete ninepath.patch_;
|
||||
ninepath.patch_=nullptr;
|
||||
ninepath.patch_ = nullptr;
|
||||
GTEST_LOG_(INFO) << "NinePathListenerTest: Scale002 end";
|
||||
}
|
||||
|
||||
|
459
frameworks/innerkitsimpl/test/unittest/pixel_astc_test.cpp
Normal file
459
frameworks/innerkitsimpl/test/unittest/pixel_astc_test.cpp
Normal file
@ -0,0 +1,459 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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, software
|
||||
* 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>
|
||||
#include "image_type.h"
|
||||
#include "image_utils.h"
|
||||
#include "media_errors.h"
|
||||
#include "pixel_map.h"
|
||||
#include "pixel_astc.h"
|
||||
#include "pixel_convert_adapter.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::Media;
|
||||
namespace OHOS {
|
||||
namespace Multimedia {
|
||||
class PixelAstcTest : public testing::Test {
|
||||
public:
|
||||
PixelAstcTest() {}
|
||||
~PixelAstcTest() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest001
|
||||
* @tc.desc: PixelAstc scale
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest001 start";
|
||||
PixelAstc pixelAstc;
|
||||
float xAxis = 1.0;
|
||||
float yAxis = 1.0;
|
||||
pixelAstc.scale(xAxis, yAxis);
|
||||
xAxis = 0.0;
|
||||
pixelAstc.scale(xAxis, yAxis);
|
||||
yAxis = 0.0;
|
||||
pixelAstc.scale(xAxis, yAxis);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest002
|
||||
* @tc.desc: PixelAstc translate
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest002, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest002 start";
|
||||
PixelAstc pixelAstc;
|
||||
float xAxis = 1.0;
|
||||
float yAxis = 1.0;
|
||||
pixelAstc.translate(xAxis, yAxis);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest002 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest003
|
||||
* @tc.desc: PixelAstc flip
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest003, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest003 start";
|
||||
PixelAstc pixelAstc;
|
||||
bool xAxis = false;
|
||||
bool yAxis = true;
|
||||
pixelAstc.flip(xAxis, yAxis);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest003 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest004
|
||||
* @tc.desc: PixelAstc rotate
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest004, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest004 start";
|
||||
PixelAstc pixelAstc;
|
||||
float degrees = 0.5;
|
||||
pixelAstc.rotate(degrees);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest004 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest005
|
||||
* @tc.desc: PixelAstc crop
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest005, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest005 start";
|
||||
PixelAstc pixelAstc;
|
||||
Rect rect;
|
||||
rect.left = 1;
|
||||
rect.top = 1;
|
||||
rect.width = 1;
|
||||
rect.height = 1;
|
||||
uint32_t ret = pixelAstc.crop(rect);
|
||||
EXPECT_EQ(ERR_IMAGE_CROP, ret);
|
||||
rect.left = -1;
|
||||
ret = pixelAstc.crop(rect);
|
||||
EXPECT_EQ(ERR_IMAGE_CROP, ret);
|
||||
rect.left = 1;
|
||||
rect.top = -1;
|
||||
ret = pixelAstc.crop(rect);
|
||||
EXPECT_EQ(ERR_IMAGE_CROP, ret);
|
||||
rect.top = 1;
|
||||
rect.width = -1;
|
||||
ret = pixelAstc.crop(rect);
|
||||
EXPECT_EQ(ERR_IMAGE_CROP, ret);
|
||||
rect.width = 1;
|
||||
rect.height = -1;
|
||||
ret = pixelAstc.crop(rect);
|
||||
EXPECT_EQ(ERR_IMAGE_CROP, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest005 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest006
|
||||
* @tc.desc: PixelAstc SetAlpha
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest006, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest006 start";
|
||||
PixelAstc pixelAstc;
|
||||
float percent = 0.5;
|
||||
uint32_t ret = pixelAstc.SetAlpha(percent);
|
||||
EXPECT_EQ(ERR_IMAGE_DATA_UNSUPPORT, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest006 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest007
|
||||
* @tc.desc: PixelAstc SetAlpha
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest007, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest007 start";
|
||||
PixelAstc pixelAstc;
|
||||
float percent = 0.5;
|
||||
uint32_t ret = pixelAstc.SetAlpha(percent);
|
||||
EXPECT_EQ(ERR_IMAGE_DATA_UNSUPPORT, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest007 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest008
|
||||
* @tc.desc: PixelAstc GetARGB32ColorA
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest008, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest008 start";
|
||||
PixelAstc pixelAstc;
|
||||
uint32_t color = 1;
|
||||
uint8_t ret = pixelAstc.GetARGB32ColorA(color);
|
||||
EXPECT_EQ(0, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest008 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest009
|
||||
* @tc.desc: PixelAstc GetARGB32ColorR
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest009, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest009 start";
|
||||
PixelAstc pixelAstc;
|
||||
uint32_t color = 1;
|
||||
uint8_t ret = pixelAstc.GetARGB32ColorR(color);
|
||||
EXPECT_EQ(0, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest009 end";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest010
|
||||
* @tc.desc: PixelAstc GetARGB32ColorG
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest010, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest010 start";
|
||||
PixelAstc pixelAstc;
|
||||
uint32_t color = 1;
|
||||
uint8_t ret = pixelAstc.GetARGB32ColorG(color);
|
||||
EXPECT_EQ(0, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest010 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest011
|
||||
* @tc.desc: PixelAstc GetARGB32ColorB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest011, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest011 start";
|
||||
PixelAstc pixelAstc;
|
||||
uint32_t color = 1;
|
||||
uint8_t ret = pixelAstc.GetARGB32ColorB(color);
|
||||
EXPECT_EQ(0, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest011 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest012
|
||||
* @tc.desc: PixelAstc IsSameImage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest012, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest012 start";
|
||||
PixelAstc pixelAstc;
|
||||
PixelMap pixelMap;
|
||||
bool ret = pixelAstc.IsSameImage(pixelMap);
|
||||
EXPECT_EQ(false, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest012 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest013
|
||||
* @tc.desc: PixelAstc IsSameImage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest013, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest013 start";
|
||||
PixelAstc pixelAstc;
|
||||
PixelMap pixelMap;
|
||||
bool ret = pixelAstc.IsSameImage(pixelMap);
|
||||
EXPECT_EQ(false, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest013 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest014
|
||||
* @tc.desc: PixelAstc ReadPixels
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest014, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest014 start";
|
||||
PixelAstc pixelAstc;
|
||||
const uint64_t bufferSize = 0;
|
||||
const uint32_t offset = 0;
|
||||
const uint32_t stride = 0;
|
||||
Rect region;
|
||||
uint8_t dst;
|
||||
uint32_t ret = pixelAstc.ReadPixels(bufferSize, offset, stride, region, &dst);
|
||||
EXPECT_EQ(ERR_IMAGE_INVALID_PARAMETER, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest014 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest015
|
||||
* @tc.desc: PixelAstc ReadPixels
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest015, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest015 start";
|
||||
PixelAstc pixelAstc;
|
||||
const uint64_t bufferSize = 0;
|
||||
uint8_t dst;
|
||||
uint32_t ret = pixelAstc.ReadPixels(bufferSize, &dst);
|
||||
EXPECT_EQ(ERR_IMAGE_INVALID_PARAMETER, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest015 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest016
|
||||
* @tc.desc: PixelAstc ReadPixels
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest016, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest016 start";
|
||||
PixelAstc pixelAstc;
|
||||
Position pos;
|
||||
uint32_t dst;
|
||||
uint32_t ret = pixelAstc.ReadPixel(pos, dst);
|
||||
EXPECT_EQ(ERR_IMAGE_INVALID_PARAMETER, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest016 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest017
|
||||
* @tc.desc: PixelAstc ResetConfig
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest017, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest017 start";
|
||||
PixelAstc pixelAstc;
|
||||
Size size;
|
||||
PixelFormat format = PixelFormat::RGBA_8888;
|
||||
uint32_t ret = pixelAstc.ResetConfig(size, format);
|
||||
EXPECT_EQ(ERR_IMAGE_INVALID_PARAMETER, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest017 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest018
|
||||
* @tc.desc: PixelAstc SetAlphaType
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest018, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest018 start";
|
||||
PixelAstc pixelAstc;
|
||||
const AlphaType alphaType = AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
|
||||
bool ret = pixelAstc.SetAlphaType(alphaType);
|
||||
EXPECT_EQ(false, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest018 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest019
|
||||
* @tc.desc: PixelAstc WritePixel
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest019, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest019 start";
|
||||
PixelAstc pixelAstc;
|
||||
Position pos;
|
||||
const uint32_t dst = 0;
|
||||
uint32_t ret = pixelAstc.WritePixel(pos, dst);
|
||||
EXPECT_EQ(ERR_IMAGE_INVALID_PARAMETER, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest019 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest020
|
||||
* @tc.desc: PixelAstc WritePixel
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest020, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest020 start";
|
||||
PixelAstc pixelAstc;
|
||||
uint8_t *source = nullptr;
|
||||
const uint64_t bufferSize = 0;
|
||||
const uint32_t offset = 0;
|
||||
const uint32_t stride = 0;
|
||||
Rect region;
|
||||
uint32_t ret = pixelAstc.WritePixels(source, bufferSize, offset, stride, region);
|
||||
EXPECT_EQ(ERR_IMAGE_INVALID_PARAMETER, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest020 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest021
|
||||
* @tc.desc: PixelAstc WritePixel
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest021, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest021 start";
|
||||
PixelAstc pixelAstc;
|
||||
const uint32_t color = 0;
|
||||
bool ret = pixelAstc.WritePixels(color);
|
||||
EXPECT_EQ(false, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest021 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest022
|
||||
* @tc.desc: PixelAstc WritePixel
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest022, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest022 start";
|
||||
PixelAstc pixelAstc;
|
||||
uint8_t *source = nullptr;
|
||||
const uint64_t bufferSize = 0;
|
||||
uint32_t ret = pixelAstc.WritePixels(source, bufferSize);
|
||||
EXPECT_EQ(ERR_IMAGE_INVALID_PARAMETER, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest022 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest023
|
||||
* @tc.desc: PixelAstc SetTransformered
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest023, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest023 start";
|
||||
PixelAstc pixelAstc;
|
||||
bool isTransFormered = false;
|
||||
pixelAstc.SetTransformered(isTransFormered);
|
||||
bool ret = pixelAstc.IsTransformered();
|
||||
EXPECT_EQ(false, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest023 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest024
|
||||
* @tc.desc: PixelAstc SetRowStride
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest024, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest024 start";
|
||||
PixelAstc pixelAstc;
|
||||
uint32_t stride = 0;
|
||||
pixelAstc.SetRowStride(stride);
|
||||
int32_t ret = pixelAstc.GetRowStride();
|
||||
EXPECT_EQ(0, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest024 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest025
|
||||
* @tc.desc: PixelAstc IsSourceAsResponse
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest025, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest025 start";
|
||||
PixelAstc pixelAstc;
|
||||
bool ret = pixelAstc.IsSourceAsResponse();
|
||||
EXPECT_EQ(false, ret);
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest025 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PixelAstcTest026
|
||||
* @tc.desc: PixelAstc GetWritablePixels
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelAstcTest, PixelAstcTest026, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest026 start";
|
||||
PixelAstc pixelAstc;
|
||||
EXPECT_EQ(nullptr, pixelAstc.GetWritablePixels());
|
||||
GTEST_LOG_(INFO) << "PixelAstcTest: PixelAstcTest026 end";
|
||||
}
|
||||
}
|
||||
}
|
@ -311,8 +311,7 @@ HWTEST_F(PixelMapTest, PixelMapTest006, TestSize.Level3)
|
||||
info1.pixelFormat = PixelFormat::RGB_888;
|
||||
info1.colorSpace = ColorSpace::SRGB;
|
||||
auto ret = pixelMap1->SetImageInfo(info1);
|
||||
EXPECT_EQ(ret, ERR_IMAGE_TOO_LARGE);
|
||||
|
||||
EXPECT_EQ(ret, SUCCESS);
|
||||
GTEST_LOG_(INFO) << "PixelMapTest: PixelMapTest006 end";
|
||||
}
|
||||
|
||||
@ -922,7 +921,7 @@ HWTEST_F(PixelMapTest, PixelMapTest024, TestSize.Level3)
|
||||
void *context = malloc(contextSize);
|
||||
EXPECT_TRUE(context != nullptr);
|
||||
char *contextChar = static_cast<char *>(context);
|
||||
for (unsigned int i = 0; i < contextSize; i++) {
|
||||
for (int32_t i = 0; i < contextSize; i++) {
|
||||
*(contextChar++) = (char)i;
|
||||
}
|
||||
pixelMap->SetPixelsAddr(buffer, context, bufferSize, AllocatorType::HEAP_ALLOC, nullptr);
|
||||
@ -1149,7 +1148,7 @@ HWTEST_F(PixelMapTest, SetAndGetRowStride, TestSize.Level3)
|
||||
uint32_t stride = 1;
|
||||
pixelMap.SetRowStride(stride);
|
||||
int32_t res = pixelMap.GetRowStride();
|
||||
ASSERT_EQ(res, 1);
|
||||
ASSERT_EQ(res, stride);
|
||||
GTEST_LOG_(INFO) << "ImagePixelMapTest: SetAndGetRowStride end";
|
||||
}
|
||||
|
||||
@ -1268,6 +1267,27 @@ HWTEST_F(PixelMapTest, SetPurgeableMemPtrTest, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "ImagePixelMapTest: SetPurgeableMemPtrTest SetPurgeableMemPtr end";
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @tc.name: IsStrideAlignment
|
||||
* @tc.desc: test IsStrideAlignment
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PixelMapTest, IsStrideAlignmentTest, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ImagePixelMapTest: IsStrideAlignmentTest IsStrideAlignment start";
|
||||
PixelMap pixelMap;
|
||||
ImageInfo info;
|
||||
info.size.width = 3;
|
||||
info.size.height = 3;
|
||||
info.pixelFormat = PixelFormat::ALPHA_8;
|
||||
info.colorSpace = ColorSpace::SRGB;
|
||||
pixelMap.SetImageInfo(info);
|
||||
bool res = pixelMap.IsStrideAlignment();
|
||||
ASSERT_EQ(res, false);
|
||||
GTEST_LOG_(INFO) << "ImagePixelMapTest: IsStrideAlignmentTest IsStrideAlignment end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetPurgeableMemPtr
|
||||
* @tc.desc: GetPixelFormatDetail***
|
||||
|
@ -949,9 +949,9 @@ HWTEST_F(PluginLibJpegTest, CreateExifEntry001, TestSize.Level3)
|
||||
bool ret = exinfo.CreateExifEntry(EXIF_TAG_BITS_PER_SAMPLE, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, false);
|
||||
ExifEntry *ptrEntry = new ExifEntry;
|
||||
exinfo.CreateExifEntry(EXIF_TAG_BITS_PER_SAMPLE, ptrExifData, value, order, &ptrEntry);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_BITS_PER_SAMPLE, ptrExifData, value, order, &ptrEntry);
|
||||
ASSERT_EQ(ret, false);
|
||||
exinfo.CreateExifEntry(EXIF_TAG_BITS_PER_SAMPLE, ptrExifData, "test,test", order, &ptrEntry);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_BITS_PER_SAMPLE, ptrExifData, "test,test", order, &ptrEntry);
|
||||
ASSERT_EQ(ret, true);
|
||||
delete ptrEntry;
|
||||
ptrEntry = nullptr;
|
||||
@ -1076,8 +1076,8 @@ HWTEST_F(PluginLibJpegTest, CreateExifEntry006, TestSize.Level3)
|
||||
bool ret = exinfo.CreateExifEntry(EXIF_TAG_GPS_LATITUDE, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, false);
|
||||
ExifEntry *ptrEntry = new ExifEntry;
|
||||
exinfo.CreateExifEntry(EXIF_TAG_GPS_LATITUDE, ptrExifData, "test,test", order, &ptrEntry);
|
||||
ASSERT_EQ(ret, false);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_GPS_LATITUDE, ptrExifData, "test,test", order, &ptrEntry);
|
||||
ASSERT_EQ(ret, true);
|
||||
delete ptrEntry;
|
||||
ptrEntry = nullptr;
|
||||
free(fileBuf);
|
||||
@ -1259,5 +1259,102 @@ HWTEST_F(PluginLibJpegTest, CreateExifEntry0012, TestSize.Level3)
|
||||
fileBuf = nullptr;
|
||||
GTEST_LOG_(INFO) << "PluginLibJpegTest: CreateExifEntry0012 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CreateExifEntry0013
|
||||
* @tc.desc: CreateExifEntry
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PluginLibJpegTest, CreateExifEntry0013, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PluginLibJpegTest: CreateExifEntry0013 start";
|
||||
EXIFInfo exinfo;
|
||||
ExifData *ptrExifData;
|
||||
bool isNewExifData = false;
|
||||
unsigned long fileLength = 100;
|
||||
unsigned char *fileBuf = static_cast<unsigned char *>(malloc(fileLength));
|
||||
exinfo.CreateExifData(fileBuf, fileLength, &ptrExifData, isNewExifData);
|
||||
ExifByteOrder order = exinfo.GetExifByteOrder(isNewExifData, fileBuf);
|
||||
ExifEntry *entry = nullptr;
|
||||
const std::string value = "test/test/test/test/test";
|
||||
bool ret = exinfo.CreateExifEntry(EXIF_TAG_GPS_DATE_STAMP, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_IMAGE_DESCRIPTION, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_ISO_SPEED_RATINGS, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_ISO_SPEED, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_LIGHT_SOURCE, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_MAKE, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_METERING_MODE, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_MODEL, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_PIXEL_X_DIMENSION, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_PIXEL_Y_DIMENSION, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_RECOMMENDED_EXPOSURE_INDEX, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_SCENE_TYPE, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_SENSITIVITY_TYPE, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_STANDARD_OUTPUT_SENSITIVITY, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
ret = exinfo.CreateExifEntry(EXIF_TAG_USER_COMMENT, ptrExifData, value, order, &entry);
|
||||
ASSERT_EQ(ret, true);
|
||||
free(fileBuf);
|
||||
fileBuf = nullptr;
|
||||
GTEST_LOG_(INFO) << "PluginLibJpegTest: CreateExifEntry0013 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetDEDataByteCount001
|
||||
* @tc.desc: SetDEDataByteCount
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PluginLibJpegTest, SetDEDataByteCount001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PluginLibJpegTest: SetDEDataByteCount001 start";
|
||||
const uint8_t *buf = new uint8_t;
|
||||
ByteOrderedBuffer byteorder(buf, 10);
|
||||
uint16_t dataFormat = byteorder.ReadUnsignedShort();
|
||||
int32_t numberOfComponents = byteorder.ReadInt32();
|
||||
uint32_t byteCount = 0;
|
||||
bool ret = byteorder.SetDEDataByteCount(0x0000, dataFormat, numberOfComponents, byteCount);
|
||||
ASSERT_EQ(ret, false);
|
||||
ret = byteorder.SetDEDataByteCount(0x0133, -1, numberOfComponents, byteCount);
|
||||
ASSERT_EQ(ret, false);
|
||||
ret = byteorder.SetDEDataByteCount(0x0133, 1, numberOfComponents, byteCount);
|
||||
ASSERT_EQ(ret, true);
|
||||
delete buf;
|
||||
buf = nullptr;
|
||||
GTEST_LOG_(INFO) << "PluginLibJpegTest: SetDEDataByteCount001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ParseIFDPointerTag002
|
||||
* @tc.desc: ParseIFDPointerTag
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PluginLibJpegTest, ParseIFDPointerTag002, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "PluginLibJpegTest: ParseIFDPointerTag002 start";
|
||||
const uint8_t *buf = new uint8_t;
|
||||
ByteOrderedBuffer byteorder(buf, 10);
|
||||
uint16_t tagNumber = byteorder.ReadUnsignedShort();
|
||||
const ExifIfd ifd = byteorder.GetIFDOfIFDPointerTag(tagNumber);;
|
||||
byteorder.ParseIFDPointerTag(ifd, EXIF_FORMAT_SHORT);
|
||||
byteorder.ParseIFDPointerTag(ifd, EXIF_FORMAT_SSHORT);
|
||||
byteorder.ParseIFDPointerTag(ifd, EXIF_FORMAT_LONG);
|
||||
byteorder.ParseIFDPointerTag(ifd, EXIF_FORMAT_SLONG);
|
||||
delete buf;
|
||||
buf = nullptr;
|
||||
GTEST_LOG_(INFO) << "PluginLibJpegTest: ParseIFDPointerTag002 end";
|
||||
}
|
||||
} // namespace Multimedia
|
||||
} // namespace OHOS
|
@ -260,6 +260,48 @@ static void ImageSourceCallbackRoutine(napi_env env, ImageSourceAsyncContext* &c
|
||||
context = nullptr;
|
||||
}
|
||||
|
||||
static void ImageSourceCallbackWithErrorObj(napi_env env,
|
||||
ImageSourceAsyncContext* &context, const napi_value &val)
|
||||
{
|
||||
napi_value result[NUM_2] = {0};
|
||||
|
||||
if (context == nullptr) {
|
||||
HiLog::Error(LABEL, "context is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->status == SUCCESS) {
|
||||
napi_get_undefined(env, &result[NUM_0]);
|
||||
result[NUM_1] = val;
|
||||
} else {
|
||||
std::string errMsg = (context->errMsg.size() > 0) ? context->errMsg : "error status, no message";
|
||||
HiLog::Debug(LABEL, "Operation failed code:%{public}d, msg:%{public}s",
|
||||
context->status, errMsg.c_str());
|
||||
ImageNapiUtils::CreateErrorObj(env, result[NUM_0], context->status, errMsg);
|
||||
napi_get_undefined(env, &result[NUM_1]);
|
||||
}
|
||||
|
||||
if (context->deferred) {
|
||||
if (context->status == SUCCESS) {
|
||||
napi_resolve_deferred(env, context->deferred, result[NUM_1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, context->deferred, result[NUM_0]);
|
||||
}
|
||||
} else {
|
||||
napi_value retVal;
|
||||
napi_value callback = nullptr;
|
||||
HiLog::Debug(LABEL, "call callback function");
|
||||
napi_get_reference_value(env, context->callbackRef, &callback);
|
||||
napi_call_function(env, nullptr, callback, NUM_2, result, &retVal);
|
||||
napi_delete_reference(env, context->callbackRef);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, context->work);
|
||||
|
||||
delete context;
|
||||
context = nullptr;
|
||||
}
|
||||
|
||||
static napi_value CreateEnumTypeObject(napi_env env,
|
||||
napi_valuetype type, napi_ref* ref, std::vector<struct ImageEnum> imageEnumMap)
|
||||
{
|
||||
@ -444,7 +486,7 @@ napi_value ImageSourceNapi::Constructor(napi_env env, napi_callback_info info)
|
||||
void ImageSourceNapi::Destructor(napi_env env, void *nativeObject, void *finalize)
|
||||
{
|
||||
reinterpret_cast<ImageSourceNapi *>(nativeObject)->nativeImgSrc = nullptr;
|
||||
HiLog::Info(LABEL, "ImageSourceNapi::Destructor");
|
||||
HiLog::Debug(LABEL, "ImageSourceNapi::Destructor");
|
||||
}
|
||||
|
||||
napi_value ImageSourceNapi::GetSupportedFormats(napi_env env, napi_callback_info info)
|
||||
@ -1755,6 +1797,7 @@ static ImageSourceAsyncContext* CheckAsyncContext(ImageSourceAsyncContext* conte
|
||||
|
||||
if (context->rImageSource == nullptr) {
|
||||
HiLog::Error(LABEL, "empty context rImageSource");
|
||||
context->status = ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -1786,7 +1829,7 @@ STATIC_EXEC_FUNC(CreatePixelMapList)
|
||||
} else {
|
||||
HiLog::Error(LABEL, "Create PixelMap List error, error=%{public}u", errorCode);
|
||||
context->errMsg = "Create PixelMap List error";
|
||||
context->status = ERROR;
|
||||
context->status = (errorCode != SUCCESS) ? errorCode : ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1821,7 +1864,7 @@ STATIC_COMPLETE_FUNC(CreatePixelMapList)
|
||||
HiLog::Debug(LABEL, "CreatePixelMapListComplete set to nullptr");
|
||||
context->pixelMaps = nullptr;
|
||||
|
||||
ImageSourceCallbackRoutine(env, context, result);
|
||||
ImageSourceCallbackWithErrorObj(env, context, result);
|
||||
}
|
||||
|
||||
napi_value ImageSourceNapi::CreatePixelMapList(napi_env env, napi_callback_info info)
|
||||
@ -1830,7 +1873,7 @@ napi_value ImageSourceNapi::CreatePixelMapList(napi_env env, napi_callback_info
|
||||
|
||||
auto asyncContext = UnwrapContextForList(env, info);
|
||||
if (asyncContext == nullptr) {
|
||||
return ImageNapiUtils::ThrowExceptionError(env, static_cast<int32_t>(napi_invalid_arg),
|
||||
return ImageNapiUtils::ThrowExceptionError(env, ERR_IMAGE_DATA_ABNORMAL,
|
||||
"async context unwrap failed");
|
||||
}
|
||||
|
||||
@ -1872,7 +1915,7 @@ STATIC_EXEC_FUNC(GetDelayTime)
|
||||
} else {
|
||||
HiLog::Error(LABEL, "Get DelayTime error, error=%{public}u", errorCode);
|
||||
context->errMsg = "Get DelayTime error";
|
||||
context->status = errorCode;
|
||||
context->status = (errorCode != SUCCESS) ? errorCode : ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1907,7 +1950,7 @@ STATIC_COMPLETE_FUNC(GetDelayTime)
|
||||
|
||||
HiLog::Debug(LABEL, "GetDelayTimeComplete set to nullptr");
|
||||
context->delayTimes = nullptr;
|
||||
ImageSourceCallbackRoutine(env, context, result);
|
||||
ImageSourceCallbackWithErrorObj(env, context, result);
|
||||
}
|
||||
|
||||
napi_value ImageSourceNapi::GetDelayTime(napi_env env, napi_callback_info info)
|
||||
@ -1984,7 +2027,7 @@ STATIC_COMPLETE_FUNC(GetFrameCount)
|
||||
}
|
||||
|
||||
context->frameCount = 0;
|
||||
ImageSourceCallbackRoutine(env, context, result);
|
||||
ImageSourceCallbackWithErrorObj(env, context, result);
|
||||
}
|
||||
|
||||
napi_value ImageSourceNapi::GetFrameCount(napi_env env, napi_callback_info info)
|
||||
|
@ -117,10 +117,10 @@ do { \
|
||||
#ifdef IMAGE_DEBUG_FLAG
|
||||
#define IMAGE_INFO(fmt, ...) DECORATOR_HILOG(HiLog::Info, fmt, ##__VA_ARGS__)
|
||||
#define IMAGE_DEBUG(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt, ##__VA_ARGS__)
|
||||
#define IMAGE_FUNCTION_IN(fmt, ...) DECORATOR_HILOG(HiLog::Info, fmt "%{public}s IN", __FUNCTION__, ##__VA_ARGS__)
|
||||
#define IMAGE_FUNCTION_OUT(fmt, ...) DECORATOR_HILOG(HiLog::Info, fmt "%{public}s OUT", __FUNCTION__, ##__VA_ARGS__)
|
||||
#define IMAGE_LINE_IN(fmt, ...) DECORATOR_HILOG(HiLog::Info, fmt "%{public}d IN", __LINE__, ##__VA_ARGS__)
|
||||
#define IMAGE_LINE_OUT(fmt, ...) DECORATOR_HILOG(HiLog::Info, fmt "%{public}d OUT", __LINE__, ##__VA_ARGS__)
|
||||
#define IMAGE_FUNCTION_IN(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}s IN", __FUNCTION__, ##__VA_ARGS__)
|
||||
#define IMAGE_FUNCTION_OUT(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}s OUT", __FUNCTION__, ##__VA_ARGS__)
|
||||
#define IMAGE_LINE_IN(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}d IN", __LINE__, ##__VA_ARGS__)
|
||||
#define IMAGE_LINE_OUT(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}d OUT", __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
#define IMAGE_INFO(fmt, ...)
|
||||
#define IMAGE_DEBUG(fmt, ...)
|
||||
|
@ -57,7 +57,7 @@ ohos_shared_library("image_receiver_ndk") {
|
||||
public_configs = [ ":native_public_config" ]
|
||||
deps = [ "$image_subsystem/interfaces/kits/js/common:image" ]
|
||||
external_deps = [ "graphic_surface:surface" ]
|
||||
|
||||
|
||||
innerapi_tags = [ "ndk" ]
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "image_framework"
|
||||
|
@ -28,6 +28,7 @@
|
||||
#endif
|
||||
#include "hitrace_meter.h"
|
||||
#include "pixel_map.h"
|
||||
#include "pixel_map_from_surface.h"
|
||||
|
||||
using OHOS::HiviewDFX::HiLog;
|
||||
namespace {
|
||||
@ -88,6 +89,7 @@ struct PixelMapAsyncContext {
|
||||
#if !defined(IOS_PLATFORM) && !defined(A_PLATFORM)
|
||||
std::shared_ptr<OHOS::ColorManager::ColorSpace> colorSpace;
|
||||
#endif
|
||||
std::string surfaceId;
|
||||
};
|
||||
|
||||
static PixelFormat ParsePixlForamt(int32_t val)
|
||||
@ -368,12 +370,14 @@ napi_value PixelMapNapi::Init(napi_env env, napi_value exports)
|
||||
DECLARE_NAPI_FUNCTION("marshalling", Marshalling),
|
||||
DECLARE_NAPI_FUNCTION("unmarshalling", Unmarshalling),
|
||||
DECLARE_NAPI_GETTER("isEditable", GetIsEditable),
|
||||
DECLARE_NAPI_GETTER("isStrideAlignment", GetIsStrideAlignment),
|
||||
};
|
||||
|
||||
napi_property_descriptor static_prop[] = {
|
||||
DECLARE_NAPI_STATIC_FUNCTION("createPixelMap", CreatePixelMap),
|
||||
DECLARE_NAPI_STATIC_FUNCTION("unmarshalling", Unmarshalling),
|
||||
DECLARE_NAPI_STATIC_FUNCTION(CREATE_PIXEL_MAP_FROM_PARCEL.c_str(), CreatePixelMapFromParcel),
|
||||
DECLARE_NAPI_STATIC_FUNCTION("createPixelMapFromSurface", CreatePixelMapFromSurface),
|
||||
};
|
||||
|
||||
napi_value constructor = nullptr;
|
||||
@ -587,17 +591,12 @@ napi_value AttachPixelMapFunc(napi_env env, void *value, void *)
|
||||
napi_value constructor = nullptr;
|
||||
napi_status status;
|
||||
|
||||
napi_value globalValue;
|
||||
napi_get_global(env, &globalValue);
|
||||
napi_value func;
|
||||
napi_get_named_property(env, globalValue, "requireNapi", &func);
|
||||
|
||||
napi_value imageInfo;
|
||||
napi_create_string_utf8(env, "multimedia.image", NAPI_AUTO_LENGTH, &imageInfo);
|
||||
napi_value funcArgv[1] = { imageInfo };
|
||||
napi_value returnValue;
|
||||
napi_call_function(env, globalValue, func, 1, funcArgv, &returnValue);
|
||||
|
||||
if (PixelMapNapi::GetConstructor() == nullptr) {
|
||||
napi_value exports = nullptr;
|
||||
napi_create_object(env, &exports);
|
||||
PixelMapNapi::Init(env, exports);
|
||||
}
|
||||
napi_value globalValue = nullptr;
|
||||
status = napi_get_named_property(env, globalValue, CLASS_NAME.c_str(), &constructor);
|
||||
IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "napi_get_named_property error"));
|
||||
|
||||
@ -666,11 +665,11 @@ void PixelMapNapi::Destructor(napi_env env, void *nativeObject, void *finalize)
|
||||
}
|
||||
}
|
||||
|
||||
static void BuildContextError(napi_env env, napi_ref &error, const std::string errMsg)
|
||||
static void BuildContextError(napi_env env, napi_ref &error, const std::string errMsg, const int32_t errCode)
|
||||
{
|
||||
HiLog::Error(LABEL, "%{public}s", errMsg.c_str());
|
||||
napi_value tmpError;
|
||||
ImageNapiUtils::CreateErrorObj(env, tmpError, ERR_RESOURCE_UNAVAILABLE, errMsg);
|
||||
ImageNapiUtils::CreateErrorObj(env, tmpError, errCode, errMsg);
|
||||
napi_create_reference(env, tmpError, NUM_1, &(error));
|
||||
}
|
||||
|
||||
@ -714,16 +713,11 @@ void PixelMapNapi::CreatePixelMapComplete(napi_env env, napi_status status, void
|
||||
|
||||
napi_value PixelMapNapi::CreatePixelMap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value globalValue;
|
||||
napi_get_global(env, &globalValue);
|
||||
napi_value func;
|
||||
napi_get_named_property(env, globalValue, "requireNapi", &func);
|
||||
|
||||
napi_value imageInfo;
|
||||
napi_create_string_utf8(env, "multimedia.image", NAPI_AUTO_LENGTH, &imageInfo);
|
||||
napi_value funcArgv[1] = { imageInfo };
|
||||
napi_value returnValue;
|
||||
napi_call_function(env, globalValue, func, 1, funcArgv, &returnValue);
|
||||
if (PixelMapNapi::GetConstructor() == nullptr) {
|
||||
napi_value exports = nullptr;
|
||||
napi_create_object(env, &exports);
|
||||
PixelMapNapi::Init(env, exports);
|
||||
}
|
||||
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
@ -769,7 +763,75 @@ napi_value PixelMapNapi::CreatePixelMap(napi_env env, napi_callback_info info)
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value PixelMapNapi::CreatePixelMap(napi_env env, std::shared_ptr<PixelMap> pixelmap)
|
||||
STATIC_EXEC_FUNC(CreatePixelMapFromSurface)
|
||||
{
|
||||
auto context = static_cast<PixelMapAsyncContext*>(data);
|
||||
HiLog::Debug(LABEL, "CreatePixelMapFromSurface id:%{public}s,area:%{public}d,%{public}d,%{public}d,%{public}d",
|
||||
context->surfaceId.c_str(), context->area.region.left, context->area.region.top,
|
||||
context->area.region.height, context->area.region.width);
|
||||
|
||||
auto pixelMap = CreatePixelMapFromSurfaceId(std::stoull(context->surfaceId), context->area.region);
|
||||
context->rPixelMap = std::move(pixelMap);
|
||||
|
||||
if (IMG_NOT_NULL(context->rPixelMap)) {
|
||||
context->status = SUCCESS;
|
||||
} else {
|
||||
context->status = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
void PixelMapNapi::CreatePixelMapFromSurfaceComplete(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
napi_value constructor = nullptr;
|
||||
napi_value result = nullptr;
|
||||
|
||||
HiLog::Debug(LABEL, "CreatePixelMapFromSurface IN");
|
||||
auto context = static_cast<PixelMapAsyncContext*>(data);
|
||||
status = napi_get_reference_value(env, sConstructor_, &constructor);
|
||||
if (IMG_IS_OK(status)) {
|
||||
status = NewPixelNapiInstance(env, constructor, context->rPixelMap, result);
|
||||
}
|
||||
|
||||
if (!IMG_IS_OK(status)) {
|
||||
context->status = ERROR;
|
||||
HiLog::Error(LABEL, "New instance could not be obtained");
|
||||
napi_get_undefined(env, &result);
|
||||
}
|
||||
|
||||
CommonCallbackRoutine(env, context, result);
|
||||
}
|
||||
|
||||
void setSurfaceId(const char *surfaceId, std::string &dst)
|
||||
{
|
||||
dst = surfaceId;
|
||||
}
|
||||
|
||||
static std::string GetStringArgument(napi_env env, napi_value value)
|
||||
{
|
||||
std::string strValue = "";
|
||||
size_t bufLength = 0;
|
||||
napi_status status = napi_get_value_string_utf8(env, value, nullptr, NUM_0, &bufLength);
|
||||
if (status == napi_ok && bufLength > NUM_0 && bufLength < PATH_MAX) {
|
||||
char *buffer = reinterpret_cast<char *>(malloc((bufLength + NUM_1) * sizeof(char)));
|
||||
if (buffer == nullptr) {
|
||||
HiLog::Error(LABEL, "No memory");
|
||||
return strValue;
|
||||
}
|
||||
|
||||
status = napi_get_value_string_utf8(env, value, buffer, bufLength + NUM_1, &bufLength);
|
||||
if (status == napi_ok) {
|
||||
HiLog::Debug(LABEL, "Get Success");
|
||||
strValue.assign(buffer, 0, bufLength + NUM_1);
|
||||
}
|
||||
if (buffer != nullptr) {
|
||||
free(buffer);
|
||||
buffer = nullptr;
|
||||
}
|
||||
}
|
||||
return strValue;
|
||||
}
|
||||
|
||||
napi_value PixelMapNapi::CreatePixelMapFromSurface(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value globalValue;
|
||||
napi_get_global(env, &globalValue);
|
||||
@ -782,6 +844,48 @@ napi_value PixelMapNapi::CreatePixelMap(napi_env env, std::shared_ptr<PixelMap>
|
||||
napi_value returnValue;
|
||||
napi_call_function(env, globalValue, func, 1, funcArgv, &returnValue);
|
||||
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
int32_t refCount = 1;
|
||||
napi_status status;
|
||||
napi_value thisVar = nullptr;
|
||||
napi_value argValue[NUM_4] = {0};
|
||||
size_t argCount = NUM_4;
|
||||
HiLog::Debug(LABEL, "CreatePixelMapFromSurface IN");
|
||||
IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar);
|
||||
IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info"));
|
||||
std::unique_ptr<PixelMapAsyncContext> asyncContext = std::make_unique<PixelMapAsyncContext>();
|
||||
asyncContext->surfaceId = GetStringArgument(env, argValue[NUM_0]);
|
||||
bool ret = parseRegion(env, argValue[NUM_1], &(asyncContext->area.region));
|
||||
HiLog::Debug(LABEL, "CreatePixelMapFromSurface get data: %{public}d", ret);
|
||||
if (argCount == NUM_3 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) {
|
||||
napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef);
|
||||
}
|
||||
if (asyncContext->callbackRef == nullptr) {
|
||||
napi_create_promise(env, &(asyncContext->deferred), &result);
|
||||
} else {
|
||||
napi_get_undefined(env, &result);
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(ret,
|
||||
BuildContextError(env, asyncContext->error, "image invalid parameter", ERR_IMAGE_GET_DATA_ABNORMAL),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreatePixelMapFromSurfaceGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, asyncContext, asyncContext->work),
|
||||
result);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreatePixelMapFromSurface",
|
||||
CreatePixelMapFromSurfaceExec, CreatePixelMapFromSurfaceComplete, asyncContext, asyncContext->work);
|
||||
IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status),
|
||||
nullptr, HiLog::Error(LABEL, "fail to create async work"));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value PixelMapNapi::CreatePixelMap(napi_env env, std::shared_ptr<PixelMap> pixelmap)
|
||||
{
|
||||
if (PixelMapNapi::GetConstructor() == nullptr) {
|
||||
napi_value exports = nullptr;
|
||||
napi_create_object(env, &exports);
|
||||
PixelMapNapi::Init(env, exports);
|
||||
}
|
||||
|
||||
napi_value constructor = nullptr;
|
||||
napi_value result = nullptr;
|
||||
napi_status status;
|
||||
@ -845,16 +949,11 @@ void PixelMapNapi::UnmarshallingComplete(napi_env env, napi_status status, void
|
||||
napi_value PixelMapNapi::Unmarshalling(napi_env env, napi_callback_info info)
|
||||
{
|
||||
#if !defined(IOS_PLATFORM) && !defined(A_PLATFORM)
|
||||
napi_value globalValue;
|
||||
napi_get_global(env, &globalValue);
|
||||
napi_value func;
|
||||
napi_get_named_property(env, globalValue, "requireNapi", &func);
|
||||
|
||||
napi_value imageInfo;
|
||||
napi_create_string_utf8(env, "multimedia.image", NAPI_AUTO_LENGTH, &imageInfo);
|
||||
napi_value funcArgv[1] = { imageInfo };
|
||||
napi_value returnValue;
|
||||
napi_call_function(env, globalValue, func, 1, funcArgv, &returnValue);
|
||||
if (PixelMapNapi::GetConstructor() == nullptr) {
|
||||
napi_value exports = nullptr;
|
||||
napi_create_object(env, &exports);
|
||||
PixelMapNapi::Init(env, exports);
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
|
||||
@ -921,15 +1020,11 @@ napi_value PixelMapNapi::CreatePixelMapFromParcel(napi_env env, napi_callback_in
|
||||
}
|
||||
#else
|
||||
{
|
||||
napi_value globalValue;
|
||||
napi_get_global(env, &globalValue);
|
||||
napi_value func;
|
||||
napi_get_named_property(env, globalValue, "requireNapi", &func);
|
||||
napi_value imageInfo;
|
||||
napi_create_string_utf8(env, "multimedia.image", NAPI_AUTO_LENGTH, &imageInfo);
|
||||
napi_value funcArgv[1] = { imageInfo };
|
||||
napi_value returnValue;
|
||||
napi_call_function(env, globalValue, func, 1, funcArgv, &returnValue);
|
||||
if (PixelMapNapi::GetConstructor() == nullptr) {
|
||||
napi_value exports = nullptr;
|
||||
napi_create_object(env, &exports);
|
||||
PixelMapNapi::Init(env, exports);
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
napi_status status;
|
||||
@ -1000,6 +1095,35 @@ napi_value PixelMapNapi::GetIsEditable(napi_env env, napi_callback_info info)
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value PixelMapNapi::GetIsStrideAlignment(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
|
||||
napi_status status;
|
||||
napi_value thisVar = nullptr;
|
||||
size_t argCount = 0;
|
||||
HiLog::Debug(LABEL, "GetIsStrideAlignment IN");
|
||||
|
||||
IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar);
|
||||
|
||||
IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info"));
|
||||
|
||||
std::unique_ptr<PixelMapNapi> pixelMapNapi = nullptr;
|
||||
status = napi_unwrap(env, thisVar, reinterpret_cast<void**>(&pixelMapNapi));
|
||||
|
||||
IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi),
|
||||
result, HiLog::Error(LABEL, "fail to unwrap context"));
|
||||
|
||||
if (pixelMapNapi->nativePixelMap_ == nullptr) {
|
||||
return result;
|
||||
}
|
||||
bool isDMA = pixelMapNapi->nativePixelMap_->IsStrideAlignment();
|
||||
napi_get_boolean(env, isDMA, &result);
|
||||
pixelMapNapi.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value PixelMapNapi::ReadPixelsToBuffer(napi_env env, napi_callback_info info)
|
||||
{
|
||||
ImageTrace imageTrace("PixelMapNapi::ReadPixelsToBuffer");
|
||||
@ -1043,8 +1167,8 @@ napi_value PixelMapNapi::ReadPixelsToBuffer(napi_env env, napi_callback_info inf
|
||||
}
|
||||
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(asyncContext->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . ReadPixelsToBuffer failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "ReadPixelsToBufferGeneralError",
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . ReadPixelsToBuffer failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, status, "ReadPixelsToBufferGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, asyncContext, asyncContext->work),
|
||||
result);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "ReadPixelsToBuffer",
|
||||
@ -1102,8 +1226,8 @@ napi_value PixelMapNapi::ReadPixels(napi_env env, napi_callback_info info)
|
||||
}
|
||||
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(asyncContext->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . ReadPixels failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "ReadPixelsGeneralError",
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . ReadPixels failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, status, "ReadPixelsGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, asyncContext, asyncContext->work),
|
||||
result);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "ReadPixels",
|
||||
@ -1159,8 +1283,8 @@ napi_value PixelMapNapi::WritePixels(napi_env env, napi_callback_info info)
|
||||
napi_get_undefined(env, &result);
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(asyncContext->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . WritePixels failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "WritePixelsGeneralError",
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . WritePixels failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, status, "WritePixelsGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, asyncContext, asyncContext->work),
|
||||
result);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "WritePixels",
|
||||
@ -1219,8 +1343,8 @@ napi_value PixelMapNapi::WriteBufferToPixels(napi_env env, napi_callback_info in
|
||||
napi_get_undefined(env, &result);
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(asyncContext->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . WriteBufferToPixels failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "WriteBufferToPixelsGeneralError",
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . WriteBufferToPixels failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, status, "WriteBufferToPixelsGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, asyncContext, asyncContext->work),
|
||||
result);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "WriteBufferToPixels",
|
||||
@ -1263,6 +1387,9 @@ STATIC_COMPLETE_FUNC(GetImageInfo)
|
||||
napi_value densityValue = nullptr;
|
||||
napi_create_int32(env, static_cast<int32_t>(context->imageInfo.baseDensity), &densityValue);
|
||||
napi_set_named_property(env, result, "density", densityValue);
|
||||
napi_value strideValue = nullptr;
|
||||
napi_create_int32(env, static_cast<int32_t>(context->rPixelMap->GetRowStride()), &strideValue);
|
||||
napi_set_named_property(env, result, "stride", strideValue);
|
||||
if (!IMG_IS_OK(status)) {
|
||||
context->status = ERROR;
|
||||
HiLog::Error(LABEL, "napi_create_int32 failed!");
|
||||
@ -1301,8 +1428,8 @@ napi_value PixelMapNapi::GetImageInfo(napi_env env, napi_callback_info info)
|
||||
napi_get_undefined(env, &result);
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(asyncContext->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . GetImageInfo failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "GetImageInfoGeneralError",
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . GetImageInfo failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, status, "GetImageInfoGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, asyncContext, asyncContext->work),
|
||||
result);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "GetImageInfo",
|
||||
@ -1512,8 +1639,8 @@ napi_value PixelMapNapi::CreateAlphaPixelmap(napi_env env, napi_callback_info in
|
||||
napi_get_undefined(env, &result);
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(asyncContext->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . CreateAlphaPixelmap failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreateAlphaPixelmapGeneralError",
|
||||
BuildContextError(env, asyncContext->error, "pixelmap has crossed threads . CreateAlphaPixelmap failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreateAlphaPixelmapGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, asyncContext, asyncContext->work),
|
||||
result);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreateAlphaPixelmap",
|
||||
@ -1737,8 +1864,8 @@ napi_value PixelMapNapi::SetAlpha(napi_env env, napi_callback_info info)
|
||||
napi_create_promise(env, &(nVal.context->deferred), &(nVal.result));
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(nVal.context->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . SetAlpha failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "SetAlphaGeneralError",
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . SetAlpha failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "SetAlphaGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, nVal.context, nVal.context->work),
|
||||
nVal.result);
|
||||
napi_value _resource = nullptr;
|
||||
@ -1811,8 +1938,8 @@ napi_value PixelMapNapi::Scale(napi_env env, napi_callback_info info)
|
||||
napi_create_promise(env, &(nVal.context->deferred), &(nVal.result));
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(nVal.context->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Scale failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "ScaleGeneralError",
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Scale failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "ScaleGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, nVal.context, nVal.context->work),
|
||||
nVal.result);
|
||||
napi_value _resource = nullptr;
|
||||
@ -1885,8 +2012,8 @@ napi_value PixelMapNapi::Translate(napi_env env, napi_callback_info info)
|
||||
napi_create_promise(env, &(nVal.context->deferred), &(nVal.result));
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(nVal.context->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Translate failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "TranslateGeneralError",
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Translate failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "TranslateGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, nVal.context, nVal.context->work),
|
||||
nVal.result);
|
||||
napi_value _resource = nullptr;
|
||||
@ -1955,8 +2082,8 @@ napi_value PixelMapNapi::Rotate(napi_env env, napi_callback_info info)
|
||||
napi_create_promise(env, &(nVal.context->deferred), &(nVal.result));
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(nVal.context->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Rotate failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "RotateGeneralError",
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Rotate failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "RotateGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, nVal.context, nVal.context->work),
|
||||
nVal.result);
|
||||
napi_value _resource = nullptr;
|
||||
@ -2029,8 +2156,8 @@ napi_value PixelMapNapi::Flip(napi_env env, napi_callback_info info)
|
||||
napi_create_promise(env, &(nVal.context->deferred), &(nVal.result));
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(nVal.context->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Flip failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "FlipGeneralError",
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Flip failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "FlipGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, nVal.context, nVal.context->work),
|
||||
nVal.result);
|
||||
napi_value _resource = nullptr;
|
||||
@ -2098,8 +2225,8 @@ napi_value PixelMapNapi::Crop(napi_env env, napi_callback_info info)
|
||||
napi_create_promise(env, &(nVal.context->deferred), &(nVal.result));
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(nVal.context->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Crop failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "CropGeneralError",
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . Crop failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "CropGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, nVal.context, nVal.context->work),
|
||||
nVal.result);
|
||||
napi_value _resource = nullptr;
|
||||
@ -2290,14 +2417,13 @@ napi_value PixelMapNapi::ApplyColorSpace(napi_env env, napi_callback_info info)
|
||||
napi_create_promise(env, &(nVal.context->deferred), &(nVal.result));
|
||||
}
|
||||
IMG_NAPI_CHECK_BUILD_ERROR(nVal.context->nConstructor->GetPixelNapiEditable(),
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . ApplyColorSpace failed"),
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "ApplyColorSpaceGeneralError",
|
||||
BuildContextError(env, nVal.context->error, "pixelmap has crossed threads . ApplyColorSpace failed",
|
||||
ERR_RESOURCE_UNAVAILABLE), IMG_CREATE_CREATE_ASYNC_WORK(env, nVal.status, "ApplyColorSpaceGeneralError",
|
||||
[](napi_env env, void *data) {}, GeneralErrorComplete, nVal.context, nVal.context->work),
|
||||
nVal.result);
|
||||
napi_value _resource = nullptr;
|
||||
napi_create_string_utf8(env, "ApplyColorSpace", NAPI_AUTO_LENGTH, &_resource);
|
||||
nVal.status = napi_create_async_work(env, nullptr, _resource, [](napi_env env, void *data)
|
||||
{
|
||||
nVal.status = napi_create_async_work(env, nullptr, _resource, [](napi_env env, void *data) {
|
||||
auto context = static_cast<PixelMapAsyncContext*>(data);
|
||||
ApplyColorSpaceExec(env, context);
|
||||
}, EmptyResultComplete, static_cast<void*>(nVal.context.get()), &(nVal.context->work));
|
||||
|
@ -53,6 +53,7 @@ base_sep_b = "/b"
|
||||
base_ase = "ase"
|
||||
resource_management_subsystem =
|
||||
"/$base_sep_b$base_ase/global/resource_management"
|
||||
graphic_surface_root = "//foundation/graphic/graphic_surface"
|
||||
|
||||
# skia
|
||||
image_use_new_skia = defined(use_new_skia) && use_new_skia
|
||||
|
@ -41,6 +41,7 @@ config("image_external_config") {
|
||||
"//foundation/multimedia/image_framework/interfaces/kits/native/include",
|
||||
"//utils/jni/jnikit/include",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
|
||||
"$graphic_surface_root/interfaces/inner_api/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/inner_api/common",
|
||||
"//foundation/graphic/graphic_2d/interfaces/kits/napi/graphic/color_manager/color_space_object_convertor",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
@ -170,13 +171,13 @@ if (use_clang_android) {
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/stream/src/ostream_packer_stream.cpp",
|
||||
]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_surface/surface:surface",
|
||||
"//foundation/graphic/graphic_2d/utils/color_manager:color_manager",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter_static",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils_static",
|
||||
"//foundation/multimedia/image_framework/mock/native:log_mock_static",
|
||||
"//foundation/multimedia/image_framework/plugins/manager:pluginmanager_static",
|
||||
]
|
||||
external_deps = [ "graphic_surface:surface" ]
|
||||
} else if (use_clang_mac) {
|
||||
defines = image_decode_mac_defines
|
||||
sources -= [
|
||||
@ -187,7 +188,6 @@ if (use_clang_android) {
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/stream/src/ostream_packer_stream.cpp",
|
||||
]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_surface/surface:surface",
|
||||
"//foundation/graphic/graphic_2d/utils/color_manager:color_manager",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter_static",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils_static",
|
||||
@ -195,6 +195,7 @@ if (use_clang_android) {
|
||||
"//foundation/multimedia/image_framework/plugins/manager:pluginmanager_static",
|
||||
"//third_party/bounds_checking_function:libsec_statics",
|
||||
]
|
||||
external_deps = [ "graphic_surface:surface" ]
|
||||
} else {
|
||||
defines = [ "DUAL_ADAPTER" ]
|
||||
DUAL_ADAPTER = true
|
||||
@ -272,13 +273,13 @@ ohos_static_library("image_static") {
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/stream/src/ostream_packer_stream.cpp",
|
||||
]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_surface/surface:surface",
|
||||
"//foundation/graphic/graphic_2d/utils/color_manager:color_manager",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter_static",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils_static",
|
||||
"//foundation/multimedia/image_framework/mock/native:log_mock_static",
|
||||
"//foundation/multimedia/image_framework/plugins/manager:pluginmanager_static",
|
||||
]
|
||||
external_deps = [ "graphic_surface:surface" ]
|
||||
} else if (use_clang_mac) {
|
||||
defines = image_decode_mac_defines
|
||||
sources -= [
|
||||
@ -290,7 +291,6 @@ ohos_static_library("image_static") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_surface/surface:surface",
|
||||
"//foundation/graphic/graphic_2d/utils/color_manager:color_manager",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter_static",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils_static",
|
||||
@ -298,6 +298,7 @@ ohos_static_library("image_static") {
|
||||
"//foundation/multimedia/image_framework/plugins/manager:pluginmanager_static",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
external_deps = [ "graphic_surface:surface" ]
|
||||
} else if (use_clang_ios) {
|
||||
defines = image_decode_ios_defines
|
||||
sources -= [
|
||||
@ -335,7 +336,6 @@ ohos_static_library("image_static") {
|
||||
deps = [
|
||||
"$image_subsystem/frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter_static",
|
||||
"//foundation/arkui/napi:ace_napi",
|
||||
"//foundation/graphic/graphic_surface/surface:surface",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils",
|
||||
"//foundation/multimedia/image_framework/plugins/manager:pluginmanager",
|
||||
]
|
||||
@ -347,6 +347,7 @@ ohos_static_library("image_static") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"graphic_2d:color_manager",
|
||||
"graphic_surface:surface",
|
||||
]
|
||||
}
|
||||
subsystem_name = "multimedia"
|
||||
|
@ -156,6 +156,7 @@ struct ImageInfo {
|
||||
ColorSpace colorSpace = ColorSpace::SRGB;
|
||||
AlphaType alphaType = AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN;
|
||||
int32_t baseDensity = 0;
|
||||
int32_t stride = 1;
|
||||
};
|
||||
|
||||
struct FillColor {
|
||||
|
@ -159,6 +159,7 @@ public:
|
||||
NATIVEEXPORT virtual uint32_t WritePixels(const uint8_t *source, const uint64_t &bufferSize);
|
||||
NATIVEEXPORT virtual bool WritePixels(const uint32_t &color);
|
||||
NATIVEEXPORT virtual void FreePixelMap();
|
||||
NATIVEEXPORT bool IsStrideAlignment();
|
||||
NATIVEEXPORT virtual AllocatorType GetAllocatorType();
|
||||
NATIVEEXPORT virtual void *GetFd() const;
|
||||
NATIVEEXPORT virtual void SetFreePixelMapProc(CustomFreePixelMap func);
|
||||
|
33
interfaces/kits/js/@ohos.multimedia.image.d.ts
vendored
33
interfaces/kits/js/@ohos.multimedia.image.d.ts
vendored
@ -1166,6 +1166,15 @@ declare namespace image {
|
||||
* @since 10
|
||||
*/
|
||||
density: number;
|
||||
|
||||
/**
|
||||
* The number of byte per row.
|
||||
*
|
||||
* @type { number }
|
||||
* @syscap SystemCapability.Multimedia.Image.Core
|
||||
* @since 11
|
||||
*/
|
||||
stride: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1762,6 +1771,20 @@ declare namespace image {
|
||||
*/
|
||||
function createPixelMapFromParcel(sequence: rpc.MessageSequence): PixelMap;
|
||||
|
||||
/**
|
||||
* Creates a PixelMap object from surface id.
|
||||
*
|
||||
* @param { string } surfaceId - surface id.
|
||||
* @param { Region } region - The region to surface.
|
||||
* @returns { PixelMap } Returns the instance if the operation is successful;Otherwise, an exception will be thrown.
|
||||
* @throws { BusinessError } 62980115 - If the image parameter invalid.
|
||||
* @throws { BusinessError } 62980105 - Failed to get the data.
|
||||
* @throws { BusinessError } 62980178 - Failed to create the PixelMap.
|
||||
* @syscap SystemCapability.Multimedia.Image.Core
|
||||
* @since 11
|
||||
*/
|
||||
function createPixelMapFromSurface(surfaceId: string, region: Region): Promise<PixelMap>;
|
||||
|
||||
/**
|
||||
* Creates an ImageSource instance based on the URI.
|
||||
*
|
||||
@ -2614,6 +2637,16 @@ declare namespace image {
|
||||
*/
|
||||
setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void;
|
||||
|
||||
/**
|
||||
* Is it stride Alignment
|
||||
*
|
||||
* @type { boolean }
|
||||
* @readonly
|
||||
* @syscap SystemCapability.Multimedia.Image.Core
|
||||
* @since 11
|
||||
*/
|
||||
readonly isStrideAlignment: boolean;
|
||||
|
||||
/**
|
||||
* Releases this PixelMap object. This method uses a callback to return the result.
|
||||
*
|
||||
|
@ -40,7 +40,7 @@ config("image_external_config") {
|
||||
"//foundation/multimedia/image_framework/interfaces/kits/native/include",
|
||||
"//utils/jni/jnikit/include",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
|
||||
"//foundation/graphic/graphic_surface/interfaces/inner_api/surface",
|
||||
"$graphic_surface_root/interfaces/inner_api/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/inner_api/common",
|
||||
"//foundation/graphic/graphic_2d/interfaces/kits/napi/graphic/color_manager/color_space_object_convertor",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
@ -85,7 +85,7 @@ config("image_external_config") {
|
||||
include_dirs -= [
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/receiver/include",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/creator/include",
|
||||
"//foundation/graphic/graphic_surface/interfaces/inner_api/surface",
|
||||
"$graphic_surface_root/interfaces/inner_api/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/inner_api/common",
|
||||
"//foundation/graphic/graphic_2d/utils/buffer_handle/export",
|
||||
"//foundation/graphic/graphic_2d/utils/color_manager/export",
|
||||
@ -99,7 +99,7 @@ config("image_external_config") {
|
||||
include_dirs -= [
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/receiver/include",
|
||||
"//foundation/multimedia/image_framework/frameworks/innerkitsimpl/creator/include",
|
||||
"//foundation/graphic/graphic_surface/interfaces/inner_api/surface",
|
||||
"$graphic_surface_root/interfaces/inner_api/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/inner_api/common",
|
||||
"//foundation/graphic/graphic_2d/utils/buffer_handle/export",
|
||||
"//foundation/graphic/graphic_2d/utils/color_manager/export",
|
||||
@ -234,6 +234,7 @@ if (use_clang_ios) {
|
||||
} else {
|
||||
defines = []
|
||||
deps = [
|
||||
"$image_subsystem/frameworks/innerkitsimpl/egl_image:egl_image",
|
||||
"$image_subsystem/frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter",
|
||||
"$image_subsystem/frameworks/innerkitsimpl/utils:image_utils",
|
||||
"$image_subsystem/interfaces/innerkits:image_native",
|
||||
@ -244,7 +245,9 @@ if (use_clang_ios) {
|
||||
"c_utils:utils",
|
||||
"graphic_2d:color_manager",
|
||||
"graphic_2d:color_space_object_convertor",
|
||||
"graphic_2d:libgl",
|
||||
"graphic_surface:surface",
|
||||
"graphic_surface:sync_fence",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
|
@ -53,13 +53,17 @@ public:
|
||||
bool IsLockPixelMap();
|
||||
bool LockPixelMap();
|
||||
void UnlockPixelMap();
|
||||
|
||||
static napi_ref GetConstructor()
|
||||
{
|
||||
return sConstructor_;
|
||||
}
|
||||
private:
|
||||
static napi_value Constructor(napi_env env, napi_callback_info info);
|
||||
static void Destructor(napi_env env, void *nativeObject, void *finalize);
|
||||
|
||||
// readonly property
|
||||
static napi_value GetIsEditable(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIsStrideAlignment(napi_env env, napi_callback_info info);
|
||||
|
||||
// static mothod
|
||||
static napi_value CreatePixelMap(napi_env env, napi_callback_info info);
|
||||
@ -67,6 +71,8 @@ private:
|
||||
static napi_value Unmarshalling(napi_env env, napi_callback_info info);
|
||||
static void UnmarshallingComplete(napi_env env, napi_status status, void *data);
|
||||
static napi_value CreatePixelMapFromParcel(napi_env env, napi_callback_info info);
|
||||
static napi_value CreatePixelMapFromSurface(napi_env env, napi_callback_info info);
|
||||
static void CreatePixelMapFromSurfaceComplete(napi_env env, napi_status status, void *data);
|
||||
static napi_value ThrowExceptionError(napi_env env,
|
||||
const std::string &tag, const std::uint32_t &code, const std::string &info);
|
||||
|
||||
|
BIN
test/resource/image/images/test_hw1.jpg
Normal file
BIN
test/resource/image/images/test_hw1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -79,7 +79,7 @@
|
||||
</target>
|
||||
<target name="jpeg_hw_decoder_test">
|
||||
<preparer>
|
||||
<option name="push" value="images/test_hw.jpg -> /data/local/tmp/image" src="res"/>
|
||||
<option name="push" value="images/test_hw1.jpg -> /data/local/tmp/image" src="res"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="test_imagesystemadapter_java_maple">
|
||||
|
Loading…
Reference in New Issue
Block a user