os/graphics/windowing/windowserver/nga/CLIENT/CLIENT.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Window server client side local header file
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __CLIENT_H__
sl@0
    19
#define __CLIENT_H__
sl@0
    20
sl@0
    21
#include <e32hashtab.h>
sl@0
    22
sl@0
    23
#if defined(_DEBUG) && defined(__WINS__)
sl@0
    24
//#define __AUTO_FLUSH		//Define this for test purposes only, it hard codes auto flushing
sl@0
    25
#endif
sl@0
    26
sl@0
    27
/** Panics the client. This will result in the client thread being destroyed. */ 
sl@0
    28
GLREF_C void Panic(TW32Panic aPanic); 
sl@0
    29
GLREF_C void Assert(TW32Assert aPanic); 
sl@0
    30
sl@0
    31
class TReadDescriptorType;
sl@0
    32
class TWriteDescriptorType;
sl@0
    33
sl@0
    34
class RWsBuffer
sl@0
    35
	{
sl@0
    36
	friend class RWsSession;
sl@0
    37
public:
sl@0
    38
	enum bufferSizes
sl@0
    39
		{
sl@0
    40
		EDefBufferSize=EClientBufferSize,
sl@0
    41
		EMinBufferSize=EClientBufferSize,
sl@0
    42
		EMaxBufferSize=EClientBufferMaxSize
sl@0
    43
		};
sl@0
    44
public:
sl@0
    45
	RWsBuffer(RWsSession *aSession);
sl@0
    46
	void Close();
sl@0
    47
	void Destroy();
sl@0
    48
	TInt Open();
sl@0
    49
	TInt Connect(TUint32 handle);
sl@0
    50
	TInt WriteReplyWs(TUint opcode);
sl@0
    51
	TInt WriteReplyWs(const TAny *pData, TInt length,TUint opcode);
sl@0
    52
	TInt WriteReplyWs(const TAny *pData, TInt length, const TAny *pData2, TInt length2, TUint opcode);
sl@0
    53
	void SetBufferSizeL(TInt aBufSize);
sl@0
    54
	void SetMaxBufferSizeL(TInt aMaxBufSize);
sl@0
    55
	TInt Flush(const TIpcArgs* aIpcArgs=NULL,TBool aRequestFinish=EFalse);
sl@0
    56
	TBool SetAutoFlush(TBool aState);
sl@0
    57
	void Write(TInt aHandle, TUint aOpcode, const TAny *aData, TInt aLength, const TAny *aData2, TInt aLength2, const TIpcArgs* aIpcArgs=NULL);
sl@0
    58
	void Write(TInt aHandle, TUint aOpcode, const TAny *aData, TInt aLength, const TIpcArgs* aIpcArgs=NULL);
sl@0
    59
	void Write(TInt handle,TUint opcode);
sl@0
    60
	void AppendData(const TAny *aData, TInt aLength, TBool aFinished);
sl@0
    61
	TInt WriteReply(TInt handle,TUint opcode, const TIpcArgs* aIpcArgs=NULL);
sl@0
    62
	TInt WriteReply(TInt handle,TUint opcode,const TAny *buf, TInt bufLen, const TIpcArgs* aIpcArgs=NULL);
sl@0
    63
	TInt WriteReply(TInt handle,TUint opcode,const TAny *buf, TInt bufLen,const TAny *buf2, TInt buflen2, const TIpcArgs* aIpcArgs=NULL);
sl@0
    64
	TInt WriteReplyP(TInt aHandle,TUint aOpcode,const TWriteDescriptorType& aReplyBuffer);
sl@0
    65
	TInt WriteReplyP(TInt aHandle,TUint aOpcode,const TAny *aData,TInt aLength,const TWriteDescriptorType& aReplyBuffer);
sl@0
    66
	TInt WriteReplyP(TInt aHandle,TUint aOpcode,const TAny *aData1,TInt aLengthData1,const TAny *aData2,TInt aLengthData2,const TWriteDescriptorType& aReplyBuffer);
sl@0
    67
	TInt WriteReplyByProvidingRemoteReadAccess(TInt aHandle,TUint aOpcode,const TAny *aData, TInt aLength,const TReadDescriptorType& aRemoteReadBuffer);
sl@0
    68
sl@0
    69
	inline TInt BufferSize() const;
sl@0
    70
	inline TBool IsEmpty() const;
sl@0
    71
	inline RWsSession* Session() {return iSession;}
sl@0
    72
	static void FlushAllBuffers(TInt aBitmapHandle);
sl@0
    73
	void SetCallBack();
sl@0
    74
	void CancelCallBack();
sl@0
    75
	void AddToBitmapArray(TInt aBitmapHandle);
sl@0
    76
	
sl@0
    77
	void SetWsGraphicManager(CWsGraphic::CManager* aManager);
sl@0
    78
	static CWsGraphic::CManager* WsGraphicManager();
sl@0
    79
sl@0
    80
	void AsyncRequest(TInt aHandle, TUint aOpcode, TRequestStatus& aStatus);
sl@0
    81
sl@0
    82
	void EnableWindowSizeCacheL();
sl@0
    83
	inline TBool WindowSizeCacheEnabled() const;
sl@0
    84
	inline void MarkWindowSizeCacheDirty(TInt aHandle);
sl@0
    85
	inline void RefreshWindowSizeCache(TInt aHandle, const TSize& aNewSize);
sl@0
    86
	inline TInt CachedWindowSize(TInt aHandle, TSize& aSize);
sl@0
    87
	inline void DestroyWindowSizeCacheEntry(TInt aHandle);	
sl@0
    88
    
sl@0
    89
private:
sl@0
    90
	TInt DoWrite(TInt aHandle, TUint aOpcode, TBool aFlush, const TIpcArgs* aIpcArgs, const TAny* aData1=NULL, TInt aLength1=0, const TAny* aData2=NULL, TInt aLength2=0);
sl@0
    91
	inline void SetAndLimitMaxBufSize(TInt aMaxBufSize);
sl@0
    92
	void ReAllocBufferL(TInt aNewSize);
sl@0
    93
	TBool ReAllocBuffer(TInt aNewSize);
sl@0
    94
	void GrowBuffer(TInt aRequiredSpace, TInt aMsgSize);
sl@0
    95
sl@0
    96
private:
sl@0
    97
	RWsSession *iSession;
sl@0
    98
	CWsGraphic::CManager* iManager;
sl@0
    99
	TBool iAutoFlush;
sl@0
   100
	TPtr8 iBuf;
sl@0
   101
	RWsBuffer *iNext;
sl@0
   102
	TInt iPreviousHandle;
sl@0
   103
	TInt iBufSize;				// current buffer size, DoWrite can expand this up to iMaxBufize
sl@0
   104
	TInt iMaxBufSize;			// maximum buffer size, set by SetBufferSizeL or SetMaxBufferSizeL
sl@0
   105
#if defined(_DEBUG)
sl@0
   106
	TInt iAppendDataLength;
sl@0
   107
#endif
sl@0
   108
private:		//Added here as adding it to RWsSession breaks BC.
sl@0
   109
	TInt iDirectAcessCount;
sl@0
   110
	RArray<TInt> iBitmapArray;
sl@0
   111
	TBool iInvalidBitmapArray;
sl@0
   112
sl@0
   113
	class TWindowSizeCacheEntry
sl@0
   114
	    {
sl@0
   115
	public:
sl@0
   116
	    inline TWindowSizeCacheEntry(const TSize& aSize);
sl@0
   117
	public:
sl@0
   118
	    TSize iSize;
sl@0
   119
	    TBool iDirty;
sl@0
   120
	    };
sl@0
   121
	
sl@0
   122
	RHashMap<TInt, TWindowSizeCacheEntry>* iWindowSizeCache;
sl@0
   123
	};
sl@0
   124
sl@0
   125
sl@0
   126
inline TInt RWsBuffer::BufferSize() const
sl@0
   127
	{return(iBuf.MaxLength());}
sl@0
   128
sl@0
   129
inline TBool RWsBuffer::IsEmpty() const
sl@0
   130
	{return iBuf.Length()==0;}
sl@0
   131
sl@0
   132
inline RWsBuffer::TWindowSizeCacheEntry::TWindowSizeCacheEntry(const TSize& aSize)
sl@0
   133
    : iSize(aSize), iDirty(EFalse)
sl@0
   134
    {
sl@0
   135
    }
sl@0
   136
sl@0
   137
inline TBool RWsBuffer::WindowSizeCacheEnabled() const
sl@0
   138
    {
sl@0
   139
    return iWindowSizeCache ? ETrue : EFalse;
sl@0
   140
    }
sl@0
   141
sl@0
   142
inline void RWsBuffer::MarkWindowSizeCacheDirty(TInt aHandle)
sl@0
   143
    {
sl@0
   144
    __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure));
sl@0
   145
    RWsBuffer::TWindowSizeCacheEntry* entry = iWindowSizeCache->Find(aHandle);
sl@0
   146
    if (entry != NULL)
sl@0
   147
        {
sl@0
   148
        entry->iDirty = ETrue;
sl@0
   149
        }
sl@0
   150
    }
sl@0
   151
sl@0
   152
inline void RWsBuffer::RefreshWindowSizeCache(TInt aHandle, const TSize& aNewSize)
sl@0
   153
    {
sl@0
   154
    __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure));
sl@0
   155
    RWsBuffer::TWindowSizeCacheEntry* entry = iWindowSizeCache->Find(aHandle);
sl@0
   156
    if (entry == NULL)
sl@0
   157
        {
sl@0
   158
        iWindowSizeCache->Insert(aHandle, RWsBuffer::TWindowSizeCacheEntry(aNewSize));
sl@0
   159
        }
sl@0
   160
    else
sl@0
   161
        {
sl@0
   162
        entry->iSize = aNewSize;
sl@0
   163
        entry->iDirty = EFalse;
sl@0
   164
        }
sl@0
   165
    }
sl@0
   166
sl@0
   167
inline TInt RWsBuffer::CachedWindowSize(TInt aHandle, TSize& aSize)
sl@0
   168
    {
sl@0
   169
    __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure));
sl@0
   170
    RWsBuffer::TWindowSizeCacheEntry* entry = iWindowSizeCache->Find(aHandle);
sl@0
   171
    if ( entry && !(entry->iDirty) )
sl@0
   172
        {
sl@0
   173
        aSize = entry->iSize;
sl@0
   174
        return KErrNone;
sl@0
   175
        }
sl@0
   176
    else
sl@0
   177
        {
sl@0
   178
        // return KErrNotFound when either entry not found for aHandle, or entry is dirty
sl@0
   179
        return KErrNotFound;
sl@0
   180
        }
sl@0
   181
    }
sl@0
   182
sl@0
   183
inline void RWsBuffer::DestroyWindowSizeCacheEntry(TInt aHandle)
sl@0
   184
    {
sl@0
   185
    __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure));
sl@0
   186
    TInt err = iWindowSizeCache->Remove(aHandle);
sl@0
   187
    // If there is a window size cache entry, then err == KErrNone.
sl@0
   188
    // Otherwise, there isn't a size cache entry, and err == KErrNotFound.
sl@0
   189
    __ASSERT_DEBUG(err == KErrNone || err == KErrNotFound, Assert(EW32AssertWindowSizeCacheFailure));
sl@0
   190
    }
sl@0
   191
sl@0
   192
sl@0
   193
#endif