javauis/m2g_qt/src/CM2GRenderContext.cpp
author hgs
Fri, 29 Oct 2010 11:49:32 +0300
changeset 87 1627c337e51e
parent 80 d6dafc5d983f
permissions -rw-r--r--
v2.2.21_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     1
/*
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     3
* All rights reserved.
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     8
*
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     9
* Initial Contributors:
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    11
*
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    12
* Contributors:
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    13
*
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    14
* Description:  Render context implementation
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    15
*
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    16
*/
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    17
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    18
// INCLUDE FILES
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    19
#include <eikenv.h> // CCoeEnv
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    20
#include <graphics.h>
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    21
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    22
#include "CM2GRenderContext.h"
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    23
#include "MM2GSVGProxy.h"
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    24
#include "svgtbitmap.h"
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    25
#include <ImageConversion.h>
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    26
#include <f32file.h>
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    27
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    28
M2G_NS_START
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    29
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    30
// EXTERNAL DATA STRUCTURES
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    31
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    32
// EXTERNAL FUNCTION PROTOTYPES
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    33
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    34
// CONSTANTS
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    35
/* static */ const TReal32       MM2GRenderContext::KFullOpaque             = 1.0;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    36
/* static */
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    37
const TReal32       MM2GRenderContext::KFullTransparency       = 0.0;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    38
/* static */
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    39
const TUint8        MM2GRenderContext::KMaxAlphaValue          = 255;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    40
/* static */
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    41
const TDisplayMode  MM2GRenderContext::KDefaultDisplayMode     = EColor16MA;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    42
/* static */
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    43
const TDisplayMode  MM2GRenderContext::KMaskDisplayMode        = EGray256;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    44
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    45
// MACROS
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    46
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    47
// LOCAL CONSTANTS AND MACROS
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    48
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    49
// MODULE DATA STRUCTURES
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    50
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    51
// LOCAL FUNCTION PROTOTYPES
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    52
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    53
// FORWARD DECLARATIONS
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    54
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    55
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    56
// CM2GRenderContext::CM2GRenderContext
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    57
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    58
CM2GRenderContext::CM2GRenderContext()
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    59
        : CBase(),
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    60
        iProxy(NULL),
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    61
        iEngineHandle(M2G_INVALID_HANDLE),
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    62
        iAlpha(MM2GRenderContext::KFullOpaque),
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    63
        iScaledAlpha(MM2GRenderContext::KMaxAlphaValue),
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    64
        iImgBmp(NULL),
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    65
        iWindowSurface(NULL)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    66
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    67
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::CM2GRenderContext");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    68
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    69
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    70
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    71
// CM2GRenderContext::NewL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    72
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    73
CM2GRenderContext* CM2GRenderContext::NewL(MM2GSVGProxy* aProxy)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    74
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    75
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::NewL()");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    76
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    77
    CM2GRenderContext* self = new(ELeave) CM2GRenderContext;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    78
    CleanupStack::PushL(self);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    79
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    80
    self->ConstructL(aProxy);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    81
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    82
    CleanupStack::Pop();
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    83
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    84
    return self;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    85
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    86
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    87
// CM2GRenderContext::~CM2GRenderContext
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    88
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    89
CM2GRenderContext::~CM2GRenderContext()
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    90
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    91
    M2G_DEBUG_2("M2G_DEBUG: CM2GRenderContext::~CM2GRenderContext() - proxy=%d, engine=%d", iProxy, iEngineHandle);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    92
    if ((iEngineHandle != M2G_INVALID_HANDLE) && (iProxy != NULL))
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    93
    {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    94
        TRAP_IGNORE(iProxy->DeleteSvgEngineL(iEngineHandle));
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    95
    }
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
    96
    if (iWindowSurface)
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
    97
    {
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
    98
        delete iWindowSurface;
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
    99
    }
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   100
    if (targetBitmap)
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   101
    {
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   102
        delete targetBitmap;
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   103
    }
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   104
    if (iTargetQImage)
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   105
    {
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   106
        delete iTargetQImage;
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   107
    }
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   108
    if (tempBitmapForMask)
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   109
    {
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   110
        delete tempBitmapForMask;
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   111
    }
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   112
    delete iImgBmp;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   113
    iFbsSession.Disconnect();
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   114
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   115
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   116
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   117
// CM2GRenderContext::BindL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   118
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   119
void CM2GRenderContext::BindL(TInt& aTargetHandle)
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   120
{
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   121
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::BindL()");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   122
    // get the screen size
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   123
    TSize screenSize = CEikonEnv::Static()->ScreenDevice()->SizeInPixels();
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   124
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   125
    iWindowSurface = (reinterpret_cast<Java::GFX::WindowSurface*>(aTargetHandle));
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   126
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   127
    iWindowSurface->bind(Java::GFX::WsTypeQtImage);
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   128
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   129
    wSurfaceType = (Java::GFX::WindowSurfaceType)iWindowSurface->getType();
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   130
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   131
    switch (wSurfaceType)
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   132
    {
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   133
    case Java::GFX::WsTypeQtImage:
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   134
        User::LeaveIfNull(iOffScreenQImage = iWindowSurface->getQtImage());
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   135
        targetBitmap = new CSvgtBitmap((TInt8*)iOffScreenQImage->bits(),
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   136
                                       TSize(iOffScreenQImage->size().width(),iOffScreenQImage->size().height()),
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   137
                                       EColor16MA,iOffScreenQImage->bytesPerLine());
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   138
        break;
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   139
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   140
    case Java::GFX::WsTypeSymbianBitmap:
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   141
        break;
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   142
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   143
    default:
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   144
        User::Leave(KErrNotSupported);
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   145
        break;
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   146
    }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   147
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   148
}
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   149
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   150
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   151
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   152
// CM2GRenderContext::InitImageBitmapL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   153
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   154
void CM2GRenderContext::InitImageBitmapL()
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   155
{
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   156
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::InitImageBitmapL() - begin");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   157
    // get the screen size
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   158
    TSize screenSize = CEikonEnv::Static()->ScreenDevice()->SizeInPixels();
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   159
    switch (wSurfaceType)
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   160
    {
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   161
    case Java::GFX::WsTypeQtImage:
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   162
    {
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   163
        break;
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   164
    }
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   165
    case Java::GFX::WsTypeSymbianBitmap:
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   166
    {
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   167
        break;
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   168
    }
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   169
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   170
    default:
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   171
        break;
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   172
    }
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   173
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::InitImageBitmapL() - end");
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   174
}
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   175
// CM2GRenderContext::ReleaseL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   176
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   177
void CM2GRenderContext::ReleaseL()
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   178
{
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   179
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ReleaseL() - begin");
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   180
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   181
    iTargetQImage = NULL;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   182
    iOffScreenQImage = NULL;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   183
    iWindowSurface->release();
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   184
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   185
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ReleaseL() - end");
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   186
}
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   187
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   188
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   189
// CM2GRenderContext::RenderL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   190
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   191
void CM2GRenderContext::RenderLCDUIL(
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   192
    TM2GSvgDocumentHandle& aSvgDocHandle,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   193
    const TReal32 aCurrentTime,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   194
    TInt aSvgW, TInt aSvgH,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   195
    TM2GRenderRect& aRect
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   196
)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   197
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   198
    // prepare viewbox
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   199
    TRect viewbox;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   200
    TPoint anchor;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   201
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   202
    PrepareViewbox(aRect, aSvgW, aSvgH, viewbox, anchor);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   203
    RenderLCDUIL(aSvgDocHandle, aCurrentTime, viewbox, anchor);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   204
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   205
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   206
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   207
void CM2GRenderContext::RenderESWTL(
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   208
    TM2GSvgDocumentHandle& aSvgDocHandle,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   209
    const TReal32 aCurrentTime,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   210
    TInt aSvgW, TInt aSvgH,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   211
    TM2GRenderRect& aRect,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   212
    TBool aUseNativeClear,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   213
    TInt* aReturnData)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   214
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   215
    // prepare viewbox
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   216
    TRect viewbox;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   217
    TPoint anchor;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   218
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   219
    PrepareViewbox(aRect, aSvgW, aSvgH, viewbox, anchor);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   220
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   221
    aReturnData[0] = 0;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   222
    aReturnData[1] = 0;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   223
    aReturnData[2] = 0;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   224
    aReturnData[3] = 0;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   225
    aReturnData[4] = anchor.iX;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   226
    aReturnData[5] = anchor.iY;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   227
    aReturnData[6] = viewbox.iTl.iX;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   228
    aReturnData[7] = viewbox.iTl.iY;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   229
    aReturnData[8] = viewbox.Width();
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   230
    aReturnData[9] = viewbox.Height();
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   231
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   232
    RenderESWTL(aSvgDocHandle, aCurrentTime, viewbox, anchor, aUseNativeClear, aReturnData);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   233
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   234
    return;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   235
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   236
// CM2GRenderContext::SetRenderingQualityL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   237
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   238
void CM2GRenderContext::SetRenderingQualityL(TInt aMode)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   239
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   240
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::SetRenderingQualityL()");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   241
    User::LeaveIfNull(iProxy);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   242
    iProxy->RenderQualityL(iEngineHandle, aMode);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   243
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   244
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   245
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   246
// CM2GRenderContext::SetTransparencyL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   247
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   248
void CM2GRenderContext::SetTransparency(TReal32 aAlpha)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   249
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   250
    iAlpha = aAlpha;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   251
    iScaledAlpha = STATIC_CAST(TUint8, (aAlpha * MM2GRenderContext::KMaxAlphaValue));
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   252
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   253
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   254
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   255
// CM2GRenderContext::ConstructL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   256
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   257
void CM2GRenderContext::ConstructL(MM2GSVGProxy* aProxy)
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   258
{
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   259
    // Init member variables
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   260
    SetTransparency(MM2GRenderContext::KFullOpaque);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   261
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   262
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ConstructL() - begin");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   263
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   264
    if (aProxy)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   265
    {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   266
        iProxy = aProxy;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   267
        iProxy->CreateSvgEngineL(iEngineHandle);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   268
        M2G_DEBUG_2("M2G_DEBUG: CM2GRenderContext::ConstructL() - proxy: %d, new engine: %d", iProxy, iEngineHandle);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   269
    }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   270
    else
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   271
    {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   272
        M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ConstructL() - proxy is invalid");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   273
        M2G_THROW(KM2GArgNotOk);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   274
    }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   275
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   276
    User::LeaveIfError(iFbsSession.Connect());
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   277
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ConstructL() - end");
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   278
}
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   279
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   280
// CM2GRenderContext::PrepareViewbox
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   281
// -----------------------------------------------------------------------------
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   282
void CM2GRenderContext::PrepareViewbox(
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   283
    TM2GRenderRect& aRr,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   284
    TInt aSvgW, TInt aSvgH,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   285
    TRect& aViewbox, TPoint& aAnchor)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   286
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   287
    M2G_DEBUG_6("M2G_DEBUG: CM2GRenderContext::PrepareViewbox() cX=%d, cY=%d, cW=%d, cH=%d, anchorX=%d, anchorY=%d - begin", aRr.GetClipX(), aRr.GetClipY(), aRr.GetClipW(), aRr.GetClipH(), aRr.GetAnchorX(), aRr.GetAnchorY());
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   288
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   289
    // Create an anchor point and an svg render area rect
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   290
    aAnchor.SetXY(aRr.GetAnchorX(), aRr.GetAnchorY());
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   291
    aViewbox.SetRect(aAnchor, TSize(aSvgW, aSvgH));
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   292
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   293
    // NOTE: It's already verified in Java side that the SVG render area and
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   294
    // the clip area intersects each other
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   295
    aViewbox.Intersection(aRr);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   296
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   297
    // Check if the clip rect has changes the svg rect
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   298
    if (aViewbox.iTl != aAnchor)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   299
    {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   300
        // Update anchor position
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   301
        TPoint oldAnchor(aAnchor);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   302
        aAnchor = aViewbox.iTl;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   303
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   304
        // Update svg rect
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   305
        aViewbox.Move((-oldAnchor.iX), (-oldAnchor.iY));
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   306
    }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   307
    else
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   308
    {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   309
        // The clip rect has not changed the svg rect. Only the
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   310
        // anchor position need to be updated
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   311
        aViewbox.Move(-aAnchor.iX, -aAnchor.iY);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   312
    }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   313
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::PrepareViewbox() - end");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   314
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   315
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   316
void CM2GRenderContext::RenderLCDUIL(
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   317
    TM2GSvgDocumentHandle& aSvgDocHandle,
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   318
    TReal32 aCurrentTime,
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   319
    const TRect& /*aViewbox*/,
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   320
    const TPoint& /*aAnchor*/)
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   321
{
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   322
    M2G_DEBUG_4("M2G_DEBUG: CM2GRenderContext::RenderL() viewbox: x=%d, y=%d, w=%d, h=%d begin", aViewbox.iTl.iX, aViewbox.iTl.iY, aViewbox.Size().iWidth, aViewbox.Size().iHeight);
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   323
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   324
    // No need to render if content is fully transparency (i.e. alpha=0)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   325
    if (iScaledAlpha == 0)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   326
    {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   327
        return;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   328
    }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   329
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   330
    // 1: render the svg document on the iImgBmp
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   331
    iProxy->RenderDocumentL(
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   332
        iEngineHandle,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   333
        aSvgDocHandle,
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   334
        (TM2GSvgBitmapHandle)targetBitmap
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   335
        , (TUint)NULL, aCurrentTime);
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   336
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   337
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::RenderL() end");
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   338
}
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   339
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   340
// -----------------------------------------------------------------------------
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   341
/*
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   342
 * Write the separate RenderDocumentL method for QImage and CFbsBitmap
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   343
 * also handle subsequent BitBlt and
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   344
 * CreateAlphaBlendMaskL
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   345
 * */
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   346
void CM2GRenderContext::RenderESWTL(
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   347
    TM2GSvgDocumentHandle& aSvgDocHandle,
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   348
    TReal32 aCurrentTime,
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   349
    const TRect& /*aViewbox*/,
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   350
    const TPoint& /*aAnchor*/,
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   351
    TBool /*aUseNativeClear*/,
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   352
    TInt* /*aReturnData*/)
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   353
{
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   354
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::RenderESWTL() Start");
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   355
    // No need to render if content is fully transparency (i.e. alpha=0)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   356
    if (iScaledAlpha == 0)
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   357
    {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   358
        return;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   359
    }
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   360
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   361
    // 1: render the svg document on the iImgBmp
87
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   362
    iProxy->RenderDocumentL(iEngineHandle,
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   363
                            aSvgDocHandle,
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   364
                            (TM2GSvgBitmapHandle)targetBitmap, (TUint)NULL, aCurrentTime);
1627c337e51e v2.2.21_1
hgs
parents: 80
diff changeset
   365
    M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::RenderESWTL() end");
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   366
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   367
}
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   368
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
   369
M2G_NS_END