OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ |
| 6 #define PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ |
| 7 |
| 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_module.h" |
| 10 #include "ppapi/c/pp_resource.h" |
| 11 |
| 12 #define PPB_SURFACE_3D_DEV_INTERFACE "PPB_Surface3D(Dev);0.1" |
| 13 |
| 14 // TODO(alokp): Should this rather be named Graphics3DSurface |
| 15 // to indicate that it is part of the Graphics3D package? |
| 16 struct PPB_Surface3D_Dev { |
| 17 // Creates a render surface and returns a handle to it. |
| 18 // Any PPB_Context3D_Dev created with a compatible PP_Graphics3DConfig_Dev |
| 19 // can be used to render into this surface. The returned surface is |
| 20 // off-screen to start with. It must be attached to a plugin instance |
| 21 // using PPB_Instance::BindGraphics to draw on the web page. |
| 22 // attrib_list specifies a list of attributes for the surface. The list has |
| 23 // the same structure as described for PPB_Graphics3D_Dev::GetConfigAttribs. |
| 24 // Attributes that can be specified in attrib_list include: |
| 25 // PP_GRAPHICS3DATTRIB_WIDTH: width of surface in pixels |
| 26 // PP_GRAPHICS3DATTRIB_HEIGHT: height of surface in pixels |
| 27 // PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: If true, creates the largest |
| 28 // possible surface when the allocation of the surface would otherwise fail. |
| 29 // The width and height of the allocated surface will never exceed the |
| 30 // values of PP_GRAPHICS3DATTRIB_WIDTH and PP_GRAPHICS3DATTRIB_HEIGHT, |
| 31 // respectively. If this option is used, PPB_Surface3D_Dev::GetAttrib |
| 32 // can be used to retrieve surface dimensions. |
| 33 // PP_GRAPHICS3DATTRIB_RENDER_BUFFER: specifies which buffer should be used |
| 34 // for client API rendering to the surface. If its value is |
| 35 // PP_GRAPHICS3DATTRIBVALUE_SINGLE_BUFFER, the surface contains a single |
| 36 // color buffer to which the client APIs render to. If its value is |
| 37 // PP_GRAPHICS3DATTRIBVALUE_BACK_BUFFER, then the surface contains two |
| 38 // color buffers and all client APIs render into the back buffer. The |
| 39 // default value of PP_GRAPHICS3DATTRIB_RENDER_BUFFER is |
| 40 // PP_GRAPHICS3DATTRIBVALUE_BACK_BUFFER. |
| 41 // |
| 42 // TODO(alokp): Need a way to return specific error codes. Would a fourth |
| 43 // int32_t* argument be fine. It will certainly be inconsistent with othe |
| 44 // functions that return error code. |
| 45 PP_Resource (*Create)(PP_Module module, |
| 46 PP_Graphics3DConfig_Dev config, |
| 47 const int32_t* attrib_list); |
| 48 |
| 49 // Returns PP_TRUE if the given resource is a valid Surface3D, PP_FALSE if it |
| 50 // is an invalid resource or is a resource of another type. |
| 51 PP_Bool (*IsSurface3D)(PP_Resource resource); |
| 52 |
| 53 // Sets an attribute for PPB_Surface3D_Dev. The specified attribute of |
| 54 // surface is set to value. Attributes that can be specified are: |
| 55 // PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE: specifies the filter to use when |
| 56 // resolving the multisample buffer. A value of |
| 57 // PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_DEFAULT chooses the default |
| 58 // implementation-defined filtering method, while |
| 59 // PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX chooses a one-pixel wide |
| 60 // box filter placing equal weighting on all multisample values. If value |
| 61 // is PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX, and the |
| 62 // PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface does |
| 63 // not contain PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX_BIT, a |
| 64 // PP_GRAPHICS3DERROR_BAD_MATCH error is returned. The initial value of |
| 65 // PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE is |
| 66 // PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_DEFAULT. |
| 67 // PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: specifies the effect on the color |
| 68 // buffer of posting a surface with SwapBuffers. A value of |
| 69 // PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED indicates that color buffer |
| 70 // contents are unaffected, while PP_GRAPHICS3DATTRIBVALUE_BUFFER_DESTROYED |
| 71 // indicates that color buffer contents may be destroyed or changed by the |
| 72 // operation. If value is PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED, and |
| 73 // the PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface |
| 74 // does not contain PP_GRAPHICS3DATTRIBVALUE_SWAP_BEHAVIOR_PRESERVED_BIT, |
| 75 // a PP_GRAPHICS3DERROR_BAD_MATCH error is returned. The initial value of |
| 76 // PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR is chosen by the implementation. |
| 77 int32_t (*SetAttrib)(PP_Resource surface, |
| 78 int32_t attribute, |
| 79 int32_t value); |
| 80 |
| 81 // Retrieves the value of attribute for surface. Attributes that can be |
| 82 // queried for are: |
| 83 // PP_GRAPHICS3DATTRIB_CONFIG_ID: returns the ID of the |
| 84 // PP_Graphics3DConfig_Dev with respect to which the surface was created. |
| 85 // PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: returns the same attribute value |
| 86 // specified when the surface was created with PPB_Surface3D_Dev::Create. |
| 87 // EGL_WIDTH and EGL_HEIGHT: returns respectively the width and height, |
| 88 // in pixels, of the surface (which may be less than the requested size if |
| 89 // PP_GRAPHICS3DATTRIB_LARGEST_SURFACE is PP_TRUE). |
| 90 // PP_GRAPHICS3DATTRIB_RENDER_BUFFER: returns the buffer which client API |
| 91 // rendering is requested to use. |
| 92 // PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE: returns the filtering method used |
| 93 // when performing multi-sample buffer resolution. The filter may be either |
| 94 // PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_DEFAULT or |
| 95 // PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX. |
| 96 // PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: describes the effect on the color |
| 97 // buffer when posting a surface with PPB_Surface3D_Dev::SwapBuffers. |
| 98 // Swap behavior may be either PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED |
| 99 // or PP_GRAPHICS3DATTRIBVALUE_BUFFER_DESTROYED. |
| 100 // |
| 101 // If attribute is not a valid PPB_Surface3D_Dev surface attribute, |
| 102 // then an PP_GRAPHICS3DERROR_BAD_ATTRIBUTE error is generated. If surface |
| 103 // is not a valid PPB_Surface3D_Dev then an PP_GRAPHICS3DERROR_BAD_SURFACE |
| 104 // error is generated. |
| 105 int32_t (*GetAttrib)(PP_Resource surface, |
| 106 int32_t attribute, |
| 107 int32_t* value); |
| 108 |
| 109 // Makes the contents of the color buffer available for compositing. |
| 110 // This function has no effect on off-screen surfaces - ones not bound |
| 111 // to any plugin instance. The contents of ancillary buffers are always |
| 112 // undefined after calling SwapBuffers. The contents of the color buffer are |
| 113 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute |
| 114 // of surface is not PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED. |
| 115 // |
| 116 // If surface is bound as the draw surface of a context then SwapBuffers |
| 117 // performs an implicit flush operation on the context. |
| 118 // |
| 119 // This functions can run in two modes: |
| 120 // - In synchronous mode, you specify NULL for the callback and the callback |
| 121 // data. This function will block the calling thread until the image has |
| 122 // been painted to the screen. It is not legal to block the main thread of |
| 123 // the plugin, you can use synchronous mode only from background threads. |
| 124 // - In asynchronous mode, you specify a callback function and the argument |
| 125 // for that callback function. The callback function will be executed on |
| 126 // the calling thread when the image has been painted to the screen. While |
| 127 // you are waiting for a Flush callback, additional calls to Flush will |
| 128 // fail. |
| 129 // |
| 130 // Because the callback is executed (or thread unblocked) only when the |
| 131 // plugin's current state is actually on the screen, this function provides a |
| 132 // way to rate limit animations. By waiting until the image is on the screen |
| 133 // before painting the next frame, you can ensure you're not generating |
| 134 // updates faster than the screen can be updated. |
| 135 // |
| 136 int32_t (*SwapBuffers)(PP_Resource surface, |
| 137 struct PP_CompletionCallback callback); |
| 138 }; |
| 139 |
| 140 #endif // PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ |
OLD | NEW |