javauis/lcdui_akn/javalcdui/src/Buffer.cpp
branchRCL_3
changeset 26 2455ef1f5bbc
parent 14 04becd199f91
equal deleted inserted replaced
25:ae942d28ec0e 26:2455ef1f5bbc
       
     1 /*
       
     2 * Copyright (c) 2002 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 #include <e32def.h> // FIX FOR MAKE_TINT64 warning
       
    19 #include <e32std.h>
       
    20 #include "javax_microedition_lcdui_Buffer.h"
       
    21 #include "CMIDBuffer.h"
       
    22 #include "CMIDToolkit.h"
       
    23 
       
    24 JNIEXPORT jint JNICALL
       
    25 Java_javax_microedition_lcdui_Buffer__1open(JNIEnv* aJni, jobject aBuffer, jint aEventServerHandle)
       
    26 {
       
    27     return CMIDBuffer::New(*aJni, aBuffer, aEventServerHandle);
       
    28 }
       
    29 
       
    30 JNIEXPORT void JNICALL
       
    31 Java_javax_microedition_lcdui_Buffer__1close
       
    32 (
       
    33     JNIEnv* aJni,
       
    34     jobject /*aBuffer*/,
       
    35     jint    aHandle
       
    36 )
       
    37 {
       
    38     JavaUnhand<CMIDBuffer>(aHandle)->Dispose(*aJni);
       
    39 }
       
    40 
       
    41 JNIEXPORT void JNICALL
       
    42 Java_javax_microedition_lcdui_Buffer__1flush
       
    43 (
       
    44     JNIEnv*     aJni,
       
    45     jobject     /* aObj */,
       
    46     jint        aBuffer,
       
    47     jintArray   aArray,
       
    48     jint        aCount
       
    49 )
       
    50 {
       
    51     ASSERT(aBuffer);
       
    52     ASSERT(aArray);
       
    53     ASSERT(aCount > 0);
       
    54 
       
    55     //
       
    56     // Flusher condition variable ensures that we cannot get here
       
    57     // whilst the server is processing the buffer. Hence it is safe to
       
    58     // access the buffer directly. If we wished to support a cicular
       
    59     // buffer, this could be done with a lightweight mutex.
       
    60     //
       
    61     CMIDBuffer& buffer = * JavaUnhand<CMIDBuffer>(aBuffer);
       
    62 
       
    63     buffer.RequestProcess(*aJni, aArray, aCount);
       
    64 }
       
    65 
       
    66 #ifdef GRAPHICS_BUFFER_DRAWPIXELS
       
    67 JNIEXPORT jint JNICALL
       
    68 Java_javax_microedition_lcdui_Buffer__1alloc
       
    69 (
       
    70     JNIEnv*     aJni,
       
    71     jobject     /* aObj */,
       
    72     jintArray   aArray,
       
    73     jint        aOffset,
       
    74     jint        aLength
       
    75 )
       
    76 {
       
    77     jint* address = (jint*)User::Alloc(aLength*sizeof(jint));
       
    78     if (!address)
       
    79     {
       
    80         return KErrNoMemory;
       
    81     }
       
    82     aJni->GetIntArrayRegion(aArray, aOffset, aLength, address);
       
    83     return JavaMakeHandle(address);
       
    84 }
       
    85 
       
    86 JNIEXPORT void JNICALL
       
    87 Java_javax_microedition_lcdui_Buffer__1free
       
    88 (
       
    89     JNIEnv*     /*aJni*/,
       
    90     jobject     /* aObj */,
       
    91     jint        aAddress
       
    92 )
       
    93 {
       
    94     User::Free(JavaUnhand<jint*>(aAddress));
       
    95 }
       
    96 #endif