Compare commits

...
10 changed files with 530 additions and 34 deletions
+32 -5
View File
@@ -95,6 +95,7 @@ message_string="no"
osname="unspecified"
runtime_mode="procs"
compositing_schema="yes"
nr_concurrent_tasks=0
virtual_window="no"
use_shmopen="no"
mgslice_use_fallback="no"
@@ -853,12 +854,16 @@ build_ctrl_animation=$enableval)
if test "x$runtime_mode" == "xprocs"; then
AC_ARG_ENABLE(compositing,
[ --enable-compositing enable compositing schema (MiniGUI-Processes runmode only) <default=yes>],
compositing_schema=$enableval)
[ --enable-compositing enable compositing schema (MiniGUI-Processes runmode only) <default=yes>],
compositing_schema=$enableval)
AC_ARG_ENABLE(shmopen,
[ --enable-shmopen use shm_open <default=no>],
use_shmopen=$enableval)
[ --enable-shmopen use shm_open <default=no>],
use_shmopen=$enableval)
AC_ARG_WITH(concurrent_tasks,
[ --with-concurrent-tasks=[0/1/3/7]],
nr_concurrent_tasks=$withval)
fi
if test "x$runtime_mode" != "xths"; then
@@ -1755,7 +1760,7 @@ case "$runtime_mode" in
[Define if build MiniGUI-Processes])
MINIGUI_RUNMODE="procs"
if test "x$compositing_schema" = "xyes"; then
surface_schema="compositing"
surface_schema="compositing"
fi
if test "x$use_shmopen" = "xyes"; then
@@ -1777,9 +1782,30 @@ esac
if test "x$surface_schema" = "xcompositing"; then
AC_DEFINE(_MGSCHEMA_COMPOSITING, 1,
[Define if use compositing schema for the current runmode])
case "$nr_concurrent_tasks" in
1)
AC_DEFINE(_MGNR_CONCURRENT_TASKS, 1,
[The number of concurrent threads.])
;;
3)
AC_DEFINE(_MGNR_CONCURRENT_TASKS, 3,
[The number of concurrent threads.])
;;
7)
AC_DEFINE(_MGNR_CONCURRENT_TASKS, 7,
[The number of concurrent threads.])
;;
*)
AC_DEFINE(_MGNR_CONCURRENT_TASKS, 0,
[The number of concurrent threads.])
;;
esac
else
AC_DEFINE(_MGSCHEMA_SHAREDFB, 1,
[Define if use legacy schema (shared frame buffer) for the current runmode])
AC_DEFINE(_MGNR_CONCURRENT_TASKS, 0,
[The number of concurrent threads.])
fi
if test "x$virtual_window" = "xyes"; then
@@ -2794,6 +2820,7 @@ AC_MSG_NOTICE([
* Runtime mode: ${runtime_mode}
* Virtual Window: ${virtual_window}
* Surface schema: ${surface_schema}
* Concurrent Tasks: ${nr_concurrent_tasks}
* Use shm_open: ${use_shmopen}
* Incore resource: ${incore_res}
* Fallback mgslice: ${mgslice_use_fallback}
+1 -1
View File
@@ -6455,7 +6455,7 @@ MG_EXPORT RES_KEY Str2Key (const char* str);
* \fn int GUIAPI GetWindowZOrder(HWND hWnd);
* \brief Get The Control ZOrder in the parent window
*
* \param hWnd Handler of a control
* \param hWnd Handle of a control
*
* \return return index of ZOrder or 0 if hWnd is a MainWindow or -1 if error
*
+1 -1
View File
@@ -1303,7 +1303,7 @@ static void transit_to_layer (CompositorCtxt* ctxt, MG_Layer* to_layer)
}
}
_DBG_PRINTF ("Average time to composite the layers: %u (times: %u)\n", total_time_ms / total_times, total_times);
_WRN_PRINTF ("Average time to composite the layers: %u (times: %u)\n", total_time_ms / total_times, total_times);
}
CompositorOps __mg_fallback_compositor = {
+2
View File
@@ -42,6 +42,8 @@ COMMON_SRCS = \
surface-shm.c \
shadow-screen.h \
shadow-screen.c \
concurrent-tasks.h \
concurrent-tasks.c \
$(NULL_FILE)
libnewgal_la_SOURCES = $(COMMON_SRCS)
+2 -2
View File
@@ -77,13 +77,13 @@ static int GAL_SoftBlit(GAL_Surface *src, GAL_Rect *srcrect,
GAL_loblit RunBlit;
/* Set up the blit information */
info.s_pixels = (Uint8 *)src->pixels +
info.s_pixels = (Uint8 *)src->pixels + src->pixels_off +
(Uint16)srcrect->y*src->pitch +
(Uint16)srcrect->x*src->format->BytesPerPixel;
info.s_width = srcrect->w;
info.s_height = srcrect->h;
info.s_skip=src->pitch-info.s_width*src->format->BytesPerPixel;
info.d_pixels = (Uint8 *)dst->pixels +
info.d_pixels = (Uint8 *)dst->pixels + dst->pixels_off +
(Uint16)dstrect->y*dst->pitch +
(Uint16)dstrect->x*dst->format->BytesPerPixel;
info.d_width = dstrect->w;
File diff suppressed because it is too large Load Diff
+72
View File
@@ -0,0 +1,72 @@
///////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT NOTICE
//
// The following open source license statement does not apply to any
// entity in the Exception List published by FMSoft.
//
// For more information, please visit:
//
// https://www.fmsoft.cn/exception-list
//
//////////////////////////////////////////////////////////////////////////////
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
* Copyright (C) 2002~2020, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Or,
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
*/
/*
** The helpers for concurrent tasks.
**
** Current maintainer: Wei Yongming.
**
** Create date: 2021/05/21
*/
#ifndef _GAL_concurrent_tasks_h
#define _GAL_concurrent_tasks_h
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef void (*CCTaskProc)(void* context, int loop_idx);
int concurrentTasks_Init (void);
int concurrentTasks_Term (void);
int concurrentTasks_SplitRect (GAL_Rect* rcs, const GAL_Rect* rc, int count);
int concurrentTasks_Do (void* context, CCTaskProc proc);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GAL_concurrent_tasks_h */
+42
View File
@@ -49,6 +49,7 @@
#include "common.h"
#include "newgal.h"
#include "blit.h"
#include "concurrent-tasks.h"
#define DEFINE_COPY_ROW(name, type) \
static void name(type *src, int src_w, type *dst, int dst_w) \
@@ -377,6 +378,31 @@ int GAL_CleanupStretchBlit (GAL_Surface *src, GAL_Surface *dst)
return 0;
}
#ifdef _MGRM_PROCESSES
typedef struct _ContextStretch {
pixman_op_t op;
pixman_image_t *src_img;
pixman_image_t *msk_img;
pixman_image_t *dst_img;
GAL_Rect dst_rects [_MGNR_CONCURRENT_TASKS + 1];
} ContextStretch;
static void stretch_proc (void* context, int loop_idx)
{
ContextStretch *ctxt = context;
if (ctxt->dst_rects[loop_idx].h > 0) {
GAL_Rect* dstrect = ctxt->dst_rects + loop_idx;
pixman_image_composite32 (ctxt->op, ctxt->src_img, ctxt->msk_img, ctxt->dst_img,
dstrect->x, dstrect->y,
0, 0,
dstrect->x, dstrect->y,
dstrect->w, dstrect->h);
}
}
#endif
int GAL_StretchBlt (GAL_Surface *src, GAL_Rect *srcrect,
GAL_Surface *dst, GAL_Rect *dstrect,
const STRETCH_EXTRA_INFO* sei, DWORD ops)
@@ -409,11 +435,27 @@ int GAL_StretchBlt (GAL_Surface *src, GAL_Rect *srcrect,
dst->clip_rect.x, dst->clip_rect.y, dst->clip_rect.w, dst->clip_rect.h);
pixman_image_set_clip_region32 (dst_img, &clip_region);
#ifdef _MGRM_PROCESSES
// we use concurrent tasks only under MiniGUI-Processes.
{
ContextStretch ctxt;
ctxt.op = op;
ctxt.src_img = src_img;
ctxt.msk_img = msk_img;
ctxt.dst_img = dst_img;
concurrentTasks_SplitRect (ctxt.dst_rects, dstrect, _MGNR_CONCURRENT_TASKS + 1);
concurrentTasks_Do (&ctxt, stretch_proc);
}
#else
pixman_image_composite32 (op, src_img, msk_img, dst_img,
dstrect->x, dstrect->y,
0, 0,
dstrect->x, dstrect->y,
dstrect->w, dstrect->h);
#endif
pixman_region32_fini (&clip_region);
return 0;
+41 -25
View File
@@ -56,6 +56,7 @@
#include "pixels_c.h"
#include "memops.h"
#include "leaks.h"
#include "concurrent-tasks.h"
#ifdef _MGRM_PROCESSES
#include <sys/mman.h> /* for munmap */
@@ -493,6 +494,28 @@ static int own_overlapped_bitblit(GAL_blit real_blit, struct GAL_Surface *src, G
}
#endif
#ifdef _MGRM_PROCESSES
typedef struct _ContextBlit {
GAL_Surface *src;
GAL_Surface *dst;
GAL_blit real_blit;
GAL_Rect src_rects [_MGNR_CONCURRENT_TASKS + 1];
GAL_Rect dst_rects [_MGNR_CONCURRENT_TASKS + 1];
} ContextBlit;
static void blit_proc (void* context, int loop_idx)
{
ContextBlit *ctxt = context;
if (ctxt->src_rects[loop_idx].h > 0) {
ctxt->real_blit (ctxt->src, ctxt->src_rects + loop_idx,
ctxt->dst, ctxt->dst_rects + loop_idx);
}
}
#endif
/*
* Set up a blit between two surfaces -- split into three parts:
* The upper part, GAL_UpperBlit(), performs clipping and rectangle
@@ -538,38 +561,31 @@ int GAL_LowerBlit (GAL_Surface *src, GAL_Rect *srcrect,
}
#endif
#ifdef MG_CONFIG_USE_OWN_OVERLAPPED_BITBLIT
ret = own_overlapped_bitblit(do_blit, src, srcrect, dst, dstrect);
#else
ret = do_blit(src, srcrect, dst, dstrect);
#endif
#if 0
#ifdef _MGRM_PROCESSES
// we use concurrent tasks only under MiniGUI-Processes.
{
static int n_sw=0, n_hw=0;
if ((src->flags & GAL_HWACCEL) == GAL_HWACCEL)
{
n_hw ++;
}
else
{
n_sw ++;
}
printf("[%06u] hw/blit=%d/%d %c size=%dX%d src=(%d %d),%p dst=(%d %d),%p\n",
times(NULL) % 1000000,
n_hw, n_hw+n_sw,
do_blit == src->map->sw_blit ? 'S':'H',
srcrect->w, srcrect->h,
srcrect->x, srcrect->y, src,
dstrect->x, dstrect->y, dst
);
ContextBlit ctxt;
ctxt.src = src;
ctxt.dst = dst;
ctxt.real_blit = do_blit;
concurrentTasks_SplitRect (ctxt.src_rects, srcrect, _MGNR_CONCURRENT_TASKS + 1);
concurrentTasks_SplitRect (ctxt.dst_rects, dstrect, _MGNR_CONCURRENT_TASKS + 1);
concurrentTasks_Do (&ctxt, blit_proc);
}
#else
# ifdef MG_CONFIG_USE_OWN_OVERLAPPED_BITBLIT
ret = own_overlapped_bitblit(do_blit, src, srcrect, dst, dstrect);
# else
ret = do_blit(src, srcrect, dst, dstrect);
# endif
#endif
return ret;
}
int GAL_UpperBlit (GAL_Surface *src, GAL_Rect *srcrect,
GAL_Surface *dst, GAL_Rect *dstrect, DWORD op)
{
+13
View File
@@ -58,6 +58,7 @@
#include "pixels_c.h"
#include "license.h"
#include "debug.h"
#include "concurrent-tasks.h"
/* Available video drivers */
static VideoBootStrap *bootstrap[] = {
@@ -288,6 +289,12 @@ int GAL_VideoInit (const char *driver_name, Uint32 flags)
video->info.vfmt = GAL_VideoSurface->format;
#ifdef _MGRM_PROCESSES
// we use concurrent tasks only under MiniGUI-Processes.
if (concurrentTasks_Init ())
return -1;
#endif
return(0);
}
@@ -1154,6 +1161,12 @@ void GAL_VideoQuit (void)
DestroyFreeClipRectList (&__mg_free_update_region_list);
#endif
}
#ifdef _MGRM_PROCESSES
// we use concurrent tasks only under MiniGUI-Processes.
concurrentTasks_Term ();
#endif
return;
}