Commit f65fddcb4ab0533d1a4e9f6a15cf5ecd631c752f

Authored by 신재종
1 parent 85a310d3f5
Exists in master

add release option on Makefile. vnc screen content transfer checked

Showing 3 changed files with 95 additions and 99 deletions   Show diff stats
1 -TOOLCHAIN_DIR = /opt/fsl-imx-wayland/5.10-hardknott  
2 -SDKTARGETSYSROOT = $(TOOLCHAIN_DIR)/sysroots/cortexa53-crypto-poky-linux  
3 -  
4 -CC_PATH = /opt/fsl-imx-wayland/5.10-hardknott/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux  
5 -CROSS_FREFIX = $(CC_PATH)/aarch64-poky-linux-  
6 -GCC = $(CROSS_FREFIX)gcc  
7 -  
8 -CFLAGS=-mcpu=cortex-a53 -march=armv8-a+crc+crypto -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  
9 -LDFLAGS=-lpthread -lm -L. -lvncserver  
10 -INC=-I./protocol -I./shared -I./  
11 -  
12 -CFLAGS+=`pkg-config --cflags pixman-1`  
13 -LDFLAGS+=`pkg-config --libs pixman-1`  
14 -  
15 -CFLAGS+=`pkg-config --cflags libweston-9`  
16 -LDFLAGS+=`pkg-config --libs libweston-9`  
17 -  
18 -CFLAGS+=`pkg-config --cflags gtk+-wayland-3.0`  
19 -LDFLAGS+=`pkg-config --libs gtk+-wayland-3.0`  
20 -  
21 -CFLAGS+=`pkg-config --cflags glib-2.0`  
22 -LDFLAGS+=`pkg-config --libs glib-2.0`  
23 -  
24 -CFLAGS+=`pkg-config --cflags pango`  
25 -LDFLAGS+=`pkg-config --libs pango`  
26 -  
27 -CFLAGS+=`pkg-config --cflags harfbuzz`  
28 -LDFLAGS+=`pkg-config --libs harfbuzz`  
29 -  
30 -CFLAGS+=`pkg-config --cflags wayland-server`  
31 -LDFLAGS+=`pkg-config --libs wayland-server`  
32 -  
33 -CFLAGS+=`pkg-config --cflags wayland-client`  
34 -LDFLAGS+=`pkg-config --libs wayland-client`  
35 -  
36 -CFLAGS+=`pkg-config --cflags xkbcommon`  
37 -LDFLAGS+=`pkg-config --libs xkbcommon`  
38 -  
39 -CFLAGS+=`pkg-config --cflags wayland-cursor`  
40 -LDFLAGS+=`pkg-config --libs wayland-cursor`  
41 -  
42 -CFLAGS+=`pkg-config --cflags weston`  
43 -LDFLAGS+=`pkg-config --libs weston`  
44 -  
45 -CFLAGS+=`pkg-config --cflags cairo-png`  
46 -LDFLAGS+=`pkg-config --libs cairo-png`  
47 -  
48 -CFLAGS+=`pkg-config --cflags libjpeg`  
49 -LDFLAGS+=`pkg-config --libs libjpeg`  
50 -  
51 -#CFLAGS+=`pkg-config --cflags `  
52 -#LDFLAGS+=`pkg-config --libs `  
53 -  
54 -#CFLAGS+=`pkg-config --cflags `  
55 -#LDFLAGS+=`pkg-config --libs `  
56 -  
57 -#CFLAGS+=`pkg-config --cflags `  
58 -#LDFLAGS+=`pkg-config --libs `  
59 -  
60 -  
61 -all:  
62 - $(GCC) $(CFLAGS) --sysroot $(SDKTARGETSYSROOT) $(LDFLAGS) $(INC) -o weston-vncserver \  
63 - vncserver.c \  
64 - protocol/pointer-constraints-unstable-v1-protocol.c \  
65 - protocol/relative-pointer-unstable-v1-protocol.c \  
66 - protocol/text-cursor-position-protocol.c \  
67 - protocol/viewporter-protocol.c \  
68 - protocol/weston-screenshooter-protocol.c \  
69 - protocol/xdg-shell-protocol.c \  
70 - shared/os-compatibility.c \  
71 - shared/xalloc.c \  
72 - shared/file-util.c \  
73 - shared/cairo-util.c \  
74 - shared/frame.c \  
75 - shared/image-loader.c \  
76 - window.c  
77 -  
78 -clean:  
79 - rm weston-vncserver 1 +TOOLCHAIN_DIR = /opt/fsl-imx-wayland/5.10-hardknott
  2 +SDKTARGETSYSROOT = $(TOOLCHAIN_DIR)/sysroots/cortexa53-crypto-poky-linux
  3 +
  4 +CC_PATH = /opt/fsl-imx-wayland/5.10-hardknott/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux
  5 +CROSS_PREFIX = $(CC_PATH)/aarch64-poky-linux-
  6 +GCC = $(CROSS_PREFIX)gcc
  7 +STRIP = $(CROSS_PREFIX)strip
  8 +
  9 +CFLAGS=-mcpu=cortex-a53 -march=armv8-a+crc+crypto -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security
  10 +LDFLAGS=-lpthread -lm -L. -lvncserver
  11 +INC=-I./protocol -I./shared -I./
  12 +
  13 +CFLAGS+=`pkg-config --cflags pixman-1 libweston-9 gtk+-wayland-3.0 glib-2.0 pango harfbuzz wayland-server wayland-client xkbcommon wayland-cursor weston cairo-png libjpeg`
  14 +LDFLAGS+=`pkg-config --libs pixman-1 libweston-9 gtk+-wayland-3.0 glib-2.0 pango harfbuzz wayland-server wayland-client xkbcommon wayland-cursor weston cairo-png libjpeg`
  15 +
  16 +#CFLAGS+=`pkg-config --cflags `
  17 +#LDFLAGS+=`pkg-config --libs `
  18 +
  19 +debug:
  20 + $(GCC) $(CFLAGS) --sysroot $(SDKTARGETSYSROOT) $(LDFLAGS) $(INC) -o weston-vncserver \
  21 + vncserver.c \
  22 + protocol/pointer-constraints-unstable-v1-protocol.c \
  23 + protocol/relative-pointer-unstable-v1-protocol.c \
  24 + protocol/text-cursor-position-protocol.c \
  25 + protocol/viewporter-protocol.c \
  26 + protocol/weston-screenshooter-protocol.c \
  27 + protocol/xdg-shell-protocol.c \
  28 + shared/os-compatibility.c \
  29 + shared/xalloc.c \
  30 + shared/file-util.c \
  31 + shared/cairo-util.c \
  32 + shared/frame.c \
  33 + shared/image-loader.c \
  34 + window.c
  35 +
  36 +release: debug
  37 + @echo "#### STRIP ####"
  38 + $(STRIP) weston-vncserver
  39 +
  40 +
  41 +clean:
  42 + rm weston-vncserver
@@ -21,6 +21,8 @@ @@ -21,6 +21,8 @@
21 * DEALINGS IN THE SOFTWARE. 21 * DEALINGS IN THE SOFTWARE.
22 */ 22 */
23 23
  24 +// #define DBG_FPS
  25 +
24 #define LCD_WIDTH 1024 26 #define LCD_WIDTH 1024
25 #define LCD_HEIGHT 768 27 #define LCD_HEIGHT 768
26 28
@@ -714,40 +716,57 @@ get_screenshot(const struct buffer_size *buff_size, @@ -714,40 +716,57 @@ get_screenshot(const struct buffer_size *buff_size,
714 { 716 {
715 int output_stride, buffer_stride, i; 717 int output_stride, buffer_stride, i;
716 cairo_surface_t *surface; 718 cairo_surface_t *surface;
717 - char *data, *d, *s; 719 + char *data, *d, *s, *vnc;
718 struct screenshooter_output *output, *next; 720 struct screenshooter_output *output, *next;
719 FILE *fp; 721 FILE *fp;
720 char filepath[PATH_MAX]; 722 char filepath[PATH_MAX];
721 723
722 buffer_stride = buff_size->width * 4; 724 buffer_stride = buff_size->width * 4;
  725 + // printf("buff_size->width[%d] buff_size->height[%d] \n",buff_size->width, buff_size->height);
  726 + // printf("buffer_stride[%d] * buff_size->height[%d] = %d\n",buffer_stride, buff_size->height, buffer_stride * buff_size->height);
  727 + data = xmalloc(LCD_WIDTH * 4 * LCD_HEIGHT);
  728 + vnc = xmalloc(LCD_WIDTH * 4 * LCD_HEIGHT);
723 729
  730 + // printf("data[%p] vnc[%p]\n",data,vnc);
724 // printf("buffer_stride[%d] * buff_size->height[%d] = %d\n",buffer_stride, buff_size->height, buffer_stride * buff_size->height); 731 // printf("buffer_stride[%d] * buff_size->height[%d] = %d\n",buffer_stride, buff_size->height, buffer_stride * buff_size->height);
725 data = xmalloc(1024 * 4 * 768); 732 data = xmalloc(1024 * 4 * 768);
726 - if (!data) 733 + if (!data || !vnc)
727 { 734 {
728 - return; 735 + return -1;
729 } 736 }
730 737
731 wl_list_for_each_safe(output, next, output_list, link) 738 wl_list_for_each_safe(output, next, output_list, link)
732 { 739 {
  740 + // printf("output->offset_x[%d] output->width[%d] output->height[%d]\n",output->offset_x,output->width,output->height);
733 if (output->offset_x == 0) 741 if (output->offset_x == 0)
734 { 742 {
735 output_stride = 4; 743 output_stride = 4;
736 - d = data + 1024 * 4 * 767 + 1023 * 4; 744 + d = data + (LCD_WIDTH * LCD_HEIGHT - 1) * output_stride;
737 s = output->data; 745 s = output->data;
738 746
739 - for (i = 0; i < 1024*768; i++) 747 + for (i = 0; i < LCD_WIDTH * LCD_HEIGHT; i++)
740 { 748 {
741 memcpy(d, s, output_stride); 749 memcpy(d, s, output_stride);
742 d -= output_stride; 750 d -= output_stride;
743 s += output_stride; 751 s += output_stride;
744 } 752 }
745 753
  754 + d = vnc;
  755 + s = data;
  756 + // printf("d[%p] s[%p]\n",d,s);
  757 + for(i = 0; i < LCD_WIDTH * LCD_HEIGHT; i++)
  758 + {
  759 + d[0] = s[2];
  760 + d[1] = s[1];
  761 + d[2] = s[0];
  762 + d[3] = s[3];
  763 + d += output_stride;
  764 + s += output_stride;
  765 + // printf("i[%10d] [%p] s[%p]\n",i,d,s);
  766 + }
  767 +
746 wl_buffer_destroy(output->buffer); 768 wl_buffer_destroy(output->buffer);
747 - int ret = munmap(output->data, 1024*4*768);  
748 - // printf("munmap error[%d]\n",ret);  
749 - // printf("%s\n",strerror(errno));  
750 - // free(output->buffer); 769 + int ret = munmap(output->data, LCD_WIDTH * 4 * LCD_HEIGHT);
751 } 770 }
752 771
753 wl_registry_destroy(output->output); 772 wl_registry_destroy(output->output);
@@ -760,6 +779,9 @@ get_screenshot(const struct buffer_size *buff_size, @@ -760,6 +779,9 @@ get_screenshot(const struct buffer_size *buff_size,
760 // fwrite(data, 1, 1024 * 4 * 768, fp); 779 // fwrite(data, 1, 1024 * 4 * 768, fp);
761 // fclose (fp); 780 // fclose (fp);
762 // } 781 // }
  782 + memcpy(fb, vnc, LCD_WIDTH * LCD_HEIGHT * 4);
  783 + rfbMarkRectAsModified(server, 0, 0, LCD_WIDTH, LCD_HEIGHT);
  784 + free(vnc);
763 785
764 return data; 786 return data;
765 } 787 }
@@ -780,7 +802,7 @@ image_create(struct display *display, const char *filename, @@ -780,7 +802,7 @@ image_create(struct display *display, const char *filename,
780 sprintf(title,"weston_clone_app"); 802 sprintf(title,"weston_clone_app");
781 image->filename = strdup(title); 803 image->filename = strdup(title);
782 804
783 - image->image = cairo_image_surface_create_for_data(cap_img, CAIRO_FORMAT_ARGB32, 1024, 768, 1024*4); 805 + image->image = cairo_image_surface_create_for_data(cap_img, CAIRO_FORMAT_ARGB32, LCD_WIDTH, LCD_HEIGHT, LCD_WIDTH*4);
784 double width = cairo_image_surface_get_width(image->image); 806 double width = cairo_image_surface_get_width(image->image);
785 double height = cairo_image_surface_get_height(image->image); 807 double height = cairo_image_surface_get_height(image->image);
786 printf("1 width[%f] height[%f]\n",width,height); 808 printf("1 width[%f] height[%f]\n",width,height);
@@ -944,7 +966,7 @@ char *get_weston_screen_image() @@ -944,7 +966,7 @@ char *get_weston_screen_image()
944 wl_list_for_each(output, &sh_data.output_list, link) 966 wl_list_for_each(output, &sh_data.output_list, link)
945 { 967 {
946 if ((output->offset_x == 0) && 968 if ((output->offset_x == 0) &&
947 - ((output->width == 1024) && (output->height == 768))) 969 + ((output->width == LCD_WIDTH) && (output->height == LCD_HEIGHT)))
948 { 970 {
949 // printf("output->offset_x[%d]\n",output->offset_x); 971 // printf("output->offset_x[%d]\n",output->offset_x);
950 output->buffer = 972 output->buffer =
@@ -973,8 +995,8 @@ char *get_weston_screen_image() @@ -973,8 +995,8 @@ char *get_weston_screen_image()
973 } 995 }
974 } 996 }
975 // end of screenshoot 997 // end of screenshoot
976 -  
977 - if (buff_size.height == 768) 998 + // printf("buff_size.width[%d] buff_size.height[%d]\n",buff_size.width,buff_size.height);
  999 + if (buff_size.height == LCD_HEIGHT)
978 { 1000 {
979 cap_img = get_screenshot(&buff_size, &sh_data.output_list); 1001 cap_img = get_screenshot(&buff_size, &sh_data.output_list);
980 } 1002 }
@@ -983,13 +1005,18 @@ char *get_weston_screen_image() @@ -983,13 +1005,18 @@ char *get_weston_screen_image()
983 struct screenshooter_output *output, *next; 1005 struct screenshooter_output *output, *next;
984 wl_list_for_each_safe(output, next, &sh_data.output_list, link) 1006 wl_list_for_each_safe(output, next, &sh_data.output_list, link)
985 { 1007 {
986 - int ret = munmap(output->data, 1024*4*768); 1008 + // printf("output->width[%d] output->height[%d]\n",output->width,output->height);
  1009 + int ret = munmap(output->data, output->width*4*output->height);
  1010 +
987 // printf("munmap error[%d]\n",ret); 1011 // printf("munmap error[%d]\n",ret);
988 // printf("%s\n",strerror(errno)); 1012 // printf("%s\n",strerror(errno));
989 1013
990 - wl_registry_destroy(output->output); 1014 + if(output->output)
  1015 + wl_registry_destroy(output->output);
991 wl_list_remove(&output->link); 1016 wl_list_remove(&output->link);
992 - wl_buffer_destroy(output->buffer); 1017 +
  1018 + if(output->buffer)
  1019 + wl_buffer_destroy(output->buffer);
993 // free(output->buffer); 1020 // free(output->buffer);
994 free(output); 1021 free(output);
995 } 1022 }
@@ -1078,11 +1105,15 @@ int main(int argc, char *argv[]) @@ -1078,11 +1105,15 @@ int main(int argc, char *argv[])
1078 int i; 1105 int i;
1079 int image_counter = 0; 1106 int image_counter = 0;
1080 char *cap_img = NULL; 1107 char *cap_img = NULL;
  1108 +#ifdef DBG_FPS
1081 struct timespec start_time, end_time; 1109 struct timespec start_time, end_time;
  1110 +#endif
1082 init_vnc(argc, argv); 1111 init_vnc(argc, argv);
1083 1112
1084 d = display_create(&argc, argv); 1113 d = display_create(&argc, argv);
1085 cap_img = get_weston_screen_image(); 1114 cap_img = get_weston_screen_image();
  1115 + if(cap_img == NULL || cap_img == -1)
  1116 + return -1;
1086 pimage = image_create(d, argv[i], &image_counter,cap_img); 1117 pimage = image_create(d, argv[i], &image_counter,cap_img);
1087 1118
1088 // full screen with 1x zoom scale 1119 // full screen with 1x zoom scale
@@ -1100,10 +1131,10 @@ int main(int argc, char *argv[]) @@ -1100,10 +1131,10 @@ int main(int argc, char *argv[])
1100 sigemptyset(&sigint.sa_mask); 1131 sigemptyset(&sigint.sa_mask);
1101 sigint.sa_flags = SA_RESETHAND; 1132 sigint.sa_flags = SA_RESETHAND;
1102 sigaction(SIGINT, &sigint, NULL); 1133 sigaction(SIGINT, &sigint, NULL);
1103 - 1134 +#ifdef DBG_FPS
1104 clock_gettime(CLOCK_MONOTONIC, &end_time); 1135 clock_gettime(CLOCK_MONOTONIC, &end_time);
1105 memcpy(&start_time, &end_time, sizeof(struct timespec)); 1136 memcpy(&start_time, &end_time, sizeof(struct timespec));
1106 - 1137 +#endif
1107 int loop = 0; 1138 int loop = 0;
1108 long long usec; 1139 long long usec;
1109 while (isloop) 1140 while (isloop)
@@ -1115,16 +1146,18 @@ int main(int argc, char *argv[]) @@ -1115,16 +1146,18 @@ int main(int argc, char *argv[])
1115 free(cap_img); 1146 free(cap_img);
1116 cap_img = get_weston_screen_image(); // 80 msec 1147 cap_img = get_weston_screen_image(); // 80 msec
1117 cairo_surface_destroy(pimage->image); // 70 usec 1148 cairo_surface_destroy(pimage->image); // 70 usec
1118 - pimage->image = cairo_image_surface_create_for_data(cap_img, CAIRO_FORMAT_ARGB32,1024, 768, 1024*4); 1149 + pimage->image = cairo_image_surface_create_for_data(cap_img, CAIRO_FORMAT_ARGB32,LCD_WIDTH, LCD_HEIGHT, LCD_WIDTH*4);
1119 1150
1120 // ui redraw request 1151 // ui redraw request
1121 window_schedule_redraw(pimage->window); 1152 window_schedule_redraw(pimage->window);
1122 1153
1123 // fps calc. 1154 // fps calc.
  1155 +#ifdef DBG_FPS
1124 clock_gettime(CLOCK_MONOTONIC, &end_time); 1156 clock_gettime(CLOCK_MONOTONIC, &end_time);
1125 usec = (end_time.tv_sec - start_time.tv_sec) * 1000000 + (end_time.tv_nsec - start_time.tv_nsec) / 1000; 1157 usec = (end_time.tv_sec - start_time.tv_sec) * 1000000 + (end_time.tv_nsec - start_time.tv_nsec) / 1000;
1126 - // printf("%d : %lld usec / %lld fps\n", loop++, usec, 1000000UL / usec); 1158 + printf("%d : %lld usec / %lld fps\n", loop++, usec, 1000000UL / usec);
1127 memcpy(&start_time, &end_time, sizeof(struct timespec)); 1159 memcpy(&start_time, &end_time, sizeof(struct timespec));
  1160 +#endif
1128 } 1161 }
1129 1162
1130 free(cap_img); 1163 free(cap_img);
weston-vncserver
No preview for this file type