sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: Internal binding API for OpenVG, used for managing OpenVG rendering contexts. sl@0: * sl@0: */ sl@0: #ifndef _OPENVG_CONTEXT_H sl@0: #define _OPENVG_CONTEXT_H sl@0: sl@0: #include sl@0: sl@0: /* sl@0: Implementation note: all VGI_ERROR_xxx should be negative and well below standard Symbian error codes! sl@0: */ sl@0: enum { sl@0: VGI_OK = 0, sl@0: VGI_ERROR_OUT_OF_MEMORY = (-10000), sl@0: VGI_ERROR_INVALID_ARGUMENTS = (-10001), sl@0: VGI_ERROR_ALREADY_EXISTS = (-10002), sl@0: VGI_ERROR_COLORSPACE_NOT_SUPPORTED = (-10003), sl@0: VGI_ERROR_NOT_SUPPORTED = (-10004), sl@0: VGI_ERROR_ILLEGAL_IMAGE_HANDLE = (-10005), sl@0: VGI_ERROR_IMAGE_IN_USE = (-10006), sl@0: VGI_ERROR_ILLEGAL_OPERATION = (-10007), sl@0: }; sl@0: sl@0: typedef enum { sl@0: VGI_COLORSPACE_LINEAR, sl@0: VGI_COLORSPACE_SRGB sl@0: } VGIColorSpace; sl@0: sl@0: typedef enum { sl@0: VGI_COLOR_BUFFER_FORMAT_RGB565, sl@0: VGI_COLOR_BUFFER_FORMAT_RGB888, sl@0: VGI_COLOR_BUFFER_FORMAT_XRGB8888, sl@0: VGI_COLOR_BUFFER_FORMAT_ARGB8888, sl@0: VGI_COLOR_BUFFER_FORMAT_ARGB8888_PRE, sl@0: VGI_COLOR_BUFFER_FORMAT_XRGB4444, sl@0: } VGIColorBufferFormat; sl@0: sl@0: typedef enum { sl@0: VGI_SKIP_TRANSPARENT_PIXELS, sl@0: VGI_COPY_TRANSPARENT_PIXELS, sl@0: } VGICopyToTargetHint; sl@0: sl@0: #ifdef GRAPHICS_LIBVGI_DLL sl@0: #define VGI_API_CALL __declspec(dllexport) sl@0: #else sl@0: #define VGI_API_CALL __declspec(dllimport) sl@0: #endif sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: /** sl@0: * OpenVG is initialized with the selected size and colorspace. A single rendering context is created and sl@0: * made active (there is no support for multiple contexts). Single rendering (back buffer) surface is created sl@0: * by OpenVG and made active for Read and Write. sl@0: * @param width of the rendering surface (back buffer) size in pixels. sl@0: * @param height of the rendering surface (back buffer) size in pixels. sl@0: * @param colorSpace space to be used. Must be either VGI_COLORSPACE_LINEAR or VGI_COLORSPACE_SRGB. sl@0: * @return Returns VGI_OK if initialization was successful. Returns error code VGI_ERROR_INVALID_ARGUMENTS sl@0: * if width or height are negative. Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient sl@0: * free memory to complete the initialization (smaller size for back buffer or smaller antialiasing setting may sl@0: * work). Returns error code VGI_ERROR_ALREADY_EXISTS if the surface and context already exists in this sl@0: * process & thread (call VGITerminate to reset). Returns error code VGI_ERROR_COLORSPACE_NOT_SUPPORTED sl@0: * if the given colorspace is not supported by the implementation. sl@0: */ sl@0: VGI_API_CALL int VGIInitialize( int width, int height, VGIColorSpace colorSpace ); sl@0: sl@0: /** sl@0: * OpenVG is initialized with the selected size and colorspace. A single rendering context is created and sl@0: * made active (there is no support for multiple contexts). Single rendering (back buffer) surface is created sl@0: * by OpenVG and made active for Read and Write. sl@0: * @param width of the rendering surface (back buffer) size in pixels. sl@0: * @param height of the rendering surface (back buffer) size in pixels. sl@0: * @param colorSpace space to be used. Must be either VGI_COLORSPACE_LINEAR or VGI_COLORSPACE_SRGB. sl@0: * @param premultiplied flag indicates whether to create a premultiplied or non-premultiplied rendering surface. sl@0: * @return Returns VGI_OK if initialization was successful. Returns error code VGI_ERROR_INVALID_ARGUMENTS sl@0: * if width or height are negative. Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient sl@0: * free memory to complete the initialization (smaller size for back buffer or smaller antialiasing setting may sl@0: * work). Returns error code VGI_ERROR_ALREADY_EXISTS if the surface and context already exists in this sl@0: * process & thread (call VGITerminate to reset). Returns error code VGI_ERROR_COLORSPACE_NOT_SUPPORTED sl@0: * if the given colorspace is not supported by the implementation. sl@0: */ sl@0: VGI_API_CALL int VGIInitializeEx( int width, int height, VGIColorSpace colorSpace, int premultiplied, int conformant ); sl@0: sl@0: /** sl@0: * Copies the current contents of the internal back buffer to the given target buffer using the given stride sl@0: * and format. Back buffer contents may be undefined after this function as it marks the start of new frame. sl@0: * All target formats are supported by all implementations and the format bit pattern definitions match the sl@0: * Symbian formats (EColo64K, EColor16M, EColor16MU, EColor16MA). Target buffer memory is assumed to be generic sl@0: * system memory (MMU mapped). sl@0: * @param format Format that is to be used when writing data to the given target buffer. Must be one of the sl@0: * VGI_COLOR_BUFFER_FORMAT_xxx values. sl@0: * @param bufferStride Amount of bytes from beginning of scanline to the beginning of the next. sl@0: * Do NOT assume that width * bpp always equals stride! sl@0: * @param buffer Target buffer where the current back buffer is copied to. sl@0: * The implementation uses internal back buffer and this target buffer is used only sl@0: * during the execution of this method. sl@0: * @param maskStride Amount of bytes from beginning of scanline to the beginning of the next sl@0: * in the target mask buffer. Do NOT assume that width * bpp always equals stride! sl@0: * @param mask Target buffer for the 8-bits per pixel destination alpha output sl@0: * (only written to by the method if parameter is not NULL and format is other than VGI_BUFFER_FORMAT_ARGB8888) sl@0: * @param hint Specify how to process transparent pixels. sl@0: * Value VGI_SKIP_TRANSPARENT_PIXELS means transparent pixels are not copied to the target buffer. sl@0: * Value VGI_COPY_TRANSPARENT_PIXELS means every pixel transparent or not is copied to the target buffer. sl@0: * @return Returns VGI_OK if copying completed successfully. Returns error code VGI_ERROR_INVALID_ARGUMENTS sl@0: * if bufferStride or maskStride are negative, if target buffer is either NULL or is not properly aligned. if sl@0: * the format is invalid or if hint is neither VGI_SKIP_TRANSPARENT_PIXELS nor VGI_COPY_TRANSPARENT_PIXELS. sl@0: * Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient sl@0: * free memory to complete the copying (before returning this error code the implementation internally sl@0: * calls VGITerminate() and current context and surface are lost. sl@0: */ sl@0: VGI_API_CALL int VGICopyToTarget( VGIColorBufferFormat format, int bufferStride, void *buffer, int maskStride, void *mask, VGICopyToTargetHint hint ); sl@0: sl@0: /** sl@0: * Rendering surface and context are freed and may not be used after call to this method. OpenVG is terminated (all sl@0: * other related resources are freed). If this method is called before VGIInitialize, or VGITerminate is called after sl@0: * already being called, this method does nothing. In other words it is safe to call VGITerminate() multiple times sl@0: * sequentially. sl@0: */ sl@0: VGI_API_CALL void VGITerminate( void ); sl@0: sl@0: /** sl@0: * 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: * many implementations the resize operation can be handled more efficiently than a plain delete old, create new method. sl@0: * Old context is preserved and can be used after the resize operation. Contents of the new frame buffer are UNDEFINED. sl@0: * @param width Width of the back buffer after resize operation. sl@0: * @param height Height of the back buffer after resize operation. sl@0: * @return Returns VGI_OK if resize operation was successful. Returns error code VGI_ERROR_ILLEGAL_OPERATION if an image is currently sl@0: * set as the render target. Returns error code VGI_ERROR_INVALID_ARGUMENTS if width sl@0: * or height are negative or error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient free memory to allocate the back sl@0: * buffer of given size (smaller size may work). sl@0: * @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: */ sl@0: VGI_API_CALL int VGIResize( int width, int height ); sl@0: sl@0: /** sl@0: * Redirects rendering to an image. sl@0: * @param image Image to be set as the render target. sl@0: * @return Returns VGI_OK if successful. sl@0: * 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: * Returns error code VGI_ERROR_NOT_SUPPORTED if image is not of the same format as the "master surface". sl@0: * Returns error code VGI_ERROR_IMAGE_IN_USE if image shares storage with any other image (via use of the vgChildImage function), sl@0: * or is set as a paint pattern image on a paint object. sl@0: * Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient free memory to perform the operation. sl@0: * @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: */ sl@0: VGI_API_CALL int VGIBindToImage( VGImage image ); sl@0: sl@0: /** sl@0: * Reset the "master surface" as current render target . sl@0: * @return Returns VGI_OK if successful. sl@0: * Returns error code VGI_ERROR_OUT_OF_MEMORY if there is insufficient free memory to perform the operation. sl@0: * @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: */ sl@0: VGI_API_CALL int VGIUnBindImage( void ); sl@0: sl@0: #ifdef __cplusplus sl@0: } /* extern "C" */ sl@0: #endif sl@0: sl@0: #endif /* _OPENVG_CONTEXT_H */