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