| OLD | NEW |
| (Empty) |
| 1 /* Copyright (c) 2011 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 | |
| 6 #ifndef PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ | |
| 7 #define PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ | |
| 8 | |
| 9 #include "ppapi/c/pp_bool.h" | |
| 10 #include "ppapi/c/pp_graphics_3d.h" | |
| 11 #include "ppapi/c/pp_completion_callback.h" | |
| 12 #include "ppapi/c/pp_instance.h" | |
| 13 #include "ppapi/c/pp_resource.h" | |
| 14 | |
| 15 #define PPB_SURFACE_3D_DEV_INTERFACE_0_2 "PPB_Surface3D(Dev);0.2" | |
| 16 #define PPB_SURFACE_3D_DEV_INTERFACE PPB_SURFACE_3D_DEV_INTERFACE_0_2 | |
| 17 | |
| 18 struct PPB_Surface3D_Dev { | |
| 19 // Creates a render surface and returns a handle to it. | |
| 20 // Any PPB_Context3D_Dev created with a compatible PP_Config3D_Dev | |
| 21 // can be used to render into this surface. The returned surface is | |
| 22 // off-screen to start with. It must be attached to a plugin instance | |
| 23 // using PPB_Instance::BindGraphics to draw on the web page. | |
| 24 // | |
| 25 // attrib_list specifies a list of attributes for the surface. The list has | |
| 26 // the same structure as described for PPB_Graphics3D_Dev::GetConfigAttribs. | |
| 27 // Attributes that can be specified in attrib_list include: | |
| 28 // - PP_GRAPHICS3DATTRIB_WIDTH | |
| 29 // - PP_GRAPHICS3DATTRIB_HEIGHT | |
| 30 // - PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: If true, creates the largest | |
| 31 // possible surface when the allocation of the surface would otherwise fail. | |
| 32 // The width and height of the allocated surface will never exceed the | |
| 33 // values of PP_GRAPHICS3DATTRIB_WIDTH and PP_GRAPHICS3DATTRIB_HEIGHT, | |
| 34 // respectively. If this option is used, PPB_Surface3D_Dev::GetAttrib | |
| 35 // can be used to retrieve surface dimensions. | |
| 36 // - PP_GRAPHICS3DATTRIB_RENDER_BUFFER | |
| 37 PP_Resource (*Create)(PP_Instance instance, | |
| 38 PP_Config3D_Dev config, | |
| 39 const int32_t* attrib_list); | |
| 40 | |
| 41 // Returns PP_TRUE if the given resource is a valid Surface3D, PP_FALSE if it | |
| 42 // is an invalid resource or is a resource of another type. | |
| 43 PP_Bool (*IsSurface3D)(PP_Resource resource); | |
| 44 | |
| 45 // Sets an attribute for PPB_Surface3D_Dev. The specified attribute of | |
| 46 // surface is set to value. Attributes that can be specified are: | |
| 47 // - PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE: If value | |
| 48 // is PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX, and the | |
| 49 // PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface does | |
| 50 // not contain PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX_BIT, a | |
| 51 // PP_GRAPHICS3DERROR_BAD_MATCH error is returned. | |
| 52 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: If value is | |
| 53 // PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED, and the | |
| 54 // PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface | |
| 55 // does not contain PP_GRAPHICS3DATTRIBVALUE_SWAP_BEHAVIOR_PRESERVED_BIT, | |
| 56 // a PP_GRAPHICS3DERROR_BAD_MATCH error is returned. | |
| 57 int32_t (*SetAttrib)(PP_Resource surface, | |
| 58 int32_t attribute, | |
| 59 int32_t value); | |
| 60 | |
| 61 // Retrieves the value of attribute for surface. Attributes that can be | |
| 62 // queried for are: | |
| 63 // - PP_GRAPHICS3DATTRIB_CONFIG_ID: returns the ID of the | |
| 64 // PP_Config3D_Dev with respect to which the surface was created. | |
| 65 // - PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: returns the same attribute value | |
| 66 // specified when the surface was created with PPB_Surface3D_Dev::Create. | |
| 67 // - PP_GRAPHICS3DATTRIB_WIDTH and PP_GRAPHICS3DATTRIB_HEIGHT: The returned | |
| 68 // size may be less than the requested size if | |
| 69 // PP_GRAPHICS3DATTRIB_LARGEST_SURFACE is true. | |
| 70 // - PP_GRAPHICS3DATTRIB_RENDER_BUFFER | |
| 71 // - PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE | |
| 72 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR | |
| 73 // | |
| 74 // If attribute is not a valid PPB_Surface3D_Dev surface attribute, | |
| 75 // then an PP_GRAPHICS3DERROR_BAD_ATTRIBUTE error is returned. If surface | |
| 76 // is not a valid PPB_Surface3D_Dev then an PP_GRAPHICS3DERROR_BAD_SURFACE | |
| 77 // error is returned. | |
| 78 int32_t (*GetAttrib)(PP_Resource surface, | |
| 79 int32_t attribute, | |
| 80 int32_t* value); | |
| 81 | |
| 82 // Makes the contents of the color buffer available for compositing. | |
| 83 // This function has no effect on off-screen surfaces - ones not bound | |
| 84 // to any plugin instance. The contents of ancillary buffers are always | |
| 85 // undefined after calling SwapBuffers. The contents of the color buffer are | |
| 86 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute | |
| 87 // of surface is not PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED. | |
| 88 // | |
| 89 // If surface is bound as the draw surface of a context then SwapBuffers | |
| 90 // performs an implicit flush operation on the context. | |
| 91 // | |
| 92 // This functions can run in two modes: | |
| 93 // - In synchronous mode, you specify NULL for the callback and the callback | |
| 94 // data. This function will block the calling thread until the image has | |
| 95 // been painted to the screen. It is not legal to block the main thread of | |
| 96 // the plugin, you can use synchronous mode only from background threads. | |
| 97 // - In asynchronous mode, you specify a callback function and the argument | |
| 98 // for that callback function. The callback function will be executed on | |
| 99 // the calling thread when the image has been painted to the screen. While | |
| 100 // you are waiting for a Flush callback, additional calls to Flush will | |
| 101 // fail. | |
| 102 // | |
| 103 // Because the callback is executed (or thread unblocked) only when the | |
| 104 // plugin's current state is actually on the screen, this function provides a | |
| 105 // way to rate limit animations. By waiting until the image is on the screen | |
| 106 // before painting the next frame, you can ensure you're not generating | |
| 107 // updates faster than the screen can be updated. | |
| 108 // | |
| 109 int32_t (*SwapBuffers)(PP_Resource surface, | |
| 110 struct PP_CompletionCallback callback); | |
| 111 }; | |
| 112 | |
| 113 #endif // PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ | |
| OLD | NEW |