Subversion Repositories Kolibri OS

Rev

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

Rev 3266 Rev 3278
Line 6... Line 6...
6
#include "sna.h"
6
#include "sna.h"
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
#include 
8
#include 
-
 
9
 
Line 9... Line 10...
9
 
10
static struct sna_fb sna_fb;
10
static struct sna_fb sna_fb;
11
static struct kgem_bo *mask_bo;
11
 
12
 
12
typedef struct __attribute__((packed))
13
typedef struct __attribute__((packed))
Line 417... Line 418...
417
        
418
        
Line 418... Line 419...
418
    kgem_bo_sync__cpu(&sna_device->kgem, bo);
419
    kgem_bo_sync__cpu(&sna_device->kgem, bo);
Line -... Line 420...
-
 
420
 
-
 
421
};
-
 
422
 
-
 
423
int sna_create_mask()
-
 
424
{
-
 
425
	struct kgem_bo *bo;
-
 
426
    char proc_info[1024];
-
 
427
    int width, height;
Line -... Line 428...
-
 
428
    int i;
-
 
429
 
Line 419... Line -...
419
 
-
 
-
 
430
    get_proc_info(proc_info);
Line -... Line 431...
-
 
431
 
-
 
432
    width  = *(uint32_t*)(proc_info+42)+1;
-
 
433
    height = *(uint32_t*)(proc_info+46)+1;
-
 
434
    
-
 
435
    printf("%s width %d height %d\n", __FUNCTION__, width, height);
-
 
436
    
-
 
437
    bo = kgem_create_2d(&sna_device->kgem, width, height,
-
 
438
                        8,I915_TILING_NONE, CREATE_CPU_MAP);
-
 
439
    
-
 
440
    if(bo == NULL)
-
 
441
        goto err_1;
-
 
442
     
-
 
443
    int *map = kgem_bo_map(&sna_device->kgem, bo);
-
 
444
    if(map == NULL)
-
 
445
        goto err_2;
-
 
446
        
-
 
447
    memset(map, 0, bo->pitch * height);
-
 
448
    
-
 
449
    mask_bo = bo;
-
 
450
 
-
 
451
    return 0;
-
 
452
    
-
 
453
err_2:
-
 
454
    kgem_bo_destroy(&sna_device->kgem, bo);
-
 
455
    
-
 
456
err_1:
-
 
457
    return -1; 
-
 
458
           
-
 
459
};
-
 
460
 
-
 
461
 
-
 
462
bool
-
 
463
gen6_composite(struct sna *sna,
-
 
464
              uint8_t op,
-
 
465
		      PixmapPtr src, struct kgem_bo *src_bo,
-
 
466
		      PixmapPtr mask,struct kgem_bo *mask_bo,
-
 
467
		      PixmapPtr dst, struct kgem_bo *dst_bo, 
-
 
468
              int32_t src_x, int32_t src_y,
-
 
469
              int32_t msk_x, int32_t msk_y,
-
 
470
              int32_t dst_x, int32_t dst_y,
420
};
471
              int32_t width, int32_t height,
421
 
472
              struct sna_composite_op *tmp);
-
 
473
 
-
 
474
 
-
 
475
#define MAP(ptr) ((void*)((uintptr_t)(ptr) & ~3))
-
 
476
 
-
 
477
int sna_blit_tex(bitmap_t *src_bitmap, int dst_x, int dst_y,
-
 
478
                  int w, int h, int src_x, int src_y)
-
 
479
 
-
 
480
{
-
 
481
 
422
 
482
//    box.x1 = dst_x;
423
 
483
//    box.y1 = dst_y;
-
 
484
//    box.x2 = dst_x+w;
424
/*
485
//    box.y2 = dst_y+h;
425
 
486
 
426
int sna_blit_tex(bitmap_t *dst_bitmap, int dst_x, int dst_y,
487
 
427
                  int w, int h, bitmap_t *src_bitmap, int src_x, int src_y,
488
 //   cop.box(sna_device, &cop, &box);
428
                  bitmap_t *mask_bitmap)
489
 
-
 
490
    struct drm_i915_mask_update update;
429
 
491
    
430
{
492
    struct sna_composite_op composite;
431
    struct sna_composite_op cop;
493
    struct _Pixmap src, dst, mask;
-
 
494
    struct kgem_bo *src_bo;
-
 
495
 
432
    batchbuffer_t  execbuffer;
496
    char proc_info[1024];
-
 
497
    int winx, winy, winw, winh;
-
 
498
 
-
 
499
    get_proc_info(proc_info);
433
    BoxRec box;
500
 
434
 
501
    winx = *(uint32_t*)(proc_info+34);
435
    struct kgem_bo src_bo, mask_bo, dst_bo;
502
    winy = *(uint32_t*)(proc_info+38);
436
 
503
    winw = *(uint32_t*)(proc_info+42)+1;
437
    memset(&cop, 0, sizeof(cop));
504
    winh = *(uint32_t*)(proc_info+46)+1;
438
    memset(&execbuffer,  0, sizeof(execbuffer));
505
    
439
    memset(&src_bo, 0, sizeof(src_bo));
506
    memset(&src, 0, sizeof(src));
440
    memset(&dst_bo, 0, sizeof(dst_bo));
507
    memset(&dst, 0, sizeof(dst));
441
    memset(&mask_bo, 0, sizeof(mask_bo));
508
    memset(&mask, 0, sizeof(dst));
442
 
509
 
443
    src_bo.gaddr  = src_bitmap->gaddr;
510
    src.drawable.bitsPerPixel = 32;
444
    src_bo.pitch  = src_bitmap->pitch;
511
    src.drawable.width  = src_bitmap->width;
445
    src_bo.tiling = 0;
512
    src.drawable.height = src_bitmap->height;
446
 
513
 
447
    dst_bo.gaddr  = dst_bitmap->gaddr;
514
    dst.drawable.bitsPerPixel = 32;
448
    dst_bo.pitch  = dst_bitmap->pitch;
515
    dst.drawable.width  = sna_fb.width;
449
    dst_bo.tiling = 0;
-
 
450
 
-
 
451
    mask_bo.gaddr  = mask_bitmap->gaddr;
516
    dst.drawable.height = sna_fb.height;
-
 
517
    
452
    mask_bo.pitch  = mask_bitmap->pitch;
518
    mask.drawable.bitsPerPixel = 8;
-
 
519
    mask.drawable.width  = winw;
453
    mask_bo.tiling = 0;
520
    mask.drawable.height = winh;
454
 
521
 
455
    box.x1 = dst_x;
522
    memset(&composite, 0, sizeof(composite));
456
    box.y1 = dst_y;
523
 
457
    box.x2 = dst_x+w;
524
    src_bo = (struct kgem_bo*)src_bitmap->handle;
458
    box.y2 = dst_y+h;
-
 
459
 
525
    
460
    sna_device->render.composite(sna_device, 0,
526
    
461
                                 src_bitmap, &src_bo,
527
    if( gen6_composite(sna_device, PictOpSrc,
-
 
528
		      &src, src_bo,
-
 
529
		      &mask, mask_bo,
-
 
530
		      &dst, sna_fb.fb_bo, 
-
 
531
                                 src_x, src_y,
-
 
532
                                 dst_x, dst_y,
-
 
533
              winx+dst_x, winy+dst_y,
-
 
534
              w, h,
-
 
535
              &composite) )
-
 
536
    {
-
 
537
	    struct sna_composite_rectangles r;
-
 
538
        
-
 
539
	    r.src.x = src_x;
-
 
540
	    r.src.y = src_y;
-
 
541
	    r.mask.x = dst_x;
-
 
542
	    r.mask.y = dst_y;
-
 
543
		r.dst.x = winx+dst_x;
-
 
544
	    r.dst.y = winy+dst_y;
-
 
545
	    r.width  = w;
-
 
546
	    r.height = h;
-
 
547
        
-
 
548
        composite.blt(sna_device, &composite, &r);
-
 
549
        composite.done(sna_device, &composite);
-
 
550
    };
-
 
551
    
-
 
552
    VG_CLEAR(update);
-
 
553
	update.handle = mask_bo->handle;
-
 
554
	update.bo_size   = __kgem_bo_size(mask_bo);
-
 
555
	update.bo_pitch  = mask_bo->pitch;
-
 
556
	update.bo_map    = MAP(mask_bo->map);
-
 
557
	drmIoctl(sna_device->kgem.fd, SRV_MASK_UPDATE, &update);
-
 
558
 
-
 
559
    kgem_submit(&sna_device->kgem);
Line 462... Line -...
462
                                 mask_bitmap, &mask_bo,
-
 
463
                                 dst_bitmap, &dst_bo,
-
 
Line 464... Line -...
464
                                 src_x, src_y,
-
 
465
                                 src_x, src_y,
-
 
466
                                 dst_x, dst_y,
-
 
Line 467... Line -...
467
                                 w, h, &cop);
-
 
Line 468... Line -...
468
 
-
 
Line 469... Line -...
469
    cop.box(sna_device, &cop, &box);
-
 
Line 470... Line 560...
470
    cop.done(sna_device, &cop);
560
 
471
 
561
    return 0;            
472
    INIT_LIST_HEAD(&execbuffer.objects);
562
}