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