mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-03-01 08:57:43 +00:00
Merge branch 'master' of gitee.com:openharmony/graphic_graphic_2d into master
Signed-off-by: 刘宇锋 <liuyufeng52@huawei.com>
This commit is contained in:
commit
7e4869d21a
@ -46,15 +46,14 @@
|
||||
"napi",
|
||||
"samgr",
|
||||
"zlib",
|
||||
"hiviewdfx_hilog_native",
|
||||
"hitrace_native",
|
||||
"hilog",
|
||||
"hisysevent",
|
||||
"hitrace",
|
||||
"ability_runtime",
|
||||
"drivers_interface_display",
|
||||
"hilog_native",
|
||||
"c_utils",
|
||||
"access_token",
|
||||
"safwk",
|
||||
"hisysevent_native",
|
||||
"eventhandler",
|
||||
"config_policy",
|
||||
"init",
|
||||
@ -66,7 +65,6 @@
|
||||
"player_framework",
|
||||
"resource_schedule_service",
|
||||
"soc_perf",
|
||||
"hilog",
|
||||
"accessibility"
|
||||
],
|
||||
"third_party": [
|
||||
|
@ -21,6 +21,7 @@ config("bootanimation_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"$graphic_2d_root/utils/log",
|
||||
"${graphic_2d_root}/rosen/modules/render_service_client",
|
||||
"//third_party/cJSON",
|
||||
"//foundation/multimedia/player_framework/interfaces/inner_api/native",
|
||||
]
|
||||
@ -72,8 +73,8 @@ ohos_executable("bootanimation") {
|
||||
|
||||
external_deps = [
|
||||
"config_policy:configpolicy_util",
|
||||
"hilog_native:libhilog",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"player_framework:media_client",
|
||||
"resource_management:global_resmgr",
|
||||
|
@ -52,22 +52,22 @@
|
||||
namespace OHOS {
|
||||
class BootAnimation {
|
||||
public:
|
||||
void Init(int32_t width, int32_t height);
|
||||
void Init(Rosen::ScreenId defaultId, int32_t width, int32_t height);
|
||||
void Draw();
|
||||
bool CheckExitAnimation();
|
||||
void PlaySound();
|
||||
void PlayVideo();
|
||||
void Run(std::vector<sptr<OHOS::Rosen::Display>>& displays);
|
||||
void Run(Rosen::ScreenId id, int screenWidth, int screenHeight);
|
||||
~BootAnimation();
|
||||
void CloseVideoPlayer();
|
||||
private:
|
||||
void OnVsync();
|
||||
void OnDraw(SkCanvas* canvas, int32_t curNo);
|
||||
void InitBootWindow();
|
||||
void InitRsSurface();
|
||||
void InitPicCoordinates();
|
||||
int32_t windowWidth_;
|
||||
int32_t windowHeight_;
|
||||
Rosen::ScreenId defaultId_;
|
||||
sptr<OHOS::Rosen::Window> window_;
|
||||
sptr<OHOS::Rosen::WindowScene> scene_;
|
||||
#ifdef NEW_RENDER_CONTEXT
|
||||
@ -77,6 +77,7 @@ private:
|
||||
std::unique_ptr<OHOS::Rosen::RSSurfaceFrame> framePtr_;
|
||||
std::shared_ptr<OHOS::Rosen::RSSurface> rsSurface_;
|
||||
OHOS::Rosen::RenderContext* rc_;
|
||||
std::shared_ptr<OHOS::Rosen::RSSurfaceNode> rsSurfaceNode_;
|
||||
#endif
|
||||
int32_t freq_ = 30;
|
||||
int32_t realHeight_ = 0;
|
||||
|
@ -34,6 +34,7 @@ class BootVideoPlayer : public std::enable_shared_from_this<BootVideoPlayer> {
|
||||
public:
|
||||
void SetVideoPath(const std::string& path);
|
||||
void SetPlayerWindow(const OHOS::sptr<OHOS::Rosen::Window>& window);
|
||||
void SetPlayerSurface(const OHOS::sptr<OHOS::Surface>& surface);
|
||||
void SetCallback(const FrameCallback* cb)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mtx_);
|
||||
@ -45,6 +46,7 @@ public:
|
||||
private:
|
||||
std::shared_ptr<Media::Player> mediaPlayer_;
|
||||
OHOS::sptr<OHOS::Rosen::Window> window_;
|
||||
OHOS::sptr<OHOS::Surface> surface_;
|
||||
std::string videopath_;
|
||||
VSyncCallback vsyncCallbacks_;
|
||||
void *userData_;
|
||||
|
@ -22,9 +22,12 @@
|
||||
#include "render_context_factory.h"
|
||||
#include "rs_surface_factory.h"
|
||||
#endif
|
||||
#include <display_manager.h>
|
||||
|
||||
using namespace OHOS;
|
||||
|
||||
constexpr float MAX_ZORDER = 100000.0f;
|
||||
|
||||
void BootAnimation::OnDraw(SkCanvas* canvas, int32_t curNo)
|
||||
{
|
||||
if (canvas == nullptr) {
|
||||
@ -89,14 +92,15 @@ void BootAnimation::Draw()
|
||||
#endif
|
||||
}
|
||||
|
||||
void BootAnimation::Init(int32_t width, int32_t height)
|
||||
void BootAnimation::Init(Rosen::ScreenId defaultId, int32_t width, int32_t height)
|
||||
{
|
||||
defaultId_ = defaultId;
|
||||
windowWidth_ = width;
|
||||
windowHeight_ = height;
|
||||
LOGI("Init enter, width: %{public}d, height: %{public}d", width, height);
|
||||
|
||||
InitPicCoordinates();
|
||||
InitBootWindow();
|
||||
InitRsSurface();
|
||||
if (animationConfig_.IsBootVideoEnabled()) {
|
||||
LOGI("Init end");
|
||||
return;
|
||||
@ -113,8 +117,6 @@ void BootAnimation::Init(int32_t width, int32_t height)
|
||||
return;
|
||||
}
|
||||
|
||||
InitRsSurface();
|
||||
|
||||
ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "BootAnimation::preload");
|
||||
if (animationConfig_.ReadPicZipFile(imageVector_, freq_)) {
|
||||
imgVecSize_ = imageVector_.size();
|
||||
@ -139,14 +141,14 @@ void BootAnimation::Init(int32_t width, int32_t height)
|
||||
}
|
||||
}
|
||||
|
||||
void BootAnimation::Run(std::vector<sptr<OHOS::Rosen::Display>>& displays)
|
||||
void BootAnimation::Run(Rosen::ScreenId id, int screenWidth, int screenHeight)
|
||||
{
|
||||
LOGI("Run enter");
|
||||
animationConfig_.ParserCustomCfgFile();
|
||||
|
||||
runner_ = AppExecFwk::EventRunner::Create(false);
|
||||
mainHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner_);
|
||||
mainHandler_->PostTask(std::bind(&BootAnimation::Init, this, displays[0]->GetWidth(), displays[0]->GetHeight()));
|
||||
mainHandler_->PostTask(std::bind(&BootAnimation::Init, this, id, screenWidth, screenHeight));
|
||||
if (animationConfig_.IsBootVideoEnabled()) {
|
||||
mainHandler_->PostTask(std::bind(&BootAnimation::PlayVideo, this));
|
||||
} else {
|
||||
@ -155,39 +157,6 @@ void BootAnimation::Run(std::vector<sptr<OHOS::Rosen::Display>>& displays)
|
||||
runner_->Run();
|
||||
}
|
||||
|
||||
void BootAnimation::InitBootWindow()
|
||||
{
|
||||
sptr<OHOS::Rosen::WindowOption> option = new OHOS::Rosen::WindowOption();
|
||||
option->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_BOOT_ANIMATION);
|
||||
option->RemoveWindowFlag(OHOS::Rosen::WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
option->SetTouchable(false);
|
||||
if (animationConfig_.IsBootVideoEnabled()) {
|
||||
option->SetWindowMode(Rosen::WindowMode::WINDOW_MODE_FLOATING);
|
||||
}
|
||||
option->SetWindowRect({0, 0, windowWidth_, windowHeight_} );
|
||||
int displayId = 0;
|
||||
sptr<OHOS::Rosen::IWindowLifeCycle> listener = nullptr;
|
||||
LOGI("Create window scene.");
|
||||
scene_ = new OHOS::Rosen::WindowScene();
|
||||
LOGI("Init window scene.");
|
||||
scene_->Init(displayId, nullptr, listener, option);
|
||||
window_ = scene_->GetMainWindow();
|
||||
while (window_ == nullptr) {
|
||||
LOGI("window is nullptr, continue to init window");
|
||||
scene_->Init(displayId, nullptr, listener, option);
|
||||
window_ = scene_->GetMainWindow();
|
||||
usleep(SLEEP_TIME_US);
|
||||
}
|
||||
LOGI("Init window scene end.");
|
||||
if (animationConfig_.IsBootVideoEnabled()) {
|
||||
auto surfaceNode = window_->GetSurfaceNode();
|
||||
surfaceNode->SetBackgroundColor(0xFF000000);
|
||||
surfaceNode->SetFrameGravity(Rosen::Gravity::RESIZE_ASPECT);
|
||||
OHOS::Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
}
|
||||
scene_->GoForeground();
|
||||
}
|
||||
|
||||
void BootAnimation::InitRsSurface()
|
||||
{
|
||||
#if defined(NEW_RENDER_CONTEXT)
|
||||
@ -199,11 +168,45 @@ void BootAnimation::InitRsSurface()
|
||||
renderContext_->Init();
|
||||
std::shared_ptr<Rosen::DrawingContext> drawingContext = std::make_shared<Rosen::DrawingContext>(
|
||||
renderContext_->GetRenderType());
|
||||
sptr<Surface> surface = window_->GetSurfaceNode()->GetSurface();
|
||||
|
||||
struct Rosen::RSSurfaceNodeConfig rsSurfaceNodeConfig;
|
||||
Rosen::RSSurfaceNodeType rsSurfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
|
||||
|
||||
rsSurfaceNode_ = Rosen::RSSurfaceNode::Create(rsSurfaceNodeConfig, rsSurfaceNodeType);
|
||||
if (!rsSurfaceNode_) {
|
||||
LOGE("rsSurfaceNode_ is nullptr");
|
||||
return;
|
||||
}
|
||||
rsSurfaceNode_->SetPositionZ(MAX_ZORDER);
|
||||
rsSurfaceNode_->SetBounds({0, 0, windowWidth_, windowHeight_});
|
||||
rsSurfaceNode_->SetBackgroundColor(0xFF000000);
|
||||
rsSurfaceNode_->SetFrameGravity(Rosen::Gravity::RESIZE_ASPECT);
|
||||
|
||||
rsSurfaceNode_->AttachToDisplay(defaultId_);
|
||||
OHOS::Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
|
||||
sptr<Surface> surface = rsSurfaceNode_->GetSurface();
|
||||
rsSurface_ = Rosen::RSSurfaceFactory::CreateRSSurface(Rosen::PlatformName::OHOS, surface, drawingContext);
|
||||
rsSurface_->SetRenderContext(renderContext_);
|
||||
|
||||
#else
|
||||
rsSurface_ = OHOS::Rosen::RSSurfaceExtractor::ExtractRSSurface(window_->GetSurfaceNode());
|
||||
struct Rosen::RSSurfaceNodeConfig rsSurfaceNodeConfig;
|
||||
Rosen::RSSurfaceNodeType rsSurfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
|
||||
|
||||
rsSurfaceNode_ = Rosen::RSSurfaceNode::Create(rsSurfaceNodeConfig, rsSurfaceNodeType);
|
||||
if (!rsSurfaceNode_) {
|
||||
LOGE("rsSurfaceNode_ is nullptr");
|
||||
return;
|
||||
}
|
||||
rsSurfaceNode_->SetPositionZ(MAX_ZORDER);
|
||||
rsSurfaceNode_->SetBounds({0, 0, windowWidth_, windowHeight_});
|
||||
rsSurfaceNode_->SetBackgroundColor(0xFF000000);
|
||||
rsSurfaceNode_->SetFrameGravity(Rosen::Gravity::RESIZE_ASPECT);
|
||||
|
||||
rsSurfaceNode_->AttachToDisplay(defaultId_);
|
||||
OHOS::Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
|
||||
rsSurface_ = OHOS::Rosen::RSSurfaceExtractor::ExtractRSSurface(rsSurfaceNode_);
|
||||
if (rsSurface_ == nullptr) {
|
||||
LOGE("rsSurface is nullptr");
|
||||
return;
|
||||
@ -222,12 +225,14 @@ void BootAnimation::InitRsSurface()
|
||||
if (rc_ == nullptr) {
|
||||
LOGI("rc is nullptr, use cpu");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
BootAnimation::~BootAnimation()
|
||||
{
|
||||
window_->Destroy();
|
||||
rsSurfaceNode_->DetachToDisplay(defaultId_);
|
||||
OHOS::Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
}
|
||||
|
||||
void BootAnimation::InitPicCoordinates()
|
||||
@ -294,7 +299,7 @@ void BootAnimation::PlayVideo()
|
||||
};
|
||||
bootVideoPlayer_ = std::make_shared<BootVideoPlayer>();
|
||||
bootVideoPlayer_->SetVideoPath(animationConfig_.GetBootVideoPath());
|
||||
bootVideoPlayer_->SetPlayerWindow(window_);
|
||||
bootVideoPlayer_->SetPlayerSurface(rsSurfaceNode_ ? rsSurfaceNode_->GetSurface() : nullptr);
|
||||
bootVideoPlayer_->SetCallback(&fcb_);
|
||||
if (!bootVideoPlayer_->PlayVideo()) {
|
||||
LOGE("Play video failed.");
|
||||
|
@ -37,6 +37,15 @@ void BootVideoPlayer::SetPlayerWindow(const OHOS::sptr<OHOS::Rosen::Window>& win
|
||||
window_ = window;
|
||||
}
|
||||
|
||||
void BootVideoPlayer::SetPlayerSurface(const sptr<Surface>& surface)
|
||||
{
|
||||
if (surface == nullptr) {
|
||||
LOGE("SetPlayerSurface surface is nullptr");
|
||||
return;
|
||||
}
|
||||
surface_ = surface;
|
||||
}
|
||||
|
||||
bool BootVideoPlayer::PlayVideo()
|
||||
{
|
||||
LOGI("PlayVideo begin");
|
||||
@ -56,12 +65,11 @@ bool BootVideoPlayer::PlayVideo()
|
||||
LOGE("PlayVideo SetSource fail, uri:%{public}s, errorCode:%{public}d", uri.c_str(), ret);
|
||||
return false;
|
||||
}
|
||||
auto surface = window_->GetSurfaceNode()->GetSurface();
|
||||
if (surface == nullptr) {
|
||||
if (surface_ == nullptr) {
|
||||
LOGE("PlayVideo surface is null");
|
||||
return false;
|
||||
}
|
||||
ret = mediaPlayer_->SetVideoSurface(surface);
|
||||
ret = mediaPlayer_->SetVideoSurface(surface_);
|
||||
if (ret != 0) {
|
||||
LOGE("PlayVideo SetVideoSurface fail, errorCode:%{public}d", ret);
|
||||
return false;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <event_handler.h>
|
||||
#include "boot_animation.h"
|
||||
#include "util.h"
|
||||
#include "core/transaction/rs_interfaces.h"
|
||||
|
||||
using namespace OHOS;
|
||||
|
||||
@ -26,16 +27,30 @@ int main(int argc, const char *argv[])
|
||||
LOGI("main enter");
|
||||
WaitRenderServiceInit();
|
||||
|
||||
auto& dms = OHOS::Rosen::DisplayManager::GetInstance();
|
||||
auto displays = dms.GetAllDisplays();
|
||||
while (displays.empty()) {
|
||||
LOGI("displays is empty, retry to get displays");
|
||||
displays = dms.GetAllDisplays();
|
||||
auto& dms= OHOS::Rosen::DisplayManager::GetInstance();
|
||||
auto displayIds = dms.GetAllDisplayIds();
|
||||
|
||||
while (displayIds.empty()) {
|
||||
LOGI("displayIds is empty, retry to get displayIds");
|
||||
displayIds = dms.GetAllDisplayIds();
|
||||
usleep(SLEEP_TIME_US);
|
||||
}
|
||||
|
||||
|
||||
Rosen::RSInterfaces& interface = Rosen::RSInterfaces::GetInstance();
|
||||
Rosen::ScreenId defaultId = interface.GetDefaultScreenId();
|
||||
if (defaultId == Rosen::INVALID_SCREEN_ID) {
|
||||
LOGE("invalid default screen id, return");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Rosen::RSScreenModeInfo modeinfo = interface.GetScreenActiveMode(defaultId);
|
||||
int screenWidth = modeinfo.GetScreenWidth();
|
||||
int screenHeight = modeinfo.GetScreenHeight();
|
||||
|
||||
|
||||
BootAnimation bootAnimation;
|
||||
bootAnimation.Run(displays);
|
||||
bootAnimation.Run(defaultId, screenWidth, screenHeight);
|
||||
|
||||
LOGI("main exit");
|
||||
return 0;
|
||||
|
@ -37,7 +37,7 @@ ohos_shared_library("libfence") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
||||
part_name = "graphic_standard"
|
||||
|
@ -29,7 +29,7 @@ ohos_unittest("fence_fd_test") {
|
||||
|
||||
deps = [ ":fence_test_common" ]
|
||||
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
}
|
||||
|
||||
## UnitTest fence_test }}}
|
||||
|
@ -62,7 +62,7 @@ if (current_os != "ohos") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
@ -111,7 +111,7 @@ ohos_shared_library("GLESv1") {
|
||||
"//third_party/openGLES:libGLES",
|
||||
]
|
||||
|
||||
external_deps = [ "hilog_native:libhilog" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
output_name = "GLESv1"
|
||||
output_extension = "so"
|
||||
@ -151,7 +151,7 @@ ohos_shared_library("GLESv2") {
|
||||
"//third_party/openGLES:libGLES",
|
||||
]
|
||||
|
||||
external_deps = [ "hilog_native:libhilog" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
output_name = "GLESv2"
|
||||
output_extension = "so"
|
||||
@ -199,7 +199,7 @@ if (current_os != "ohos") {
|
||||
"//third_party/openGLES:libGLES",
|
||||
]
|
||||
|
||||
external_deps = [ "hilog_native:libhilog" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
if (defined(graphic_2d_ext_configs.vendor_root)) {
|
||||
install_enable = false
|
||||
@ -236,7 +236,7 @@ ohos_executable("opengl_wrapper_native_test") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
||||
part_name = "graphic_standard"
|
||||
@ -270,7 +270,7 @@ ohos_shared_library("debug_layer_test1") {
|
||||
|
||||
public_deps = [ "//third_party/EGL:libEGL" ]
|
||||
|
||||
external_deps = [ "hilog_native:libhilog" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
symlink_target_name = [ "libdebug_layer_test1.so" ]
|
||||
|
||||
@ -286,7 +286,7 @@ ohos_shared_library("debug_layer_test2") {
|
||||
|
||||
public_deps = [ "//third_party/EGL:libEGL" ]
|
||||
|
||||
external_deps = [ "hilog_native:libhilog" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
symlink_target_name = [ "libdebug_layer_test2.so" ]
|
||||
|
||||
|
@ -95,8 +95,8 @@ ohos_shared_library("surface") {
|
||||
external_deps = [
|
||||
"drivers_interface_display:display_buffer_idl_headers",
|
||||
"drivers_interface_display:libdisplay_buffer_hdi_impl",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
|
||||
|
@ -49,7 +49,6 @@ public:
|
||||
int32_t GetFormat() const override;
|
||||
uint64_t GetUsage() const override;
|
||||
uint64_t GetPhyAddr() const override;
|
||||
int32_t GetKey() const override;
|
||||
void *GetVirAddr() override;
|
||||
int32_t GetFileDescriptor() const override;
|
||||
uint32_t GetSize() const override;
|
||||
|
@ -433,16 +433,6 @@ uint64_t SurfaceBufferImpl::GetPhyAddr() const
|
||||
return handle_->phyAddr;
|
||||
}
|
||||
|
||||
int32_t SurfaceBufferImpl::GetKey() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (handle_ == nullptr) {
|
||||
BLOGE("handle is nullptr");
|
||||
return -1;
|
||||
}
|
||||
return handle_->key;
|
||||
}
|
||||
|
||||
void *SurfaceBufferImpl::GetVirAddr()
|
||||
{
|
||||
GSError ret = this->Map();
|
||||
|
@ -62,7 +62,7 @@ ohos_shared_library("libnative_image") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/graphic/graphic_2d/graphic_config.gni")
|
||||
|
||||
## Build libvulkan_swapchain.so {{{
|
||||
config("vulkan_config") {
|
||||
@ -43,13 +44,15 @@ ohos_shared_library("vulkan_swapchain_layer") {
|
||||
|
||||
public_configs = [ ":vulkan_public_config" ]
|
||||
|
||||
deps = [ "//third_party/vulkan-headers:vulkan_headers" ]
|
||||
deps = [
|
||||
"$graphic_2d_root:libsurface",
|
||||
"$graphic_2d_root/utils:sync_fence",
|
||||
"//third_party/vulkan-headers:vulkan_headers",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"graphic_standard:surface",
|
||||
"graphic_standard:sync_fence",
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
||||
output_name = "vulkan_swapchain"
|
||||
|
@ -125,6 +125,30 @@ void FreeLayerDataPtr(DispatchKey dataKey)
|
||||
g_layerDataMap.erase(it);
|
||||
}
|
||||
|
||||
void DebugMessageToUserCallback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, const char* message)
|
||||
{
|
||||
VkDebugUtilsMessengerCallbackDataEXT callbackData = {};
|
||||
callbackData.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT;
|
||||
callbackData.pMessageIdName = "SwapchainLayer";
|
||||
callbackData.pMessage = message;
|
||||
|
||||
for (auto [key, layerData] : g_layerDataMap) {
|
||||
if (layerData->debugCallbacks.empty()) {
|
||||
continue;
|
||||
}
|
||||
for (auto& callback : layerData->debugCallbacks) {
|
||||
if (!(severity & callback.second.messageSeverity)) {
|
||||
continue;
|
||||
}
|
||||
if (!(VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT & callback.second.messageType)) {
|
||||
continue;
|
||||
}
|
||||
callback.second.pfnUserCallback(severity, VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT,
|
||||
&callbackData, callback.second.pUserData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VkResult GetExtensionProperties(const uint32_t count, const VkExtensionProperties* layerExtensions,
|
||||
uint32_t* pCount, VkExtensionProperties* pProperties)
|
||||
{
|
||||
@ -349,7 +373,9 @@ void ReleaseSwapchainImage(VkDevice device, NativeWindow* window, int releaseFen
|
||||
bool deferIfPending)
|
||||
{
|
||||
if (releaseFence != -1 && !image.requested) {
|
||||
SWLOGE("%{public}s, can't provide a release fence for non-dequeued images", __func__);
|
||||
SWLOGE("%{public}s, can't provide a release fence for non-requested images", __func__);
|
||||
DebugMessageToUserCallback(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
|
||||
"can't provide a release fence for non-requested images");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -420,6 +446,8 @@ GraphicPixelFormat GetPixelFormat(VkFormat format)
|
||||
break;
|
||||
default:
|
||||
SWLOGE("unsupported swapchain format %{public}d", format);
|
||||
DebugMessageToUserCallback(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
|
||||
("unsupported swapchain format " + std::to_string(format)).c_str());
|
||||
break;
|
||||
}
|
||||
return nativeFormat;
|
||||
@ -527,7 +555,7 @@ VKAPI_ATTR VkResult CreateImages(int32_t &numImages, Swapchain* swapchain, const
|
||||
NativeWindowBuffer* buffer = nullptr;
|
||||
int err = NativeWindowRequestBuffer(window, &buffer, &img.requestFence);
|
||||
if (err != OHOS::GSERROR_OK) {
|
||||
SWLOGE("dequeueBuffer[%{public}u] failed: (%{public}d)", i, err);
|
||||
SWLOGE("RequestBuffer[%{public}u] failed: (%{public}d)", i, err);
|
||||
result = VK_ERROR_SURFACE_LOST_KHR;
|
||||
break;
|
||||
}
|
||||
@ -696,7 +724,9 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK
|
||||
int fence = -1;
|
||||
int32_t ret = NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer, &fence);
|
||||
if (ret != OHOS::GSERROR_OK) {
|
||||
SWLOGE("dequeueBuffer failed: (%{public}d)", ret);
|
||||
SWLOGE("RequestBuffer failed: (%{public}d)", ret);
|
||||
DebugMessageToUserCallback(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
|
||||
("RequestBuffer failed: " + std::to_string(ret)).c_str());
|
||||
return VK_ERROR_SURFACE_LOST_KHR;
|
||||
}
|
||||
|
||||
@ -711,7 +741,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK
|
||||
}
|
||||
|
||||
if (index == swapchain.numImages) {
|
||||
SWLOGE("dequeueBuffer returned unrecognized buffer");
|
||||
SWLOGE("RequestBuffer returned unrecognized buffer");
|
||||
if (NativeWindowCancelBuffer(nativeWindow, nativeWindowBuffer) != OHOS::GSERROR_OK) {
|
||||
SWLOGE("NativeWindowCancelBuffer failed: (%{public}d)", ret);
|
||||
}
|
||||
@ -835,7 +865,7 @@ VkResult FlushBuffer(const VkPresentRegionKHR* region, struct Region::Rect* rect
|
||||
int err = NativeWindowFlushBuffer(window, img.buffer, fence, localRegion);
|
||||
VkResult scResult = VK_SUCCESS;
|
||||
if (err != OHOS::GSERROR_OK) {
|
||||
SWLOGE("queueBuffer failed: (%{public}d)", err);
|
||||
SWLOGE("FlushBuffer failed: (%{public}d)", err);
|
||||
scResult = VK_ERROR_SURFACE_LOST_KHR;
|
||||
} else {
|
||||
if (img.requestFence >= 0) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include "refbase.h"
|
||||
#include "surface.h"
|
||||
@ -43,12 +44,20 @@ public:
|
||||
uint32_t GetQueueFamilyIndex(VkQueueFlagBits queueFlags);
|
||||
OHNativeWindow* CreateNativeWindow(std::string name);
|
||||
VkSwapchainCreateInfoKHR GetSwapchainCreateInfo(VkFormat imageFormat, VkColorSpaceKHR imageColorSpace);
|
||||
static VkBool32 UserCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||
void* pUserData);
|
||||
|
||||
static inline void DLOpenLibVulkan();
|
||||
static inline void TrytoCreateVkInstance();
|
||||
|
||||
static inline PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
|
||||
static inline PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
|
||||
static inline PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties;
|
||||
static inline PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
|
||||
static inline PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT;
|
||||
static inline PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT;
|
||||
static inline PFN_vkCreateInstance vkCreateInstance;
|
||||
static inline PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
|
||||
static inline PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
|
||||
@ -86,6 +95,8 @@ public:
|
||||
static inline bool isSupportedVulkan_ = false;
|
||||
static inline std::vector<VkQueueFamilyProperties> queueProps_;
|
||||
static inline uint32_t queueCount_;
|
||||
static inline VkDebugUtilsMessengerEXT debugUtilsMessenger = VK_NULL_HANDLE;
|
||||
static inline std::stringstream debugMessage_;
|
||||
};
|
||||
|
||||
void VulkanLoaderUnitTest::DLOpenLibVulkan()
|
||||
@ -114,7 +125,8 @@ void VulkanLoaderUnitTest::TrytoCreateVkInstance()
|
||||
|
||||
std::vector<const char*> instanceExtensions = {
|
||||
VK_KHR_SURFACE_EXTENSION_NAME,
|
||||
VK_OHOS_SURFACE_EXTENSION_NAME
|
||||
VK_OHOS_SURFACE_EXTENSION_NAME,
|
||||
VK_EXT_DEBUG_UTILS_EXTENSION_NAME
|
||||
};
|
||||
|
||||
VkInstanceCreateInfo instanceCreateInfo = {};
|
||||
@ -199,6 +211,27 @@ uint32_t VulkanLoaderUnitTest::GetQueueFamilyIndex(VkQueueFlagBits queueFlags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
VkBool32 VulkanLoaderUnitTest::UserCallback(
|
||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||
void* pUserData)
|
||||
{
|
||||
std::string prefix("");
|
||||
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
|
||||
prefix = "ERROR: ";
|
||||
} else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
|
||||
prefix = "WARN: ";
|
||||
} else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) {
|
||||
prefix = "INFO: ";
|
||||
} else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) {
|
||||
prefix = "DEBUG: ";
|
||||
}
|
||||
debugMessage_ << prefix << "[" << pCallbackData->messageIdNumber << "]["
|
||||
<< pCallbackData->pMessageIdName << "] : " << pCallbackData->pMessage;
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
void VulkanLoaderUnitTest::TearDownTestCase()
|
||||
{
|
||||
if (device_ != nullptr) {
|
||||
@ -234,6 +267,12 @@ HWTEST_F(VulkanLoaderUnitTest, LoadBaseFuncPtr, TestSize.Level1)
|
||||
vkEnumerateInstanceLayerProperties = reinterpret_cast<PFN_vkEnumerateInstanceLayerProperties>(
|
||||
dlsym(libVulkan_, "vkEnumerateInstanceLayerProperties"));
|
||||
EXPECT_NE(vkEnumerateInstanceLayerProperties, nullptr);
|
||||
vkEnumerateDeviceExtensionProperties = reinterpret_cast<PFN_vkEnumerateDeviceExtensionProperties>(
|
||||
dlsym(libVulkan_, "vkEnumerateDeviceExtensionProperties"));
|
||||
EXPECT_NE(vkEnumerateDeviceExtensionProperties, nullptr);
|
||||
vkEnumerateDeviceLayerProperties = reinterpret_cast<PFN_vkEnumerateDeviceLayerProperties>(
|
||||
dlsym(libVulkan_, "vkEnumerateDeviceLayerProperties"));
|
||||
EXPECT_NE(vkEnumerateDeviceLayerProperties, nullptr);
|
||||
vkCreateInstance = reinterpret_cast<PFN_vkCreateInstance>(dlsym(libVulkan_, "vkCreateInstance"));
|
||||
EXPECT_NE(vkCreateInstance, nullptr);
|
||||
vkGetInstanceProcAddr = reinterpret_cast<PFN_vkGetInstanceProcAddr>(dlsym(libVulkan_, "vkGetInstanceProcAddr"));
|
||||
@ -258,7 +297,27 @@ HWTEST_F(VulkanLoaderUnitTest, vkEnumerateInstanceExtensionProperties_Test, Test
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
if (extCount > 0) {
|
||||
std::vector<VkExtensionProperties> extensions(extCount);
|
||||
err = vkEnumerateInstanceExtensionProperties(nullptr, &extCount, &extensions.front());
|
||||
err = vkEnumerateInstanceExtensionProperties(nullptr, &extCount, extensions.data());
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: test vkEnumerateInstanceLayerProperties
|
||||
* @tc.desc: test vkEnumerateInstanceLayerProperties
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6SKRO
|
||||
*/
|
||||
HWTEST_F(VulkanLoaderUnitTest, vkEnumerateInstanceLayerProperties_Test, TestSize.Level1)
|
||||
{
|
||||
if (isSupportedVulkan_) {
|
||||
uint32_t propertyCount = 0;
|
||||
VkResult err = vkEnumerateInstanceLayerProperties(&propertyCount, nullptr);
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
if (propertyCount > 0) {
|
||||
std::vector<VkLayerProperties> properties(propertyCount);
|
||||
err = vkEnumerateInstanceLayerProperties(&propertyCount, properties.data());
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
}
|
||||
}
|
||||
@ -273,8 +332,6 @@ HWTEST_F(VulkanLoaderUnitTest, vkEnumerateInstanceExtensionProperties_Test, Test
|
||||
HWTEST_F(VulkanLoaderUnitTest, LoadInstanceFuncPtr, TestSize.Level1)
|
||||
{
|
||||
if (isSupportedVulkan_) {
|
||||
EXPECT_NE(instance_, nullptr);
|
||||
|
||||
vkDestroyInstance = reinterpret_cast<PFN_vkDestroyInstance>(
|
||||
vkGetInstanceProcAddr(instance_, "vkDestroyInstance"));
|
||||
EXPECT_NE(vkDestroyInstance, nullptr);
|
||||
@ -317,6 +374,12 @@ HWTEST_F(VulkanLoaderUnitTest, LoadInstanceFuncPtr, TestSize.Level1)
|
||||
vkGetPhysicalDeviceSurfaceSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceSupportKHR>(
|
||||
vkGetInstanceProcAddr(instance_, "vkGetPhysicalDeviceSurfaceSupportKHR"));
|
||||
EXPECT_NE(vkGetPhysicalDeviceSurfaceSupportKHR, nullptr);
|
||||
vkCreateDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(
|
||||
vkGetInstanceProcAddr(instance_, "vkCreateDebugUtilsMessengerEXT"));
|
||||
EXPECT_NE(vkCreateDebugUtilsMessengerEXT, nullptr);
|
||||
vkDestroyDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(
|
||||
vkGetInstanceProcAddr(instance_, "vkDestroyDebugUtilsMessengerEXT"));
|
||||
EXPECT_NE(vkDestroyDebugUtilsMessengerEXT, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,6 +413,46 @@ HWTEST_F(VulkanLoaderUnitTest, vkEnumeratePhysicalDevices_Test, TestSize.Level1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: test vkEnumerateDeviceExtensionProperties
|
||||
* @tc.desc: test vkEnumerateDeviceExtensionProperties
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6SKRO
|
||||
*/
|
||||
HWTEST_F(VulkanLoaderUnitTest, vkEnumerateDeviceExtensionProperties_Test, TestSize.Level1)
|
||||
{
|
||||
if (isSupportedVulkan_) {
|
||||
uint32_t extCount = 0;
|
||||
VkResult err = vkEnumerateDeviceExtensionProperties(physicalDevice_, nullptr, &extCount, nullptr);
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
if (extCount > 0) {
|
||||
std::vector<VkExtensionProperties> extensions(extCount);
|
||||
err = vkEnumerateDeviceExtensionProperties(physicalDevice_, nullptr, &extCount, extensions.data());
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: test vkEnumerateDeviceLayerProperties
|
||||
* @tc.desc: test vkEnumerateDeviceLayerProperties
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6SKRO
|
||||
*/
|
||||
HWTEST_F(VulkanLoaderUnitTest, vkEnumerateDeviceLayerProperties_Test, TestSize.Level1)
|
||||
{
|
||||
if (isSupportedVulkan_) {
|
||||
uint32_t propertyCount = 0;
|
||||
VkResult err = vkEnumerateDeviceLayerProperties(physicalDevice_, &propertyCount, nullptr);
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
if (propertyCount > 0) {
|
||||
std::vector<VkLayerProperties> properties(propertyCount);
|
||||
err = vkEnumerateDeviceLayerProperties(physicalDevice_, &propertyCount, properties.data());
|
||||
EXPECT_EQ(err, VK_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: test vkGetPhysicalDeviceQueueFamilyProperties
|
||||
* @tc.desc: test vkGetPhysicalDeviceQueueFamilyProperties
|
||||
@ -707,6 +810,70 @@ HWTEST_F(VulkanLoaderUnitTest, fpCreateSwapchainKHR_Fail_Test, TestSize.Level1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: test vkCreateDebugUtilsMessengerEXT
|
||||
* @tc.desc: test vkCreateDebugUtilsMessengerEXT
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6SKRO
|
||||
*/
|
||||
HWTEST_F(VulkanLoaderUnitTest, vkCreateDebugUtilsMessengerEXT_Test, TestSize.Level1)
|
||||
{
|
||||
if (isSupportedVulkan_) {
|
||||
EXPECT_NE(vkCreateDebugUtilsMessengerEXT, nullptr);
|
||||
EXPECT_NE(fpCreateSwapchainKHR, nullptr);
|
||||
EXPECT_NE(instance_, nullptr);
|
||||
EXPECT_NE(device_, nullptr);
|
||||
|
||||
VkDebugUtilsMessengerCreateInfoEXT createInfo{};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
||||
createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||
createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
|
||||
createInfo.pfnUserCallback = UserCallback;
|
||||
VkResult result = vkCreateDebugUtilsMessengerEXT(instance_, &createInfo, nullptr, &debugUtilsMessenger);
|
||||
EXPECT_EQ(result, VK_SUCCESS);
|
||||
|
||||
debugMessage_.str("");
|
||||
VkSwapchainCreateInfoKHR swapchainCI = GetSwapchainCreateInfo(VK_FORMAT_MAX_ENUM, surfaceFormat_.colorSpace);
|
||||
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
||||
result = fpCreateSwapchainKHR(device_, &swapchainCI, nullptr, &swapChain);
|
||||
EXPECT_EQ(result, VK_SUCCESS);
|
||||
EXPECT_NE(swapChain, VK_NULL_HANDLE);
|
||||
fpDestroySwapchainKHR(device_, swapChain, nullptr);
|
||||
|
||||
EXPECT_EQ((debugMessage_.str().find("unsupported swapchain format") != -1), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: test vkDestroyDebugUtilsMessengerEXT
|
||||
* @tc.desc: test vkDestroyDebugUtilsMessengerEXT
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6SKRO
|
||||
*/
|
||||
HWTEST_F(VulkanLoaderUnitTest, vkDestroyDebugUtilsMessengerEXT_Test, TestSize.Level1)
|
||||
{
|
||||
if (isSupportedVulkan_) {
|
||||
EXPECT_NE(vkDestroyDebugUtilsMessengerEXT, nullptr);
|
||||
EXPECT_NE(instance_, nullptr);
|
||||
EXPECT_NE(device_, nullptr);
|
||||
EXPECT_NE(debugUtilsMessenger, VK_NULL_HANDLE);
|
||||
|
||||
vkDestroyDebugUtilsMessengerEXT(instance_, debugUtilsMessenger, nullptr);
|
||||
|
||||
debugMessage_.str("");
|
||||
VkSwapchainCreateInfoKHR swapchainCI = GetSwapchainCreateInfo(VK_FORMAT_MAX_ENUM, surfaceFormat_.colorSpace);
|
||||
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
||||
VkResult result = fpCreateSwapchainKHR(device_, &swapchainCI, nullptr, &swapChain);
|
||||
EXPECT_EQ(result, VK_SUCCESS);
|
||||
EXPECT_NE(swapChain, VK_NULL_HANDLE);
|
||||
fpDestroySwapchainKHR(device_, swapChain, nullptr);
|
||||
|
||||
EXPECT_EQ((debugMessage_.str() == ""), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: test fpCreateSwapchainKHR
|
||||
* @tc.desc: test fpCreateSwapchainKHR
|
||||
|
@ -62,7 +62,7 @@ OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length);
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeVsync
|
||||
* @param window Indicates the pointer to a <b>NativeVsync</b> instance.
|
||||
* @return Returns int32_t, return value == 0, success, value < 0, failed.
|
||||
* @return Returns int32_t, return value == 0, success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -75,7 +75,7 @@ void OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync);
|
||||
* @param nativeVsync Indicates the pointer to a NativeVsync.
|
||||
* @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming.
|
||||
* @param data Indicates data whick will be used in callback.
|
||||
* @return Returns int32_t, return value == 0, success, value < 0, failed.
|
||||
* @return Returns int32_t, return value == 0, success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
virtual VsyncError Init();
|
||||
virtual VsyncError RequestNextVSync(FrameCallback callback);
|
||||
virtual VsyncError SetVSyncRate(FrameCallback callback, int32_t rate);
|
||||
virtual VsyncError GetVSyncPeriod(int64_t &period);
|
||||
|
||||
private:
|
||||
sptr<IVSyncConnection> connection_;
|
||||
|
@ -196,7 +196,7 @@ enum NativeWindowOperation {
|
||||
/**
|
||||
* @brief Indicates Scaling Mode.
|
||||
* @since 9
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
@ -223,7 +223,7 @@ typedef enum {
|
||||
/**
|
||||
* @brief Enumerates the HDR metadata keys.
|
||||
* @since 9
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
typedef enum {
|
||||
OH_METAKEY_RED_PRIMARY_X = 0,
|
||||
@ -245,7 +245,7 @@ typedef enum {
|
||||
/**
|
||||
* @brief Defines the HDR metadata.
|
||||
* @since 9
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
typedef struct {
|
||||
OHHDRMetadataKey key;
|
||||
@ -255,7 +255,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief Defines the ExtData Handle
|
||||
* @since 9
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
typedef struct OHExtDataHandle {
|
||||
/**< Handle fd, -1 if not supported */
|
||||
@ -267,55 +267,55 @@ typedef struct OHExtDataHandle {
|
||||
} OHExtDataHandle;
|
||||
|
||||
/**
|
||||
* @brief Creates a <b>NativeWindow</b> instance. A new <b>NativeWindow</b> instance is created each time this function is called.
|
||||
* @brief Creates a <b>OHNativeWindow</b> instance. A new <b>OHNativeWindow</b> instance is created each time this function is called.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param pSurface Indicates the pointer to a <b>ProduceSurface</b>. The type is a pointer to <b>sptr<OHOS::Surface></b>.
|
||||
* @return Returns the pointer to the <b>NativeWindow</b> instance created.
|
||||
* @return Returns the pointer to the <b>OHNativeWindow</b> instance created.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
OHNativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface);
|
||||
|
||||
/**
|
||||
* @brief Decreases the reference count of a <b>NativeWindow</b> instance by 1, and when the reference count reaches 0, destroys the instance.
|
||||
* @brief Decreases the reference count of a <b>OHNativeWindow</b> instance by 1, and when the reference count reaches 0, destroys the instance.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
void OH_NativeWindow_DestroyNativeWindow(OHNativeWindow* window);
|
||||
|
||||
/**
|
||||
* @brief Creates a <b>NativeWindowBuffer</b> instance. A new <b>NativeWindowBuffer</b> instance is created each time this function is called.
|
||||
* @brief Creates a <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created each time this function is called.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param pSurfaceBuffer Indicates the pointer to a produce buffer. The type is <b>sptr<OHOS::SurfaceBuffer></b>.
|
||||
* @return Returns the pointer to the <b>NativeWindowBuffer</b> instance created.
|
||||
* @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer);
|
||||
|
||||
/**
|
||||
* @brief Decreases the reference count of a <b>NativeWindowBuffer</b> instance by 1 and, when the reference count reaches 0, destroys the instance.
|
||||
* @brief Decreases the reference count of a <b>OHNativeWindowBuffer</b> instance by 1 and, when the reference count reaches 0, destroys the instance.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param buffer Indicates the pointer to a <b>NativeWindowBuffer</b> instance.
|
||||
* @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
void OH_NativeWindow_DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer);
|
||||
|
||||
/**
|
||||
* @brief Requests a <b>NativeWindowBuffer</b> through a <b>NativeWindow</b> instance for content production.
|
||||
* @brief Requests a <b>OHNativeWindowBuffer</b> through a <b>OHNativeWindow</b> instance for content production.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param buffer Indicates the double pointer to a <b>NativeWindowBuffer</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param buffer Indicates the double pointer to a <b>OHNativeWindowBuffer</b> instance.
|
||||
* @param fenceFd Indicates the pointer to a file descriptor handle.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -323,14 +323,14 @@ int32_t OH_NativeWindow_NativeWindowRequestBuffer(OHNativeWindow *window,
|
||||
OHNativeWindowBuffer **buffer, int *fenceFd);
|
||||
|
||||
/**
|
||||
* @brief Flushes the <b>NativeWindowBuffer</b> filled with the content to the buffer queue through a <b>NativeWindow</b> instance for content consumption.
|
||||
* @brief Flushes the <b>OHNativeWindowBuffer</b> filled with the content to the buffer queue through a <b>OHNativeWindow</b> instance for content consumption.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param buffer Indicates the pointer to a <b>NativeWindowBuffer</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
|
||||
* @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization.
|
||||
* @param region Indicates a dirty region where content is updated.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -338,12 +338,12 @@ int32_t OH_NativeWindow_NativeWindowFlushBuffer(OHNativeWindow *window, OHNative
|
||||
int fenceFd, Region region);
|
||||
|
||||
/**
|
||||
* @brief Returns the <b>NativeWindowBuffer</b> to the buffer queue through a <b>NativeWindow</b> instance, without filling in any content. The <b>NativeWindowBuffer</b> can be used for another request.
|
||||
* @brief Returns the <b>OHNativeWindowBuffer</b> to the buffer queue through a <b>OHNativeWindow</b> instance, without filling in any content. The <b>OHNativeWindowBuffer</b> can be used for another request.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param buffer Indicates the pointer to a <b>NativeWindowBuffer</b> instance.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -353,20 +353,20 @@ int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNative
|
||||
* @brief Sets or obtains the attributes of a native window, including the width, height, and content format.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param code Indicates the operation code, pointer to <b>NativeWindowOperation</b>.
|
||||
* @param ... variable parameter, must correspond to code one-to-one.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, ...);
|
||||
|
||||
/**
|
||||
* @brief Obtains the pointer to a <b>BufferHandle</b> of a <b>NativeWindowBuffer</b> instance.
|
||||
* @brief Obtains the pointer to a <b>BufferHandle</b> of a <b>OHNativeWindowBuffer</b> instance.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param buffer Indicates the pointer to a <b>NativeWindowBuffer</b> instance.
|
||||
* @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
|
||||
* @return Returns the pointer to the <b>BufferHandle</b> instance obtained.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
@ -377,8 +377,8 @@ BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *bu
|
||||
* @brief Adds the reference count of a native object.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param obj Indicates the pointer to a <b>NativeWindow</b> or <b>NativeWindowBuffer</b> instance.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -388,8 +388,8 @@ int32_t OH_NativeWindow_NativeObjectReference(void *obj);
|
||||
* @brief Decreases the reference count of a native object and, when the reference count reaches 0, destroys this object.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param obj Indicates the pointer to a <b>NativeWindow</b> or <b>NativeWindowBuffer</b> instance.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -399,7 +399,7 @@ int32_t OH_NativeWindow_NativeObjectUnreference(void *obj);
|
||||
* @brief Obtains the magic ID of a native object.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param obj Indicates the pointer to a <b>NativeWindow</b> or <b>NativeWindowBuffer</b> instance.
|
||||
* @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
|
||||
* @return Returns the magic ID, which is unique for each native object.
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
@ -410,13 +410,13 @@ int32_t OH_NativeWindow_GetNativeObjectMagic(void *obj);
|
||||
* @brief Sets scalingMode of a native window.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param sequence Indicates the sequence to a produce buffer.
|
||||
* @param scalingMode Indicates the enum value to <b>OHScalingMode</b>
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
int32_t OH_NativeWindow_NativeWindowSetScalingMode(OHNativeWindow *window, uint32_t sequence,
|
||||
OHScalingMode scalingMode);
|
||||
@ -425,14 +425,14 @@ int32_t OH_NativeWindow_NativeWindowSetScalingMode(OHNativeWindow *window, uint3
|
||||
* @brief Sets metaData of a native window.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param sequence Indicates the sequence to a produce buffer.
|
||||
* @param size Indicates the size of a <b>OHHDRMetaData</b> vector.
|
||||
* @param metaDate Indicates the pointer to a <b>OHHDRMetaData</b> vector.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
int32_t OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow *window, uint32_t sequence, int32_t size,
|
||||
const OHHDRMetaData *metaData);
|
||||
@ -441,15 +441,15 @@ int32_t OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow *window, uint32_t
|
||||
* @brief Sets metaDataSet of a native window.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param sequence Indicates the sequence to a produce buffer.
|
||||
* @param key Indicates the enum value to <b>OHHDRMetadataKey</b>
|
||||
* @param size Indicates the size of a uint8_t vector.
|
||||
* @param metaDate Indicates the pointer to a uint8_t vector.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key,
|
||||
int32_t size, const uint8_t *metaData);
|
||||
@ -458,12 +458,12 @@ int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint3
|
||||
* @brief Sets tunnel handle of a native window.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
|
||||
* @param window Indicates the pointer to a <b>NativeWindow</b> instance.
|
||||
* @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
|
||||
* @param handle Indicates the pointer to a <b>OHExtDataHandle</b>.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
* @deprecated(since = "9")
|
||||
* @deprecated(since = "10")
|
||||
*/
|
||||
int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle);
|
||||
|
||||
|
@ -78,7 +78,7 @@ OH_NativeBuffer* OH_NativeBuffer_Alloc(const OH_NativeBuffer_Config* config);
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer
|
||||
* @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -90,7 +90,7 @@ int32_t OH_NativeBuffer_Reference(OH_NativeBuffer *buffer);
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer
|
||||
* @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -102,8 +102,7 @@ int32_t OH_NativeBuffer_Unreference(OH_NativeBuffer *buffer);
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer
|
||||
* @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance.
|
||||
* @param config Indicates the pointer to the <b>NativeBufferConfig</b> of the buffer.
|
||||
* @return Returns the pointer to the <b>BufferRequestConfig</b> instance if the operation is successful, \n
|
||||
* returns <b>NULL</b> otherwise.
|
||||
* @return <b>void</b>
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -115,7 +114,7 @@ void OH_NativeBuffer_GetConfig(OH_NativeBuffer *buffer, OH_NativeBuffer_Config*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer
|
||||
* @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance.
|
||||
* @param virAddr Indicates the address of the <b>OH_NativeBuffer</b> in virtual memory.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -127,7 +126,7 @@ int32_t OH_NativeBuffer_Map(OH_NativeBuffer *buffer, void **virAddr);
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer
|
||||
* @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance.
|
||||
* @return Returns an error code defined in <b>GSError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -47,11 +47,11 @@ typedef struct OH_NativeImage OH_NativeImage;
|
||||
typedef struct NativeWindow OHNativeWindow;
|
||||
|
||||
/**
|
||||
* @brief Create a <b>OH_NativeImage</b> related to an OPENGL ES texture and target. \n
|
||||
* @brief Create a <b>OH_NativeImage</b> related to an Opengl ES texture and target. \n
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeImage
|
||||
* @param textureId Indicates the id of the OPENGL ES texture which the native image attached to.
|
||||
* @param textureTarget Indicates the OPENGL ES target.
|
||||
* @param textureId Indicates the id of the Opengl ES texture which the native image attached to.
|
||||
* @param textureTarget Indicates the Opengl ES target.
|
||||
* @return Returns the pointer to the <b>OH_NativeImage</b> instance created if the operation is successful, \n
|
||||
* returns <b>NULL</b> otherwise.
|
||||
* @since 9
|
||||
@ -72,24 +72,24 @@ OH_NativeImage* OH_NativeImage_Create(uint32_t textureId, uint32_t textureTarget
|
||||
OHNativeWindow* OH_NativeImage_AcquireNativeWindow(OH_NativeImage* image);
|
||||
|
||||
/**
|
||||
* @brief Attach the OH_NativeImage to OPENGL ES context, and the OPENGL ES texture is bound to the \n
|
||||
* @brief Attach the OH_NativeImage to Opengl ES context, and the Opengl ES texture is bound to the \n
|
||||
* GL_TEXTURE_EXTERNAL_OES, which will update by the OH_NativeImage.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeImage
|
||||
* @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
|
||||
* @param textureId Indicates the id of the OPENGL ES texture which the native image attached to.
|
||||
* @return Returns an error code defined in <b>SurfaceError</b>.
|
||||
* @param textureId Indicates the id of the Opengl ES texture which the native image attached to.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t OH_NativeImage_AttachContext(OH_NativeImage* image, uint32_t textureId);
|
||||
|
||||
/**
|
||||
* @brief Detach the OH_NativeImage from the OPENGL ES context.
|
||||
* @brief Detach the OH_NativeImage from the Opengl ES context.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeImage
|
||||
* @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
|
||||
* @return Returns an error code defined in <b>SurfaceError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -97,11 +97,11 @@ int32_t OH_NativeImage_AttachContext(OH_NativeImage* image, uint32_t textureId);
|
||||
int32_t OH_NativeImage_DetachContext(OH_NativeImage* image);
|
||||
|
||||
/**
|
||||
* @brief Update the related OPENGL ES texture with the OH_NativeImage acquired buffer.
|
||||
* @brief Update the related Opengl ES texture with the OH_NativeImage acquired buffer.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeImage
|
||||
* @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
|
||||
* @return Returns an error code defined in <b>SurfaceError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
@ -125,7 +125,7 @@ int64_t OH_NativeImage_GetTimestamp(OH_NativeImage* image);
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeImage
|
||||
* @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
|
||||
* @param matrix Indicates the retrieved 4*4 transform matrix .
|
||||
* @return Returns an error code defined in <b>SurfaceError</b>.
|
||||
* @return Returns an error code, 0 is success, otherwise, failed.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -40,7 +40,6 @@ public:
|
||||
virtual int32_t GetFormat() const = 0;
|
||||
virtual uint64_t GetUsage() const = 0;
|
||||
virtual uint64_t GetPhyAddr() const = 0;
|
||||
virtual int32_t GetKey() const = 0;
|
||||
virtual void *GetVirAddr() = 0;
|
||||
virtual int32_t GetFileDescriptor() const = 0;
|
||||
virtual uint32_t GetSize() const = 0;
|
||||
|
@ -253,6 +253,7 @@ using SurfaceBufferUsage = enum {
|
||||
BUFFER_USAGE_CAMERA_WRITE = (1ULL << 13), /**< For camera write case */
|
||||
BUFFER_USAGE_VIDEO_ENCODER = (1ULL << 14), /**< For encode case */
|
||||
BUFFER_USAGE_VIDEO_DECODER = (1ULL << 15), /**< For decode case */
|
||||
BUFFER_USAGE_CPU_READ_OFTEN = (1ULL << 16), /**< CPU read often buffer */
|
||||
BUFFER_USAGE_VENDOR_PRI0 = (1ULL << 44), /**< Reserverd for vendor */
|
||||
BUFFER_USAGE_VENDOR_PRI1 = (1ULL << 45), /**< Reserverd for vendor */
|
||||
BUFFER_USAGE_VENDOR_PRI2 = (1ULL << 46), /**< Reserverd for vendor */
|
||||
|
@ -16,6 +16,7 @@ group("napi_packages") {
|
||||
"graphic/animation/window_animation_manager:windowanimationmanager_napi",
|
||||
"graphic/color_manager:colorspacemanager_napi",
|
||||
"graphic/effect_kit:effectkit",
|
||||
"graphic/hyper_graphic_manager:libhgmnapi",
|
||||
"graphic/webgl:libwebglnapi",
|
||||
]
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ ohos_shared_library("color_space_object_convertor") {
|
||||
deps = [ "//foundation/graphic/graphic_2d/utils:libgraphic_utils" ]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
@ -71,7 +71,7 @@ ohos_shared_library("colorspacemanager_napi") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -28,6 +28,7 @@ namespace {
|
||||
constexpr uint32_t NUM_0 = 0;
|
||||
constexpr uint32_t NUM_1 = 1;
|
||||
constexpr uint32_t NUM_2 = 2;
|
||||
constexpr uint32_t NUM_3 = 3;
|
||||
constexpr uint32_t NUM_4 = 4;
|
||||
}
|
||||
|
||||
@ -50,6 +51,8 @@ struct ColorPickerAsyncContext {
|
||||
std::shared_ptr<ColorPicker> rColorPicker;
|
||||
std::shared_ptr<Media::PixelMap> rPixelMap;
|
||||
ColorManager::Color color;
|
||||
bool regionFlag = false;
|
||||
double coordinatesBuffer[4];
|
||||
};
|
||||
|
||||
static void BuildMsgOnError(napi_env env,
|
||||
@ -216,8 +219,12 @@ static void CreateColorPickerFromPixelmapExecute(napi_env env, void* data)
|
||||
EFFECT_LOG_I("create ColorPicker Execute");
|
||||
auto context = static_cast<ColorPickerAsyncContext*>(data);
|
||||
uint32_t errorCode = ERR_EFFECT_INVALID_VALUE;
|
||||
context->rColorPicker = ColorPicker::CreateColorPicker(context->rPixelMap, errorCode);
|
||||
|
||||
if (context->regionFlag) {
|
||||
context->rColorPicker = ColorPicker::CreateColorPicker(
|
||||
context->rPixelMap, context->coordinatesBuffer, errorCode);
|
||||
} else {
|
||||
context->rColorPicker = ColorPicker::CreateColorPicker(context->rPixelMap, errorCode);
|
||||
}
|
||||
context->status = ERROR;
|
||||
if (IMG_NOT_NULL(context->rColorPicker) && errorCode == SUCCESS) {
|
||||
context->status = SUCCESS;
|
||||
@ -255,6 +262,52 @@ static void CreateColorPickerErrorComplete(napi_env env, napi_status status, voi
|
||||
CommonCallbackRoutine(env, context, result);
|
||||
}
|
||||
|
||||
static bool IsArrayForNapiValue(napi_env env, napi_value param, uint32_t &arraySize)
|
||||
{
|
||||
bool isArray = false;
|
||||
arraySize = 0;
|
||||
if ((napi_is_array(env, param, &isArray) != napi_ok) || (isArray == false)) {
|
||||
return false;
|
||||
}
|
||||
if (napi_get_array_length(env, param, &arraySize) != napi_ok) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool GetRegionCoordinates(napi_env env, napi_value param, std::unique_ptr<ColorPickerAsyncContext>& asyncContext)
|
||||
{
|
||||
uint32_t arraySize = 0;
|
||||
if (!IsArrayForNapiValue(env, param, arraySize)) {
|
||||
EFFECT_LOG_E("GetRegionCoordinates get args fail, not array");
|
||||
return false;
|
||||
}
|
||||
if (arraySize < NUM_4) {
|
||||
EFFECT_LOG_E("GetRegionCoordinates coordinates num less than 4");
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < NUM_4; i++) {
|
||||
napi_value jsValue;
|
||||
if ((napi_get_element(env, param, i, &jsValue)) != napi_ok) {
|
||||
EFFECT_LOG_E("GetRegionCoordinates get args fail");
|
||||
return false;
|
||||
}
|
||||
double value = 0.0;
|
||||
if (napi_get_value_double(env, jsValue, &value) == napi_ok) {
|
||||
asyncContext->coordinatesBuffer[i] = std::clamp<double>(value, 0.0, 1.0);
|
||||
} else {
|
||||
EFFECT_LOG_E("GetRegionCoordinates region coordinates not double");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((asyncContext->coordinatesBuffer[NUM_2] <= asyncContext->coordinatesBuffer[NUM_0]) ||
|
||||
(asyncContext->coordinatesBuffer[NUM_3] <= asyncContext->coordinatesBuffer[NUM_1])) {
|
||||
EFFECT_LOG_E("GetRegionCoordinates right must be greater than left, bottom must be greater than top");
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
napi_value ColorPickerNapi::CreateColorPicker(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
@ -265,7 +318,6 @@ napi_value ColorPickerNapi::CreateColorPicker(napi_env env, napi_callback_info i
|
||||
napi_value argValue[NUM_4] = {0};
|
||||
size_t argCount = NUM_4;
|
||||
ImageType imgType = ImageType::TYPE_UNKOWN;
|
||||
EFFECT_LOG_I("[ColorPickerNapi]Create ColorPicker IN");
|
||||
IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar);
|
||||
IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, EFFECT_LOG_E("fail to napi_get_cb_info"));
|
||||
std::unique_ptr<ColorPickerAsyncContext> asyncContext = std::make_unique<ColorPickerAsyncContext>();
|
||||
@ -279,28 +331,32 @@ napi_value ColorPickerNapi::CreateColorPicker(napi_env env, napi_callback_info i
|
||||
}
|
||||
}
|
||||
IMG_NAPI_CHECK_RET_D(asyncContext->errorMsg == nullptr, nullptr, EFFECT_LOG_E("image type mismatch."));
|
||||
if (argCount == NUM_2 && Media::ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) {
|
||||
napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef);
|
||||
if (argCount == NUM_2) {
|
||||
if (Media::ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) {
|
||||
napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef);
|
||||
} else {
|
||||
IMG_NAPI_CHECK_RET_D(GetRegionCoordinates(
|
||||
env, argValue[NUM_1], asyncContext), nullptr, EFFECT_LOG_E("fail to parse coordinates"));
|
||||
asyncContext->regionFlag = true;
|
||||
}
|
||||
}
|
||||
if (argCount == NUM_3 && Media::ImageNapiUtils::getType(env, argValue[argCount - NUM_2]) == napi_function) {
|
||||
IMG_NAPI_CHECK_RET_D(GetRegionCoordinates(
|
||||
env, argValue[NUM_1], asyncContext), nullptr, EFFECT_LOG_E("fail to parse coordinates"));
|
||||
asyncContext->regionFlag = true;
|
||||
}
|
||||
|
||||
if (asyncContext->callbackRef == nullptr) {
|
||||
napi_create_promise(env, &(asyncContext->deferred), &result);
|
||||
}
|
||||
if (asyncContext->errorMsg != nullptr) {
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status,
|
||||
"CreateColorPickerError",
|
||||
[](napi_env env, void* data) {},
|
||||
CreateColorPickerErrorComplete,
|
||||
asyncContext,
|
||||
asyncContext->work);
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreateColorPickerError", [](napi_env env, void* data) {},
|
||||
CreateColorPickerErrorComplete, asyncContext, asyncContext->work);
|
||||
} else if (imgType == ImageType::TYPE_PIXEL_MAP) {
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status,
|
||||
"CreateColorPickerFromPixelMap",
|
||||
CreateColorPickerFromPixelmapExecute,
|
||||
CreateColorPickerFromPixelmapComplete,
|
||||
asyncContext, asyncContext->work);
|
||||
} else {
|
||||
EFFECT_LOG_E("Create error");
|
||||
IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreateColorPickerFromPixelMap", CreateColorPickerFromPixelmapExecute,
|
||||
CreateColorPickerFromPixelmapComplete, asyncContext, asyncContext->work);
|
||||
}
|
||||
|
||||
IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, EFFECT_LOG_E("fail to create async work"));
|
||||
return result;
|
||||
}
|
||||
|
57
interfaces/kits/napi/graphic/hyper_graphic_manager/BUILD.gn
Normal file
57
interfaces/kits/napi/graphic/hyper_graphic_manager/BUILD.gn
Normal file
@ -0,0 +1,57 @@
|
||||
# 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/graphic/graphic_2d/graphic_config.gni")
|
||||
|
||||
config("graphic_napi_hyper_graphic_manager_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-g3",
|
||||
"-Wno-pointer-arith",
|
||||
"-Wno-non-virtual-dtor",
|
||||
"-Wno-missing-field-initializers",
|
||||
"-Wno-c++11-narrowing",
|
||||
"-Wno-unused-but-set-variable",
|
||||
]
|
||||
|
||||
defines = [ "EGL_EGLEXT_PROTOTYPES" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("libhgmnapi") {
|
||||
include_dirs = [
|
||||
"$graphic_2d_root/rosen/modules/hyper_graphic_manager/config/include",
|
||||
"$graphic_2d_root/rosen/modules/hyper_graphic_manager/utils/include",
|
||||
"$graphic_2d_root/rosen/modules/render_service_base/include/screen_manager",
|
||||
"$graphic_2d_root/rosen/modules/render_service_client/core",
|
||||
]
|
||||
|
||||
configs = [ ":graphic_napi_hyper_graphic_manager_config" ]
|
||||
|
||||
sources = [ "src/hyper_graphic_manager_napi.cpp" ]
|
||||
|
||||
deps = [ "$graphic_2d_root/rosen/modules/render_service_client:librender_service_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
relative_install_dir = "module"
|
||||
part_name = "graphic_standard"
|
||||
subsystem_name = "graphic"
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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 <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "hgm_command.h"
|
||||
#include "hgm_log.h"
|
||||
#include "js_native_api.h"
|
||||
#include "js_native_api_types.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "screen_types.h"
|
||||
#include "transaction/rs_interfaces.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
thread_local static RSInterfaces& interfaces = RSInterfaces::GetInstance();
|
||||
|
||||
static napi_value SetRefreshRateMode(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_status status;
|
||||
HGM_LOGE("Napi SetRefreshRateMode starting");
|
||||
|
||||
size_t argc = 1;
|
||||
napi_value arg[argc];
|
||||
napi_get_cb_info(env, info, &argc, arg, nullptr, nullptr);
|
||||
|
||||
//get refresh rate mode to set
|
||||
napi_valuetype valueType;
|
||||
status = napi_typeof(env, arg[0], &valueType);
|
||||
if (status != napi_ok) {
|
||||
HGM_LOGE("Napi SetRefreshRateMode failed to get argument");
|
||||
napi_throw_error(env, NULL, "Napi SetRefreshRateMode failed to get argument");
|
||||
}
|
||||
if (valueType != napi_number) {
|
||||
HGM_LOGE("Napi SetRefreshRateMode wrong argument type");
|
||||
napi_throw_error(env, NULL, "Napi SetRefreshRateMode wrong argument type");
|
||||
}
|
||||
|
||||
int32_t mode;
|
||||
napi_get_value_int32(env, arg[0], &mode);
|
||||
interfaces.SetRefreshRateMode(mode);
|
||||
|
||||
napi_value napiValue = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, EXEC_SUCCESS, &napiValue));
|
||||
return napiValue;
|
||||
}
|
||||
|
||||
static napi_value GetScreenCurrentRefreshRate(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_status status;
|
||||
HGM_LOGE("Napi GetScreenCurrentRefreshRate starting");
|
||||
|
||||
size_t argc = 1;
|
||||
napi_value arg[argc];
|
||||
napi_get_cb_info(env, info, &argc, arg, nullptr, nullptr);
|
||||
|
||||
//get the screenId
|
||||
napi_valuetype valueType;
|
||||
status = napi_typeof(env, arg[0], &valueType);
|
||||
if (status != napi_ok) {
|
||||
HGM_LOGE("Napi GetScreenCurrentRefreshRate failed to get argument");
|
||||
napi_throw_error(env, NULL, "Napi GetScreenCurrentRefreshRate failed to get argument");
|
||||
}
|
||||
if (valueType != napi_number) {
|
||||
HGM_LOGE("Napi GetScreenCurrentRefreshRate wrong argument type");
|
||||
napi_throw_error(env, NULL, "Napi GetScreenCurrentRefreshRate wrong argument type");
|
||||
}
|
||||
|
||||
int32_t screen = 0;
|
||||
ScreenId id = 0;
|
||||
napi_get_value_int32(env, arg[0], &screen);
|
||||
if (screen < 0) {
|
||||
HGM_LOGE("Napi GetScreenCurrentRefreshRate illegal screenId input: %d", screen);
|
||||
napi_throw_error(env, NULL, "Napi GetScreenCurrentRefreshRate illegal screenId");
|
||||
} else {
|
||||
id = static_cast<ScreenId>(screen);
|
||||
}
|
||||
|
||||
uint32_t currentRate = interfaces.GetScreenCurrentRefreshRate(id);
|
||||
int32_t returnInt = 0;
|
||||
if (currentRate > static_cast<uint32_t>(OLED_MAX_HZ)) {
|
||||
HGM_LOGE("Napi GetScreenCurrentRefreshRate got a rate too above maximal value");
|
||||
napi_throw_error(env, NULL, "Napi GetScreenCurrentRefreshRate got a rate too above maximal value");
|
||||
} else {
|
||||
returnInt = static_cast<int32_t>(currentRate);
|
||||
}
|
||||
|
||||
napi_value returnRate = nullptr;
|
||||
napi_create_int32(env, returnInt, &returnRate);
|
||||
return returnRate;
|
||||
}
|
||||
|
||||
static napi_value GetScreenSupportedRefreshRates(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_status status;
|
||||
HGM_LOGE("Napi GetScreenSupportedRefreshRates starting");
|
||||
|
||||
size_t argc = 1;
|
||||
napi_value arg[argc];
|
||||
napi_get_cb_info(env, info, &argc, arg, nullptr, nullptr);
|
||||
|
||||
//get the screenId
|
||||
napi_valuetype valueType;
|
||||
status = napi_typeof(env, arg[0], &valueType);
|
||||
if (status != napi_ok) {
|
||||
HGM_LOGE("Napi GetScreenSupportedRefreshRates failed to get argument");
|
||||
napi_throw_error(env, NULL, "Napi GetScreenSupportedRefreshRates failed to get argument");
|
||||
}
|
||||
if (valueType != napi_number) {
|
||||
HGM_LOGE("Napi GetScreenSupportedRefreshRates wrong argument type");
|
||||
napi_throw_error(env, NULL, "Napi GetScreenSupportedRefreshRates wrong argument type");
|
||||
}
|
||||
|
||||
int32_t screen = 0;
|
||||
ScreenId id = 0;
|
||||
napi_get_value_int32(env, arg[0], &screen);
|
||||
if (screen < 0) {
|
||||
HGM_LOGE("Napi GetScreenSupportedRefreshRates illegal screenId input: %d", screen);
|
||||
napi_throw_error(env, NULL, "Napi GetScreenSupportedRefreshRates illegal screenId input");
|
||||
} else {
|
||||
id = static_cast<ScreenId>(screen);
|
||||
}
|
||||
std::vector<uint32_t> currentRates = interfaces.GetScreenSupportedRefreshRates(id);
|
||||
|
||||
napi_value returnRates = nullptr;
|
||||
NAPI_CALL(env, napi_create_array(env, &returnRates));
|
||||
int numSupportedRates = currentRates.size();
|
||||
std::vector<napi_value> napiVector(numSupportedRates, nullptr);
|
||||
for (int index = 0; index < numSupportedRates; ++index) {
|
||||
if (currentRates[index] > static_cast<uint32_t>(OLED_MAX_HZ)) {
|
||||
HGM_LOGE("Napi GetScreenCurrentRefreshRate got a rate too above maximal value");
|
||||
napi_throw_error(env, NULL, "Napi GetScreenCurrentRefreshRate got a rate too above maximal value");
|
||||
}
|
||||
NAPI_CALL(env, napi_create_int32(env, currentRates[index], &napiVector[index]));
|
||||
NAPI_CALL(env, napi_set_element(env, returnRates, currentRates[index], napiVector[index]));
|
||||
}
|
||||
|
||||
return returnRates;
|
||||
}
|
||||
|
||||
EXTERN_C_START
|
||||
static napi_value HgmInit(napi_env env, napi_value exports)
|
||||
{
|
||||
HGM_LOGD("HgmInit Napi");
|
||||
|
||||
napi_property_descriptor desc[] = {
|
||||
DECLARE_NAPI_FUNCTION("setRefreshRateMode", SetRefreshRateMode),
|
||||
DECLARE_NAPI_FUNCTION("getScreenCurrentRefreshRate", GetScreenCurrentRefreshRate),
|
||||
DECLARE_NAPI_FUNCTION("getScreenSupportedRefreshRates", GetScreenSupportedRefreshRates),
|
||||
};
|
||||
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(napi_property_descriptor), desc));
|
||||
|
||||
return exports;
|
||||
}
|
||||
EXTERN_C_END
|
||||
|
||||
static napi_module hgm_module = {
|
||||
.nm_version = 1,
|
||||
.nm_flags = 0,
|
||||
.nm_filename = "libhgmnapi",
|
||||
.nm_register_func = HgmInit,
|
||||
.nm_modname = "libhgmnapi",
|
||||
.nm_priv = ((void*)0),
|
||||
.reserved = {0}
|
||||
};
|
||||
|
||||
extern "C" __attribute__((constructor)) void RegisterModule(void)
|
||||
{
|
||||
napi_module_register(&hgm_module);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -35,7 +35,7 @@ ohos_source_set("webgl_src") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -186,7 +186,7 @@ template("flutter_engine_fml") {
|
||||
"$flutter_root/engine/flutter/fml/platform/linux/message_loop_linux.cc",
|
||||
"$flutter_root/engine/flutter/fml/platform/linux/paths_linux.cc",
|
||||
]
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
} else {
|
||||
sources += [
|
||||
"$flutter_root/engine/flutter/fml/platform/android/jni_util.cc",
|
||||
|
@ -125,7 +125,7 @@ template("graphics2d_source_set") {
|
||||
|
||||
if (platform == "ohos") {
|
||||
external_deps = [
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"multimedia_image_framework:image_native",
|
||||
]
|
||||
deps = [
|
||||
@ -277,7 +277,7 @@ ohos_shared_library("2d_graphics_canvaskit0310") {
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"multimedia_image_framework:image_native",
|
||||
]
|
||||
|
||||
|
@ -41,11 +41,7 @@ void MemoryHandler::ConfigureContext(Drawing::GPUContextOptions* context, const
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NEW_RENDER_CONTEXT
|
||||
std::string MemoryHandler::QuerryShader()
|
||||
#else
|
||||
std::string MemoryHandler::QuerryShader() const
|
||||
#endif
|
||||
{
|
||||
const auto& cache = ShaderCache::Instance();
|
||||
if (!cache.IfInitialized()) {
|
||||
@ -58,11 +54,7 @@ std::string MemoryHandler::QuerryShader() const
|
||||
return ramString;
|
||||
}
|
||||
|
||||
#ifdef NEW_RENDER_CONTEXT
|
||||
std::string MemoryHandler::ClearShader()
|
||||
#else
|
||||
std::string MemoryHandler::ClearShader() const
|
||||
#endif
|
||||
{
|
||||
const auto& cache = ShaderCache::Instance();
|
||||
LOGW("All shaders are cleaned");
|
||||
|
@ -41,13 +41,8 @@ public:
|
||||
const std::string& cacheFilePath, bool isUni);
|
||||
#endif
|
||||
MemoryHandler() = default;
|
||||
#ifdef NEW_RENDER_CONTEXT
|
||||
static std::string QuerryShader();
|
||||
static std::string ClearShader();
|
||||
#else
|
||||
std::string QuerryShader() const;
|
||||
std::string ClearShader() const;
|
||||
#endif
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -35,7 +35,7 @@ ohos_shared_library("window_animation") {
|
||||
|
||||
external_deps = [
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
|
@ -40,7 +40,7 @@ ohos_unittest("RSWindowAnimationTest") {
|
||||
"access_token:libtoken_setproc",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
|
@ -60,24 +60,22 @@ ohos_shared_library("libcomposer") {
|
||||
"//commonlibrary/c_utils/base:utils_config",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"$graphic_2d_root:libsurface",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
]
|
||||
deps = [ "$graphic_2d_root:libsurface" ]
|
||||
|
||||
public_deps = [
|
||||
"$graphic_2d_root/utils:buffer_handle",
|
||||
"$graphic_2d_root/utils:scoped_bytrace",
|
||||
"$graphic_2d_root/utils:sync_fence",
|
||||
"vsync:libvsync",
|
||||
"//commonlibrary/c_utils/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"drivers_interface_display:display_buffer_idl_headers",
|
||||
"drivers_interface_display:display_composer_idl_headers",
|
||||
"drivers_interface_display:libdisplay_composer_hdi_impl",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
part_name = "graphic_standard"
|
||||
|
@ -428,9 +428,7 @@ int32_t HdiOutput::ReleaseFramebuffer(const sptr<SyncFence>& releaseFence)
|
||||
|
||||
int32_t ret = GRAPHIC_DISPLAY_SUCCESS;
|
||||
if (lastFrameBuffer_ != nullptr) {
|
||||
// wrong check
|
||||
if (!CheckFbSurface()) {
|
||||
HLOGE("Current frame buffer is nullptr.");
|
||||
if (!CheckFbSurface()) { // wrong check
|
||||
ret = GRAPHIC_DISPLAY_NULL_PTR;
|
||||
} else {
|
||||
ret = fbSurface_->ReleaseFramebuffer(lastFrameBuffer_, releaseFence);
|
||||
@ -438,6 +436,7 @@ int32_t HdiOutput::ReleaseFramebuffer(const sptr<SyncFence>& releaseFence)
|
||||
}
|
||||
|
||||
lastFrameBuffer_ = currFrameBuffer_;
|
||||
currFrameBuffer_ = nullptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/graphic/graphic_2d/graphic_config.gni")
|
||||
|
||||
## Build libnative_vsync.so
|
||||
|
||||
@ -47,10 +48,9 @@ ohos_shared_library("libnative_vsync") {
|
||||
|
||||
output_extension = "so"
|
||||
|
||||
deps = [
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
]
|
||||
deps = [ "$graphic_2d_root/rosen/modules/render_service_client:librender_service_client" ]
|
||||
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
part_name = "graphic_standard"
|
||||
subsystem_name = "graphic"
|
||||
|
@ -63,16 +63,14 @@ ohos_shared_library("libvsync") {
|
||||
deps = [
|
||||
"$graphic_2d_root/utils:sandbox_utils",
|
||||
"$graphic_2d_root/utils:socketpair",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"$graphic_2d_root/utils:scoped_bytrace",
|
||||
"//commonlibrary/c_utils/base:utils",
|
||||
]
|
||||
public_deps = [ "$graphic_2d_root/utils:scoped_bytrace" ]
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog_native:libhilog",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
if (defined(graphic_2d_ext_configs.vendor_root)) {
|
||||
|
@ -32,6 +32,8 @@ public:
|
||||
// if rate > 0, we will continue to send Vsync signals at a frequency of FREQ / rate
|
||||
virtual VsyncError SetVSyncRate(int32_t rate) = 0;
|
||||
|
||||
virtual VsyncError GetVSyncPeriod(int64_t &period) = 0;
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IVSyncConnection");
|
||||
|
||||
protected:
|
||||
@ -39,6 +41,7 @@ protected:
|
||||
IVSYNC_CONNECTION_REQUEST_NEXT_VSYNC,
|
||||
IVSYNC_CONNECTION_GET_RECEIVE_FD,
|
||||
IVSYNC_CONNECTION_SET_RATE,
|
||||
IVSYNC_CONNECTION_GET_PERIOD,
|
||||
};
|
||||
};
|
||||
} // namespace Vsync
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
virtual VsyncError RequestNextVSync() override;
|
||||
virtual VsyncError GetReceiveFd(int32_t &fd) override;
|
||||
virtual VsyncError SetVSyncRate(int32_t rate) override;
|
||||
virtual VsyncError GetVSyncPeriod(int64_t &period) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<VSyncConnectionProxy> delegator_;
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
virtual VsyncError RequestNextVSync() override;
|
||||
virtual VsyncError GetReceiveFd(int32_t &fd) override;
|
||||
virtual VsyncError SetVSyncRate(int32_t rate) override;
|
||||
virtual VsyncError GetVSyncPeriod(int64_t &period) override;
|
||||
|
||||
int32_t PostEvent(int64_t now, int64_t period, int64_t vsyncCount);
|
||||
|
||||
@ -79,6 +80,7 @@ public:
|
||||
VsyncError GetVSyncConnectionInfos(std::vector<ConnectionInfo>& infos);
|
||||
VsyncError GetQosVSyncRateInfos(std::vector<std::pair<uint32_t, int32_t>>& vsyncRateInfos);
|
||||
VsyncError SetQosVSyncRate(uint32_t pid, int32_t rate);
|
||||
VsyncError GetVSyncPeriod(int64_t &period);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -69,5 +69,20 @@ VsyncError VSyncConnectionProxy::SetVSyncRate(int32_t rate)
|
||||
}
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
|
||||
VsyncError VSyncConnectionProxy::GetVSyncPeriod(int64_t &period)
|
||||
{
|
||||
MessageOption opt;
|
||||
MessageParcel arg;
|
||||
MessageParcel ret;
|
||||
|
||||
arg.WriteInterfaceToken(GetDescriptor());
|
||||
int res = Remote()->SendRequest(IVSYNC_CONNECTION_GET_PERIOD, arg, ret, opt);
|
||||
if (res != NO_ERROR) {
|
||||
return VSYNC_ERROR_BINDER_ERROR;
|
||||
}
|
||||
period = ret.ReadInt64();
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
} // namespace Vsync
|
||||
} // namespace OHOS
|
||||
|
@ -51,6 +51,15 @@ int32_t VSyncConnectionStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IVSYNC_CONNECTION_GET_PERIOD: {
|
||||
int64_t period = 0;
|
||||
int32_t ret = GetVSyncPeriod(period);
|
||||
if (ret != VSYNC_ERROR_OK) {
|
||||
return ret;
|
||||
}
|
||||
reply.WriteInt64(period);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// check add log
|
||||
return VSYNC_ERROR_INVALID_OPERATING;
|
||||
|
@ -97,6 +97,15 @@ VsyncError VSyncConnection::SetVSyncRate(int32_t rate)
|
||||
return distributor->SetVSyncRate(rate, this);
|
||||
}
|
||||
|
||||
VsyncError VSyncConnection::GetVSyncPeriod(int64_t &period)
|
||||
{
|
||||
const sptr<VSyncDistributor> distributor = distributor_.promote();
|
||||
if (distributor == nullptr) {
|
||||
return VSYNC_ERROR_NULLPTR;
|
||||
}
|
||||
return distributor->GetVSyncPeriod(period);
|
||||
}
|
||||
|
||||
VSyncDistributor::VSyncDistributor(sptr<VSyncController> controller, std::string name)
|
||||
: controller_(controller), mutex_(), con_(), connections_(),
|
||||
event_(), vsyncEnabled_(false), name_(name)
|
||||
@ -389,5 +398,12 @@ VsyncError VSyncDistributor::GetQosVSyncRateInfos(std::vector<std::pair<uint32_t
|
||||
}
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
|
||||
VsyncError VSyncDistributor::GetVSyncPeriod(int64_t &period)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
period = event_.period;
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,5 +140,14 @@ VsyncError VSyncReceiver::SetVSyncRate(FrameCallback callback, int32_t rate)
|
||||
listener_->SetCallback(callback);
|
||||
return connection_->SetVSyncRate(rate);
|
||||
}
|
||||
|
||||
VsyncError VSyncReceiver::GetVSyncPeriod(int64_t &period)
|
||||
{
|
||||
VsyncError ret = connection_->GetVSyncPeriod(period);
|
||||
if (ret != VSYNC_ERROR_OK) {
|
||||
VLOGE("%{public}s get vsync period failed", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -35,6 +35,7 @@ ohos_fuzztest("VsyncControllerFuzzTest") {
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/composer/vsync:libvsync",
|
||||
]
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
@ -35,6 +35,7 @@ ohos_fuzztest("VsyncSamplerFuzzTest") {
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/composer/vsync:libvsync",
|
||||
]
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
@ -50,6 +50,7 @@ ohos_unittest("vsync_controller_test") {
|
||||
sources = [ "vsync_controller_test.cpp" ]
|
||||
|
||||
deps = [ ":vsync_test_common" ]
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
## UnitTest vsync_controller_test }}}
|
||||
@ -75,6 +76,7 @@ ohos_unittest("vsync_generator_test") {
|
||||
sources = [ "vsync_generator_test.cpp" ]
|
||||
|
||||
deps = [ ":vsync_test_common" ]
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
## UnitTest vsync_generator_test }}}
|
||||
@ -101,6 +103,7 @@ ohos_unittest("vsync_sampler_test") {
|
||||
sources = [ "vsync_sampler_test.cpp" ]
|
||||
|
||||
deps = [ ":vsync_test_common" ]
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
## UnitTest vsync_sampler_test }}}
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
|
||||
protected:
|
||||
ColorExtract(std::shared_ptr<Media::PixelMap> pixmap);
|
||||
ColorExtract(std::shared_ptr<Media::PixelMap> pixmap, double* coordinates);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -43,7 +43,9 @@ class ColorPicker : public ColorExtract {
|
||||
public:
|
||||
~ColorPicker() {}
|
||||
NATIVEEXPORT static std::shared_ptr<ColorPicker> CreateColorPicker(const std::shared_ptr<Media::PixelMap>& pixmap,
|
||||
uint32_t &errorCode);
|
||||
uint32_t &errorCode);
|
||||
NATIVEEXPORT static std::shared_ptr<ColorPicker> CreateColorPicker(const std::shared_ptr<Media::PixelMap>& pixmap,
|
||||
double* coordinates, uint32_t &errorCode);
|
||||
NATIVEEXPORT std::shared_ptr<Media::PixelMap> GetScaledPixelMap();
|
||||
NATIVEEXPORT uint32_t GetMainColor(ColorManager::Color &color);
|
||||
|
||||
@ -54,6 +56,7 @@ public:
|
||||
|
||||
private:
|
||||
ColorPicker(std::shared_ptr<Media::PixelMap> pixmap);
|
||||
ColorPicker(std::shared_ptr<Media::PixelMap> pixmap, double* coordinates);
|
||||
bool IsEquals(double val1, double val2) const;
|
||||
HSV RGB2HSV(uint32_t rgb) const;
|
||||
void AdjustHSVToDefinedIterval(HSV& hsv) const;
|
||||
|
@ -50,6 +50,34 @@ ColorExtract::ColorExtract(std::shared_ptr<Media::PixelMap> pixmap)
|
||||
GetNFeatureColors(specifiedFeatureColorNum_);
|
||||
}
|
||||
|
||||
ColorExtract::ColorExtract(std::shared_ptr<Media::PixelMap> pixmap, double* coordinates)
|
||||
{
|
||||
if (pixmap == nullptr) {
|
||||
return;
|
||||
}
|
||||
pixelmap_ = pixmap;
|
||||
uint32_t left = static_cast<uint32_t>(pixmap->GetWidth() * coordinates[0]); // 0 is index of left
|
||||
uint32_t top = static_cast<uint32_t>(pixmap->GetHeight() * coordinates[1]); // 1 is index of top
|
||||
uint32_t right = static_cast<uint32_t>(pixmap->GetWidth() * coordinates[2]); // 2 is index of right
|
||||
uint32_t bottom = static_cast<uint32_t>(pixmap->GetHeight() * coordinates[3]); // 3 is index of bottom
|
||||
colorValLen_ = (right - left) * (bottom -top);
|
||||
if (colorValLen_ <= 0) {
|
||||
return;
|
||||
}
|
||||
auto colorVal = new uint32_t[colorValLen_]();
|
||||
std::shared_ptr<uint32_t> colorShared(colorVal, [](uint32_t *ptr) {
|
||||
delete[] ptr;
|
||||
});
|
||||
colorVal_ = std::move(colorShared);
|
||||
for (uint32_t i = top; i < bottom; i++) {
|
||||
for (uint32_t j = left; j < right; j++) {
|
||||
pixmap->GetARGB32Color(j, i, colorVal[(i - top) * (right - left) + (j - left)]);
|
||||
}
|
||||
}
|
||||
grayMsd_ = CalcGrayMsd();
|
||||
contrastToWhite_ = CalcContrastToWhite();
|
||||
GetNFeatureColors(specifiedFeatureColorNum_);
|
||||
}
|
||||
|
||||
// Return red component of a quantized color
|
||||
uint32_t ColorExtract::QuantizedRed(uint32_t color)
|
||||
@ -174,6 +202,9 @@ uint8_t ColorExtract::Rgb2Gray(uint32_t color)
|
||||
|
||||
uint32_t ColorExtract::CalcGrayMsd() const
|
||||
{
|
||||
if (colorValLen_ == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t *colorVal = colorVal_.get();
|
||||
long long int graySum = 0;
|
||||
long long int grayVar = 0;
|
||||
@ -212,6 +243,9 @@ float ColorExtract::CalcRelativeLum(uint32_t color)
|
||||
|
||||
float ColorExtract::CalcContrastToWhite() const
|
||||
{
|
||||
if (colorValLen_ == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
uint32_t *colorVal = colorVal_.get();
|
||||
float lightDegree = 0;
|
||||
float luminanceSum = 0;
|
||||
@ -226,6 +260,9 @@ float ColorExtract::CalcContrastToWhite() const
|
||||
|
||||
void ColorExtract::GetNFeatureColors(int colorNum)
|
||||
{
|
||||
if (colorValLen_ == 0) {
|
||||
return;
|
||||
}
|
||||
uint32_t *colorVal = colorVal_.get();
|
||||
uint32_t histLen = (1 << (QUANTIZE_WORD_WIDTH * 3));
|
||||
auto hist = new uint32_t[histLen]();
|
||||
|
@ -62,6 +62,25 @@ std::shared_ptr<ColorPicker> ColorPicker::CreateColorPicker(const std::shared_pt
|
||||
return std::shared_ptr<ColorPicker>(colorPicker);
|
||||
}
|
||||
|
||||
std::shared_ptr<ColorPicker> ColorPicker::CreateColorPicker(const std::shared_ptr<Media::PixelMap>& pixmap,
|
||||
double* coordinates, uint32_t &errorCode)
|
||||
{
|
||||
if (pixmap == nullptr) {
|
||||
HiLog::Info(LABEL, "[ColorPicker]failed to create ColorPicker with null pixmap.");
|
||||
errorCode = ERR_EFFECT_INVALID_VALUE;
|
||||
return nullptr;
|
||||
}
|
||||
ColorPicker *colorPicker = new (std::nothrow) ColorPicker(pixmap, coordinates);
|
||||
if (colorPicker == nullptr) {
|
||||
HiLog::Info(LABEL, "[ColorPicker]failed to create ColorPicker with pixmap.");
|
||||
errorCode = ERR_EFFECT_INVALID_VALUE;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
errorCode = SUCCESS;
|
||||
return std::shared_ptr<ColorPicker>(colorPicker);
|
||||
}
|
||||
|
||||
std::shared_ptr<Media::PixelMap> ColorPicker::GetScaledPixelMap()
|
||||
{
|
||||
// Create scaled pixelmap
|
||||
@ -94,6 +113,8 @@ uint32_t ColorPicker::GetMainColor(ColorManager::Color &color)
|
||||
}
|
||||
|
||||
ColorPicker::ColorPicker(std::shared_ptr<Media::PixelMap> pixmap):ColorExtract(pixmap) {}
|
||||
ColorPicker::ColorPicker(
|
||||
std::shared_ptr<Media::PixelMap> pixmap, double* coordinates):ColorExtract(pixmap, coordinates) {}
|
||||
|
||||
uint32_t ColorPicker::GetLargestProportionColor(ColorManager::Color &color) const
|
||||
{
|
||||
|
@ -126,6 +126,64 @@ HWTEST_F(ColorPickerUnittest, CreateColorPickerFromPixelmapTest003, TestSize.Lev
|
||||
EXPECT_EQ(pColorPicker, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CreateColorPickerFromPixelmapTest004
|
||||
* @tc.desc: Ensure the ability of creating color picker from pixelmap.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
*/
|
||||
HWTEST_F(ColorPickerUnittest, CreateColorPickerFromPixelmapTest004, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ColorPickerUnittest CreateColorPickerFromPixelmapTest004 start";
|
||||
/**
|
||||
* @tc.steps: step1. Create a pixelmap
|
||||
*/
|
||||
Media::InitializationOptions opts;
|
||||
opts.size.width = 200;
|
||||
opts.size.height = 150;
|
||||
opts.editable = true;
|
||||
std::unique_ptr<Media::PixelMap> pixmap = Media::PixelMap::Create(opts);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. Call create From pixelMap
|
||||
*/
|
||||
uint32_t errorCode = SUCCESS;
|
||||
double region[4] = {0, 0, 0.5, 0.5};
|
||||
std::shared_ptr<ColorPicker> pColorPicker = ColorPicker::CreateColorPicker(std::move(pixmap), region, errorCode);
|
||||
ASSERT_EQ(errorCode, SUCCESS);
|
||||
EXPECT_NE(pColorPicker, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CreateColorPickerFromPixelmapTest005
|
||||
* @tc.desc: Ensure the ability of creating color picker from pixelmap.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
*/
|
||||
HWTEST_F(ColorPickerUnittest, CreateColorPickerFromPixelmapTest005, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "ColorPickerUnittest CreateColorPickerFromPixelmapTest005 start";
|
||||
/**
|
||||
* @tc.steps: step1. Create a pixelmap
|
||||
*/
|
||||
Media::InitializationOptions opts;
|
||||
opts.size.width = 200;
|
||||
opts.size.height = 150;
|
||||
opts.editable = true;
|
||||
std::unique_ptr<Media::PixelMap> pixmap = Media::PixelMap::Create(opts);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. Call create From pixelMap
|
||||
*/
|
||||
uint32_t errorCode = SUCCESS;
|
||||
double region[4] = {0, 0.5, 0.5, 0.5};
|
||||
std::shared_ptr<ColorPicker> pColorPicker = ColorPicker::CreateColorPicker(std::move(pixmap), region, errorCode);
|
||||
ASSERT_EQ(pColorPicker->colorValLen_, 0);
|
||||
EXPECT_NE(pColorPicker, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetMainColorTest001
|
||||
* @tc.desc: Ensure the ability of creating effect chain from config file.
|
||||
|
@ -58,7 +58,7 @@ ohos_shared_library("libframe_analyzer") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
|
@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/graphic/graphic_2d/graphic_config.gni")
|
||||
@ -45,7 +45,7 @@ ohos_shared_library("libhyper_graphic_manager") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
@ -54,7 +54,7 @@ ohos_shared_library("libhyper_graphic_manager") {
|
||||
subsystem_name = "graphic"
|
||||
|
||||
if (is_standard_system) {
|
||||
external_deps += [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
external_deps += [ "hilog:libhilog" ]
|
||||
} else {
|
||||
external_deps += [ "hilog:libhilog" ]
|
||||
}
|
||||
|
@ -155,6 +155,13 @@ int32_t XMLParser::ParseParams(xmlNode &node)
|
||||
}
|
||||
return EXEC_SUCCESS;
|
||||
}
|
||||
|
||||
if (paraName == "app_whitelist") {
|
||||
if (ParseSetting(node, mParsedData_->app_whitelist_) != EXEC_SUCCESS) {
|
||||
HGM_LOGD("XMLParser failed to parse app_whitelist");
|
||||
}
|
||||
return EXEC_SUCCESS;
|
||||
}
|
||||
HGM_LOGD("XMLParser parsing params finish");
|
||||
return XML_PARSE_INTERNAL_FAIL;
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ public:
|
||||
std::unordered_map<std::string, std::string> customerSettingConfig_;
|
||||
std::unordered_map<std::string, detailedStrat> detailedStrategies_;
|
||||
std::unordered_map<std::string, std::string> animationDynamicStrats_;
|
||||
std::unordered_map<std::string, std::string> app_whitelist_;
|
||||
};
|
||||
} // namespace OHOS
|
||||
#endif // HGM_COMMAND_H
|
@ -39,6 +39,12 @@
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define RS_EXPORT __attribute__((dllexport))
|
||||
#else
|
||||
#define RS_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
/**
|
||||
* @ingroup SmartPointer
|
||||
@ -376,7 +382,7 @@ private:
|
||||
* @note All classes which intend to be managed by smart pointers should be
|
||||
* derived from RefBase.
|
||||
*/
|
||||
class RefBase {
|
||||
class RS_EXPORT RefBase {
|
||||
public:
|
||||
RefBase();
|
||||
|
||||
|
@ -146,8 +146,8 @@ ohos_shared_library("librender_service") {
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hicollie:libhicollie",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -25,8 +25,18 @@
|
||||
#include "pipeline/rs_uni_render_util.h"
|
||||
#include "pipeline/rs_uni_render_visitor.h"
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
#include "res_type.h"
|
||||
#include "res_sched_client.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
namespace {
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
const uint32_t RS_SUB_QOS_LEVEL = 7;
|
||||
constexpr const char* RS_BUNDLE_NAME = "render_service";
|
||||
#endif
|
||||
}
|
||||
RSSubThread::~RSSubThread()
|
||||
{
|
||||
RS_LOGI("~RSSubThread():%d", threadIndex_);
|
||||
@ -42,6 +52,19 @@ void RSSubThread::Start()
|
||||
runner_ = AppExecFwk::EventRunner::Create(name);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(runner_);
|
||||
PostTask([this]() {
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
std::string strBundleName = RS_BUNDLE_NAME;
|
||||
std::string strPid = std::to_string(getpid());
|
||||
std::string strTid = std::to_string(gettid());
|
||||
std::string strQos = std::to_string(RS_SUB_QOS_LEVEL);
|
||||
std::unordered_map<std::string, std::string> mapPayload;
|
||||
mapPayload["pid"] = strPid;
|
||||
mapPayload[strTid] = strQos;
|
||||
mapPayload["bundleName"] = strBundleName;
|
||||
uint32_t type = OHOS::ResourceSchedule::ResType::RES_TYPE_THREAD_QOS_CHANGE;
|
||||
int64_t value = 0;
|
||||
OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(type, value, mapPayload);
|
||||
#endif
|
||||
CreateShareEglContext();
|
||||
});
|
||||
}
|
||||
@ -146,6 +169,7 @@ void RSSubThread::RenderCache(const std::shared_ptr<RSSuperRenderTask>& threadTa
|
||||
surfaceNodePtr->GetCacheSurface()->flushAndSubmit(false);
|
||||
}
|
||||
#endif
|
||||
surfaceNodePtr->UpdateBackendTexture();
|
||||
surfaceNodePtr->SetCacheSurfaceProcessedStatus(CacheProcessStatus::DONE);
|
||||
|
||||
if (needNotify) {
|
||||
|
@ -67,6 +67,7 @@ void RSSubThreadManager::SubmitSubThreadTask(const std::shared_ptr<RSDisplayRend
|
||||
auto cacheSkippedNodeMap = RSMainThread::Instance()->GetCacheCmdSkippedNodes();
|
||||
for (const auto& child : subThreadNodes) {
|
||||
if (!child->ShouldPaint()) {
|
||||
RS_TRACE_NAME_FMT("SubmitTask skip node: [%s, %llu]", child->GetName().c_str(), child->GetId());
|
||||
continue;
|
||||
}
|
||||
if (cacheSkippedNodeMap.count(child->GetId()) != 0 && child->HasCachedTexture()) {
|
||||
@ -84,8 +85,8 @@ void RSSubThreadManager::SubmitSubThreadTask(const std::shared_ptr<RSDisplayRend
|
||||
RSMainThread::Instance()->GetFrameCount()));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < renderTaskList.size(); i++) {
|
||||
auto renderNode = renderTaskList[i]->GetNode();
|
||||
for (auto& renderTask : renderTaskList) {
|
||||
auto renderNode = renderTask->GetNode();
|
||||
auto surfaceNode = renderNode->ReinterpretCastTo<RSSurfaceRenderNode>();
|
||||
if (surfaceNode == nullptr) {
|
||||
ROSEN_LOGE("RSSubThreadManager::SubmitSubThreadTask surfaceNode is null");
|
||||
@ -93,20 +94,24 @@ void RSSubThreadManager::SubmitSubThreadTask(const std::shared_ptr<RSDisplayRend
|
||||
}
|
||||
auto threadIndex = surfaceNode->GetSubmittedSubThreadIndex();
|
||||
if (threadIndex != INT_MAX && superRenderTaskList[threadIndex]) {
|
||||
superRenderTaskList[threadIndex]->AddTask(std::move(renderTaskList[i]));
|
||||
RS_TRACE_NAME("node:[ " + surfaceNode->GetName() + ", " + std::to_string(surfaceNode->GetId()) +
|
||||
", " + std::to_string(threadIndex) + " ]; ");
|
||||
superRenderTaskList[threadIndex]->AddTask(std::move(renderTask));
|
||||
} else {
|
||||
if (superRenderTaskList[minLoadThreadIndex_]) {
|
||||
superRenderTaskList[minLoadThreadIndex_]->AddTask(std::move(renderTaskList[i]));
|
||||
RS_TRACE_NAME("node:[ " + surfaceNode->GetName() + ", " + std::to_string(surfaceNode->GetId()) +
|
||||
", " + std::to_string(minLoadThreadIndex_) + " ]; ");
|
||||
superRenderTaskList[minLoadThreadIndex_]->AddTask(std::move(renderTask));
|
||||
surfaceNode->SetSubmittedSubThreadIndex(minLoadThreadIndex_);
|
||||
}
|
||||
}
|
||||
uint32_t minLoadThreadIndex = 0;
|
||||
auto minNodesNum = superRenderTaskList[0]->GetTaskSize();
|
||||
for (uint32_t j = 0; j < SUB_THREAD_NUM; j++) {
|
||||
auto num = superRenderTaskList[j]->GetTaskSize();
|
||||
for (uint32_t i = 0; i < SUB_THREAD_NUM; i++) {
|
||||
auto num = superRenderTaskList[i]->GetTaskSize();
|
||||
if (num < minNodesNum) {
|
||||
minNodesNum = num;
|
||||
minLoadThreadIndex = j;
|
||||
minLoadThreadIndex = i;
|
||||
}
|
||||
}
|
||||
minLoadThreadIndex_ = minLoadThreadIndex;
|
||||
@ -136,38 +141,4 @@ void RSSubThreadManager::NodeTaskNotify(uint64_t nodeId)
|
||||
}
|
||||
cvParallelRender_.notify_one();
|
||||
}
|
||||
|
||||
void RSSubThreadManager::SaveCacheTexture(RSRenderNode& node) const
|
||||
{
|
||||
std::scoped_lock<std::recursive_mutex> lock(node.GetSurfaceMutex());
|
||||
#ifdef NEW_SKIA
|
||||
auto surface = node.GetCompletedCacheSurface(UNI_MAIN_THREAD_INDEX, true);
|
||||
if (surface == nullptr || (surface->width() == 0 || surface->height() == 0)) {
|
||||
RS_LOGE("invalid cache surface");
|
||||
return;
|
||||
}
|
||||
if (renderContext_ == nullptr) {
|
||||
RS_LOGE("SaveCacheTexture render context is nullptr");
|
||||
return;
|
||||
}
|
||||
auto mainGrContext = renderContext_->GetGrContext();
|
||||
if (mainGrContext == nullptr) {
|
||||
RS_LOGE("SaveCacheTexture GrDirectContext is nullptr");
|
||||
return;
|
||||
}
|
||||
auto sharedBackendTexture =
|
||||
surface->getBackendTexture(SkSurface::BackendHandleAccess::kFlushRead_BackendHandleAccess);
|
||||
if (!sharedBackendTexture.isValid()) {
|
||||
RS_LOGE("SaveCacheTexture does not has GPU backend, %llu", node.GetId());
|
||||
return;
|
||||
}
|
||||
auto sharedTexture = SkImage::MakeFromTexture(mainGrContext, sharedBackendTexture,
|
||||
kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
if (sharedTexture == nullptr) {
|
||||
RS_LOGE("SaveCacheTexture shared texture is nullptr, %llu", node.GetId());
|
||||
return;
|
||||
}
|
||||
node.SetCacheTexture(sharedTexture);
|
||||
#endif
|
||||
}
|
||||
}
|
@ -37,7 +37,6 @@ public:
|
||||
void NodeTaskNotify(uint64_t nodeId);
|
||||
void SubmitSubThreadTask(const std::shared_ptr<RSDisplayRenderNode>& node,
|
||||
const std::list<std::shared_ptr<RSSurfaceRenderNode>>& subThreadNodes);
|
||||
void SaveCacheTexture(RSRenderNode& node) const;
|
||||
|
||||
private:
|
||||
RSSubThreadManager() = default;
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
// we guarantee when constructing this object, all parameters are valid.
|
||||
#ifdef NEW_RENDER_CONTEXT
|
||||
RSRenderFrame(const std::shared_ptr<RSRenderSurfaceOhos>& target)
|
||||
: targetSurface_(target)
|
||||
: targetSurface_(target) explicit
|
||||
{
|
||||
}
|
||||
#else
|
||||
@ -194,11 +194,11 @@ public:
|
||||
return isHighContrastEnabled_;
|
||||
}
|
||||
#if defined(NEW_RENDER_CONTEXT)
|
||||
const std::shared_ptr<RenderContextBase>& GetRenderContext()
|
||||
const std::shared_ptr<RenderContextBase>& GetRenderContext() const
|
||||
{
|
||||
return renderContext_;
|
||||
}
|
||||
const std::shared_ptr<DrawingContext>& GetDrawingContext()
|
||||
const std::shared_ptr<DrawingContext>& GetDrawingContext() const
|
||||
{
|
||||
return drawingContext_;
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ void RSMainThread::CheckParallelSubThreadNodesStatus()
|
||||
void RSMainThread::ProcessCommandForUniRender()
|
||||
{
|
||||
ResetHardwareEnabledState();
|
||||
TransactionDataMap transactionDataEffective;
|
||||
std::shared_ptr<TransactionDataMap> transactionDataEffective = std::make_shared<TransactionDataMap>();
|
||||
std::string transactionFlags;
|
||||
if (RSSystemProperties::GetUIFirstEnabled() && RSSystemProperties::GetCacheCmdEnabled()) {
|
||||
CheckParallelSubThreadNodesStatus();
|
||||
@ -522,17 +522,17 @@ void RSMainThread::ProcessCommandForUniRender()
|
||||
}
|
||||
}
|
||||
if (iter != transactionVec.begin()) {
|
||||
transactionDataEffective[pid].insert(transactionDataEffective[pid].end(),
|
||||
(*transactionDataEffective)[pid].insert((*transactionDataEffective)[pid].end(),
|
||||
std::make_move_iterator(transactionVec.begin()), std::make_move_iterator(iter));
|
||||
transactionVec.erase(transactionVec.begin(), iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!transactionDataEffective.empty()) {
|
||||
if (!transactionDataEffective->empty()) {
|
||||
doDirectComposition_ = false;
|
||||
}
|
||||
RS_TRACE_NAME("RSMainThread::ProcessCommandUni" + transactionFlags);
|
||||
for (auto& rsTransactionElem: transactionDataEffective) {
|
||||
for (auto& rsTransactionElem: *transactionDataEffective) {
|
||||
for (auto& rsTransaction: rsTransactionElem.second) {
|
||||
if (rsTransaction) {
|
||||
if (rsTransaction->IsNeedSync() || syncTransactionData_.count(rsTransactionElem.first) > 0) {
|
||||
@ -543,6 +543,10 @@ void RSMainThread::ProcessCommandForUniRender()
|
||||
}
|
||||
}
|
||||
}
|
||||
RSUnmarshalThread::Instance().PostTask([ transactionDataEffective ] () {
|
||||
RS_TRACE_NAME("RSMainThread::ProcessCommandForUniRender transactionDataEffective clear");
|
||||
transactionDataEffective->clear();
|
||||
});
|
||||
}
|
||||
|
||||
void RSMainThread::ProcessCommandForDividedRender()
|
||||
@ -1002,7 +1006,7 @@ void RSMainThread::UniRender(std::shared_ptr<RSBaseRenderNode> rootNode)
|
||||
RSUniRenderUtil::AssignWindowNodes(displayNode, mainThreadNodes, subThreadNodes);
|
||||
const auto& nodeMap = context_->GetNodeMap();
|
||||
RSUniRenderUtil::ClearSurfaceIfNeed(nodeMap, displayNode, oldDisplayChildren_);
|
||||
uniVisitor->SetAssignedWindowNodes(mainThreadNodes, subThreadNodes);
|
||||
uniVisitor->DrawSurfaceLayer(displayNode, subThreadNodes);
|
||||
RSUniRenderUtil::CacheSubThreadNodes(subThreadNodes_, subThreadNodes);
|
||||
}
|
||||
rootNode->Process(uniVisitor);
|
||||
@ -1275,6 +1279,8 @@ void RSMainThread::OnVsync(uint64_t timestamp, void* data)
|
||||
ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSMainThread::OnVsync");
|
||||
RSJankStats::GetInstance().SetStartTime();
|
||||
timestamp_ = timestamp;
|
||||
curTime_ = std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||
requestNextVsyncNum_ = 0;
|
||||
frameCount_++;
|
||||
if (isUniRender_) {
|
||||
@ -1864,6 +1870,11 @@ void RSMainThread::ForceRefreshForUni()
|
||||
PostTask([=]() {
|
||||
MergeToEffectiveTransactionDataMap(cachedTransactionDataMap_);
|
||||
RSUnmarshalThread::Instance().PostTask(unmarshalBarrierTask_);
|
||||
auto now = std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||
timestamp_ = timestamp_ + (now - curTime_);
|
||||
curTime_ = now;
|
||||
RS_TRACE_NAME("RSMainThread::ForceRefreshForUni timestamp:" + std::to_string(timestamp_));
|
||||
mainLoop_();
|
||||
});
|
||||
auto screenManager_ = CreateOrGetScreenManager();
|
||||
|
@ -257,6 +257,7 @@ private:
|
||||
TransactionDataIndexMap effectiveTransactionDataIndexMap_;
|
||||
std::unordered_map<pid_t, uint64_t> transactionDataLastWaitTime_;
|
||||
|
||||
uint64_t curTime_ = 0;
|
||||
uint64_t timestamp_ = 0;
|
||||
uint64_t lastAnimateTimestamp_ = 0;
|
||||
uint64_t prePerfTimestamp_ = 0;
|
||||
|
@ -161,8 +161,8 @@ void RSRenderEngine::RSSurfaceNodeCommonPreProcess(RSSurfaceRenderNode& node, RS
|
||||
node.GetRenderProperties(), canvas, RSPropertiesPainter::Rect2SkRect(maskBounds));
|
||||
|
||||
// draw background filter (should execute this filter before drawing buffer/image).
|
||||
RSPropertiesPainter::DrawFilter(
|
||||
property, canvas, FilterType::BACKGROUND_FILTER, SkRect::MakeWH(params.srcRect.width(), params.srcRect.height()));
|
||||
RSPropertiesPainter::DrawFilter(property, canvas, FilterType::BACKGROUND_FILTER,
|
||||
SkRect::MakeWH(params.srcRect.width(), params.srcRect.height()));
|
||||
#else
|
||||
RectF maskBounds(0, 0, params.dstRect.GetWidth(), params.dstRect.GetHeight());
|
||||
RSPropertiesPainter::DrawMask(
|
||||
@ -184,8 +184,8 @@ void RSRenderEngine::RSSurfaceNodeCommonPostProcess(RSSurfaceRenderNode& node, R
|
||||
|
||||
// draw preprocess filter (should execute this filter after drawing buffer/image).
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
RSPropertiesPainter::DrawFilter(
|
||||
property, canvas, FilterType::FOREGROUND_FILTER, SkRect::MakeWH(params.srcRect.width(), params.srcRect.height()));
|
||||
RSPropertiesPainter::DrawFilter(property, canvas, FilterType::FOREGROUND_FILTER,
|
||||
SkRect::MakeWH(params.srcRect.width(), params.srcRect.height()));
|
||||
RSPropertiesPainter::DrawLinearGradientBlurFilter(
|
||||
property, canvas, SkRect::MakeWH(params.srcRect.width(), params.srcRect.height()));
|
||||
#else
|
||||
|
@ -231,8 +231,10 @@ sptr<Surface> RSRenderServiceConnection::CreateNodeAndSurface(const RSSurfaceRen
|
||||
return nullptr;
|
||||
}
|
||||
const std::string& surfaceName = surface->GetName();
|
||||
RS_LOGI("RsDebug RSRenderService::CreateNodeAndSurface node id:%" PRIu64 " name:%s surface id:%" PRIu64 " name:%s",
|
||||
node->GetId(), node->GetName().c_str(), surface->GetUniqueId(), surfaceName.c_str());
|
||||
RS_LOGI("RsDebug RSRenderService::CreateNodeAndSurface node" \
|
||||
"id:%" PRIu64 " name:%s bundleName:%s surface id:%" PRIu64 " name:%s",
|
||||
node->GetId(), node->GetName().c_str(), node->GetBundleName().c_str(),
|
||||
surface->GetUniqueId(), surfaceName.c_str());
|
||||
node->SetConsumer(surface);
|
||||
std::function<void()> registerNode = [node, this]() -> void {
|
||||
this->mainThread_->GetContext().GetMutableNodeMap().RegisterRenderNode(node);
|
||||
|
@ -162,9 +162,12 @@ std::unique_ptr<Media::PixelMap> RSSurfaceCaptureTask::Run()
|
||||
if (auto displayNode = node->ReinterpretCastTo<RSDisplayRenderNode>()) {
|
||||
if (visitor_->IsUniRender() && !visitor_->GetHasingSecurityLayer()) {
|
||||
auto rotation = displayNode->GetRotation();
|
||||
if (rotation == ScreenRotation::ROTATION_90 || rotation == ScreenRotation::ROTATION_270) {
|
||||
if (rotation == ScreenRotation::ROTATION_90) {
|
||||
pixelmap->rotate(static_cast<int32_t>(90)); // 90 degrees
|
||||
}
|
||||
if (rotation == ScreenRotation::ROTATION_270) {
|
||||
pixelmap->rotate(static_cast<int32_t>(270)); // 270 degrees
|
||||
}
|
||||
RS_LOGD("RSSurfaceCaptureTask::Run: PixelmapRotation: %d", static_cast<int32_t>(rotation));
|
||||
}
|
||||
}
|
||||
@ -1058,10 +1061,15 @@ void RSSurfaceCaptureVisitor::DrawWatermarkIfNeed(float screenWidth, float scree
|
||||
if (RSMainThread::Instance()->GetWatermarkFlag()) {
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
sk_sp<SkImage> skImage = RSMainThread::Instance()->GetWatermarkImg();
|
||||
SkPaint rectPaint;
|
||||
auto skSrcRect = SkRect::MakeWH(skImage->width(), skImage->height());
|
||||
auto skDstRect = SkRect::MakeWH(screenWidth, screenHeight);
|
||||
#ifdef NEW_SKIA
|
||||
sk_sp<SkShader> shader = skImage->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, SkSamplingOptions());
|
||||
canvas_->drawImageRect(
|
||||
skImage, skSrcRect, skDstRect, SkSamplingOptions(),
|
||||
&rectPaint, SkCanvas::kStrict_SrcRectConstraint);
|
||||
#else
|
||||
sk_sp<SkShader> shader = skImage->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat);
|
||||
canvas_->drawImageRect(skImage, skSrcRect, skDstRect, &rectPaint);
|
||||
#endif
|
||||
#else
|
||||
auto image = RSMainThread::Instance()->GetWatermarkImg();
|
||||
|
@ -631,7 +631,7 @@ LayerInfoPtr RSUniRenderComposerAdapter::CreateBufferLayer(RSSurfaceRenderNode&
|
||||
return layer;
|
||||
}
|
||||
|
||||
LayerInfoPtr RSUniRenderComposerAdapter::CreateLayer(RSSurfaceRenderNode& node)
|
||||
LayerInfoPtr RSUniRenderComposerAdapter::CreateLayer(RSSurfaceRenderNode& node) const
|
||||
{
|
||||
const auto& consumer = node.GetConsumer();
|
||||
if (consumer == nullptr) {
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
bool Init(const ScreenInfo& screenInfo, int32_t offsetX, int32_t offsetY, float mirrorAdaptiveCoefficient);
|
||||
|
||||
LayerInfoPtr CreateLayer(RSDisplayRenderNode& node);
|
||||
LayerInfoPtr CreateLayer(RSSurfaceRenderNode& node);
|
||||
LayerInfoPtr CreateLayer(RSSurfaceRenderNode& node) const;
|
||||
LayerInfoPtr CreateLayer(RSDrivenSurfaceRenderNode& node);
|
||||
void CommitLayers(const std::vector<LayerInfoPtr>& layers);
|
||||
|
||||
|
@ -375,7 +375,6 @@ bool RSUniRenderUtil::HandleSubThreadNode(RSRenderNode& node, RSPaintFilterCanva
|
||||
#if defined(RS_ENABLE_GL)
|
||||
RSSubThreadManager::Instance()->WaitNodeTask(node.GetId());
|
||||
node.UpdateCompletedCacheSurface();
|
||||
RSSubThreadManager::Instance()->SaveCacheTexture(node);
|
||||
#endif
|
||||
}
|
||||
RS_TRACE_NAME_FMT("RSUniRenderUtil::HandleSubThreadNode %" PRIu64 "", node.GetId());
|
||||
@ -454,25 +453,38 @@ void RSUniRenderUtil::AssignWindowNodes(const std::shared_ptr<RSDisplayRenderNod
|
||||
RS_TRACE_NAME("AssignWindowNodes");
|
||||
bool isRotation = displayNode->IsRotationChanged();
|
||||
bool isScale = false;
|
||||
uint32_t leashWindowCount = 0;
|
||||
for (auto iter = displayNode->GetSortedChildren().begin(); iter != displayNode->GetSortedChildren().end(); iter++) {
|
||||
auto node = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(*iter);
|
||||
if (node == nullptr) {
|
||||
ROSEN_LOGE("RSUniRenderUtil::AssignWindowNodes nullptr found in sortedChildren, this should not happen");
|
||||
continue;
|
||||
}
|
||||
if (node->IsLeashWindow()) {
|
||||
leashWindowCount++;
|
||||
}
|
||||
if (node->IsLeashWindow() && node->IsScale()) {
|
||||
isScale = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// trace info for assign window nodes
|
||||
std::string traceInfo = "{ isScale: " + std::to_string(isScale) + ", " +
|
||||
"leashWindowCount: " + std::to_string(leashWindowCount) + ", " +
|
||||
"isRotation: " + std::to_string(isRotation) + " }; ";
|
||||
for (auto iter = displayNode->GetSortedChildren().begin(); iter != displayNode->GetSortedChildren().end(); iter++) {
|
||||
auto node = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(*iter);
|
||||
if (node == nullptr) {
|
||||
ROSEN_LOGE("RSUniRenderUtil::AssignWindowNodes nullptr found in sortedChildren, this should not happen");
|
||||
continue;
|
||||
}
|
||||
// trace info for assign window nodes
|
||||
traceInfo += "node:[ " + node->GetName() + ", " + std::to_string(node->GetId()) + " ]" +
|
||||
"( " + std::to_string(static_cast<uint32_t>(node->GetCacheSurfaceProcessedStatus())) + ", " +
|
||||
std::to_string(node->HasFilter()) + ", " + std::to_string(node->HasAbilityComponent()) + " ); ";
|
||||
if (node->GetCacheSurfaceProcessedStatus() == CacheProcessStatus::DOING) { // node exceed one vsync
|
||||
AssignSubThreadNode(subThreadNodes, node);
|
||||
} else if (leashWindowCount > 1) { // start app from another app
|
||||
AssignMainThreadNode(mainThreadNodes, node);
|
||||
} else if (isScale) { // app start or close scene
|
||||
if (!node->HasFilter() && !node->HasAbilityComponent() && !isRotation) {
|
||||
AssignSubThreadNode(subThreadNodes, node);
|
||||
@ -484,6 +496,7 @@ void RSUniRenderUtil::AssignWindowNodes(const std::shared_ptr<RSDisplayRenderNod
|
||||
}
|
||||
}
|
||||
SortSubThreadNodes(subThreadNodes);
|
||||
RS_TRACE_NAME_FMT("AssignWindowNodes Infos: %s", traceInfo.c_str());
|
||||
}
|
||||
|
||||
void RSUniRenderUtil::AssignMainThreadNode(std::list<std::shared_ptr<RSSurfaceRenderNode>>& mainThreadNodes,
|
||||
@ -501,7 +514,6 @@ void RSUniRenderUtil::AssignMainThreadNode(std::list<std::shared_ptr<RSSurfaceRe
|
||||
if (changeThread) {
|
||||
RS_LOGD("RSUniRenderUtil::AssignMainThreadNode clear cache surface:[%s, %llu]",
|
||||
node->GetName().c_str(), node->GetId());
|
||||
node->SetCacheTexture(nullptr);
|
||||
ClearCacheSurface(node, UNI_MAIN_THREAD_INDEX);
|
||||
}
|
||||
}
|
||||
@ -520,7 +532,6 @@ void RSUniRenderUtil::AssignSubThreadNode(std::list<std::shared_ptr<RSSurfaceRen
|
||||
#if defined(RS_ENABLE_GL)
|
||||
if (node->GetCacheSurfaceProcessedStatus() == CacheProcessStatus::DONE && node->GetCacheSurface()) {
|
||||
node->UpdateCompletedCacheSurface();
|
||||
RSSubThreadManager::Instance()->SaveCacheTexture(*node);
|
||||
}
|
||||
#endif
|
||||
if (node->HasCachedTexture()) {
|
||||
@ -605,7 +616,6 @@ void RSUniRenderUtil::ClearSurfaceIfNeed(const RSRenderNodeMap& map,
|
||||
if (surface && map.GetRenderNode(surface->GetId()) != nullptr) {
|
||||
RS_LOGD("RSUniRenderUtil::ClearSurfaceIfNeed clear cache surface:[%s, %llu]",
|
||||
surface->GetName().c_str(), surface->GetId());
|
||||
surface->SetCacheTexture(nullptr);
|
||||
ClearCacheSurface(surface, UNI_MAIN_THREAD_INDEX);
|
||||
}
|
||||
}
|
||||
@ -619,18 +629,21 @@ void RSUniRenderUtil::ClearCacheSurface(const std::shared_ptr<RSSurfaceRenderNod
|
||||
uint32_t cacheSurfaceThreadIndex = node->GetCacheSurfaceThreadIndex();
|
||||
if (cacheSurfaceThreadIndex == threadIndex) {
|
||||
node->ClearCacheSurface();
|
||||
node->SetIsMainThreadNode(true);
|
||||
return;
|
||||
}
|
||||
if (cacheSurfaceThreadIndex == UNI_MAIN_THREAD_INDEX) {
|
||||
RSMainThread::Instance()->PostTask([node]() {
|
||||
RS_LOGD("clear node cache surface in main thread");
|
||||
node->ClearCacheSurface();
|
||||
node->SetIsMainThreadNode(true);
|
||||
});
|
||||
} else {
|
||||
#ifdef RS_ENABLE_GL
|
||||
RSSubThreadManager::Instance()->PostTask([node]() {
|
||||
RS_LOGD("clear node cache surface in sub thread");
|
||||
node->ClearCacheSurface();
|
||||
node->SetIsMainThreadNode(true);
|
||||
}, cacheSurfaceThreadIndex);
|
||||
#endif
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "memory/rs_tag_tracker.h"
|
||||
#include "pipeline/rs_base_render_node.h"
|
||||
#include "pipeline/rs_base_render_util.h"
|
||||
#include "pipeline/rs_canvas_drawing_render_node.h"
|
||||
#include "pipeline/rs_cold_start_thread.h"
|
||||
#include "pipeline/rs_display_render_node.h"
|
||||
#include "pipeline/rs_effect_render_node.h"
|
||||
@ -219,6 +220,7 @@ void RSUniRenderVisitor::PrepareBaseRenderNode(RSBaseRenderNode& node)
|
||||
|
||||
for (auto& child : children) {
|
||||
if (PrepareSharedTransitionNode(*child)) {
|
||||
curDirty_ = child->IsDirty();
|
||||
child->Prepare(shared_from_this());
|
||||
}
|
||||
}
|
||||
@ -249,7 +251,7 @@ void RSUniRenderVisitor::UpdateCacheChangeStatus(RSBaseRenderNode& node)
|
||||
static_cast<int>(isDrawingCacheChanged_));
|
||||
} else {
|
||||
// Any child node dirty causes cache change
|
||||
isDrawingCacheChanged_ = isDrawingCacheChanged_ || targetNode->IsDirty();
|
||||
isDrawingCacheChanged_ = isDrawingCacheChanged_ || curDirty_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1185,9 +1187,9 @@ void RSUniRenderVisitor::DrawDirtyRegionForDFX(std::vector<RectI> dirtyRects)
|
||||
|
||||
void RSUniRenderVisitor::DrawAllSurfaceDirtyRegionForDFX(RSDisplayRenderNode& node, const Occlusion::Region& region)
|
||||
{
|
||||
std::vector<Occlusion::Rect> visibleDirtyRects = region.GetRegionRects();
|
||||
const auto& visibleDirtyRects = region.GetRegionRects();
|
||||
std::vector<RectI> rects;
|
||||
for (auto rect : visibleDirtyRects) {
|
||||
for (auto& rect : visibleDirtyRects) {
|
||||
rects.emplace_back(rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_);
|
||||
}
|
||||
DrawDirtyRegionForDFX(rects);
|
||||
@ -1223,14 +1225,14 @@ void RSUniRenderVisitor::DrawTargetSurfaceDirtyRegionForDFX(RSDisplayRenderNode&
|
||||
if (DrawDetailedTypesOfDirtyRegionForDFX(*surfaceNode)) {
|
||||
continue;
|
||||
}
|
||||
auto visibleDirtyRegions = surfaceNode->GetVisibleDirtyRegion().GetRegionRects();
|
||||
const auto& visibleDirtyRegions = surfaceNode->GetVisibleDirtyRegion().GetRegionRects();
|
||||
std::vector<RectI> rects;
|
||||
for (auto rect : visibleDirtyRegions) {
|
||||
for (auto& rect : visibleDirtyRegions) {
|
||||
rects.emplace_back(rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_);
|
||||
}
|
||||
auto visibleRegions = surfaceNode->GetVisibleRegion().GetRegionRects();
|
||||
const auto& visibleRegions = surfaceNode->GetVisibleRegion().GetRegionRects();
|
||||
auto displayDirtyRegion = node.GetDirtyManager()->GetDirtyRegion();
|
||||
for (auto rect : visibleRegions) {
|
||||
for (auto& rect : visibleRegions) {
|
||||
auto visibleRect = RectI(rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_);
|
||||
auto intersectRegion = displayDirtyRegion.IntersectRect(visibleRect);
|
||||
rects.emplace_back(intersectRegion);
|
||||
@ -1304,7 +1306,7 @@ bool RSUniRenderVisitor::DrawDetailedTypesOfDirtyRegionForDFX(RSSurfaceRenderNod
|
||||
|
||||
void RSUniRenderVisitor::DrawSurfaceOpaqueRegionForDFX(RSSurfaceRenderNode& node)
|
||||
{
|
||||
auto opaqueRegionRects = node.GetOpaqueRegion().GetRegionRects();
|
||||
const auto& opaqueRegionRects = node.GetOpaqueRegion().GetRegionRects();
|
||||
for (const auto &subRect: opaqueRegionRects) {
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
DrawDirtyRectForDFX(subRect.ToRectI(), SK_ColorGREEN, SkPaint::kFill_Style, 0.2f, 0);
|
||||
@ -1571,6 +1573,7 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
curDisplayDirtyManager_->SetSurfaceSize(screenInfo_.width, screenInfo_.height);
|
||||
if (isPartialRenderEnabled_) {
|
||||
CalcDirtyDisplayRegion(displayNodePtr);
|
||||
AddContainerDirtyToGlobalDirty(displayNodePtr);
|
||||
// Aligning displayRenderNode and surfaceRenderNode dirty region before merge dirty filter region
|
||||
if (isDirtyRegionAlignedEnable_) {
|
||||
AlignGlobalAndSurfaceDirtyRegions(displayNodePtr);
|
||||
@ -1649,17 +1652,17 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessDisplayRenderNode, RGBA 8888 to RGBA 1010102");
|
||||
}
|
||||
node.SetFingerprint(hasFingerprint_);
|
||||
RS_TRACE_BEGIN("RSUniRender::wait for bufferRequest cond");
|
||||
if (!RSMainThread::Instance()->WaitUntilDisplayNodeBufferReleased(node)) {
|
||||
RS_TRACE_NAME("RSUniRenderVisitor no released buffer");
|
||||
}
|
||||
RS_TRACE_END();
|
||||
#ifdef NEW_RENDER_CONTEXT
|
||||
renderFrame_ = renderEngine_->RequestFrame(std::static_pointer_cast<RSRenderSurfaceOhos>(rsSurface),
|
||||
bufferConfig);
|
||||
#else
|
||||
renderFrame_ = renderEngine_->RequestFrame(std::static_pointer_cast<RSSurfaceOhos>(rsSurface), bufferConfig);
|
||||
#endif
|
||||
RS_TRACE_BEGIN("RSUniRender::wait for bufferRequest cond");
|
||||
if (!RSMainThread::Instance()->WaitUntilDisplayNodeBufferReleased(node)) {
|
||||
RS_TRACE_NAME("RSUniRenderVisitor no released buffer");
|
||||
}
|
||||
RS_TRACE_END();
|
||||
RS_TRACE_END();
|
||||
|
||||
if (renderFrame_ == nullptr) {
|
||||
@ -1721,8 +1724,6 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
int bufferAge = renderFrame_->GetBufferAge();
|
||||
RS_TRACE_END();
|
||||
RSUniRenderUtil::MergeDirtyHistory(displayNodePtr, bufferAge, isDirtyRegionAlignedEnable_);
|
||||
// The global dirty region caused by container dirty should be calculated after merge dirty history.
|
||||
AddContainerDirtyToGlobalDirty(displayNodePtr);
|
||||
Occlusion::Region dirtyRegion = RSUniRenderUtil::MergeVisibleDirtyRegion(
|
||||
displayNodePtr, isDirtyRegionAlignedEnable_);
|
||||
dirtyRegionTest = dirtyRegion;
|
||||
@ -1797,9 +1798,6 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
FinishOffscreenRender();
|
||||
} else {
|
||||
// render directly
|
||||
if (isUIFirst_) {
|
||||
DrawSurfaceLayer(node);
|
||||
}
|
||||
ProcessBaseRenderNode(node);
|
||||
}
|
||||
canvas_->restoreToCount(saveCount);
|
||||
@ -1938,14 +1936,13 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessDisplayRenderNode end");
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::DrawSurfaceLayer(RSDisplayRenderNode& node)
|
||||
void RSUniRenderVisitor::DrawSurfaceLayer(const std::shared_ptr<RSDisplayRenderNode>& displayNode,
|
||||
const std::list<std::shared_ptr<RSSurfaceRenderNode>>& subThreadNodes) const
|
||||
{
|
||||
#if defined(RS_ENABLE_GL)
|
||||
auto subThreadManager = RSSubThreadManager::Instance();
|
||||
std::shared_ptr<RSBaseRenderNode> nodePtr = node.shared_from_this();
|
||||
auto displayNodePtr = nodePtr->ReinterpretCastTo<RSDisplayRenderNode>();
|
||||
subThreadManager->Start(renderEngine_->GetRenderContext().get());
|
||||
subThreadManager->SubmitSubThreadTask(displayNodePtr, subThreadNodes_);
|
||||
subThreadManager->SubmitSubThreadTask(displayNode, subThreadNodes);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2158,23 +2155,6 @@ void RSUniRenderVisitor::CalcDirtyDisplayRegion(std::shared_ptr<RSDisplayRenderN
|
||||
surfaceNode->SetShadowValidLastFrame(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (surfaceNode->IsAppWindow() && !surfaceNode->HasContainerWindow()) {
|
||||
auto transparentRegion = surfaceNode->GetTransparentRegion();
|
||||
Occlusion::Rect tmpRect = Occlusion::Rect { surfaceDirtyRect.left_, surfaceDirtyRect.top_,
|
||||
surfaceDirtyRect.GetRight(), surfaceDirtyRect.GetBottom() };
|
||||
Occlusion::Region surfaceDirtyRegion { tmpRect };
|
||||
Occlusion::Region transparentDirtyRegion = transparentRegion.And(surfaceDirtyRegion);
|
||||
if (!transparentDirtyRegion.IsEmpty()) {
|
||||
RS_LOGD("CalcDirtyDisplayRegion merge TransparentDirtyRegion %s region %s",
|
||||
surfaceNode->GetName().c_str(), transparentDirtyRegion.GetRegionInfo().c_str());
|
||||
std::vector<Occlusion::Rect> rects = transparentDirtyRegion.GetRegionRects();
|
||||
for (const auto& rect : rects) {
|
||||
displayDirtyManager->MergeDirtyRect(RectI
|
||||
{ rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_ });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<RectI> surfaceChangedRects = node->GetSurfaceChangedRects();
|
||||
for (auto& surfaceChangedRect : surfaceChangedRects) {
|
||||
@ -2365,21 +2345,44 @@ void RSUniRenderVisitor::AddContainerDirtyToGlobalDirty(std::shared_ptr<RSDispla
|
||||
continue;
|
||||
}
|
||||
auto surfaceDirtyManager = surfaceNode->GetDirtyManager();
|
||||
RectI surfaceDirtyRect = surfaceDirtyManager->GetDirtyRegion();
|
||||
if (surfaceDirtyManager == nullptr) {
|
||||
continue;
|
||||
}
|
||||
RectI surfaceDirtyRect = surfaceDirtyManager->GetCurrentFrameDirtyRegion();
|
||||
|
||||
// If a surface's dirty is intersect with container region (which can be considered transparent)
|
||||
// should be added to display dirty region.
|
||||
// Note: we use containerRegion rather transparentRegion to bypass inner corner dirty problem.
|
||||
auto containerRegion = surfaceNode->GetContainerRegion();
|
||||
auto surfaceDirtyRegion = Occlusion::Region{Occlusion::Rect{surfaceDirtyRect}};
|
||||
auto containerDirtyRegion = containerRegion.And(surfaceDirtyRegion);
|
||||
if (!containerDirtyRegion.IsEmpty()) {
|
||||
RS_LOGD("CalcDirtyDisplayRegion merge containerDirtyRegion %s region %s",
|
||||
surfaceNode->GetName().c_str(), containerDirtyRegion.GetRegionInfo().c_str());
|
||||
std::vector<Occlusion::Rect> rects = containerDirtyRegion.GetRegionRects();
|
||||
for (const auto& rect : rects) {
|
||||
displayDirtyManager->MergeDirtyRectAfterMergeHistory(RectI{
|
||||
rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_ });
|
||||
if (surfaceNode->HasContainerWindow()) {
|
||||
// If a surface's dirty is intersect with container region (which can be considered transparent)
|
||||
// should be added to display dirty region.
|
||||
// Note: we use containerRegion rather transparentRegion to bypass inner corner dirty problem.
|
||||
auto containerRegion = surfaceNode->GetContainerRegion();
|
||||
auto surfaceDirtyRegion = Occlusion::Region{Occlusion::Rect{surfaceDirtyRect}};
|
||||
auto containerDirtyRegion = containerRegion.And(surfaceDirtyRegion);
|
||||
if (!containerDirtyRegion.IsEmpty()) {
|
||||
RS_LOGD("CalcDirtyDisplayRegion merge containerDirtyRegion %s region %s",
|
||||
surfaceNode->GetName().c_str(), containerDirtyRegion.GetRegionInfo().c_str());
|
||||
// plan: we can use surfacenode's absrect as containerRegion's bound
|
||||
const auto& rect = containerRegion.GetBoundRef();
|
||||
displayDirtyManager->MergeDirtyRect(RectI{
|
||||
rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_ });
|
||||
}
|
||||
} else {
|
||||
// warning: if a surfacenode has transparent region and opaque region, and its dirty pattern appears in
|
||||
// transparent region and opaque region in adjacent frame, may cause displaydirty region incomplete after
|
||||
// merge history (as surfacenode's dirty region merging opaque region will enlarge surface dirty region
|
||||
// which include transparent region but not counted in display dirtyregion)
|
||||
auto transparentRegion = surfaceNode->GetTransparentRegion();
|
||||
Occlusion::Rect tmpRect = Occlusion::Rect { surfaceDirtyRect.left_, surfaceDirtyRect.top_,
|
||||
surfaceDirtyRect.GetRight(), surfaceDirtyRect.GetBottom() };
|
||||
Occlusion::Region surfaceDirtyRegion { tmpRect };
|
||||
Occlusion::Region transparentDirtyRegion = transparentRegion.And(surfaceDirtyRegion);
|
||||
if (!transparentDirtyRegion.IsEmpty()) {
|
||||
RS_LOGD("CalcDirtyDisplayRegion merge TransparentDirtyRegion %s region %s",
|
||||
surfaceNode->GetName().c_str(), transparentDirtyRegion.GetRegionInfo().c_str());
|
||||
const std::vector<Occlusion::Rect>& rects = transparentDirtyRegion.GetRegionRects();
|
||||
for (const auto& rect : rects) {
|
||||
displayDirtyManager->MergeDirtyRect(RectI
|
||||
{ rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_ });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2466,7 +2469,7 @@ void RSUniRenderVisitor::AlignGlobalAndSurfaceDirtyRegions(std::shared_ptr<RSDis
|
||||
#ifdef RS_ENABLE_EGLQUERYSURFACE
|
||||
std::vector<RectI> RSUniRenderVisitor::GetDirtyRects(const Occlusion::Region ®ion)
|
||||
{
|
||||
std::vector<Occlusion::Rect> rects = region.GetRegionRects();
|
||||
const std::vector<Occlusion::Rect>& rects = region.GetRegionRects();
|
||||
std::vector<RectI> retRects;
|
||||
for (const Occlusion::Rect& rect : rects) {
|
||||
// origin transformation
|
||||
@ -2730,7 +2733,7 @@ void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
// when display is in rotation state, occlusion relationship will be ruined,
|
||||
// hence visibleRegions cannot be used.
|
||||
if (isOpDropped_ && node.IsAppWindow()) {
|
||||
auto visibleRegions = node.GetVisibleRegion().GetRegionRects();
|
||||
const auto& visibleRegions = node.GetVisibleRegion().GetRegionRects();
|
||||
if (visibleRegions.size() == 1) {
|
||||
canvas_->SetVisibleRect(SkRect::MakeLTRB(
|
||||
visibleRegions[0].left_, visibleRegions[0].top_, visibleRegions[0].right_, visibleRegions[0].bottom_));
|
||||
@ -2834,7 +2837,7 @@ void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
|
||||
if (displayNodeMatrix_.has_value()) {
|
||||
auto& displayNodeMatrix = displayNodeMatrix_.value();
|
||||
canvas_->concat(displayNodeMatrix);
|
||||
canvas_->setMatrix(displayNodeMatrix.preConcat(canvas_->getTotalMatrix()));
|
||||
}
|
||||
node.SetTotalMatrix(canvas_->getTotalMatrix());
|
||||
|
||||
@ -3146,6 +3149,12 @@ void RSUniRenderVisitor::ProcessCanvasRenderNode(RSCanvasRenderNode& node)
|
||||
DrawSpherize(node);
|
||||
return;
|
||||
}
|
||||
if (auto drawingNode = node.ReinterpretCastTo<RSCanvasDrawingRenderNode>()) {
|
||||
auto clearFunc = [id = threadIndex_](sk_sp<SkSurface> surface) {
|
||||
RSUniRenderUtil::ClearNodeCacheSurface(surface, nullptr, id);
|
||||
};
|
||||
drawingNode->SetSurfaceClearFunc({ threadIndex_, clearFunc });
|
||||
}
|
||||
CheckAndSetNodeCacheType(node);
|
||||
DrawChildRenderNode(node);
|
||||
}
|
||||
@ -3446,8 +3455,12 @@ bool RSUniRenderVisitor::PrepareSharedTransitionNode(RSBaseRenderNode& node)
|
||||
// If the paired node has already been visited (this means all sanity checks passed), process both nodes in order.
|
||||
if (auto existingNodeIter = unpairedTransitionNodes_.find(key);
|
||||
existingNodeIter != unpairedTransitionNodes_.end()) {
|
||||
// backup curAlpha_
|
||||
// backup environment variables
|
||||
auto curAlpha = curAlpha_;
|
||||
auto clipRect = prepareClipRect_;
|
||||
|
||||
// hack to ensure that dirty region will include the shared-transition nodes
|
||||
prepareClipRect_.SetAll(0, 0, INT_MAX, INT_MAX);
|
||||
|
||||
// set curAlpha_ and prepare paired node
|
||||
[[maybe_unused]] auto& [node, alpha, unused_matrix] = existingNodeIter->second;
|
||||
@ -3455,8 +3468,9 @@ bool RSUniRenderVisitor::PrepareSharedTransitionNode(RSBaseRenderNode& node)
|
||||
node->Prepare(shared_from_this());
|
||||
unpairedTransitionNodes_.erase(existingNodeIter);
|
||||
|
||||
// restore curAlpha_ and continue prepare current node
|
||||
// restore environment variables and continue prepare node
|
||||
curAlpha_ = curAlpha;
|
||||
prepareClipRect_ = clipRect;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,13 +88,6 @@ public:
|
||||
currentFocusedPid_ = pid;
|
||||
}
|
||||
|
||||
void SetAssignedWindowNodes(const std::list<std::shared_ptr<RSSurfaceRenderNode>>& mainThreadNodes,
|
||||
const std::list<std::shared_ptr<RSSurfaceRenderNode>>& subThreadNodes)
|
||||
{
|
||||
mainThreadNodes_ = mainThreadNodes;
|
||||
subThreadNodes_ = subThreadNodes;
|
||||
}
|
||||
|
||||
void SetSubThreadConfig(uint32_t threadIndex)
|
||||
{
|
||||
isSubThread_ = true;
|
||||
@ -102,7 +95,8 @@ public:
|
||||
threadIndex_ = threadIndex;
|
||||
}
|
||||
|
||||
void DrawSurfaceLayer(RSDisplayRenderNode& node);
|
||||
void DrawSurfaceLayer(const std::shared_ptr<RSDisplayRenderNode>& displayNode,
|
||||
const std::list<std::shared_ptr<RSSurfaceRenderNode>>& subThreadNodes) const;
|
||||
|
||||
bool GetAnimateState() const
|
||||
{
|
||||
@ -323,8 +317,6 @@ private:
|
||||
std::vector<ScreenColorGamut> colorGamutModes_;
|
||||
pid_t currentFocusedPid_ = -1;
|
||||
|
||||
std::list<std::shared_ptr<RSSurfaceRenderNode>> mainThreadNodes_;
|
||||
std::list<std::shared_ptr<RSSurfaceRenderNode>> subThreadNodes_;
|
||||
bool isSubThread_ = false;
|
||||
bool isUIFirst_ = false;
|
||||
uint32_t threadIndex_ = UNI_MAIN_THREAD_INDEX;
|
||||
@ -396,6 +388,7 @@ private:
|
||||
bool needCacheImg_ = false;
|
||||
uint32_t captureWindowZorder_ = 0;
|
||||
std::optional<SkPath> effectRegion_ = std::nullopt;
|
||||
bool curDirty_ = false;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -205,7 +205,6 @@ void RSScreenManager::AddScreenToHgm(std::shared_ptr<HdiOutput> &output)
|
||||
RS_LOGE("RSScreenManager %s: output is nullptr.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
RS_LOGI("RSScreenManager AddScreenToHgm");
|
||||
auto &hgmCore = OHOS::Rosen::HgmCore::Instance();
|
||||
ScreenId thisId = ToScreenId(output->GetScreenId());
|
||||
@ -214,15 +213,21 @@ void RSScreenManager::AddScreenToHgm(std::shared_ptr<HdiOutput> &output)
|
||||
return;
|
||||
}
|
||||
|
||||
auto supportedModes = screens_[thisId]->GetSupportedModes();
|
||||
int32_t initMode = 2;
|
||||
if (hgmCore.AddScreen(thisId, initMode)) {
|
||||
int32_t initModeId = 0;
|
||||
auto initMode = screens_[thisId]->GetActiveMode();
|
||||
if (!initMode) {
|
||||
RS_LOGE("RSScreenManager failed to get initial mode");
|
||||
} else {
|
||||
initModeId = initMode->id;
|
||||
}
|
||||
if (hgmCore.AddScreen(thisId, initModeId)) {
|
||||
RS_LOGW("RSScreenManager failed to add screen : %" PRIu64 "", thisId);
|
||||
return;
|
||||
}
|
||||
|
||||
// for each supported mode, use the index as modeId to add the detailed mode to hgm
|
||||
int32_t modeId = 0;
|
||||
auto supportedModes = screens_[thisId]->GetSupportedModes();
|
||||
for (auto mode = supportedModes.begin(); mode != supportedModes.end(); ++mode) {
|
||||
if (!hgmCore.AddScreenInfo(thisId, (*mode).width, (*mode).height,
|
||||
(*mode).freshRate, modeId)) {
|
||||
|
@ -312,7 +312,7 @@ private:
|
||||
mutable std::mutex mutex_;
|
||||
HdiBackend *composer_ = nullptr;
|
||||
ScreenId defaultScreenId_ = INVALID_SCREEN_ID;
|
||||
std::unordered_map<ScreenId, std::unique_ptr<OHOS::Rosen::RSScreen>> screens_;
|
||||
std::map<ScreenId, std::unique_ptr<OHOS::Rosen::RSScreen>> screens_;
|
||||
std::queue<ScreenId> freeVirtualScreenIds_;
|
||||
uint32_t maxVirtualScreenNum_ = 0;
|
||||
std::vector<sptr<RSIScreenChangeCallback>> screenChangeCallbacks_;
|
||||
|
@ -29,7 +29,7 @@ bool RSSystemParameters::GetCalcCostEnabled()
|
||||
|
||||
bool RSSystemParameters::GetDrawingCacheEnabled()
|
||||
{
|
||||
return std::atoi((system::GetParameter("rosen.drawingCache.enabled", "0")).c_str()) != 0;
|
||||
return std::atoi((system::GetParameter("rosen.drawingCache.enabled", "1")).c_str()) != 0;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -144,7 +144,8 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
case CREATE_NODE: {
|
||||
auto nodeId = data.ReadUint64();
|
||||
auto surfaceName = data.ReadString();
|
||||
RSSurfaceRenderNodeConfig config = {.id = nodeId, .name = surfaceName};
|
||||
auto bundleName = data.ReadString();
|
||||
RSSurfaceRenderNodeConfig config = {.id = nodeId, .name = surfaceName, .bundleName = bundleName};
|
||||
reply.WriteBool(CreateNode(config));
|
||||
break;
|
||||
}
|
||||
@ -152,8 +153,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
auto nodeId = data.ReadUint64();
|
||||
auto surfaceName = data.ReadString();
|
||||
auto type = static_cast<RSSurfaceNodeType>(data.ReadUint8());
|
||||
RSSurfaceRenderNodeConfig config = {.id = nodeId, .name = surfaceName, .nodeType = type };
|
||||
auto bundleName = data.ReadString();
|
||||
RSSurfaceRenderNodeConfig config = {
|
||||
.id = nodeId, .name = surfaceName, .nodeType = type, .bundleName = bundleName};
|
||||
sptr<Surface> surface = CreateNodeAndSurface(config);
|
||||
if (surface == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
auto producer = surface->GetProducer();
|
||||
reply.WriteRemoteObject(producer->AsObject());
|
||||
break;
|
||||
@ -217,7 +224,6 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
|
||||
ScreenId mirrorId = data.ReadUint64();
|
||||
int32_t flags = data.ReadInt32();
|
||||
|
||||
ScreenId id = CreateVirtualScreen(name, width, height, surface, mirrorId, flags);
|
||||
reply.WriteUint64(id);
|
||||
break;
|
||||
@ -238,7 +244,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
}
|
||||
auto bufferProducer = iface_cast<IBufferProducer>(remoteObject);
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsProducer(bufferProducer);
|
||||
|
||||
if (surface == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
int32_t status = SetVirtualScreenSurface(id, surface);
|
||||
reply.WriteInt32(status);
|
||||
break;
|
||||
@ -266,6 +275,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
break;
|
||||
}
|
||||
sptr<RSIScreenChangeCallback> cb = iface_cast<RSIScreenChangeCallback>(remoteObject);
|
||||
if (cb == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
int32_t status = SetScreenChangeCallback(cb);
|
||||
reply.WriteInt32(status);
|
||||
break;
|
||||
@ -360,6 +373,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
break;
|
||||
}
|
||||
sptr<RSISurfaceCaptureCallback> cb = iface_cast<RSISurfaceCaptureCallback>(remoteObject);
|
||||
if (cb == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
float scaleX = data.ReadFloat();
|
||||
float scaleY = data.ReadFloat();
|
||||
TakeSurfaceCapture(id, cb, scaleX, scaleY);
|
||||
@ -373,6 +390,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
break;
|
||||
}
|
||||
sptr<IApplicationAgent> app = iface_cast<IApplicationAgent>(remoteObject);
|
||||
if (app == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
RegisterApplicationAgent(pid, app);
|
||||
break;
|
||||
}
|
||||
@ -505,6 +526,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
break;
|
||||
}
|
||||
sptr<RSIBufferAvailableCallback> cb = iface_cast<RSIBufferAvailableCallback>(remoteObject);
|
||||
if (cb == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
RegisterBufferAvailableListener(id, cb, isFromRenderThread);
|
||||
break;
|
||||
}
|
||||
@ -605,6 +630,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
case CREATE_VSYNC_CONNECTION: {
|
||||
std::string name = data.ReadString();
|
||||
sptr<IVSyncConnection> conn = CreateVSyncConnection(name);
|
||||
if (conn == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
reply.WriteRemoteObject(conn->AsObject());
|
||||
break;
|
||||
}
|
||||
@ -680,6 +709,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
break;
|
||||
}
|
||||
sptr<RSIOcclusionChangeCallback> callback = iface_cast<RSIOcclusionChangeCallback>(remoteObject);
|
||||
if (callback == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
int32_t status = RegisterOcclusionChangeCallback(callback);
|
||||
reply.WriteInt32(status);
|
||||
break;
|
||||
@ -739,10 +772,6 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
break;
|
||||
}
|
||||
std::shared_ptr<RSSyncTask> task(command);
|
||||
if (task == nullptr) {
|
||||
ret = ERR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
ExecuteSynchronousTask(task);
|
||||
if (!task->Marshalling(reply)) {
|
||||
ret = ERR_INVALID_STATE;
|
||||
|
@ -225,7 +225,7 @@ ohos_source_set("render_service_base_src") {
|
||||
"$rosen_root/modules/platform:image_native_config",
|
||||
]
|
||||
} else {
|
||||
external_deps = [ "hitrace_native:hitrace_meter" ]
|
||||
external_deps = [ "hitrace:hitrace_meter" ]
|
||||
}
|
||||
|
||||
if (rosen_is_win) {
|
||||
|
@ -147,14 +147,14 @@ private:
|
||||
#ifdef ROSEN_INSTANTIATE_COMMAND_TEMPLATE
|
||||
#define ADD_SHOWING_COMMAND(ALIAS, TYPE) \
|
||||
using ALIAS = RSGetRenderPropertyAndCancelAnimationTask<TYPE>; \
|
||||
template class RSGetRenderPropertyAndCancelAnimationTask<TYPE>;
|
||||
template class RSGetRenderPropertyAndCancelAnimationTask<TYPE>
|
||||
#else
|
||||
|
||||
#define ADD_SHOWING_COMMAND(ALIAS, TYPE) using ALIAS = RSGetRenderPropertyAndCancelAnimationTask<TYPE>;
|
||||
#define ADD_SHOWING_COMMAND(ALIAS, TYPE) using ALIAS = RSGetRenderPropertyAndCancelAnimationTask<TYPE>
|
||||
#endif
|
||||
|
||||
ADD_SHOWING_COMMAND(
|
||||
RSNodeGetShowingPropertyAndCancelAnimation, ARG(RS_NODE_SYNCHRONOUS_READ_PROPERTY, GET_RENDER_PROPERTY))
|
||||
RSNodeGetShowingPropertyAndCancelAnimation, ARG(RS_NODE_SYNCHRONOUS_READ_PROPERTY, GET_RENDER_PROPERTY));
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
|
@ -119,6 +119,7 @@ enum class RSSurfaceNodeType : uint8_t {
|
||||
struct RSSurfaceRenderNodeConfig {
|
||||
NodeId id = 0;
|
||||
std::string name = "SurfaceNode";
|
||||
std::string bundleName = "";
|
||||
RSSurfaceNodeType nodeType = RSSurfaceNodeType::DEFAULT;
|
||||
void* additionalData = nullptr;
|
||||
};
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef ROSEN_RENDER_SERVICE_BASE_PIPELINE_RS_CANVAS_DRAWING_RENDER_NODE_H
|
||||
#define ROSEN_RENDER_SERVICE_BASE_PIPELINE_RS_CANVAS_DRAWING_RENDER_NODE_H
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "pipeline/rs_canvas_render_node.h"
|
||||
@ -23,6 +24,7 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
struct RSModifierContext;
|
||||
using ThreadInfo = std::pair<uint64_t, std::function<void(sk_sp<SkSurface>)>>;
|
||||
|
||||
class RSB_EXPORT RSCanvasDrawingRenderNode : public RSCanvasRenderNode {
|
||||
public:
|
||||
@ -42,11 +44,20 @@ public:
|
||||
|
||||
bool GetBitmap(SkBitmap& bitmap);
|
||||
|
||||
void SetSurfaceClearFunc(ThreadInfo threadInfo)
|
||||
{
|
||||
curThreadInfo_ = threadInfo;
|
||||
}
|
||||
|
||||
private:
|
||||
void ApplyDrawCmdModifier(RSModifierContext& context, RSModifierType type) const override;
|
||||
bool ResetSurface(int width, int height, RSPaintFilterCanvas& canvas);
|
||||
bool GetSizeFromDrawCmdModifiers(int& width, int& height);
|
||||
|
||||
sk_sp<SkSurface> skSurface_;
|
||||
std::unique_ptr<RSPaintFilterCanvas> canvas_;
|
||||
ThreadInfo curThreadInfo_ = {};
|
||||
ThreadInfo preThreadInfo_ = {};
|
||||
};
|
||||
|
||||
} // namespace Rosen
|
||||
|
@ -57,6 +57,8 @@ public:
|
||||
std::string PlayBackForRecord(RSPaintFilterCanvas& canvas, int startOpId, int endOpId,
|
||||
int descStartOpId, const SkRect* rect = nullptr);
|
||||
|
||||
void SetWidth(int width);
|
||||
void SetHeight(int height);
|
||||
std::string GetOpsWithDesc() const;
|
||||
size_t GetSize() const;
|
||||
int GetWidth() const;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#else
|
||||
#include "draw/surface.h"
|
||||
#endif
|
||||
@ -188,6 +189,10 @@ public:
|
||||
cacheCompletedSurface_ = nullptr;
|
||||
}
|
||||
|
||||
#ifdef RS_ENABLE_GL
|
||||
void UpdateBackendTexture();
|
||||
#endif
|
||||
|
||||
void DrawCacheSurface(RSPaintFilterCanvas& canvas, uint32_t threadIndex = UNI_MAIN_THREAD_INDEX,
|
||||
bool isUIFirst = false);
|
||||
|
||||
@ -359,17 +364,12 @@ public:
|
||||
|
||||
bool HasCachedTexture() const
|
||||
{
|
||||
return cacheTexture_ != nullptr;
|
||||
}
|
||||
|
||||
void SetCacheTexture(sk_sp<SkImage> texture)
|
||||
{
|
||||
cacheTexture_ = texture;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> GetCacheTexture() const
|
||||
{
|
||||
return cacheTexture_;
|
||||
#ifdef RS_ENABLE_GL
|
||||
return grBackendTexture_.isValid();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SetNeedClearFlag(bool needClear)
|
||||
@ -452,6 +452,9 @@ private:
|
||||
#else
|
||||
std::shared_ptr<Drawing::Surface> cacheSurface_ = nullptr;
|
||||
std::shared_ptr<Drawing::Surface> cacheCompletedSurface_ = nullptr;
|
||||
#endif
|
||||
#ifdef RS_ENABLE_GL
|
||||
GrBackendTexture grBackendTexture_;
|
||||
#endif
|
||||
std::atomic<bool> isStaticCached_ = false;
|
||||
CacheType cacheType_ = CacheType::NONE;
|
||||
@ -460,7 +463,6 @@ private:
|
||||
bool isDrawingCacheChanged_ = false;
|
||||
|
||||
mutable std::recursive_mutex surfaceMutex_;
|
||||
sk_sp<SkImage> cacheTexture_ = nullptr;
|
||||
ClearCacheSurfaceFunc clearCacheSurfaceFunc_ = nullptr;
|
||||
uint32_t cacheSurfaceThreadIndex_ = UNI_MAIN_THREAD_INDEX;
|
||||
bool isMainThreadNode_ = true;
|
||||
|
@ -188,6 +188,11 @@ public:
|
||||
return name_;
|
||||
}
|
||||
|
||||
std::string GetBundleName() const
|
||||
{
|
||||
return bundleName_;
|
||||
}
|
||||
|
||||
void SetOffSetX(int32_t offset)
|
||||
{
|
||||
offsetX_ = offset;
|
||||
@ -697,6 +702,7 @@ private:
|
||||
bool qosPidCal_ = false;
|
||||
|
||||
std::string name_;
|
||||
std::string bundleName_;
|
||||
RSSurfaceNodeType nodeType_ = RSSurfaceNodeType::DEFAULT;
|
||||
#ifndef ROSEN_CROSS_PLATFORM
|
||||
GraphicColorGamut colorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB;
|
||||
|
@ -51,33 +51,40 @@ public:
|
||||
|
||||
// Similar to DrawFilter(), but not draw anything on canvas, just return the cache data.
|
||||
// for effect component adaption in RSPropertiesPainter::DrawBackgroundEffect
|
||||
CachedEffectData GeneratedCacheEffectData(RSPaintFilterCanvas& canvas, const std::shared_ptr<RSSkiaFilter>& filter);
|
||||
CachedEffectData GeneratedCachedEffectData(
|
||||
RSPaintFilterCanvas& canvas, const std::shared_ptr<RSSkiaFilter>& filter);
|
||||
|
||||
// Clear the cache, next time DrawFilter() will regenerate the cache.
|
||||
void InvalidateCache();
|
||||
|
||||
private:
|
||||
// UpdateSnapshot won't apply the filter, but we need to call filter::Preprocess()
|
||||
// UpdateSnapshot won't apply the filter, but we need to call filter::PreProcess()
|
||||
void TakeSnapshot(RSPaintFilterCanvas& canvas, const std::shared_ptr<RSSkiaFilter>& filter);
|
||||
// Convert cached snapshot to blurred snapshot
|
||||
// GenerateBlurredSnapshot will use DrawCachedSnapshot to generate blurred snapshot.
|
||||
void GenerateBlurredSnapshot(RSPaintFilterCanvas& canvas, const std::shared_ptr<RSSkiaFilter>& filter);
|
||||
// If filter is nullptr, we'll directly draw the cached image on canvas
|
||||
void DrawCache(RSPaintFilterCanvas& canvas, const std::shared_ptr<RSSkiaFilter>& filter = nullptr) const;
|
||||
void DrawCachedSnapshot(RSPaintFilterCanvas& canvas, const std::shared_ptr<RSSkiaFilter>& filter) const;
|
||||
void DrawCachedBlurredSnapshot(RSPaintFilterCanvas& canvas) const;
|
||||
void ClipVisibleRect(RSPaintFilterCanvas& canvas) const;
|
||||
|
||||
enum class CacheType : uint8_t {
|
||||
CACHE_TYPE_NONE = 0,
|
||||
CACHE_TYPE_SNAPSHOT = 1,
|
||||
CACHE_TYPE_BLURRED_SNAPSHOT = 2,
|
||||
CACHE_TYPE_NONE,
|
||||
CACHE_TYPE_SNAPSHOT,
|
||||
CACHE_TYPE_BLURRED_SNAPSHOT,
|
||||
};
|
||||
|
||||
CacheType cacheType_ = CacheType::CACHE_TYPE_NONE;
|
||||
std::optional<SkIRect> cachedImageRegion_ = std::nullopt; // Note: this should always be in device coordinate space
|
||||
sk_sp<SkImage> cachedImage_ = nullptr ;
|
||||
sk_sp<SkImage> cachedImage_ = nullptr;
|
||||
|
||||
// for automatically converting cached snapshot to blurred snapshot if the filter is persistent
|
||||
uint32_t cachedFilterHash_ = 0;
|
||||
int frameSinceFilterChange_ = 0;
|
||||
// for lowering snapshot frequency even if the snapshot is changed
|
||||
int frameSinceLastBlurChange_ = 0;
|
||||
|
||||
// for delaying snapshot update even if the snapshot is intersected with dirty region
|
||||
int cacheUpdateInterval_ = 0;
|
||||
|
||||
// Note: all rects should be in device coordinate space
|
||||
SkIRect cachedImageRegion_; // region of cached image
|
||||
SkIRect blurRegion_; // region of previous blur region
|
||||
};
|
||||
|
||||
} // namespace Rosen
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define RENDER_SERVICE_CLIENT_CORE_PROPERTY_RS_PROPERTIES_H
|
||||
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "include/effects/SkColorMatrix.h"
|
||||
@ -276,6 +277,17 @@ public:
|
||||
void SetUseEffect(bool useEffect);
|
||||
bool GetUseEffect() const;
|
||||
|
||||
std::tuple<bool, bool, bool> GetDirtyStatus() const
|
||||
{
|
||||
return { isDirty_, geoDirty_, contentDirty_ };
|
||||
}
|
||||
void SetDirtyStatus(std::tuple<bool, bool, bool> status)
|
||||
{
|
||||
isDirty_ = std::get<0>(status);
|
||||
geoDirty_ = std::get<1>(status);
|
||||
contentDirty_ = std::get<2>(status);
|
||||
}
|
||||
|
||||
private:
|
||||
void Reset();
|
||||
void ResetProperty(RSModifierType type);
|
||||
@ -351,6 +363,7 @@ private:
|
||||
friend class RSCanvasRenderNode;
|
||||
friend class RSPropertiesPainter;
|
||||
friend class RSRenderNode;
|
||||
friend class RSCanvasDrawingRenderNode;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -14,8 +14,10 @@
|
||||
*/
|
||||
#ifndef RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H
|
||||
#define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H
|
||||
|
||||
#ifdef NEW_SKIA
|
||||
#include "include/effects/SkRuntimeEffect.h"
|
||||
#endif
|
||||
|
||||
#include "common/rs_macros.h"
|
||||
#include "render/rs_skia_filter.h"
|
||||
|
||||
@ -55,11 +57,9 @@ public:
|
||||
private:
|
||||
float blurRadiusX_;
|
||||
float blurRadiusY_;
|
||||
bool useKawase = true;
|
||||
sk_sp<SkRuntimeEffect> fBlurEffect;
|
||||
sk_sp<SkRuntimeEffect> fMixEffect;
|
||||
bool useKawase = false;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H
|
||||
#endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H
|
||||
|
@ -131,6 +131,7 @@ public:
|
||||
desc += split + "}\n";
|
||||
}
|
||||
private:
|
||||
bool HasRadius() const;
|
||||
void ApplyImageFit();
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void ApplyCanvasClip(SkCanvas& canvas);
|
||||
@ -158,6 +159,7 @@ private:
|
||||
#else
|
||||
std::vector<Drawing::Point> radius_ = std::vector<Drawing::Point>(4);
|
||||
#endif
|
||||
bool hasRadius_ = false;
|
||||
RectF frameRect_;
|
||||
double scale_ = 1.0;
|
||||
NodeId nodeId_ = 0;
|
||||
|
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2023-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 RENDER_SERVICE_CLIENT_CORE_RENDER_RS_KAWASE_BLUR_H
|
||||
#define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_KAWASE_BLUR_H
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#ifdef NEW_SKIA
|
||||
#include "include/effects/SkRuntimeEffect.h"
|
||||
#endif
|
||||
#include "tools/Resources.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class KawaseBlur {
|
||||
public:
|
||||
static constexpr float kBlurScale = 0.03f;
|
||||
// Maximum number of render passes
|
||||
static constexpr uint32_t kMaxPasses = 4;
|
||||
static constexpr uint32_t kMaxPassesLargeRadius = 7;
|
||||
static constexpr float kDilatedConvolution = 2.0f;
|
||||
static constexpr float kDilatedConvolutionLargeRadius = 4.0f;
|
||||
// To avoid downscaling artifacts, we interpolate the blurred fbo with the full composited
|
||||
// image, up to this radius.
|
||||
static constexpr float kMaxCrossFadeRadius = 10.0f;
|
||||
bool supporteLargeRadius = true;
|
||||
|
||||
KawaseBlur()
|
||||
{
|
||||
SkString blurString(R"(
|
||||
uniform shader imageInput;
|
||||
uniform float2 in_blurOffset;
|
||||
uniform float2 in_maxSizeXY;
|
||||
|
||||
half4 main(float2 xy) {
|
||||
half4 c = imageInput.eval(xy);
|
||||
c += imageInput.eval(float2(clamp(in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
|
||||
clamp(in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));
|
||||
c += imageInput.eval(float2(clamp(in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
|
||||
clamp(-in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));
|
||||
c += imageInput.eval(float2(clamp(-in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
|
||||
clamp(in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));
|
||||
c += imageInput.eval(float2(clamp(-in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
|
||||
clamp(-in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));
|
||||
return half4(c.rgb * 0.2, 1.0);
|
||||
}
|
||||
)");
|
||||
|
||||
SkString mixString(R"(
|
||||
uniform shader blurredInput;
|
||||
uniform shader originalInput;
|
||||
uniform float mixFactor;
|
||||
half4 main(float2 xy) {
|
||||
return half4(mix(originalInput.eval(xy), blurredInput.eval(xy), mixFactor));
|
||||
}
|
||||
)");
|
||||
|
||||
#ifdef NEW_SKIA
|
||||
auto [blurEffect, error] = SkRuntimeEffect::MakeForShader(blurString);
|
||||
if (!blurEffect) {
|
||||
ROSEN_LOGE("KawaseBlurFilter::RuntimeShader error: %s\n", error.c_str());
|
||||
}
|
||||
fBlurEffect = std::move(blurEffect);
|
||||
|
||||
auto [mixEffect, error2] = SkRuntimeEffect::MakeForShader(mixString);
|
||||
if (!mixEffect) {
|
||||
ROSEN_LOGE("KawaseBlurFilter::RuntimeShader error: %s\n", error2.c_str());
|
||||
}
|
||||
fMixEffect = std::move(mixEffect);
|
||||
#endif
|
||||
}
|
||||
#ifdef NEW_SKIA
|
||||
static SkMatrix getShaderTransform(const SkCanvas* canvas, const SkRect& blurRect, float scale)
|
||||
{
|
||||
auto matrix = SkMatrix::Scale(scale, scale);
|
||||
matrix.postConcat(SkMatrix::Translate(blurRect.fLeft, blurRect.fTop));
|
||||
SkMatrix drawInverse;
|
||||
if (canvas != nullptr && canvas->getTotalMatrix().invert(&drawInverse)) {
|
||||
matrix.postConcat(drawInverse);
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
|
||||
void ApplyKawaseBlur(
|
||||
SkCanvas& canvas, const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst, int radius) const
|
||||
{
|
||||
float blurRadius = radius * 3; // 3 : radio between gauss to kawase
|
||||
float blurScale = std::min(1.f,
|
||||
std::max(0.01f, 3.f / static_cast<float>(radius + 0.1f))); // 0.01 : min downSample radio
|
||||
int maxPasses = supporteLargeRadius ? kMaxPassesLargeRadius : kMaxPasses;
|
||||
float dilatedConvolutionFactor = supporteLargeRadius ? kDilatedConvolutionLargeRadius : kDilatedConvolution;
|
||||
float tmpRadius = static_cast<float>(blurRadius) / dilatedConvolutionFactor;
|
||||
int numberOfPasses = std::min(maxPasses, std::max(static_cast<int>(ceil(tmpRadius)), 1));// 1 : min pass num
|
||||
float radiusByPasses = tmpRadius / (float)numberOfPasses;
|
||||
SkImageInfo scaledInfo = image->imageInfo().makeWH(std::ceil(dst.width() * blurScale),
|
||||
std::ceil(dst.height() * blurScale));
|
||||
SkMatrix blurMatrix = SkMatrix::Translate(-dst.fLeft, -dst.fTop);
|
||||
blurMatrix.postScale(blurScale, blurScale);
|
||||
SkSamplingOptions linear(SkFilterMode::kLinear, SkMipmapMode::kNone);
|
||||
SkRuntimeShaderBuilder blurBuilder(fBlurEffect);
|
||||
blurBuilder.child("imageInput") = image->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear, blurMatrix);
|
||||
blurBuilder.uniform("in_blurOffset") = SkV2{radiusByPasses * blurScale, radiusByPasses * blurScale};
|
||||
blurBuilder.uniform("in_maxSizeXY") = SkV2{dst.width() * blurScale, dst.height() * blurScale};
|
||||
sk_sp<SkImage> tmpBlur(blurBuilder.makeImage(canvas.recordingContext(), nullptr, scaledInfo, false));
|
||||
// And now we'll build our chain of scaled blur stages
|
||||
for (auto i = 1; i < numberOfPasses; i++) {
|
||||
const float stepScale = (float)i * blurScale;
|
||||
blurBuilder.child("imageInput") = tmpBlur->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear);
|
||||
blurBuilder.uniform("in_blurOffset") = SkV2{radiusByPasses * stepScale, radiusByPasses * stepScale};
|
||||
blurBuilder.uniform("in_maxSizeXY") = SkV2{dst.width() * blurScale, dst.height() * blurScale};
|
||||
tmpBlur = blurBuilder.makeImage(canvas.recordingContext(), nullptr, scaledInfo, false);
|
||||
}
|
||||
float invBlurScale = 1 / blurScale;
|
||||
blurMatrix = SkMatrix::Scale(invBlurScale, invBlurScale);
|
||||
blurMatrix.postConcat(SkMatrix::Translate(dst.fLeft, dst.fTop));
|
||||
SkMatrix drawInverse;
|
||||
if (canvas.getTotalMatrix().invert(&drawInverse)) {
|
||||
blurMatrix.postConcat(drawInverse);
|
||||
}
|
||||
const auto blurShader = tmpBlur->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear, &blurMatrix);
|
||||
SkMatrix inputMatrix;
|
||||
if (!canvas.getTotalMatrix().invert(&inputMatrix)) {
|
||||
inputMatrix.setIdentity();
|
||||
}
|
||||
if (tmpBlur->width() == image->width() && tmpBlur->height() == image->height()) {
|
||||
inputMatrix.preScale(invBlurScale, invBlurScale);
|
||||
}
|
||||
SkRuntimeShaderBuilder mixBuilder(fMixEffect);
|
||||
mixBuilder.child("blurredInput") = blurShader;
|
||||
mixBuilder.child("originalInput") = image->makeShader(
|
||||
SkTileMode::kClamp, SkTileMode::kClamp, linear, inputMatrix);
|
||||
mixBuilder.uniform("mixFactor") = std::min(1.0f, (float)blurRadius / kMaxCrossFadeRadius);
|
||||
SkPaint paint;
|
||||
paint.setShader(mixBuilder.makeShader(nullptr, true));
|
||||
canvas.drawRect(dst, paint);
|
||||
}
|
||||
#endif
|
||||
private:
|
||||
#ifdef NEW_SKIA
|
||||
sk_sp<SkRuntimeEffect> fBlurEffect;
|
||||
sk_sp<SkRuntimeEffect> fMixEffect;
|
||||
#endif
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_KAWASE_BLUR_H
|
@ -15,7 +15,10 @@
|
||||
#ifndef RENDER_SERVICE_CLIENT_CORE_RENDER_RS_MATERIAL_FILTER_H
|
||||
#define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_MATERIAL_FILTER_H
|
||||
|
||||
#ifdef NEW_SKIA
|
||||
#include "include/effects/SkRuntimeEffect.h"
|
||||
#endif
|
||||
|
||||
#include "common/rs_color.h"
|
||||
#include "render/rs_skia_filter.h"
|
||||
|
||||
@ -112,10 +115,7 @@ private:
|
||||
#endif
|
||||
static float RadiusVp2Sigma(float radiusVp, float dipScale);
|
||||
|
||||
bool useKawase = true;
|
||||
sk_sp<SkRuntimeEffect> fBlurEffect;
|
||||
sk_sp<SkRuntimeEffect> fMixEffect;
|
||||
|
||||
bool useKawase = false;
|
||||
friend class RSMarshallingHelper;
|
||||
};
|
||||
} // namespace Rosen
|
||||
|
@ -123,9 +123,12 @@ public:
|
||||
static bool UnmarshallingArray(Parcel& parcel, T*& val, int count)
|
||||
{
|
||||
if (count <= 0) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (const uint8_t* buff = parcel.ReadUnpadBuffer(count * sizeof(T))) {
|
||||
if (buff == nullptr) {
|
||||
return false;
|
||||
}
|
||||
val = reinterpret_cast<const T*>(buff);
|
||||
return true;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define ROSEN_RENDER_SERVICE_BASE_RS_TRANSACTION_DATA_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "command/rs_command.h"
|
||||
@ -154,6 +155,7 @@ private:
|
||||
bool needCloseSync_ { false };
|
||||
int32_t syncTransactionCount_ { 0 };
|
||||
uint64_t syncId_ { 0 };
|
||||
std::mutex commandMutex_;
|
||||
|
||||
friend class RSTransactionProxy;
|
||||
friend class RSMessageProcessor;
|
||||
|
@ -51,6 +51,9 @@ void RSMessageProcessor::AddUIMessage(uint32_t pid, std::unique_ptr<RSCommand>&
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(transactionMapMutex_);
|
||||
#ifdef ROSEN_CROSS_PLATFORM
|
||||
ROSEN_LOGD("RSMessageProcessor::AddUIMessage %lu %p", transactionMap_[pid].GetCommandCount(), command.get());
|
||||
#endif
|
||||
transactionMap_[pid].AddCommand(command, 0, FollowType::NONE);
|
||||
}
|
||||
|
||||
@ -60,6 +63,9 @@ void RSMessageProcessor::AddUIMessage(uint32_t pid, std::unique_ptr<RSCommand>&&
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(transactionMapMutex_);
|
||||
#ifdef ROSEN_CROSS_PLATFORM
|
||||
ROSEN_LOGD("RSMessageProcessor::AddUIMessage %lu %p", transactionMap_[pid].GetCommandCount(), command.get());
|
||||
#endif
|
||||
transactionMap_[pid].AddCommand(command, 0, FollowType::NONE);
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,6 @@ void RSRenderPropertyBase::OnChange() const
|
||||
if (auto node = node_.lock()) {
|
||||
node->SetDirty();
|
||||
node->AddDirtyType(modifierType_);
|
||||
if (modifierType_ == (RSModifierType::SHADOW_ALPHA) || modifierType_ == (RSModifierType::SHADOW_COLOR)) {
|
||||
node->AddDirtyType(RSModifierType::SHADOW_ALPHA);
|
||||
node->AddDirtyType(RSModifierType::SHADOW_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
#include "pipeline/rs_canvas_drawing_render_node.h"
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
#ifdef NEW_SKIA
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#endif
|
||||
|
||||
#include "common/rs_common_def.h"
|
||||
#include "common/rs_obj_abs_geometry.h"
|
||||
@ -30,52 +33,104 @@ RSCanvasDrawingRenderNode::RSCanvasDrawingRenderNode(NodeId id, std::weak_ptr<RS
|
||||
: RSCanvasRenderNode(id, context)
|
||||
{}
|
||||
|
||||
RSCanvasDrawingRenderNode::~RSCanvasDrawingRenderNode() {}
|
||||
RSCanvasDrawingRenderNode::~RSCanvasDrawingRenderNode()
|
||||
{
|
||||
if (preThreadInfo_.second && skSurface_) {
|
||||
preThreadInfo_.second(std::move(skSurface_));
|
||||
}
|
||||
}
|
||||
|
||||
void RSCanvasDrawingRenderNode::ProcessRenderContents(RSPaintFilterCanvas& canvas)
|
||||
{
|
||||
if (GetRenderProperties().GetBoundsWidth() <= 0 || GetRenderProperties().GetBoundsHeight() <= 0) {
|
||||
RS_LOGE("RSCanvasDrawingRenderNode::ProcessRenderContents: The width or height of the canvas is less than or "
|
||||
"equal to 0");
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
if (!GetSizeFromDrawCmdModifiers(width, height)) {
|
||||
return;
|
||||
}
|
||||
if (!skSurface_ ||
|
||||
static_cast<int>(GetRenderProperties().GetBoundsWidth()) != static_cast<int>(skSurface_->width()) ||
|
||||
static_cast<int>(GetRenderProperties().GetBoundsHeight()) != static_cast<int>(skSurface_->height())) {
|
||||
SkImageInfo info = SkImageInfo::Make(GetRenderProperties().GetBoundsWidth(),
|
||||
GetRenderProperties().GetBoundsHeight(), kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
|
||||
#if (defined RS_ENABLE_GL) && (defined RS_ENABLE_EGLIMAGE)
|
||||
#ifdef NEW_SKIA
|
||||
auto grContext = canvas.recordingContext();
|
||||
#else
|
||||
auto grContext = canvas.getGrContext();
|
||||
#endif
|
||||
if (grContext == nullptr) {
|
||||
RS_LOGE("RSCanvasDrawingRenderNode::ProcessRenderContents: GrContext is nullptr");
|
||||
if (!skSurface_ || width != skSurface_->width() || height != skSurface_->height()) {
|
||||
if (preThreadInfo_.second && skSurface_) {
|
||||
preThreadInfo_.second(std::move(skSurface_));
|
||||
}
|
||||
if (!ResetSurface(width, height, canvas)) {
|
||||
return;
|
||||
}
|
||||
skSurface_ = SkSurface::MakeRenderTarget(grContext, SkBudgeted::kNo, info);
|
||||
preThreadInfo_ = curThreadInfo_;
|
||||
} else if (preThreadInfo_.first != curThreadInfo_.first) {
|
||||
auto preSurface = skSurface_;
|
||||
if (!ResetSurface(width, height, canvas)) {
|
||||
return;
|
||||
}
|
||||
#if (defined NEW_SKIA) && (defined RS_ENABLE_GL)
|
||||
auto image = preSurface->makeImageSnapshot();
|
||||
if (!image) {
|
||||
return;
|
||||
}
|
||||
auto sharedBackendTexture = image->getBackendTexture(false);
|
||||
if (!sharedBackendTexture.isValid()) {
|
||||
RS_LOGE("RSCanvasDrawingRenderNode::ProcessRenderContents sharedBackendTexture is nullptr");
|
||||
return;
|
||||
}
|
||||
auto sharedTexture = SkImage::MakeFromTexture(canvas.recordingContext(), sharedBackendTexture,
|
||||
kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
if (sharedTexture == nullptr) {
|
||||
RS_LOGE("RSCanvasDrawingRenderNode::ProcessRenderContents sharedTexture is nullptr");
|
||||
return;
|
||||
}
|
||||
canvas_->drawImage(sharedTexture, 0.f, 0.f);
|
||||
#else
|
||||
skSurface_ = SkSurface::MakeRaster(info);
|
||||
if (auto image = preSurface->makeImageSnapshot()) {
|
||||
canvas_->drawImage(image, 0.f, 0.f);
|
||||
}
|
||||
#endif
|
||||
canvas_ = std::make_unique<RSPaintFilterCanvas>(skSurface_.get());
|
||||
if (preThreadInfo_.second && preSurface) {
|
||||
preThreadInfo_.second(std::move(preSurface));
|
||||
}
|
||||
preThreadInfo_ = curThreadInfo_;
|
||||
}
|
||||
|
||||
RSModifierContext context = { GetMutableRenderProperties(), canvas_.get() };
|
||||
ApplyDrawCmdModifier(context, RSModifierType::CONTENT_STYLE);
|
||||
|
||||
SkMatrix mat;
|
||||
if (RSPropertiesPainter::GetGravityMatrix(
|
||||
GetRenderProperties().GetFrameGravity(), GetRenderProperties().GetFrameRect(), width, height, mat)) {
|
||||
canvas.concat(mat);
|
||||
}
|
||||
auto image = skSurface_->makeImageSnapshot();
|
||||
auto srcRect = SkRect::MakeXYWH(0, 0, image->width(), image->height());
|
||||
auto dstRect =
|
||||
SkRect::MakeXYWH(0, 0, GetRenderProperties().GetFrameWidth(), GetRenderProperties().GetFrameHeight());
|
||||
#ifdef NEW_SKIA
|
||||
canvas.drawImageRect(image, srcRect, dstRect, SkSamplingOptions(), nullptr, SkCanvas::kFast_SrcRectConstraint);
|
||||
canvas.drawImage(image, 0.f, 0.f, SkSamplingOptions(), nullptr);
|
||||
#else
|
||||
canvas.drawImageRect(image, srcRect, dstRect, nullptr, SkCanvas::kFast_SrcRectConstraint);
|
||||
canvas.drawImage(image, 0.f, 0.f, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RSCanvasDrawingRenderNode::ResetSurface(int width, int height, RSPaintFilterCanvas& canvas)
|
||||
{
|
||||
SkImageInfo info = SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
|
||||
#if (defined RS_ENABLE_GL) && (defined RS_ENABLE_EGLIMAGE)
|
||||
#ifdef NEW_SKIA
|
||||
auto grContext = canvas.recordingContext();
|
||||
#else
|
||||
auto grContext = canvas.getGrContext();
|
||||
#endif
|
||||
if (grContext == nullptr) {
|
||||
RS_LOGE("RSCanvasDrawingRenderNode::ProcessRenderContents: GrContext is nullptr");
|
||||
return false;
|
||||
}
|
||||
skSurface_ = SkSurface::MakeRenderTarget(grContext, SkBudgeted::kNo, info);
|
||||
#else
|
||||
skSurface_ = SkSurface::MakeRaster(info);
|
||||
#endif
|
||||
if (!skSurface_) {
|
||||
RS_LOGE("RSCanvasDrawingRenderNode::ResetSurface SkSurface is nullptr");
|
||||
return false;
|
||||
}
|
||||
canvas_ = std::make_unique<RSPaintFilterCanvas>(skSurface_.get());
|
||||
return skSurface_ != nullptr;
|
||||
}
|
||||
|
||||
void RSCanvasDrawingRenderNode::ApplyDrawCmdModifier(RSModifierContext& context, RSModifierType type) const
|
||||
{
|
||||
auto it = drawCmdModifiers_.find(type);
|
||||
@ -83,9 +138,9 @@ void RSCanvasDrawingRenderNode::ApplyDrawCmdModifier(RSModifierContext& context,
|
||||
return;
|
||||
}
|
||||
for (const auto& modifier : it->second) {
|
||||
modifier->Apply(context);
|
||||
auto prop = modifier->GetProperty();
|
||||
auto cmd = std::static_pointer_cast<RSRenderProperty<DrawCmdListPtr>>(prop)->Get();
|
||||
cmd->Playback(*context.canvas_);
|
||||
cmd->ClearOp();
|
||||
}
|
||||
}
|
||||
@ -107,5 +162,26 @@ bool RSCanvasDrawingRenderNode::GetBitmap(SkBitmap& bitmap)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RSCanvasDrawingRenderNode::GetSizeFromDrawCmdModifiers(int& width, int& height)
|
||||
{
|
||||
auto it = drawCmdModifiers_.find(RSModifierType::CONTENT_STYLE);
|
||||
if (it == drawCmdModifiers_.end() || it->second.empty()) {
|
||||
return false;
|
||||
}
|
||||
for (const auto& modifier : it->second) {
|
||||
auto prop = modifier->GetProperty();
|
||||
if (auto cmd = std::static_pointer_cast<RSRenderProperty<DrawCmdListPtr>>(prop)->Get()) {
|
||||
width = std::max(width, cmd->GetWidth());
|
||||
height = std::max(height, cmd->GetHeight());
|
||||
}
|
||||
}
|
||||
if (width <= 0 || height <= 0) {
|
||||
RS_LOGE("RSCanvasDrawingRenderNode::GetSizeFromDrawCmdModifiers: The width or height of the canvas is less "
|
||||
"than or equal to 0");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -176,6 +176,16 @@ std::string DrawCmdList::PlayBackForRecord(RSPaintFilterCanvas& canvas, int star
|
||||
return str;
|
||||
}
|
||||
|
||||
void DrawCmdList::SetWidth(int width)
|
||||
{
|
||||
width_ = width;
|
||||
}
|
||||
|
||||
void DrawCmdList::SetHeight(int height)
|
||||
{
|
||||
height_ = height;
|
||||
}
|
||||
|
||||
std::string DrawCmdList::GetOpsWithDesc() const
|
||||
{
|
||||
std::string desc;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "pipeline/rs_render_node.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "animation/rs_render_animation.h"
|
||||
@ -116,38 +117,24 @@ bool RSRenderNode::Update(
|
||||
renderProperties_.ResetDirty();
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
if (RSSystemProperties::GetFilterCacheEnabled()) {
|
||||
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(GetRenderProperties().GetBoundsGeometry());
|
||||
auto absRect = geoPtr->GetAbsRect();
|
||||
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(GetRenderProperties().GetBoundsGeometry());
|
||||
auto& absRect = geoPtr->GetAbsRect();
|
||||
|
||||
// Note: cache manager will use dirty region to update cache validity, but:
|
||||
// background filter cache manager should use 'dirty region of all the nodes drawn before this node', and
|
||||
// foreground filter cache manager should use 'dirty region of all the nodes drawn before this node, this node,
|
||||
// and the children of this node'
|
||||
// Note:
|
||||
// 1. cache manager will use dirty region to update cache validity, background filter cache manager should use
|
||||
// 'dirty region of all the nodes drawn before this node', and foreground filter cache manager should use 'dirty
|
||||
// region of all the nodes drawn before this node, this node, and the children of this node'
|
||||
// 2. Filter must be valid when filter cache manager is valid, we make sure that in RSRenderNode::ApplyModifiers().
|
||||
|
||||
// background filter
|
||||
if (auto& filter = renderProperties_.GetBackgroundFilter()) {
|
||||
auto& manager = renderProperties_.backgroundFilterCacheManager_;
|
||||
if (manager == nullptr) {
|
||||
manager = std::make_unique<RSFilterCacheManager>();
|
||||
}
|
||||
// empty implementation, invalidate filter cache on every update
|
||||
manager->UpdateCacheState({ 0, 0, INT_MAX, INT_MAX }, absRect, filter->Hash());
|
||||
} else {
|
||||
renderProperties_.backgroundFilterCacheManager_.reset();
|
||||
}
|
||||
|
||||
// foreground filter
|
||||
if (auto& filter = renderProperties_.GetFilter()) {
|
||||
auto& manager = renderProperties_.filterCacheManager_;
|
||||
if (manager == nullptr) {
|
||||
manager = std::make_unique<RSFilterCacheManager>();
|
||||
}
|
||||
// empty implementation, invalidate filter cache on every update
|
||||
manager->UpdateCacheState({ 0, 0, INT_MAX, INT_MAX }, absRect, filter->Hash());
|
||||
} else {
|
||||
renderProperties_.filterCacheManager_.reset();
|
||||
}
|
||||
// background filter
|
||||
if (auto& manager = renderProperties_.backgroundFilterCacheManager_) {
|
||||
// empty implementation, invalidate filter cache on every update
|
||||
manager->UpdateCacheState({ 0, 0, INT_MAX, INT_MAX }, absRect, renderProperties_.GetBackgroundFilter()->Hash());
|
||||
}
|
||||
// foreground filter
|
||||
if (auto& manager = renderProperties_.filterCacheManager_) {
|
||||
// empty implementation, invalidate filter cache on every update
|
||||
manager->UpdateCacheState({ 0, 0, INT_MAX, INT_MAX }, absRect, renderProperties_.GetFilter()->Hash());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -386,15 +373,37 @@ void RSRenderNode::ApplyModifiers()
|
||||
for (auto type : dirtyTypes_) {
|
||||
renderProperties_.ResetProperty(type);
|
||||
}
|
||||
|
||||
auto dirtyStatus = renderProperties_.GetDirtyStatus();
|
||||
renderProperties_.Reset();
|
||||
for (auto& [id, modifier] : modifiers_) {
|
||||
if (modifier && (dirtyTypes_.find(modifier->GetType()) != dirtyTypes_.end())) {
|
||||
if (modifier) {
|
||||
modifier->Apply(context);
|
||||
}
|
||||
}
|
||||
renderProperties_.SetDirtyStatus(dirtyStatus);
|
||||
OnApplyModifiers();
|
||||
UpdateDrawRegion();
|
||||
dirtyTypes_.clear();
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
if (!RSSystemProperties::GetFilterCacheEnabled()) {
|
||||
return;
|
||||
}
|
||||
// make sure filter cache manager is created when filter is not null, and vice versa
|
||||
if (renderProperties_.GetBackgroundFilter() != nullptr &&
|
||||
renderProperties_.backgroundFilterCacheManager_ == nullptr) {
|
||||
renderProperties_.backgroundFilterCacheManager_ = std::make_unique<RSFilterCacheManager>();
|
||||
} else if (renderProperties_.GetBackgroundFilter() == nullptr &&
|
||||
renderProperties_.backgroundFilterCacheManager_ != nullptr) {
|
||||
renderProperties_.backgroundFilterCacheManager_.reset();
|
||||
}
|
||||
|
||||
if (renderProperties_.GetFilter() != nullptr && renderProperties_.filterCacheManager_ == nullptr) {
|
||||
renderProperties_.filterCacheManager_ = std::make_unique<RSFilterCacheManager>();
|
||||
} else if (renderProperties_.GetFilter() == nullptr && renderProperties_.filterCacheManager_ != nullptr) {
|
||||
renderProperties_.filterCacheManager_.reset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RSRenderNode::UpdateDrawRegion()
|
||||
@ -613,14 +622,21 @@ void RSRenderNode::DrawCacheSurface(RSPaintFilterCanvas& canvas, uint32_t thread
|
||||
float scaleY = size.y_ / boundsHeight_;
|
||||
canvas.scale(scaleX, scaleY);
|
||||
SkPaint paint;
|
||||
#ifdef NEW_SKIA
|
||||
#if defined(NEW_SKIA) && defined(RS_ENABLE_GL)
|
||||
if (isUIFirst) {
|
||||
if (cacheTexture_ == nullptr) {
|
||||
RS_LOGE("invalid cache texture");
|
||||
if (!grBackendTexture_.isValid()) {
|
||||
RS_LOGE("invalid grBackendTexture_");
|
||||
canvas.restore();
|
||||
return;
|
||||
}
|
||||
canvas.drawImage(cacheTexture_, -shadowRectOffsetX_ * scaleX, -shadowRectOffsetY_ * scaleY);
|
||||
auto image = SkImage::MakeFromTexture(canvas.recordingContext(), grBackendTexture_,
|
||||
kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
if (image == nullptr) {
|
||||
RS_LOGE("make Image failed");
|
||||
canvas.restore();
|
||||
return;
|
||||
}
|
||||
canvas.drawImage(image, -shadowRectOffsetX_ * scaleX, -shadowRectOffsetY_ * scaleY);
|
||||
canvas.restore();
|
||||
return;
|
||||
}
|
||||
@ -682,6 +698,18 @@ void RSRenderNode::DrawCacheSurface(RSPaintFilterCanvas& canvas, uint32_t thread
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RS_ENABLE_GL
|
||||
void RSRenderNode::UpdateBackendTexture()
|
||||
{
|
||||
std::scoped_lock<std::recursive_mutex> lock(surfaceMutex_);
|
||||
if (cacheSurface_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
grBackendTexture_
|
||||
= cacheSurface_->getBackendTexture(SkSurface::BackendHandleAccess::kFlushRead_BackendHandleAccess);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
sk_sp<SkSurface> RSRenderNode::GetCompletedCacheSurface(uint32_t threadIndex, bool isUIFirst)
|
||||
#else
|
||||
@ -705,7 +733,7 @@ std::shared_ptr<Drawing::Surface> RSRenderNode::GetCompletedCacheSurface(uint32_
|
||||
|
||||
void RSRenderNode::CheckGroupableAnimation(const PropertyId& id, bool isAnimAdd)
|
||||
{
|
||||
if (id <= 0) {
|
||||
if (id <= 0 || GetType() != RSRenderNodeType::CANVAS_NODE) {
|
||||
return;
|
||||
}
|
||||
auto context = GetContext().lock();
|
||||
|
@ -45,6 +45,7 @@ RSSurfaceRenderNode::RSSurfaceRenderNode(const RSSurfaceRenderNodeConfig& config
|
||||
: RSRenderNode(config.id, context),
|
||||
RSSurfaceHandler(config.id),
|
||||
name_(config.name),
|
||||
bundleName_(config.bundleName),
|
||||
nodeType_(config.nodeType),
|
||||
dirtyManager_(std::make_shared<RSDirtyRegionManager>()),
|
||||
cacheSurfaceDirtyManager_(std::make_shared<RSDirtyRegionManager>())
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user