os/graphics/graphicsaccelaration/vgi/inc/vg/vgcontext.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
/*
sl@0
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: Internal binding API for OpenVG, used for managing OpenVG rendering contexts.
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
#ifndef _OPENVG_CONTEXT_H
sl@0
    18
#define _OPENVG_CONTEXT_H
sl@0
    19
sl@0
    20
#include <VG/openvg.h>
sl@0
    21
sl@0
    22
/*
sl@0
    23
Implementation note: all VGI_ERROR_xxx should be negative and well below standard Symbian error codes!
sl@0
    24
*/
sl@0
    25
enum {
sl@0
    26
	VGI_OK                              = 0,						
sl@0
    27
	VGI_ERROR_OUT_OF_MEMORY             = (-10000),
sl@0
    28
	VGI_ERROR_INVALID_ARGUMENTS         = (-10001),
sl@0
    29
	VGI_ERROR_ALREADY_EXISTS            = (-10002),
sl@0
    30
	VGI_ERROR_COLORSPACE_NOT_SUPPORTED  = (-10003),
sl@0
    31
    VGI_ERROR_NOT_SUPPORTED             = (-10004),
sl@0
    32
    VGI_ERROR_ILLEGAL_IMAGE_HANDLE      = (-10005),
sl@0
    33
    VGI_ERROR_IMAGE_IN_USE              = (-10006),
sl@0
    34
    VGI_ERROR_ILLEGAL_OPERATION         = (-10007),
sl@0
    35
};
sl@0
    36
sl@0
    37
typedef enum {
sl@0
    38
	VGI_COLORSPACE_LINEAR,
sl@0
    39
	VGI_COLORSPACE_SRGB
sl@0
    40
} VGIColorSpace;
sl@0
    41
sl@0
    42
typedef enum {
sl@0
    43
	VGI_COLOR_BUFFER_FORMAT_RGB565,
sl@0
    44
	VGI_COLOR_BUFFER_FORMAT_RGB888,
sl@0
    45
	VGI_COLOR_BUFFER_FORMAT_XRGB8888,
sl@0
    46
	VGI_COLOR_BUFFER_FORMAT_ARGB8888,
sl@0
    47
	VGI_COLOR_BUFFER_FORMAT_ARGB8888_PRE,
sl@0
    48
	VGI_COLOR_BUFFER_FORMAT_XRGB4444,
sl@0
    49
} VGIColorBufferFormat;
sl@0
    50
sl@0
    51
typedef enum {
sl@0
    52
   VGI_SKIP_TRANSPARENT_PIXELS,
sl@0
    53
   VGI_COPY_TRANSPARENT_PIXELS,
sl@0
    54
} VGICopyToTargetHint;
sl@0
    55
sl@0
    56
#ifdef GRAPHICS_LIBVGI_DLL
sl@0
    57
	#define VGI_API_CALL		__declspec(dllexport)
sl@0
    58
#else
sl@0
    59
	#define VGI_API_CALL		__declspec(dllimport)
sl@0
    60
#endif
sl@0
    61
sl@0
    62
#ifdef __cplusplus
sl@0
    63
extern "C" {
sl@0
    64
#endif
sl@0
    65
sl@0
    66
/**
sl@0
    67
 * OpenVG is initialized with the selected size and colorspace. A single rendering context is created and
sl@0
    68
 * made active (there is no support for multiple contexts). Single rendering (back buffer) surface is created
sl@0
    69
 * by OpenVG and made active for Read and Write.
sl@0
    70
 * @param width of the rendering surface (back buffer) size in pixels.
sl@0
    71
 * @param height of the rendering surface (back buffer) size in pixels.
sl@0
    72
 * @param colorSpace space to be used. Must be either VGI_COLORSPACE_LINEAR or VGI_COLORSPACE_SRGB.
sl@0
    73
 * @return Returns VGI_OK if initialization was successful. Returns error code VGI_ERROR_INVALID_ARGUMENTS
sl@0
    74
 *         if width or height are negative. Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient
sl@0
    75
 *         free memory to complete the initialization (smaller size for back buffer or smaller antialiasing setting may
sl@0
    76
 *         work). Returns error code VGI_ERROR_ALREADY_EXISTS if the surface and context already exists in this
sl@0
    77
 *         process & thread (call VGITerminate to reset). Returns error code VGI_ERROR_COLORSPACE_NOT_SUPPORTED
sl@0
    78
 *         if the given colorspace is not supported by the implementation.
sl@0
    79
 */
sl@0
    80
VGI_API_CALL int VGIInitialize( int width, int height, VGIColorSpace colorSpace );
sl@0
    81
sl@0
    82
/**
sl@0
    83
 * OpenVG is initialized with the selected size and colorspace. A single rendering context is created and
sl@0
    84
 * made active (there is no support for multiple contexts). Single rendering (back buffer) surface is created
sl@0
    85
 * by OpenVG and made active for Read and Write.
sl@0
    86
 * @param width of the rendering surface (back buffer) size in pixels.
sl@0
    87
 * @param height of the rendering surface (back buffer) size in pixels.
sl@0
    88
 * @param colorSpace space to be used. Must be either VGI_COLORSPACE_LINEAR or VGI_COLORSPACE_SRGB.
sl@0
    89
 * @param premultiplied flag indicates whether to create a premultiplied or non-premultiplied rendering surface.
sl@0
    90
 * @return Returns VGI_OK if initialization was successful. Returns error code VGI_ERROR_INVALID_ARGUMENTS
sl@0
    91
 *         if width or height are negative. Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient
sl@0
    92
 *         free memory to complete the initialization (smaller size for back buffer or smaller antialiasing setting may
sl@0
    93
 *         work). Returns error code VGI_ERROR_ALREADY_EXISTS if the surface and context already exists in this
sl@0
    94
 *         process & thread (call VGITerminate to reset). Returns error code VGI_ERROR_COLORSPACE_NOT_SUPPORTED
sl@0
    95
 *         if the given colorspace is not supported by the implementation.
sl@0
    96
 */
sl@0
    97
VGI_API_CALL int VGIInitializeEx( int width, int height, VGIColorSpace colorSpace, int premultiplied, int conformant );
sl@0
    98
sl@0
    99
/**
sl@0
   100
 * Copies the current contents of the internal back buffer to the given target buffer using the given stride
sl@0
   101
 * and format. Back buffer contents may be undefined after this function as it marks the start of new frame.
sl@0
   102
 * All target formats are supported by all implementations and the format bit pattern definitions match the
sl@0
   103
 * Symbian formats (EColo64K, EColor16M, EColor16MU, EColor16MA). Target buffer memory is assumed to be generic
sl@0
   104
 * system memory (MMU mapped).
sl@0
   105
 * @param format Format that is to be used when writing data to the given target buffer. Must be one of the
sl@0
   106
 *        VGI_COLOR_BUFFER_FORMAT_xxx values.
sl@0
   107
 * @param bufferStride Amount of bytes from beginning of scanline to the beginning of the next.
sl@0
   108
 *        Do NOT assume that width * bpp always equals stride!
sl@0
   109
 * @param buffer Target buffer where the current back buffer is copied to.
sl@0
   110
 *        The implementation uses internal back buffer and this target buffer is used only
sl@0
   111
 *        during the execution of this method.
sl@0
   112
 * @param maskStride Amount of bytes from beginning of scanline to the beginning of the next
sl@0
   113
 *        in the target mask buffer. Do NOT assume that width * bpp always equals stride!
sl@0
   114
 * @param mask Target buffer for the 8-bits per pixel destination alpha output
sl@0
   115
 *        (only written to by the method if parameter is not NULL and format is other than VGI_BUFFER_FORMAT_ARGB8888)
sl@0
   116
 * @param hint Specify how to process transparent pixels.
sl@0
   117
 *         Value VGI_SKIP_TRANSPARENT_PIXELS means transparent pixels are not copied to the target buffer.
sl@0
   118
 *         Value VGI_COPY_TRANSPARENT_PIXELS means every pixel transparent or not is copied to the target buffer.
sl@0
   119
 * @return Returns VGI_OK if copying completed successfully. Returns error code VGI_ERROR_INVALID_ARGUMENTS
sl@0
   120
 *         if bufferStride or maskStride are negative, if target buffer is either NULL or is not properly aligned. if
sl@0
   121
 *         the format is invalid or if hint is neither VGI_SKIP_TRANSPARENT_PIXELS nor VGI_COPY_TRANSPARENT_PIXELS.
sl@0
   122
 *         Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient
sl@0
   123
 *         free memory to complete the copying (before returning this error code the implementation internally
sl@0
   124
 *         calls VGITerminate() and current context and surface are lost.
sl@0
   125
 */
sl@0
   126
VGI_API_CALL int VGICopyToTarget( VGIColorBufferFormat format, int bufferStride, void *buffer, int maskStride, void *mask, VGICopyToTargetHint hint );
sl@0
   127
sl@0
   128
/**
sl@0
   129
 * Rendering surface and context are freed and may not be used after call to this method. OpenVG is terminated (all
sl@0
   130
 * other related resources are freed). If this method is called before VGIInitialize, or VGITerminate is called after
sl@0
   131
 * already being called, this method does nothing. In other words it is safe to call VGITerminate() multiple times
sl@0
   132
 * sequentially.
sl@0
   133
 */
sl@0
   134
VGI_API_CALL void VGITerminate( void );
sl@0
   135
sl@0
   136
/**
sl@0
   137
 * Resizes the back buffer to have the given width and height . This method should always be used to resize the back buffer as in
sl@0
   138
 * many implementations the resize operation can be handled more efficiently than a plain delete old, create new method.
sl@0
   139
 * Old context is preserved and can be used after the resize operation. Contents of the new frame buffer are UNDEFINED.
sl@0
   140
 * @param width Width of the back buffer after resize operation.
sl@0
   141
 * @param height Height of the back buffer after resize operation.
sl@0
   142
 * @return Returns VGI_OK if resize operation was successful. Returns error code VGI_ERROR_ILLEGAL_OPERATION if an image is currently
sl@0
   143
 *    set as the render target. Returns error code VGI_ERROR_INVALID_ARGUMENTS if width
sl@0
   144
 *    or height are negative or error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient free memory to allocate the back
sl@0
   145
 *    buffer of given size (smaller size may work).
sl@0
   146
 * @note: if VGI_ERROR_OUT_OF_MEMORY is returned, the original surface is lost and VGITerminate is called internally (context & surface is lost)
sl@0
   147
 */
sl@0
   148
VGI_API_CALL int VGIResize( int width, int height );
sl@0
   149
sl@0
   150
/**
sl@0
   151
 * Redirects rendering to an image.
sl@0
   152
 * @param image Image to be set as the render target.
sl@0
   153
 * @return Returns VGI_OK if successful.
sl@0
   154
 *    Returns error code VGI_ERROR_ILLEGAL_IMAGE_HANDLE if image is not a valid image handle, or is not shared with the current context.
sl@0
   155
 *    Returns error code VGI_ERROR_NOT_SUPPORTED if image is not of the same format as the "master surface".
sl@0
   156
 *    Returns error code VGI_ERROR_IMAGE_IN_USE if image shares storage with any other image (via use of the vgChildImage function),
sl@0
   157
 *      or is set as a paint pattern image on a paint object.
sl@0
   158
 *    Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient free memory to perform the operation.
sl@0
   159
 * @note: if VGI_ERROR_OUT_OF_MEMORY is returned, the original surface is lost and VGITerminate is called internally (context & surface is lost)
sl@0
   160
 */
sl@0
   161
VGI_API_CALL int VGIBindToImage( VGImage image );
sl@0
   162
sl@0
   163
/**
sl@0
   164
 * Reset the "master surface" as current render target .
sl@0
   165
 * @return Returns VGI_OK if successful.
sl@0
   166
 *    Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient free memory to perform the operation.
sl@0
   167
 * @note: if VGI_ERROR_OUT_OF_MEMORY is returned, the original surface is lost and VGITerminate is called internally (context & surface is lost)
sl@0
   168
 */
sl@0
   169
VGI_API_CALL int VGIUnBindImage( void );
sl@0
   170
sl@0
   171
#ifdef __cplusplus 
sl@0
   172
} /* extern "C" */
sl@0
   173
#endif
sl@0
   174
sl@0
   175
#endif /* _OPENVG_CONTEXT_H */