~ubuntu-branches/ubuntu/intrepid/gpac/intrepid-proposed

« back to all changes in this revision

Viewing changes to modules/render3d/texture_stacks.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2007-01-24 23:34:57 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070124233457-zzlls8afkt0nyakj
Tags: 0.4.2~rc2-0ubuntu1
* New upstream release
  * Most notably MP4 tagging support via MP4Box -itags
* debian/patches/01_64bits.dpatch: dropped; included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
206
206
                }
207
207
 
208
208
                /*generate texture*/
 
209
#if 1
209
210
                st->txh.pixelformat = GF_PIXEL_RGBA;
210
 
 
211
211
                st->txh.stride = st->txh.width*4;
212
212
                st->txh.transparent = 1;
 
213
#else
 
214
                st->txh.pixelformat = GF_PIXEL_RGB_24;
 
215
                st->txh.stride = st->txh.width*3;
 
216
#endif
213
217
                st->surface->width = st->txh.width;
214
218
                st->surface->height = st->txh.height;
215
219
 
318
322
 
319
323
void R3D_InitCompositeTexture3D(Render3D *sr, GF_Node *node)
320
324
{
 
325
        M_CompositeTexture3D *c3d = (M_CompositeTexture3D *)node;
321
326
        CompositeTextureStack *st = malloc(sizeof(CompositeTextureStack));
322
327
        memset(st, 0, sizeof(CompositeTextureStack));
323
328
        gf_sr_texture_setup(&st->txh, sr->compositor, node);
324
 
        st->txh.flags = GF_SR_TEXTURE_REPEAT_S | GF_SR_TEXTURE_REPEAT_T;
 
329
        st->txh.flags = 0;
 
330
        if (c3d->repeatS) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S;
 
331
        if (c3d->repeatT) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T;
325
332
        st->first = 1;
326
333
        /*create composite surface*/
327
334
        st->surface = VS_New();
336
343
 
337
344
void R3D_InitCompositeTexture2D(Render3D *sr, GF_Node *node)
338
345
{
 
346
        M_CompositeTexture2D *c2d = (M_CompositeTexture2D *)node;
339
347
        CompositeTextureStack *st = malloc(sizeof(CompositeTextureStack));
340
348
        memset(st, 0, sizeof(CompositeTextureStack));
341
349
        gf_sr_texture_setup(&st->txh, sr->compositor, node);
342
 
        st->txh.flags = GF_SR_TEXTURE_REPEAT_S | GF_SR_TEXTURE_REPEAT_T;
 
350
        st->txh.flags = 0;
 
351
        if ((c2d->repeatSandT==1) || (c2d->repeatSandT==3) ) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S;
 
352
        if (c2d->repeatSandT>1) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T;
343
353
        st->first = 1;
344
354
        /*create composite surface*/
345
355
        st->surface = VS_New();
356
366
{
357
367
        CompositeTextureStack *st;
358
368
        GF_Matrix mx;
 
369
        GF_Node *child;
359
370
        RenderEffect3D *eff;
360
371
        GF_List *children;
361
372
        Bool res;
379
390
                while (txcoord.y<0) txcoord.y += FIX_ONE; while (txcoord.y>FIX_ONE) txcoord.y -= FIX_ONE;
380
391
        }
381
392
        /*convert to tx space*/
382
 
        ev->mouse.x = FIX2INT(txcoord.x - FIX_ONE/2) * st->surface->width;
383
 
        ev->mouse.y = FIX2INT(txcoord.y - FIX_ONE/2) * st->surface->height;
 
393
        ev->mouse.x = FIX2INT( (txcoord.x - FIX_ONE/2) * st->surface->width);
 
394
        ev->mouse.y = FIX2INT( (txcoord.y - FIX_ONE/2) * st->surface->height);
384
395
 
385
396
        eff = effect3d_new();
386
397
        eff->surface = st->surface;
391
402
        VS_SetupEffects(st->surface, eff);
392
403
 
393
404
        children = Composite_GetChildren(st->txh.owner);
394
 
        for (i=0; i<gf_list_count(children); i++) {
395
 
                GF_Node *child = gf_list_get(children, i);
 
405
        i=0;
 
406
        while ((child = gf_list_enum(children, &i))) {
396
407
                SensorHandler *hsens = r3d_get_sensor_handler(child);
397
408
                if (hsens) gf_list_add(eff->sensors, hsens);
398
409
        }
401
412
        return res;
402
413
}
403
414
 
404
 
 
 
415
static void UpdateMatteTexture(GF_TextureHandler *txh)
 
416
{
 
417
        /*nothing to do*/
 
418
}
 
419
static void DestroyMatteTexture(GF_Node *node)
 
420
{
 
421
        MatteTextureStack *st = (MatteTextureStack *) gf_node_get_private(node);
 
422
        /*prevent destroying of sub textures*/
 
423
        st->txh.hwtx = NULL;
 
424
        gf_sr_texture_destroy(&st->txh);
 
425
        free(st);
 
426
}
 
427
 
 
428
void R3D_InitMatteTexture(Render3D *sr, GF_Node *node)
 
429
{
 
430
        M_MatteTexture *matte = (M_MatteTexture *)node;
 
431
        MatteTextureStack *st;
 
432
        GF_SAFEALLOC(st, sizeof(MatteTextureStack));
 
433
        gf_sr_texture_setup(&st->txh, sr->compositor, node);
 
434
        st->txh.flags = GF_SR_TEXTURE_MATTE;
 
435
        st->txh.update_texture_fcnt = UpdateMatteTexture;
 
436
        gf_node_set_private(node, st);
 
437
        gf_node_set_predestroy_function(node, DestroyMatteTexture);
 
438
}
 
439
 
 
440
GF_TextureHandler *r3d_matte_get_texture(GF_Node *node)
 
441
{
 
442
        GF_TextureHandler *hdl = R3D_GetTextureHandler(((M_MatteTexture*)node)->surfaceB);
 
443
        if (hdl) hdl->matteTexture = node;
 
444
        return hdl;
 
445
}
405
446
 
406
447
GF_TextureHandler *R3D_GetTextureHandler(GF_Node *n)
407
448
{
 
449
        GF_TextureHandler *hdl;
408
450
        if (!n) return NULL;
409
451
        switch (gf_node_get_tag(n)) {
410
 
        case TAG_MPEG4_CompositeTexture2D: return r3d_composite_get_texture(n);
411
 
        case TAG_MPEG4_CompositeTexture3D: return r3d_composite_get_texture(n);
412
 
        case TAG_MPEG4_LinearGradient: return r3d_lg_get_texture(n);
413
 
        case TAG_MPEG4_RadialGradient: return r3d_rg_get_texture(n);
414
 
/*      
415
 
        case TAG_MPEG4_MatteTexture: return matte_get_texture(n);
416
 
*/
417
 
        default: return gf_sr_texture_get_handler(n);
 
452
        case TAG_MPEG4_CompositeTexture2D: hdl = r3d_composite_get_texture(n); break;
 
453
        case TAG_MPEG4_CompositeTexture3D: hdl = r3d_composite_get_texture(n); break;
 
454
        case TAG_MPEG4_LinearGradient: hdl = r3d_lg_get_texture(n); break;
 
455
        case TAG_MPEG4_RadialGradient: hdl = r3d_rg_get_texture(n); break;
 
456
        case TAG_MPEG4_MatteTexture: return r3d_matte_get_texture(n);
 
457
        default: hdl = gf_sr_texture_get_handler(n); break;
418
458
        }
 
459
        hdl->matteTexture = NULL;
 
460
        return hdl;
419
461
}