Subversion Repositories Kolibri OS

Rev

Rev 2360 | Rev 3031 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2360 Rev 2361
Line 59... Line 59...
59
    void      (*show_cursor)(int show);
59
    void      (*show_cursor)(int show);
60
    void      (__stdcall *move_cursor)(cursor_t *cursor, int x, int y);
60
    void      (__stdcall *move_cursor)(cursor_t *cursor, int x, int y);
61
    void      (__stdcall *restore_cursor)(int x, int y);
61
    void      (__stdcall *restore_cursor)(int x, int y);
62
    void      (*disable_mouse)(void);
62
    void      (*disable_mouse)(void);
63
};
63
    u32  mask_seqno;
-
 
64
};
64
 
65
 
Line 65... Line 66...
65
 
66
 
Line 962... Line 963...
962
    ring->add_request(ring, &seqno);
963
    ring->add_request(ring, &seqno);
Line 963... Line 964...
963
 
964
 
Line 964... Line -...
964
//    i915_interrupt_info(main_device);
-
 
965
 
965
//    i915_interrupt_info(main_device);
Line 966... Line 966...
966
//    ironlake_enable_vblank(main_device, 0);
966
 
967
};
967
};
Line 1005... Line 1005...
1005
    sna_blit_copy(dst_bitmap, dst_x, dst_y, w, h, src_bitmap, src_x, src_y);
1005
    sna_blit_copy(dst_bitmap, dst_x, dst_y, w, h, src_bitmap, src_x, src_y);
Line 1006... Line 1006...
1006
 
1006
 
Line -... Line 1007...
-
 
1007
};
-
 
1008
 
-
 
1009
int sna_blit_tex(bitmap_t *dst_bitmap, int dst_x, int dst_y,
-
 
1010
                  int w, int h, bitmap_t *src_bitmap, int src_x, int src_y,
-
 
1011
                  bitmap_t *mask_bitmap);
-
 
1012
 
-
 
1013
int create_context();
-
 
1014
struct context *get_context();
-
 
1015
 
-
 
1016
int blit_tex(u32 hbitmap, int  dst_x, int dst_y,
-
 
1017
             int src_x, int src_y, u32 w, u32 h)
-
 
1018
{
-
 
1019
    drm_i915_private_t *dev_priv = main_device->dev_private;
-
 
1020
    struct context *ctx;
-
 
1021
 
-
 
1022
    bitmap_t  *src_bitmap, *dst_bitmap;
-
 
1023
    bitmap_t   screen;
-
 
1024
    int        ret;
-
 
1025
 
-
 
1026
    bitmap_t *mask_bitmap;
-
 
1027
    rect_t     winrc;
-
 
1028
 
-
 
1029
//    dbgprintf("  handle: %d dx %d dy %d sx %d sy %d w %d h %d\n",
-
 
1030
//              hbitmap, dst_x, dst_y, src_x, src_y, w, h);
-
 
1031
 
-
 
1032
    if(unlikely(hbitmap==0))
-
 
1033
        return -1;
-
 
1034
 
-
 
1035
    src_bitmap = (bitmap_t*)hman_get_data(&bm_man, hbitmap);
-
 
1036
//    dbgprintf("bitmap %x\n", src_bitmap);
-
 
1037
 
-
 
1038
    if(unlikely(src_bitmap==NULL))
-
 
1039
        return -1;
-
 
1040
 
-
 
1041
    ctx = get_context();
-
 
1042
    if(unlikely(ctx==NULL))
-
 
1043
    {
-
 
1044
        ret = create_context();
-
 
1045
        if(ret!=0)
-
 
1046
            return -1;
-
 
1047
 
-
 
1048
        ctx = get_context();
-
 
1049
    };
-
 
1050
 
-
 
1051
    mask_bitmap = ctx->mask;
-
 
1052
 
-
 
1053
    GetWindowRect(&winrc);
-
 
1054
    dst_x+= winrc.left;
-
 
1055
    dst_y+= winrc.top;
-
 
1056
 
-
 
1057
 
-
 
1058
    if(ctx->seqno != os_display->mask_seqno)
-
 
1059
    {
-
 
1060
        u8* src_offset;
-
 
1061
        u8* dst_offset;
-
 
1062
        u32 slot = *((u8*)CURRENT_TASK);
-
 
1063
        u32 ifl;
-
 
1064
 
-
 
1065
        ret = gem_object_lock(mask_bitmap->obj);
-
 
1066
        if(ret !=0 )
-
 
1067
        {
-
 
1068
            dbgprintf("%s fail\n", __FUNCTION__);
-
 
1069
            return ret;
-
 
1070
        };
-
 
1071
 
-
 
1072
        printf("width %d height %d\n", winrc.right, winrc.bottom);
-
 
1073
 
-
 
1074
        mask_bitmap->width  = winrc.right;
-
 
1075
        mask_bitmap->height = winrc.bottom;
-
 
1076
        mask_bitmap->pitch =  ALIGN(w,64);
-
 
1077
 
-
 
1078
        slot|= (slot<<8)|(slot<<16)|(slot<<24);
-
 
1079
 
-
 
1080
 
-
 
1081
        __asm__ __volatile__ (
-
 
1082
        "movd       %[slot],   %%xmm6    \n"
-
 
1083
        "punpckldq  %%xmm6, %%xmm6            \n"
-
 
1084
        "punpcklqdq %%xmm6, %%xmm6            \n"
-
 
1085
        :: [slot]  "g" (slot)
-
 
1086
        :"xmm6");
-
 
1087
 
-
 
1088
        src_offset = mask_bitmap->uaddr;
-
 
1089
 
-
 
1090
        dst_offset = (u8*)(dst_y*os_display->width + dst_x);
-
 
1091
        dst_offset+= get_display_map();
-
 
1092
 
-
 
1093
        u32_t tmp_h = mask_bitmap->height;
-
 
1094
 
-
 
1095
      ifl = safe_cli();
-
 
1096
        while( tmp_h--)
-
 
1097
        {
-
 
1098
            int tmp_w = mask_bitmap->width;
-
 
1099
 
-
 
1100
            u8* tmp_src = src_offset;
-
 
1101
            u8* tmp_dst = dst_offset;
-
 
1102
 
-
 
1103
            src_offset+= mask_bitmap->pitch;
-
 
1104
            dst_offset+= os_display->width;
-
 
1105
 
-
 
1106
//            while( tmp_w--)
-
 
1107
//            {
-
 
1108
//                *(tmp_src) = (*tmp_dst==slot)?0x1:0x00;
-
 
1109
//                tmp_src++;
-
 
1110
//                tmp_dst++;
-
 
1111
//            };
-
 
1112
            while(tmp_w >= 64)
-
 
1113
            {
-
 
1114
                __asm__ __volatile__ (
-
 
1115
                "movdqu     (%0),   %%xmm0            \n"
-
 
1116
                "movdqu   16(%0),   %%xmm1            \n"
-
 
1117
                "movdqu   32(%0),   %%xmm2            \n"
-
 
1118
                "movdqu   48(%0),   %%xmm3            \n"
-
 
1119
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1120
                "pcmpeqb    %%xmm6, %%xmm1            \n"
-
 
1121
                "pcmpeqb    %%xmm6, %%xmm2            \n"
-
 
1122
                "pcmpeqb    %%xmm6, %%xmm3            \n"
-
 
1123
                "movdqa     %%xmm0,   (%%edi)         \n"
-
 
1124
                "movdqa     %%xmm1, 16(%%edi)         \n"
-
 
1125
                "movdqa     %%xmm2, 32(%%edi)         \n"
-
 
1126
                "movdqa     %%xmm3, 48(%%edi)         \n"
-
 
1127
 
-
 
1128
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1129
                :"xmm0","xmm1","xmm2","xmm3");
-
 
1130
                tmp_w -= 64;
-
 
1131
                tmp_src += 64;
-
 
1132
                tmp_dst += 64;
-
 
1133
            }
-
 
1134
 
-
 
1135
            if( tmp_w >= 32 )
-
 
1136
            {
-
 
1137
                __asm__ __volatile__ (
-
 
1138
                "movdqu     (%0),   %%xmm0            \n"
-
 
1139
                "movdqu   16(%0),   %%xmm1            \n"
-
 
1140
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1141
                "pcmpeqb    %%xmm6, %%xmm1            \n"
-
 
1142
                "movdqa     %%xmm0,   (%%edi)         \n"
-
 
1143
                "movdqa     %%xmm1, 16(%%edi)         \n"
-
 
1144
 
-
 
1145
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1146
                :"xmm0","xmm1");
-
 
1147
                tmp_w -= 32;
-
 
1148
                tmp_src += 32;
-
 
1149
                tmp_dst += 32;
-
 
1150
            }
-
 
1151
 
-
 
1152
            while( tmp_w > 0 )
-
 
1153
            {
-
 
1154
                __asm__ __volatile__ (
-
 
1155
                "movdqu     (%0),   %%xmm0            \n"
-
 
1156
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1157
                "movdqa     %%xmm0,   (%%edi)         \n"
-
 
1158
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1159
                :"xmm0");
-
 
1160
                tmp_w -= 16;
-
 
1161
                tmp_src += 16;
-
 
1162
                tmp_dst += 16;
-
 
1163
            }
-
 
1164
        };
-
 
1165
      safe_sti(ifl);
-
 
1166
      ctx->seqno = os_display->mask_seqno;
-
 
1167
    }
-
 
1168
 
-
 
1169
    screen.pitch  = os_display->pitch;
-
 
1170
    screen.gaddr  = 0;
-
 
1171
    screen.width  = os_display->width;
-
 
1172
    screen.height = os_display->height;
-
 
1173
    screen.obj    = (void*)-1;
-
 
1174
 
-
 
1175
    dst_bitmap = &screen;
-
 
1176
 
-
 
1177
 
-
 
1178
    sna_blit_tex(dst_bitmap, dst_x, dst_y, w, h, src_bitmap, src_x, src_y,
-
 
1179
                 mask_bitmap);
-
 
1180
 
-
 
1181
//    asm volatile ("int3");
-
 
1182
};
-
 
1183
 
-
 
1184
 
-
 
1185
struct context *context_map[256];
-
 
1186
 
-
 
1187
void __attribute__((regparm(1))) destroy_context(struct context *context)
-
 
1188
{
-
 
1189
    printf("destroy context %x\n", context);
-
 
1190
 
-
 
1191
    context_map[context->slot] = NULL;
-
 
1192
    __DestroyObject(context);
-
 
1193
};
-
 
1194
 
-
 
1195
 
-
 
1196
int create_context()
-
 
1197
{
-
 
1198
    struct context *context;
-
 
1199
 
-
 
1200
    bitmap_t  *mask;
-
 
1201
    int        slot;
-
 
1202
 
-
 
1203
    struct io_call_10 io_10;
-
 
1204
    int    ret;
-
 
1205
 
-
 
1206
    slot = *((u8*)CURRENT_TASK);
-
 
1207
 
-
 
1208
    if(context_map[slot] != NULL)
-
 
1209
        return 0;
-
 
1210
 
-
 
1211
    context = CreateObject(GetPid(), sizeof(*context));
-
 
1212
//    printf("context %x\n", coontext);
-
 
1213
    if( context == NULL)
-
 
1214
        goto err1;
-
 
1215
    context->header.destroy = destroy_context;
-
 
1216
 
-
 
1217
    dbgprintf("Create mask surface\n");
-
 
1218
 
-
 
1219
    io_10.width  = os_display->width/4;     /* need bitmap format here */
-
 
1220
    io_10.height = os_display->height+1;
-
 
1221
    io_10.max_width  = os_display->width/4;
-
 
1222
    io_10.max_height = os_display->height+1;
-
 
1223
 
-
 
1224
    ret = create_surface(&io_10);
-
 
1225
    if(ret)
-
 
1226
        goto err2;
-
 
1227
 
-
 
1228
    mask= (bitmap_t*)hman_get_data(&bm_man, io_10.handle);
-
 
1229
    if(unlikely(mask == NULL)) /* something really terrible happend */
-
 
1230
        goto err2;
-
 
1231
    dbgprintf("done\n");
-
 
1232
 
-
 
1233
    context->mask  = mask;
-
 
1234
    context->seqno = os_display->mask_seqno-1;
-
 
1235
    context->slot  = slot;
-
 
1236
 
-
 
1237
    context_map[slot] = context;
-
 
1238
    return 0;
-
 
1239
 
-
 
1240
err2:
-
 
1241
    __DestroyObject(context);
-
 
1242
err1:
-
 
1243
    return -1;
-
 
1244
};
-
 
1245
 
-
 
1246
struct context *get_context()
-
 
1247
{
-
 
1248
 
-
 
1249
    int slot = *((u8*)CURRENT_TASK);
-
 
1250
 
-
 
1251
    return context_map[slot];
-
 
1252
}
-
 
1253
 
-
 
1254
 
-
 
1255
 
-
 
1256
 
-
 
1257
 
-
 
1258
 
-
 
1259
 
Line 1007... Line 1260...
1007
};
1260
 
1008
 
1261
 
1009
 
1262