graphicscomposition/openwfcompositionengine/composition/src/wfcpipeline.c
branchRCL_3
changeset 19 bbf46f59e123
parent 0 5d03bc08d59c
child 20 25ffed67c7ef
equal deleted inserted replaced
18:57c618273d5c 19:bbf46f59e123
     1 /* Copyright (c) 2009 The Khronos Group Inc.
     1 /* Copyright (c) 2009-2010 The Khronos Group Inc.
       
     2  * Portions copyright (c) 2009-2010  Nokia Corporation and/or its subsidiary(-ies)
     2  *
     3  *
     3  * Permission is hereby granted, free of charge, to any person obtaining a
     4  * Permission is hereby granted, free of charge, to any person obtaining a
     4  * copy of this software and/or associated documentation files (the
     5  * copy of this software and/or associated documentation files (the
     5  * "Materials"), to deal in the Materials without restriction, including
     6  * "Materials"), to deal in the Materials without restriction, including
     6  * without limitation the rights to use, copy, modify, merge, publish,
     7  * without limitation the rights to use, copy, modify, merge, publish,
   100     state->blendInfo.destination.rectangle = &state->dstRect;
   101     state->blendInfo.destination.rectangle = &state->dstRect;
   101     state->blendInfo.source.image          = state->scaledSourceImage;
   102     state->blendInfo.source.image          = state->scaledSourceImage;
   102     state->blendInfo.source.rectangle      = &state->scaledSrcRect;
   103     state->blendInfo.source.rectangle      = &state->scaledSrcRect;
   103     state->blendInfo.mask                  = state->originalMaskImage ? state->maskImage : NULL;
   104     state->blendInfo.mask                  = state->originalMaskImage ? state->maskImage : NULL;
   104     state->blendInfo.globalAlpha           = state->globalAlpha;
   105     state->blendInfo.globalAlpha           = state->globalAlpha;
   105     
       
   106     /* composition does not use these values ever */
       
   107     state->blendInfo.tsColor                = NULL;
       
   108     state->blendInfo.destinationFullyOpaque = OWF_FALSE;    
       
   109     
   106     
   110     DPRINT(("  globalAplha = %f", state->globalAlpha));
   107     DPRINT(("  globalAplha = %f", state->globalAlpha));
   111     /* no need to check with OWF_ALPHA_MIN_VALUE as it is zero */
   108     /* no need to check with OWF_ALPHA_MIN_VALUE as it is zero */
   112     OWF_ASSERT(state->blendInfo.globalAlpha <= OWF_ALPHA_MAX_VALUE);    
   109     OWF_ASSERT(state->blendInfo.globalAlpha <= OWF_ALPHA_MAX_VALUE);    
   113 }
   110 }
   335         DPRINT(("  element [%x] totally outside of target - skipped",
   332         DPRINT(("  element [%x] totally outside of target - skipped",
   336                         element ? element->handle : 0));
   333                         element ? element->handle : 0));
   337         return NULL;
   334         return NULL;
   338     }
   335     }
   339 
   336 
   340     
       
   341     /* setup temporary images used in composition. since the original
   337     /* setup temporary images used in composition. since the original
   342        source data must not be altered, we must copy it to scratch buffer
   338        source data must not be altered, we must copy it to scratch buffer
   343        and work it there. another scratch buffer is needed for scaling
   339        and work it there. another scratch buffer is needed for scaling
   344        the image to its final size. same applies for masks; thus a grand total
   340        the image to its final size. same applies for masks; thus a grand total
   345        of 4 scratch buffers are needed. */
   341        of 4 scratch buffers are needed. */
   350     state->rotation = element->sourceRotation;
   346     state->rotation = element->sourceRotation;
   351     state->sourceFlip = element->sourceFlip;
   347     state->sourceFlip = element->sourceFlip;
   352     state->globalAlpha = element->globalAlpha;
   348     state->globalAlpha = element->globalAlpha;
   353     state->sourceScaleFilter = element->sourceScaleFilter;
   349     state->sourceScaleFilter = element->sourceScaleFilter;
   354     state->transparencyTypes = element->transparencyTypes;
   350     state->transparencyTypes = element->transparencyTypes;
   355     /* replicate the source viewport rectangle and target extent rectangle */
   351 
       
   352     if (state->transparencyTypes & WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA)
       
   353         {
       
   354         if (state->globalAlpha == OWF_FULLY_TRANSPARENT)
       
   355             {
       
   356             /* Fully transparent element - no contribution. */
       
   357             return NULL;
       
   358             }
       
   359         if (state->globalAlpha == OWF_FULLY_OPAQUE)
       
   360             {
       
   361             /* Fully opaque global alpha - global alpha can be ignored */
       
   362             state->transparencyTypes &= ~WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA;
       
   363             }
       
   364         }
       
   365     
       
   366 /* replicate the source viewport rectangle and target extent rectangle */
   356     for (x = 0; x < 4; x++)
   367     for (x = 0; x < 4; x++)
   357     {
   368     {
   358         state->sourceRect[x] = element->srcRect[x];
   369         state->sourceRect[x] = element->srcRect[x];
   359         state->destinationRect[x] = element->dstRect[x];
   370         state->destinationRect[x] = element->dstRect[x];
   360     }
   371     }
   589         DPRINT(("WFC_Context_ExecuteCropStage: context = %p, state = %p",
   600         DPRINT(("WFC_Context_ExecuteCropStage: context = %p, state = %p",
   590                context, state));
   601                context, state));
   591     }
   602     }
   592     else
   603     else
   593     {
   604     {
   594 
       
   595         /* Source rectangle */
   605         /* Source rectangle */
   596         OWF_Rect_Set(&sourceRect,
   606         OWF_Rect_Set(&sourceRect,
   597                      state->oversizedCropRect.x, state->oversizedCropRect.y,
   607                      state->oversizedCropRect.x, state->oversizedCropRect.y,
   598                      state->oversizedCropRect.width, state->oversizedCropRect.height);
   608                      state->oversizedCropRect.width, state->oversizedCropRect.height);
   599 
   609 
   615  *----------------------------------------------------------------------------*/
   625  *----------------------------------------------------------------------------*/
   616 OWF_API_CALL void
   626 OWF_API_CALL void
   617 WFC_Pipeline_ExecuteFlipStage(WFC_CONTEXT* context, WFC_ELEMENT_STATE* state)
   627 WFC_Pipeline_ExecuteFlipStage(WFC_CONTEXT* context, WFC_ELEMENT_STATE* state)
   618 {
   628 {
   619     OWF_FLIP_DIRECTION      flipping;
   629     OWF_FLIP_DIRECTION      flipping;
   620     
   630 	
   621     if (NULL == context || NULL == state)
   631     if (NULL == context || NULL == state)
   622     {
   632     {
   623         DPRINT(("WFC_Context_ExecuteFlipStage: context = %p, state = %p",
   633         DPRINT(("WFC_Context_ExecuteFlipStage: context = %p, state = %p",
   624                context, state));
   634                context, state));
   625     }
   635     }
   626     else
   636     else
   627     {
   637     {
   628         OWF_ASSERT(state);
       
   629         flipping = state->sourceFlip > 0.0f ? OWF_FLIP_VERTICALLY
   638         flipping = state->sourceFlip > 0.0f ? OWF_FLIP_VERTICALLY
   630                                           : OWF_FLIP_NONE;
   639                                           : OWF_FLIP_NONE;
   631         
   640         
   632         OWF_Image_Flip(state->flippedSourceImage, flipping);
   641         OWF_Image_Flip(state->flippedSourceImage, flipping);
   633     }
   642     }
   644 {
   653 {
   645     OWF_ROTATION            rot = OWF_ROTATION_0;
   654     OWF_ROTATION            rot = OWF_ROTATION_0;
   646     OWF_RECTANGLE           rect;    
   655     OWF_RECTANGLE           rect;    
   647     WFCRotation             rotation;
   656     WFCRotation             rotation;
   648 
   657 
   649 
       
   650     if (NULL == context || NULL == state)
   658     if (NULL == context || NULL == state)
   651     {
   659     {
   652         DPRINT(("WFC_Context_ExecuteRotationStage: context = %p, state = %p",
   660         DPRINT(("WFC_Context_ExecuteRotationStage: context = %p, state = %p",
   653                context, state));
   661                context, state));
   654         return;
   662         return;
   655     }
   663     }
   656     OWF_ASSERT(state);
       
   657 
   664 
   658     rotation = state->rotation;
   665     rotation = state->rotation;
   659     DPRINT(("  Element rotation = %d", rotation));
   666     DPRINT(("  Element rotation = %d", rotation));
   660 
   667 
   661     switch (rotation)
   668     switch (rotation)
   721 {
   728 {
   722     OWF_RECTANGLE           scaledRect,
   729     OWF_RECTANGLE           scaledRect,
   723                             cropRect;
   730                             cropRect;
   724     OWF_FILTERING           filteringMode = OWF_FILTER_POINT_SAMPLING;
   731     OWF_FILTERING           filteringMode = OWF_FILTER_POINT_SAMPLING;
   725     WFCScaleFilter          filter;
   732     WFCScaleFilter          filter;
   726 
   733 	
   727     DPRINT(("WFC_Context_ExecuteScalingStage(%p,%p)", context, state));
   734     DPRINT(("WFC_Context_ExecuteScalingStage(%p,%p)", context, state));
   728 
   735 
   729     if (NULL == context || NULL == state)
   736     if (NULL == context || NULL == state)
   730     {
   737     {
   731         DPRINT(("WFC_Context_ExecuteScalingStage: context = %p, state = %p",
   738         DPRINT(("WFC_Context_ExecuteScalingStage: context = %p, state = %p",
   732                context, state));
   739                context, state));
   733         return;
   740         return;
   734     }
   741     }
   735 
       
   736     OWF_ASSERT(state);
       
   737 
   742 
   738     filter = state->sourceScaleFilter;
   743     filter = state->sourceScaleFilter;
   739 
   744 
   740     switch (filter)
   745     switch (filter)
   741     {
   746     {
   798 OWF_API_CALL void
   803 OWF_API_CALL void
   799 WFC_Pipeline_ExecuteBlendingStage(WFC_CONTEXT* context, WFC_ELEMENT_STATE* state)
   804 WFC_Pipeline_ExecuteBlendingStage(WFC_CONTEXT* context, WFC_ELEMENT_STATE* state)
   800 {
   805 {
   801     OWF_TRANSPARENCY        blendMode = OWF_TRANSPARENCY_NONE;
   806     OWF_TRANSPARENCY        blendMode = OWF_TRANSPARENCY_NONE;
   802     WFCbitfield             transparency = 0;
   807     WFCbitfield             transparency = 0;
   803 
   808 	
   804     DPRINT(("WFC_Pipeline_ExecuteBlendingStage"));
   809     DPRINT(("WFC_Pipeline_ExecuteBlendingStage"));
   805 
   810 
   806     if (NULL == context || NULL == state)
   811     if (NULL == context || NULL == state)
   807     {
   812     {
   808         return;
   813         return;
   809     }
   814     }
   810 
   815 
   811     DPRINT(("  context = %d, state = %d",
   816     DPRINT(("  context = %d, state = %d",
   812            context->handle, state));
   817            context->handle, state));
   813 
   818 
   814     OWF_ASSERT(state);
       
   815 
       
   816     transparency = state->transparencyTypes;
   819     transparency = state->transparencyTypes;
   817     blendMode = OWF_TRANSPARENCY_NONE;
   820     blendMode = OWF_TRANSPARENCY_NONE;
   818 
   821 
   819     if (transparency & WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA)
   822     if (transparency & WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA)
   820     {
   823     {