fbs/fontandbitmapserver/sfbs/fbsoogmplugin.cpp
author hgs
Thu, 09 Sep 2010 10:13:45 +0300
changeset 171 414d4b727fd9
parent 121 d72fc2aace31
permissions -rw-r--r--
201034
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
121
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     1
/*
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     3
* All rights reserved.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     8
*
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     9
* Initial Contributors:
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    11
*
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    12
* Contributors:
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    13
*
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    14
* Description:  Graphics-Out-Of-Memory plugin for Font and Bitmap server.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    15
*
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    16
*/
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    17
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    18
#include <ecom/ecom.h>
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    19
#include <ecom/implementationproxy.h>
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    20
#include <graphics/fbsoogmmessage.h>
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    21
#include <w32std.h>
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    22
#include <FBS.H>
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    23
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    24
#include "fbsoogmplugin.h"
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    25
#include "OstTraceDefinitions.h"
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    26
#ifdef OST_TRACE_COMPILER_IN_USE
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    27
#include "fbsoogmpluginTraces.h"
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    28
#endif
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    29
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    30
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    31
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    32
 Called by the GOoM monitor framework in the case of low GPU memory.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    33
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    34
 Note: In the case of failure, this framework method will do so silently.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    35
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    36
 @param aBytesToFree The amount of GPU memory to be freed.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    37
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    38
void CFbsOogmMonitorPlugin::FreeRam( TInt aBytesToFree, TInt aFlags )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    39
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    40
    OstTrace0( TRACE_NORMAL, CFBSOOGMMONITORPLUGIN_FREERAM, "> " );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    41
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    42
    if ( (NULL == RFbsSession::GetSession()) )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    43
         {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    44
         if ( KErrNone != RFbsSession::Connect() )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    45
             {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    46
             OstTrace0( TRACE_NORMAL, DUP2_CFBSOOGMMONITORPLUGIN_FREERAM, "< No FbsSession" );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    47
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    48
             return;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    49
             }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    50
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    51
         }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    52
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    53
    TFbsOogmMessage oogmMessage( TFbsOogmMessage::EFbsOogmLowNotification, aBytesToFree, aFlags );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    54
    (void)RFbsSession::GetSession()->ConveyOogmMessage( oogmMessage );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    55
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    56
    OstTrace0( TRACE_NORMAL, DUP1_CFBSOOGMMONITORPLUGIN_FREERAM, "< " );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    57
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    58
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    59
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    60
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    61
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    62
 Called by the GOoM monitor framework in the case of normal GPU memory-usage being permissible.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    63
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    64
 Note: In the case of failure, this framework method will do so silently.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    65
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    66
void CFbsOogmMonitorPlugin::MemoryGood( TInt aFlags )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    67
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    68
    OstTrace0( TRACE_NORMAL, CFBSOOGMMONITORPLUGIN_MEMORYGOOD, ">" );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    69
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    70
    if ( (NULL == RFbsSession::GetSession()) )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    71
         {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    72
        if ( KErrNone != RFbsSession::Connect() )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    73
            {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    74
            OstTrace0( TRACE_NORMAL, DUP2_CFBSOOGMMONITORPLUGIN_MEMORYGOOD, "< No FbsSession" );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    75
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    76
            return;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    77
            }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    78
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    79
         }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    80
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    81
    const TInt KOogmDummyIntegerArgument = 0;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    82
    TFbsOogmMessage oogmMessage( TFbsOogmMessage::EFbsOogmOkayNotification, KOogmDummyIntegerArgument, aFlags );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    83
    (void)RFbsSession::GetSession()->ConveyOogmMessage( oogmMessage );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    84
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    85
	OstTrace0( TRACE_NORMAL, DUP1_CFBSOOGMMONITORPLUGIN_MEMORYGOOD, "<" );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    86
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    87
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    88
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    89
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    90
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    91
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    92
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    93
CFbsOogmMonitorPlugin::CFbsOogmMonitorPlugin()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    94
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    95
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    96
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    97
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    98
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    99
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   100
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   101
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   102
CFbsOogmMonitorPlugin::~CFbsOogmMonitorPlugin()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   103
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   104
    RFbsSession::Disconnect();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   105
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   106
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   107
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   108
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   109
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   110
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   111
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   112
void CFbsOogmMonitorPlugin::ConstructL()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   113
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   114
    CGOomMonitorPluginBase::ConstructL();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   115
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   116
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   117
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   118
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   119
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   120
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   121
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   122
TAny* CreatePlugin()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   123
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   124
    CFbsOogmMonitorPlugin* self = new CFbsOogmMonitorPlugin;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   125
    if ( self )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   126
        {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   127
        TRAPD( err, self->ConstructL() );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   128
        if ( err != KErrNone )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   129
            {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   130
            delete self;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   131
            self = NULL;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   132
            }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   133
        }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   134
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   135
    return self;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   136
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   137
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   138
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   139
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   140
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   141
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   142
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   143
const TImplementationProxy ImplementationTable[] =
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   144
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   145
    { {0x2002B638}, ::CreatePlugin }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   146
    };
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   147
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   148
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   149
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   150
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   151
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   152
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   153
EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   154
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   155
    OstTrace0( TRACE_NORMAL, _IMPLEMENTATIONGROUPPROXY, "> ::ImplementationGroupProxy" );
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   156
    
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   157
    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ) ;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   158
    return ImplementationTable;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   159
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   160
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   161
d72fc2aace31 201027_1
hgs
parents:
diff changeset
   162