mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-01-10 08:53:03 +00:00
commit
51f089e6a1
@ -42,7 +42,7 @@ public:
|
||||
static sptr<RawParser> GetInstance();
|
||||
|
||||
// 0 for success
|
||||
int32_t Parse(std::string &filename);
|
||||
int32_t Parse(int32_t width, int32_t height);
|
||||
|
||||
// 0 for success
|
||||
int32_t GetData(uint32_t count, uint8_t* &pData, uint32_t &offset, uint32_t &length);
|
||||
@ -52,7 +52,7 @@ public:
|
||||
|
||||
protected:
|
||||
// 0 for success
|
||||
int32_t ReadFile(std::string &filename);
|
||||
int32_t ReadFile(int32_t width, int32_t height);
|
||||
|
||||
private:
|
||||
static sptr<RawParser> instance;
|
||||
|
@ -63,10 +63,10 @@ int32_t Main::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t co
|
||||
}
|
||||
|
||||
if (last != count && length > 0) {
|
||||
memcpy_s(frame.get() + offset, addrSize - offset, data, length);
|
||||
(void)memcpy_s(frame.get() + offset, addrSize - offset, data, length);
|
||||
}
|
||||
|
||||
memcpy_s(addr, addrSize, frame.get(), addrSize);
|
||||
(void)memcpy_s(addr, addrSize, frame.get(), addrSize);
|
||||
last = count;
|
||||
LOG("GetData time: %{public}" PRIu64 ", data: %{public}p, length: %{public}d",
|
||||
GetNowTime() - start, data, length);
|
||||
@ -232,14 +232,8 @@ int main(int argc, const char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
const int32_t width = displays[0].width;
|
||||
const int32_t height = displays[0].height;
|
||||
|
||||
int64_t start = GetNowTime();
|
||||
std::stringstream ss;
|
||||
ss << "/system/etc/bootanimation-" << width << "x" << height << ".raw";
|
||||
std::string filename = ss.str();
|
||||
if (RawParser::GetInstance()->Parse(filename)) {
|
||||
if (RawParser::GetInstance()->Parse(displays[0].width, displays[0].height)) {
|
||||
return -1;
|
||||
}
|
||||
LOG("time: %{public}" PRIu64 "", GetNowTime() - start);
|
||||
@ -248,7 +242,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
auto runner = AppExecFwk::EventRunner::Create(false);
|
||||
auto handler = std::make_shared<AppExecFwk::EventHandler>(runner);
|
||||
handler->PostTask(std::bind(&Main::Init, &m, width, height));
|
||||
handler->PostTask(std::bind(&Main::Init, &m, displays[0].width, displays[0].height));
|
||||
runner->Run();
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,8 +16,10 @@
|
||||
#include "raw_parser.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <securec.h>
|
||||
#include <sstream>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
@ -46,9 +48,9 @@ RawParser::~RawParser()
|
||||
{
|
||||
}
|
||||
|
||||
int32_t RawParser::Parse(std::string &filename)
|
||||
int32_t RawParser::Parse(int32_t width, int32_t height)
|
||||
{
|
||||
int32_t ret = ReadFile(filename);
|
||||
int32_t ret = ReadFile(width, height);
|
||||
if (ret) {
|
||||
LOG("ReadFile failed");
|
||||
return ret;
|
||||
@ -127,11 +129,13 @@ int32_t RawParser::GetData(uint32_t count, uint8_t* &pData, uint32_t &offset, ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RawParser::ReadFile(std::string &filename)
|
||||
int32_t RawParser::ReadFile(int32_t width, int32_t height)
|
||||
{
|
||||
FILE *fp = fopen(filename.c_str(), "rb");
|
||||
std::stringstream ss;
|
||||
ss << "/system/etc/bootanimation-" << width << "x" << height << ".raw";
|
||||
FILE *fp = fopen(ss.str().c_str(), "rb");
|
||||
if (fp == nullptr) {
|
||||
LOG("open %{public}s failed, %{public}d", filename.c_str(), errno);
|
||||
LOG("open %{public}s failed, %{public}d", ss.str().c_str(), errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -140,7 +144,7 @@ int32_t RawParser::ReadFile(std::string &filename)
|
||||
(void)fseek(fp, 0, SEEK_SET);
|
||||
|
||||
if (clength < magicHeaderLength) {
|
||||
LOG("%{public}s is too small", filename.c_str());
|
||||
LOG("%{public}s is too small", ss.str().c_str());
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ HWTEST_F(SurfaceIPCTest, BufferIPC, testing::ext::TestSize.Level0)
|
||||
auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
sam->AddSystemAbility(ipcSystemAbilityID, producer->AsObject());
|
||||
|
||||
int64_t data;
|
||||
int64_t data = 0;
|
||||
write(pipeFd[1], &data, sizeof(data));
|
||||
sleep(0);
|
||||
read(pipeFd[0], &data, sizeof(data));
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
nameT = nameT.substr(sizeof("T ="), nameT.length() - sizeof("T = "));
|
||||
SingletonContainer::GetInstance()->AddSingleton(nameT, T::GetInstance());
|
||||
}
|
||||
~SingletonDelegator() = default;
|
||||
|
||||
template<class S>
|
||||
sptr<S> Dep()
|
||||
|
@ -69,14 +69,14 @@ void LogListener::RemoveListener(sptr<InputListener> &listener)
|
||||
delegator.Dep<InputListenerManager>()->RemoveListener(listener);
|
||||
}
|
||||
|
||||
void LogListener::PointerHandleEnter(void *data, uint32_t serial, double x, double y)
|
||||
void LogListener::PointerHandleEnter(void *data, uint32_t sss, double x, double y)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u, (%{public}lf, %{public}lf)", serial, x, y);
|
||||
WMLOGFD("sss: %{public}u, (%{public}lf, %{public}lf)", sss, x, y);
|
||||
}
|
||||
|
||||
void LogListener::PointerHandleLeave(void *data, uint32_t serial)
|
||||
void LogListener::PointerHandleLeave(void *data, uint32_t sss)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u", serial);
|
||||
WMLOGFD("sss: %{public}u", sss);
|
||||
}
|
||||
|
||||
void LogListener::PointerHandleMotion(void *data, uint32_t time, double x, double y)
|
||||
@ -84,11 +84,11 @@ void LogListener::PointerHandleMotion(void *data, uint32_t time, double x, doubl
|
||||
WMLOGFD("time: %{public}u, (%{public}lf, %{public}lf)", time, x, y);
|
||||
}
|
||||
|
||||
void LogListener::PointerHandleButton(void *data, uint32_t serial,
|
||||
void LogListener::PointerHandleButton(void *data, uint32_t sss,
|
||||
uint32_t time, uint32_t button, PointerButtonState state)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u, button: %{public}u, state: %{public}u, time: %{public}d",
|
||||
serial, button, state, time);
|
||||
WMLOGFD("sss: %{public}u, button: %{public}u, state: %{public}u, time: %{public}d",
|
||||
sss, button, state, time);
|
||||
}
|
||||
|
||||
void LogListener::PointerHandleFrame(void *data)
|
||||
@ -122,27 +122,27 @@ void LogListener::KeyboardHandleKeyMap(void *data,
|
||||
WMLOGFD("format: %{public}d, size: %{public}u", format, size);
|
||||
}
|
||||
|
||||
void LogListener::KeyboardHandleEnter(void *data, uint32_t serial, const std::vector<uint32_t> &keys)
|
||||
void LogListener::KeyboardHandleEnter(void *data, uint32_t sss, const std::vector<uint32_t> &keys)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u", serial);
|
||||
WMLOGFD("sss: %{public}u", sss);
|
||||
}
|
||||
|
||||
void LogListener::KeyboardHandleLeave(void *data, uint32_t serial)
|
||||
void LogListener::KeyboardHandleLeave(void *data, uint32_t sss)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u", serial);
|
||||
WMLOGFD("sss: %{public}u", sss);
|
||||
}
|
||||
|
||||
void LogListener::KeyboardHandleKey(void *data,
|
||||
uint32_t serial, uint32_t time, uint32_t key, KeyboardKeyState state)
|
||||
uint32_t sss, uint32_t time, uint32_t key, KeyboardKeyState state)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u, time: %{public}u, key: %{public}u, state: %{public}d",
|
||||
serial, time, key, state);
|
||||
WMLOGFD("sss: %{public}u, time: %{public}u, key: %{public}u, state: %{public}d",
|
||||
sss, time, key, state);
|
||||
}
|
||||
|
||||
void LogListener::KeyboardHandleModifiers(void *data, uint32_t serial,
|
||||
void LogListener::KeyboardHandleModifiers(void *data, uint32_t sss,
|
||||
uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u, modsDepressed: %{public}u", serial, modsDepressed);
|
||||
WMLOGFD("sss: %{public}u, modsDepressed: %{public}u", sss, modsDepressed);
|
||||
}
|
||||
|
||||
void LogListener::KeyboardHandleRepeatInfo(void *data, int32_t rate, int32_t delay)
|
||||
@ -151,20 +151,20 @@ void LogListener::KeyboardHandleRepeatInfo(void *data, int32_t rate, int32_t del
|
||||
}
|
||||
|
||||
void LogListener::TouchHandleDown(void *data,
|
||||
uint32_t serial, uint32_t time, int32_t id, double x, double y)
|
||||
uint32_t sss, uint32_t time, int32_t id, double x, double y)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u, time: %{public}u, id: %{public}d, (%{public}lf, %{public}lf)",
|
||||
serial, time, id, x, y);
|
||||
WMLOGFD("sss: %{public}u, time: %{public}u, (%{public}lf, %{public}lf)",
|
||||
sss, time, x, y);
|
||||
}
|
||||
|
||||
void LogListener::TouchHandleUp(void *data, uint32_t serial, uint32_t time, int32_t id)
|
||||
void LogListener::TouchHandleUp(void *data, uint32_t sss, uint32_t time, int32_t id)
|
||||
{
|
||||
WMLOGFD("serial: %{public}u, time: %{public}u, id: %{public}d", serial, time, id);
|
||||
WMLOGFD("sss: %{public}u, time: %{public}u", sss, time);
|
||||
}
|
||||
|
||||
void LogListener::TouchHandleMotion(void *data, uint32_t time, int32_t id, double x, double y)
|
||||
{
|
||||
WMLOGFD("time: %{public}u, id: %{public}d, (%{public}lf, %{public}lf)", time, id, x, y);
|
||||
WMLOGFD("time: %{public}u, (%{public}lf, %{public}lf)", time, x, y);
|
||||
}
|
||||
|
||||
void LogListener::TouchHandleFrame(void *data)
|
||||
@ -179,11 +179,11 @@ void LogListener::TouchHandleCancel(void *data)
|
||||
|
||||
void LogListener::TouchHandleShape(void *data, int32_t id, double major, double minor)
|
||||
{
|
||||
WMLOGFD("id: %{public}d, major: %{public}lf, minor: %{public}lf", id, major, minor);
|
||||
WMLOGFD("major: %{public}lf, minor: %{public}lf", major, minor);
|
||||
}
|
||||
|
||||
void LogListener::TouchHandleOrientation(void *data, int32_t id, double orientation)
|
||||
{
|
||||
WMLOGFD("id: %{public}d, orientation: %{public}lf", id, orientation);
|
||||
WMLOGFD("orientation: %{public}lf", orientation);
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#include "wl_shm_buffer_factory.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <map>
|
||||
#include <securec.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
@ -95,7 +95,7 @@ int32_t CreateShmFile(int32_t size)
|
||||
|
||||
ret = fcntl(fd, F_GETFD);
|
||||
if (ret == -1) {
|
||||
WMLOGFE("fcntl F_GETFD return -1, errno: %{public}s", strerror(ret));
|
||||
WMLOGFE("fcntl F_GETFD return -1, errno: %{public}s", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
@ -103,21 +103,21 @@ int32_t CreateShmFile(int32_t size)
|
||||
uint32_t flags = ret;
|
||||
ret = fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
||||
if (ret == -1) {
|
||||
WMLOGFE("fctn F_SETFD return -1, errno: %{public}s", strerror(ret));
|
||||
WMLOGFE("fctn F_SETFD return -1, errno: %{public}s", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = unlink(name.get());
|
||||
if (ret == -1) {
|
||||
WMLOGFE("unlink return -1, errno: %{public}s", strerror(ret));
|
||||
WMLOGFE("unlink return -1, errno: %{public}s", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ftruncate(fd, size);
|
||||
if (ret < 0) {
|
||||
WMLOGFE("ftruncate: %{public}s", strerror(ret));
|
||||
WMLOGFE("ftruncate: %{public}s", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
@ -176,6 +176,9 @@ sptr<WlBuffer> WlSHMBufferFactory::Create(uint32_t w, uint32_t h, int32_t format
|
||||
if (buffer == nullptr) {
|
||||
WMLOGFE("%{public}s failed, %{public}dx%{public}d, stride: %{public}d, format: %{public}d",
|
||||
"wl_shm_pool_create_buffer", w, h, stride, format);
|
||||
munmap(mmapPtr, mmapSize);
|
||||
close(fd);
|
||||
wl_shm_pool_destroy(pool);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -183,15 +186,20 @@ sptr<WlBuffer> WlSHMBufferFactory::Create(uint32_t w, uint32_t h, int32_t format
|
||||
if (display->GetError() != 0) {
|
||||
WMLOGFE("%{public}s failed with %{public}d, %{public}dx%{public}d, stride: %{public}d, format: %{public}d",
|
||||
"wl_shm_pool_create_buffer", display->GetError(), w, h, stride, format);
|
||||
wl_buffer_destroy(buffer);
|
||||
munmap(mmapPtr, mmapSize);
|
||||
close(fd);
|
||||
wl_shm_pool_destroy(pool);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<WlSHMBuffer> ret = new WlSHMBuffer(buffer);
|
||||
if (ret == nullptr) {
|
||||
WMLOGFE("new WlSHMBuffer failed");
|
||||
wl_buffer_destroy(buffer);
|
||||
munmap(mmapPtr, mmapSize);
|
||||
close(fd);
|
||||
wl_shm_pool_destroy(pool);
|
||||
return nullptr;
|
||||
}
|
||||
ret->SetMmap(mmapPtr, mmapSize);
|
||||
|
@ -86,7 +86,11 @@ HWTEST_F(WlDisplayTest, SyncPromise, testing::ext::TestSize.Level0)
|
||||
|
||||
// 2. wl_display_sync
|
||||
callCount = 0;
|
||||
auto callback = wl_display_sync(display->GetRawPtr());
|
||||
wl_callback *callback = nullptr;
|
||||
if (display->GetRawPtr() != nullptr) {
|
||||
callback = wl_display_sync(display->GetRawPtr());
|
||||
}
|
||||
|
||||
ASSERT_NE(callback, nullptr) << "CaseDescription: 2. wl_display_sync (callback != nullptr)";
|
||||
|
||||
const struct wl_callback_listener listener = { &WlDisplayTest::SyncDone };
|
||||
|
@ -53,7 +53,9 @@ static void RegistryHandleGlobal(void *data, struct wl_registry *registry,
|
||||
|
||||
if (strcmp(interface, "screen_info") == 0) {
|
||||
ctx->screenInfo = wl_registry_bind(registry, id, &screen_info_interface, 1);
|
||||
screen_info_add_listener(ctx->screenInfo, &g_listener, ctx);
|
||||
if (ctx->screenInfo != NULL) {
|
||||
screen_info_add_listener(ctx->screenInfo, &g_listener, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,19 +177,19 @@ struct WmsContext *GetWmsInstance(void)
|
||||
return &g_wmsCtx;
|
||||
}
|
||||
|
||||
static inline uint32_t GetBit(uint32_t flags, int32_t n)
|
||||
static inline uint32_t GetBit(uint32_t flags, uint32_t n)
|
||||
{
|
||||
return ((flags) & (1 << (n)));
|
||||
return flags & (1u << n);
|
||||
}
|
||||
|
||||
static inline void SetBit(uint32_t *flags, int32_t n)
|
||||
static inline void SetBit(uint32_t *flags, uint32_t n)
|
||||
{
|
||||
(*flags) |= (1 << (n));
|
||||
*flags |= (1u << n);
|
||||
}
|
||||
|
||||
static inline void ClearBit(uint32_t *flags, int32_t n)
|
||||
static inline void ClearBit(uint32_t *flags, uint32_t n)
|
||||
{
|
||||
(*flags) &= ~(1 << (n));
|
||||
*flags &= ~(1u << n);
|
||||
}
|
||||
|
||||
static inline int GetLayerId(uint32_t screenId, uint32_t type, uint32_t mode)
|
||||
@ -1256,7 +1256,7 @@ static void Screenshot(const struct ScreenshotFrameListener *pFrameListener, uin
|
||||
int32_t width = westonOutput->current_mode->width;
|
||||
int32_t height = westonOutput->current_mode->height;
|
||||
pixman_format_code_t format = westonOutput->compositor->read_format;
|
||||
int32_t stride = width * (PIXMAN_FORMAT_BPP(format) / PIXMAN_FORMAT_AVERAGE);
|
||||
int32_t stride = width * PIXMAN_FORMAT_BPP((uint32_t)format) / PIXMAN_FORMAT_AVERAGE;
|
||||
size_t size = stride * height;
|
||||
|
||||
int fd = CreateScreenshotFile(size);
|
||||
|
@ -84,13 +84,17 @@ void OnGlobalWindowStatus(void *, struct wms *, uint32_t a, uint32_t b, uint32_t
|
||||
WindowManagerServiceProxy::OnGlobalWindowStatus(a, b, c);
|
||||
}
|
||||
|
||||
void RegistryGlobal(void *pwms, struct wl_registry *registry,
|
||||
void RegistryGlobal(void *ppwms, struct wl_registry *registry,
|
||||
uint32_t id, const char *interface, uint32_t version)
|
||||
{
|
||||
if (ppwms == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(interface, "wms") == 0) {
|
||||
auto wms = static_cast<struct wms**>(pwms);
|
||||
auto &pwms = *static_cast<struct wms**>(ppwms);
|
||||
constexpr uint32_t wmsVersion = 1;
|
||||
*wms = (struct wms *)wl_registry_bind(registry, id, &wms_interface, wmsVersion);
|
||||
pwms = (struct wms *)wl_registry_bind(registry, id, &wms_interface, wmsVersion);
|
||||
const struct wms_listener listener = {
|
||||
nullptr,
|
||||
OnDisplayChange,
|
||||
@ -102,7 +106,9 @@ void RegistryGlobal(void *pwms, struct wl_registry *registry,
|
||||
OnWindowShotError,
|
||||
OnGlobalWindowStatus,
|
||||
};
|
||||
wms_add_listener(*wms, &listener, nullptr);
|
||||
if (pwms != nullptr) {
|
||||
wms_add_listener(pwms, &listener, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
@ -161,13 +167,13 @@ void WindowManagerServiceClientImpl::DispatchThreadMain()
|
||||
break;
|
||||
}
|
||||
|
||||
if (pfd[1].revents & POLLIN) {
|
||||
if ((uint32_t)pfd[1].revents & POLLIN) {
|
||||
WMLOGFI("return by interrupt");
|
||||
wl_display_cancel_read(display);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pfd[0].revents & POLLIN) {
|
||||
if ((uint32_t)pfd[0].revents & POLLIN) {
|
||||
wl_display_read_events(display);
|
||||
if (wl_display_dispatch_pending(display) == -1) {
|
||||
WMLOGFE("wl_display_dispatch_pending return -1");
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t maxWidth;
|
||||
uint32_t maxHeight;
|
||||
uint32_t maxWidth = 0;
|
||||
uint32_t maxHeight = 0;
|
||||
} g_autoload;
|
||||
} // namespace
|
||||
|
@ -180,7 +180,7 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t pipeFd[2];
|
||||
int32_t pipeFd[2] = {};
|
||||
static inline constexpr uint32_t SAID = 4699;
|
||||
sptr<Window> window;
|
||||
sptr<NativeTestSync> windowSync;
|
||||
|
Loading…
Reference in New Issue
Block a user