uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10FilterBase.cpp
changeset 0 15bf7259bb7c
child 29 ac3859d43844
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "HuiFxVg10FilterBase.h"
       
    21 #include "uiacceltk/HuiUtil.h"
       
    22 
       
    23 
       
    24 //_LIT(KLitPanicMessage, "HuiFx");
       
    25 
       
    26 
       
    27 TBool CHuiFxVg10FilterBase::Draw(CHuiFxEngine& aEngine, CHuiGc& /* aGc */, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
       
    28                                             const TRect& aTargetRect, const TRect& aSourceRect)
       
    29     {
       
    30     aTarget.BindAsTexture(ERenderbufferUsageWriteOnly);
       
    31     aSource.BindAsTexture(ERenderbufferUsageReadOnly);
       
    32     VGImage srcImage  = (reinterpret_cast<CHuiFxVg10RenderbufferBase*>(&aSource))->AcquireSubImage(aSourceRect);
       
    33     VGImage destImage = (reinterpret_cast<CHuiFxVg10RenderbufferBase*>(&aTarget))->AcquireSubImage(aTargetRect);
       
    34     
       
    35     // take opacity into account
       
    36     const VGfloat opacity = clamp(iOpacity, 0.0f, 1.0f);
       
    37 
       
    38     if(opacity > EPSILON)
       
    39         {
       
    40         DrawEffect(aEngine, destImage, srcImage, aSourceRect.Width(), aSourceRect.Height());
       
    41         }
       
    42     else
       
    43         {
       
    44 //        VGint width = vgGetParameteri(srcImage, VG_IMAGE_WIDTH);
       
    45 //        VGint height = vgGetParameteri(srcImage, VG_IMAGE_HEIGHT);
       
    46         VGint width = aSourceRect.Width();
       
    47         VGint height = aSourceRect.Height();
       
    48         vgCopyImage(destImage, 0, 0, srcImage, 0, 0, width, height, VG_FALSE);
       
    49         }
       
    50 
       
    51     HUIFX_VG_INVARIANT();    
       
    52     (reinterpret_cast<CHuiFxVg10RenderbufferBase*>(&aSource))->ReleaseSubImage(srcImage);
       
    53     (reinterpret_cast<CHuiFxVg10RenderbufferBase*>(&aTarget))->ReleaseSubImage(destImage);
       
    54     aTarget.UnbindAsTexture();
       
    55     aSource.UnbindAsTexture();
       
    56     
       
    57     return wasEnoughMemory();
       
    58     }
       
    59 
       
    60 // any unexpected error results in panic
       
    61 TBool CHuiFxVg10FilterBase::wasEnoughMemory()
       
    62     {
       
    63 #ifndef _DEBUG
       
    64 	// vgGetError() -call is REALLY SLOW on HW, remove for now at least,
       
    65 	// since nobody is really even checking this return value nor acting on it..
       
    66     TBool success = ETrue;
       
    67 #else
       
    68     TBool success = EFalse;
       
    69     const VGErrorCode vgError = vgGetError();
       
    70     
       
    71     switch(vgError)
       
    72         {
       
    73         case VG_NO_ERROR : 
       
    74             success = ETrue;
       
    75             break;
       
    76             
       
    77         case VG_OUT_OF_MEMORY_ERROR : 
       
    78             success = EFalse;
       
    79             break;
       
    80             
       
    81         default :
       
    82             success = EFalse;
       
    83             // should print an error instead of panicking
       
    84             HUI_DEBUG1(_L("CHuiFxVg10FilterBase::wasEnoughMemory() vgError -- %04x"), vgError);
       
    85 //            User::Panic(KLitPanicMessage, vgError);
       
    86         }
       
    87 #endif
       
    88     return success;
       
    89     }