From fae0e947dd72d6499abcd4cc9d8a2c988802ecc7 Mon Sep 17 00:00:00 2001 From: "nfullagar@google.com" Date: Wed, 7 Sep 2011 17:10:46 +0000 Subject: reconstitute moving 3d out of dev CL. (previous attempt was reverted) previous CL: http://codereview.chromium.org/7737013/ BUG= http://code.google.com/p/chromium/issues/detail?id=94320 TEST= try bots, manual testing Review URL: http://codereview.chromium.org/7837018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99968 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/c/dev/pp_graphics_3d_dev.h | 48 ---- ppapi/c/dev/pp_video_dev.h | 2 +- ppapi/c/dev/ppb_context_3d_dev.h | 5 +- .../c/dev/ppb_gles_chromium_texture_mapping_dev.h | 2 +- ppapi/c/dev/ppb_graphics_3d_dev.h | 204 -------------- ppapi/c/dev/ppb_graphics_3d_trusted_dev.h | 103 ------- ppapi/c/dev/ppb_opengles_dev.h | 308 --------------------- ppapi/c/dev/ppb_surface_3d_dev.h | 2 +- ppapi/c/dev/ppp_graphics_3d_dev.h | 18 -- ppapi/c/pp_graphics_3d.h | 48 ++++ ppapi/c/ppb_graphics_3d.h | 204 ++++++++++++++ ppapi/c/ppb_opengles.h | 305 ++++++++++++++++++++ ppapi/c/ppp_graphics_3d.h | 18 ++ ppapi/c/trusted/ppb_graphics_3d_trusted.h | 103 +++++++ ppapi/cpp/dev/graphics_3d_client_dev.cc | 43 --- ppapi/cpp/dev/graphics_3d_client_dev.h | 36 --- ppapi/cpp/dev/graphics_3d_dev.cc | 76 ----- ppapi/cpp/dev/graphics_3d_dev.h | 39 --- ppapi/cpp/dev/video_decoder_dev.cc | 4 +- ppapi/cpp/dev/video_decoder_dev.h | 4 +- ppapi/cpp/graphics_3d.cc | 76 +++++ ppapi/cpp/graphics_3d.h | 39 +++ ppapi/cpp/graphics_3d_client.cc | 43 +++ ppapi/cpp/graphics_3d_client.h | 36 +++ ppapi/cpp/instance.cc | 4 +- ppapi/cpp/instance.h | 6 +- ppapi/examples/gles2/gles2.cc | 18 +- ppapi/lib/gl/gles2/gl2ext_ppapi.c | 8 +- ppapi/lib/gl/gles2/gl2ext_ppapi.h | 6 +- .../src/shared/ppapi_proxy/browser_globals.cc | 14 +- .../src/shared/ppapi_proxy/browser_globals.h | 8 +- .../browser_ppb_graphics_3d_rpc_server.cc | 6 +- .../src/shared/ppapi_proxy/command_buffer_nacl.h | 6 +- .../src/shared/ppapi_proxy/plugin_opengles.cc | 6 +- .../src/shared/ppapi_proxy/plugin_ppb.cc | 4 +- .../shared/ppapi_proxy/plugin_ppb_graphics_3d.cc | 4 +- .../shared/ppapi_proxy/plugin_ppb_graphics_3d.h | 18 +- .../tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc | 6 +- .../ppb_graphics3d/ppapi_ppb_graphics3d.cc | 110 +++++++- .../ppb_graphics3d/ppapi_ppb_graphics3d.html | 12 +- .../tests/ppapi_test_lib/get_browser_interface.cc | 24 +- .../tests/ppapi_test_lib/get_browser_interface.h | 8 +- ppapi/ppapi_cpp.gypi | 18 +- ppapi/proxy/dispatcher.cc | 2 +- ppapi/proxy/interface_id.h | 2 +- ppapi/proxy/ppb_context_3d_proxy.h | 2 +- ppapi/proxy/ppb_graphics_3d_proxy.cc | 2 +- ppapi/proxy/ppb_graphics_3d_proxy.h | 6 +- ppapi/proxy/ppb_opengles2_proxy.cc | 2 +- ppapi/proxy/ppb_surface_3d_proxy.h | 2 +- ppapi/proxy/ppp_graphics_3d_proxy.cc | 10 +- ppapi/proxy/ppp_graphics_3d_proxy.h | 6 +- ppapi/shared_impl/opengles2_impl.cc | 4 +- ppapi/shared_impl/opengles2_impl.h | 4 +- ppapi/tests/all_c_includes.h | 10 +- ppapi/tests/all_cpp_includes.h | 4 +- ppapi/tests/test_graphics_3d.cc | 14 +- ppapi/tests/test_graphics_3d.h | 10 +- ppapi/thunk/ppb_graphics_3d_api.h | 4 +- ppapi/thunk/ppb_graphics_3d_thunk.cc | 4 +- ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc | 4 +- ppapi/thunk/resource_creation_api.h | 2 +- ppapi/thunk/thunk.h | 8 +- 63 files changed, 1118 insertions(+), 1036 deletions(-) delete mode 100644 ppapi/c/dev/pp_graphics_3d_dev.h delete mode 100644 ppapi/c/dev/ppb_graphics_3d_dev.h delete mode 100644 ppapi/c/dev/ppb_graphics_3d_trusted_dev.h delete mode 100644 ppapi/c/dev/ppb_opengles_dev.h delete mode 100644 ppapi/c/dev/ppp_graphics_3d_dev.h create mode 100644 ppapi/c/pp_graphics_3d.h create mode 100644 ppapi/c/ppb_graphics_3d.h create mode 100644 ppapi/c/ppb_opengles.h create mode 100644 ppapi/c/ppp_graphics_3d.h create mode 100644 ppapi/c/trusted/ppb_graphics_3d_trusted.h delete mode 100644 ppapi/cpp/dev/graphics_3d_client_dev.cc delete mode 100644 ppapi/cpp/dev/graphics_3d_client_dev.h delete mode 100644 ppapi/cpp/dev/graphics_3d_dev.cc delete mode 100644 ppapi/cpp/dev/graphics_3d_dev.h create mode 100644 ppapi/cpp/graphics_3d.cc create mode 100644 ppapi/cpp/graphics_3d.h create mode 100644 ppapi/cpp/graphics_3d_client.cc create mode 100644 ppapi/cpp/graphics_3d_client.h (limited to 'ppapi') diff --git a/ppapi/c/dev/pp_graphics_3d_dev.h b/ppapi/c/dev/pp_graphics_3d_dev.h deleted file mode 100644 index 300f110..0000000 --- a/ppapi/c/dev/pp_graphics_3d_dev.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2011 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef PPAPI_C_DEV_PP_GRAPHICS_3D_DEV_H_ -#define PPAPI_C_DEV_PP_GRAPHICS_3D_DEV_H_ - -#include "ppapi/c/pp_stdint.h" - -enum PP_Graphics3DAttrib_Dev { - // Bits of Alpha in the color buffer. - PP_GRAPHICS3DATTRIB_ALPHA_SIZE = 0x3021, - // Bits of Blue in the color buffer. - PP_GRAPHICS3DATTRIB_BLUE_SIZE = 0x3022, - // Bits of Green in the color buffer. - PP_GRAPHICS3DATTRIB_GREEN_SIZE = 0x3023, - // Bits of Red in the color buffer. - PP_GRAPHICS3DATTRIB_RED_SIZE = 0x3024, - // Bits of Z in the depth buffer. - PP_GRAPHICS3DATTRIB_DEPTH_SIZE = 0x3025, - // Bits of Stencil in the stencil buffer. - PP_GRAPHICS3DATTRIB_STENCIL_SIZE = 0x3026, - // Number of samples per pixel. - PP_GRAPHICS3DATTRIB_SAMPLES = 0x3031, - // Number of multisample buffers. - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS = 0x3032, - // Attrib list terminator. - PP_GRAPHICS3DATTRIB_NONE = 0x3038, - // Height of surface in pixels. - PP_GRAPHICS3DATTRIB_HEIGHT = 0x3056, - // Width of surface in pixels. - PP_GRAPHICS3DATTRIB_WIDTH = 0x3057, - - // Specifies the effect on the color buffer of posting a surface - // with SwapBuffers. The initial value is chosen by the implementation. - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR = 0x3093, - // Indicates that color buffer contents are unaffected. - PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED = 0x3094, - // Indicates that color buffer contents may be destroyed or changed. - PP_GRAPHICS3DATTRIB_BUFFER_DESTROYED = 0x3095 -}; - -// TODO(alokp): Remove this when PPB_Context3D_Dev and PPB_Surface3D_Dev -// are deprecated. -typedef int32_t PP_Config3D_Dev; - -#endif // PPAPI_C_DEV_PP_GRAPHICS_3D_DEV_H_ diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index 7b54f9d..04e8643 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -5,13 +5,13 @@ #ifndef PPAPI_C_DEV_PP_VIDEO_DEV_H_ #define PPAPI_C_DEV_PP_VIDEO_DEV_H_ -#include "ppapi/c/dev/ppb_opengles_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/c/ppb_opengles.h" // Video decoder configuration-related enums. diff --git a/ppapi/c/dev/ppb_context_3d_dev.h b/ppapi/c/dev/ppb_context_3d_dev.h index 4bd13e7..447cdfa 100644 --- a/ppapi/c/dev/ppb_context_3d_dev.h +++ b/ppapi/c/dev/ppb_context_3d_dev.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -6,9 +6,8 @@ #ifndef PPAPI_C_DEV_PPB_CONTEXT_3D_DEV_H_ #define PPAPI_C_DEV_PPB_CONTEXT_3D_DEV_H_ -#include "ppapi/c/dev/pp_graphics_3d_dev.h" - #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_graphics_3d.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" diff --git a/ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h b/ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h index cc13b6d..bba6826 100644 --- a/ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h +++ b/ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h @@ -6,7 +6,7 @@ #define PPAPI_C_DEV_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_H_ #include "ppapi/c/pp_resource.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" +#include "ppapi/c/ppb_opengles.h" #define PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE_0_1 \ "PPB_GLESChromiumTextureMapping(Dev);0.1" diff --git a/ppapi/c/dev/ppb_graphics_3d_dev.h b/ppapi/c/dev/ppb_graphics_3d_dev.h deleted file mode 100644 index 28c759c..0000000 --- a/ppapi/c/dev/ppb_graphics_3d_dev.h +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (c) 2011 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ -#define PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ - -#include "ppapi/c/dev/pp_graphics_3d_dev.h" - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" - -// Example usage from plugin code: -// -// // Setup. -// PP_Resource context; -// int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, -// PP_GRAPHICS3DATTRIB_HEIGHT, 800, -// PP_GRAPHICS3DATTRIB_NONE}; -// context = g3d->Create(instance, attribs, &context); -// inst->BindGraphics(instance, context); -// -// // Present one frame. -// gles2->Clear(context, GL_COLOR_BUFFER); -// g3d->SwapBuffers(context); -// -// // Shutdown. -// core->ReleaseResource(context); - -#define PPB_GRAPHICS_3D_DEV_INTERFACE_0_9 "PPB_Graphics3D(Dev);0.9" -#define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_9 - -struct PPB_Graphics3D_Dev { - // Retrieves the maximum supported value for the given attribute. - // - // This function may be used to check if a particular attribute value is - // supported before attempting to create a context. - // Attributes that can be queried for include: - // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE - // - PP_GRAPHICS3DATTRIB_BLUE_SIZE - // - PP_GRAPHICS3DATTRIB_GREEN_SIZE - // - PP_GRAPHICS3DATTRIB_RED_SIZE - // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE - // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE - // - PP_GRAPHICS3DATTRIB_SAMPLES - // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS - // - PP_GRAPHICS3DATTRIB_WIDTH - // - PP_GRAPHICS3DATTRIB_HEIGHT - // - // On failure the following error codes may be returned: - // - PP_ERROR_BADRESOURCE if instance is invalid. - // - PP_ERROR_BADARGUMENT if attribute is invalid or value is NULL - int32_t (*GetAttribMaxValue)(PP_Resource instance, - int32_t attribute, int32_t* value); - - // Creates and initializes a rendering context and returns a handle to it. - // The returned context is off-screen to start with. It must be attached to - // a plugin instance using PPB_Instance::BindGraphics to draw on the web page. - // - // If share_context is not NULL, then all shareable data, as defined - // by the client API (note that for OpenGL and OpenGL ES, shareable data - // excludes texture objects named 0) will be shared by share_context, all - // other contexts share_context already shares with, and the newly created - // context. An arbitrary number of PPB_Graphics3D_Dev can share data in - // this fashion. - // - // attrib_list specifies a list of attributes for the context. It is a list - // of attribute name-value pairs in which each attribute is immediately - // followed by the corresponding desired value. The list is terminated with - // PP_GRAPHICS3DATTRIB_NONE. The attrib_list may be NULL or empty - // (first attribute is PP_GRAPHICS3DATTRIB_NONE). If an attribute is not - // specified in attrib_list, then the default value is used (it is said to - // be specified implicitly). - // - // Attributes for the context are chosen according to an attribute-specific - // criteria. Attributes can be classified into two categories: - // - AtLeast: The attribute value in the returned context meets or exceeds - // the value specified in attrib_list. - // - Exact: The attribute value in the returned context is equal to - // the value specified in attrib_list. - // - // Attributes that can be specified in attrib_list include: - // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0. - // - PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0. - // - PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0. - // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: - // Category: Exact Default: Implementation defined. - // - // On failure NULL resource is returned. - PP_Resource (*Create)(PP_Instance instance, - PP_Resource share_context, - const int32_t* attrib_list); - - // Returns PP_TRUE if the given resource is a valid PPB_Graphics3D_Dev, - // PP_FALSE if it is an invalid resource or is a resource of another type. - PP_Bool (*IsGraphics3D)(PP_Resource resource); - - // Retrieves the value for each attribute in attrib_list. The list - // has the same structure as described for PPB_Graphics3D_Dev::Create. - // It is both input and output structure for this function. - // - // All attributes specified in PPB_Graphics3D_Dev::Create can be queried for. - // On failure the following error codes may be returned: - // - PP_ERROR_BADRESOURCE if context is invalid. - // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the - // attrib_list is not a valid attribute. - // - // Example usage: To get the values for rgb bits in the color buffer, - // this function must be called as following: - // int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, - // PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, - // PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, - // PP_GRAPHICS3DATTRIB_NONE}; - // GetAttribs(context, attrib_list); - // int red_bits = attrib_list[1]; - // int green_bits = attrib_list[3]; - // int blue_bits = attrib_list[5]; - int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list); - - // Sets the values for each attribute in attrib_list. The list - // has the same structure as described for PPB_Graphics3D_Dev::Create. - // - // Attributes that can be specified are: - // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR - // - // On failure the following error codes may be returned: - // - PP_ERROR_BADRESOURCE if context is invalid. - // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the - // attrib_list is not a valid attribute. - int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list); - - // The recoverable error conditions that have no side effect are - // detected and returned immediately by all functions in this interface. - // In addition the implementation may get into a fatal state while - // processing a command. In this case the application must detroy the - // context and reinitialize client API state and objects to continue - // rendering. - // - // Note that the same error code is also returned in the SwapBuffers callback. - // It is recommended to handle error in the SwapBuffers callback because - // GetError is synchronous. This function may be useful in rare cases where - // drawing a frame is expensive and you want to verify the result of - // ResizeBuffers before attemptimg to draw a frame. - // - // The following error codes may be returned: - // - PP_ERROR_NOMEMORY - // - PP_ERROR_CONTEXT_LOST - int32_t (*GetError)(PP_Resource context); - - // Resizes the backing surface for context. - // - // On failure the following error codes may be returned: - // - PP_ERROR_BADRESOURCE if context is invalid. - // - PP_ERROR_BADARGUMENT if the value specified for width or height - // is less than zero. - // - // If the surface could not be resized due to insufficient resources, - // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. - int32_t (*ResizeBuffers)(PP_Resource context, - int32_t width, int32_t height); - - // Makes the contents of the color buffer available for compositing. - // This function has no effect on off-screen surfaces - ones not bound - // to any plugin instance. The contents of ancillary buffers are always - // undefined after calling SwapBuffers. The contents of the color buffer are - // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute - // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. - // - // SwapBuffers runs in asynchronous mode. Specify a callback function and the - // argument for that callback function. The callback function will be executed - // on the calling thread after the color buffer has been composited with - // rest of the html page. While you are waiting for a SwapBuffers callback, - // additional calls to SwapBuffers will fail. - // - // Because the callback is executed (or thread unblocked) only when the - // plugin's current state is actually on the screen, this function provides a - // way to rate limit animations. By waiting until the image is on the screen - // before painting the next frame, you can ensure you're not generating - // updates faster than the screen can be updated. - // - // SwapBuffers performs an implicit flush operation on context. - // If the context gets into an unrecoverable error condition while - // processing a command, the error code will be returned as the argument - // for the callback. The callback may return the following error codes: - // - PP_ERROR_NOMEMORY - // - PP_ERROR_CONTEXT_LOST - // Note that the same error code may also be obtained by calling GetError. - // - // On failure SwapBuffers may return the following error codes: - // - PP_ERROR_BADRESOURCE if context is invalid. - // - PP_ERROR_BADARGUMENT if callback is invalid. - int32_t (*SwapBuffers)(PP_Resource context, - struct PP_CompletionCallback callback); -}; - -#endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ diff --git a/ppapi/c/dev/ppb_graphics_3d_trusted_dev.h b/ppapi/c/dev/ppb_graphics_3d_trusted_dev.h deleted file mode 100644 index c82f345..0000000 --- a/ppapi/c/dev/ppb_graphics_3d_trusted_dev.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_C_DEV_PPB_GRAPHICS_3D_TRUSTED_DEV_H_ -#define PPAPI_C_DEV_PPB_GRAPHICS_3D_TRUSTED_DEV_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" - -#define PPB_GRAPHICS_3D_TRUSTED_DEV_INTERFACE_0_1 \ - "PPB_Graphics3DTrusted(Dev);0.1" -#define PPB_GRAPHICS_3D_TRUSTED_DEV_INTERFACE \ - PPB_GRAPHICS_3D_TRUSTED_DEV_INTERFACE_0_1 - -typedef enum { - PPB_GRAPHICS3D_TRUSTED_ERROR_OK, - PPB_GRAPHICS3D_TRUSTED_ERROR_GENERICERROR, - PPB_GRAPHICS3D_TRUSTED_ERROR_INVALIDARGUMENTS, - PPB_GRAPHICS3D_TRUSTED_ERROR_INVALIDSIZE, - PPB_GRAPHICS3D_TRUSTED_ERROR_LOSTCONTEXT, - PPB_GRAPHICS3D_TRUSTED_ERROR_OUTOFBOUNDS, - PPB_GRAPHICS3D_TRUSTED_ERROR_UNKNOWNCOMMAND -} PPB_Graphics3DTrustedError; - -struct PP_Graphics3DTrustedState { - // Size of the command buffer in command buffer entries. - int32_t num_entries; - - // The offset (in entries) from which the reader is reading. - int32_t get_offset; - - // The offset (in entries) at which the writer is writing. - int32_t put_offset; - - // The current token value. This is used by the writer to defer - // changes to shared memory objects until the reader has reached a certain - // point in the command buffer. The reader is responsible for updating the - // token value, for example in response to an asynchronous set token command - // embedded in the command buffer. The default token value is zero. - int32_t token; - - // Error status. - PPB_Graphics3DTrustedError error; - - // Generation index of this state. The generation index is incremented every - // time a new state is retrieved from the command processor, so that - // consistency can be kept even if IPC messages are processed out-of-order. - uint32_t generation; -}; - -struct PPB_Graphics3DTrusted_Dev { - // Creates a raw Graphics3D resource. A raw Graphics3D is intended to be used - // with the trusted interface, through the command buffer (for proxying). - PP_Resource (*CreateRaw)(PP_Instance instance_id, - PP_Resource share_context, - const int32_t* attrib_list); - - // Initializes the command buffer with the given size. - PP_Bool (*InitCommandBuffer)(PP_Resource context_id, int32_t size); - - // Gets the ring buffer for the command buffer. - PP_Bool (*GetRingBuffer)(PP_Resource context_id, - int* shm_handle, - uint32_t* shm_size); - - // Returns the current state. - struct PP_Graphics3DTrustedState (*GetState)(PP_Resource context); - - // Create a transfer buffer and return a handle that uniquely - // identifies it or -1 on error. - int32_t (*CreateTransferBuffer)(PP_Resource context, uint32_t size); - - // Destroy a transfer buffer and recycle the handle. - PP_Bool (*DestroyTransferBuffer)(PP_Resource context, int32_t id); - - // Get the transfer buffer associated with a handle. - PP_Bool (*GetTransferBuffer)(PP_Resource context, - int32_t id, - int* shm_handle, - uint32_t* shm_size); - - // The writer calls this to update its put offset. - PP_Bool (*Flush)(PP_Resource context, int32_t put_offset); - - // The writer calls this to update its put offset. This function returns the - // reader's most recent get offset. Does not return until after the put offset - // change callback has been invoked. - struct PP_Graphics3DTrustedState (*FlushSync)(PP_Resource context, - int32_t put_offset); - - // Like FlushSync, but returns before processing commands if the get offset is - // different than last_known_get. Allows synchronization with the command - // processor without forcing immediate command execution. - struct PP_Graphics3DTrustedState (*FlushSyncFast)(PP_Resource context, - int32_t put_offset, - int32_t last_known_get); -}; - -#endif // PPAPI_C_DEV_PPB_GRAPHICS_3D_TRUSTED_DEV_H_ - diff --git a/ppapi/c/dev/ppb_opengles_dev.h b/ppapi/c/dev/ppb_opengles_dev.h deleted file mode 100644 index 3e19134..0000000 --- a/ppapi/c/dev/ppb_opengles_dev.h +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file is auto-generated. DO NOT EDIT! - -// OpenGL ES interface. -#ifndef PPAPI_C_DEV_PPB_OPENGLES_DEV_H_ -#define PPAPI_C_DEV_PPB_OPENGLES_DEV_H_ - -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" - -#ifndef __gl2_h_ -typedef unsigned int GLenum; -typedef void GLvoid; -typedef long int GLintptr; -typedef int GLsizei; -typedef long int GLsizeiptr; -typedef int GLint; -typedef unsigned char GLboolean; -typedef unsigned int GLuint; -typedef unsigned int GLbitfield; -typedef short GLshort; -typedef float GLfloat; -typedef float GLclampf; -typedef int8_t GLbyte; -typedef uint8_t GLubyte; -typedef int32_t GLfixed; -typedef unsigned short GLushort; -typedef int GLclampx; -#endif // __gl2_h_ - -// TODO(brettw) this string should be PPB_OpenGLES2;1.0 when this is frozen. -// The 2.0 is trying to describe the version of OpenGL ES which is different -// than the Pepper interface version. -#define PPB_OPENGLES2_DEV_INTERFACE_0_1 "PPB_OpenGLES(Dev);2.0" -#define PPB_OPENGLES2_DEV_INTERFACE PPB_OPENGLES2_DEV_INTERFACE_0_1 - -struct PPB_OpenGLES2_Dev { - void (*ActiveTexture)(PP_Resource context, GLenum texture); - void (*AttachShader)(PP_Resource context, GLuint program, GLuint shader); - void (*BindAttribLocation)( - PP_Resource context, GLuint program, GLuint index, const char* name); - void (*BindBuffer)(PP_Resource context, GLenum target, GLuint buffer); - void (*BindFramebuffer)( - PP_Resource context, GLenum target, GLuint framebuffer); - void (*BindRenderbuffer)( - PP_Resource context, GLenum target, GLuint renderbuffer); - void (*BindTexture)(PP_Resource context, GLenum target, GLuint texture); - void (*BlendColor)( - PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha); - void (*BlendEquation)(PP_Resource context, GLenum mode); - void (*BlendEquationSeparate)( - PP_Resource context, GLenum modeRGB, GLenum modeAlpha); - void (*BlendFunc)(PP_Resource context, GLenum sfactor, GLenum dfactor); - void (*BlendFuncSeparate)( - PP_Resource context, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, - GLenum dstAlpha); - void (*BufferData)( - PP_Resource context, GLenum target, GLsizeiptr size, const void* data, - GLenum usage); - void (*BufferSubData)( - PP_Resource context, GLenum target, GLintptr offset, GLsizeiptr size, - const void* data); - GLenum (*CheckFramebufferStatus)(PP_Resource context, GLenum target); - void (*Clear)(PP_Resource context, GLbitfield mask); - void (*ClearColor)( - PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha); - void (*ClearDepthf)(PP_Resource context, GLclampf depth); - void (*ClearStencil)(PP_Resource context, GLint s); - void (*ColorMask)( - PP_Resource context, GLboolean red, GLboolean green, GLboolean blue, - GLboolean alpha); - void (*CompileShader)(PP_Resource context, GLuint shader); - void (*CompressedTexImage2D)( - PP_Resource context, GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, GLsizei imageSize, - const void* data); - void (*CompressedTexSubImage2D)( - PP_Resource context, GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const void* data); - void (*CopyTexImage2D)( - PP_Resource context, GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLsizei height, GLint border); - void (*CopyTexSubImage2D)( - PP_Resource context, GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - GLuint (*CreateProgram)(PP_Resource context); - GLuint (*CreateShader)(PP_Resource context, GLenum type); - void (*CullFace)(PP_Resource context, GLenum mode); - void (*DeleteBuffers)(PP_Resource context, GLsizei n, const GLuint* buffers); - void (*DeleteFramebuffers)( - PP_Resource context, GLsizei n, const GLuint* framebuffers); - void (*DeleteProgram)(PP_Resource context, GLuint program); - void (*DeleteRenderbuffers)( - PP_Resource context, GLsizei n, const GLuint* renderbuffers); - void (*DeleteShader)(PP_Resource context, GLuint shader); - void (*DeleteTextures)( - PP_Resource context, GLsizei n, const GLuint* textures); - void (*DepthFunc)(PP_Resource context, GLenum func); - void (*DepthMask)(PP_Resource context, GLboolean flag); - void (*DepthRangef)(PP_Resource context, GLclampf zNear, GLclampf zFar); - void (*DetachShader)(PP_Resource context, GLuint program, GLuint shader); - void (*Disable)(PP_Resource context, GLenum cap); - void (*DisableVertexAttribArray)(PP_Resource context, GLuint index); - void (*DrawArrays)( - PP_Resource context, GLenum mode, GLint first, GLsizei count); - void (*DrawElements)( - PP_Resource context, GLenum mode, GLsizei count, GLenum type, - const void* indices); - void (*Enable)(PP_Resource context, GLenum cap); - void (*EnableVertexAttribArray)(PP_Resource context, GLuint index); - void (*Finish)(PP_Resource context); - void (*Flush)(PP_Resource context); - void (*FramebufferRenderbuffer)( - PP_Resource context, GLenum target, GLenum attachment, - GLenum renderbuffertarget, GLuint renderbuffer); - void (*FramebufferTexture2D)( - PP_Resource context, GLenum target, GLenum attachment, GLenum textarget, - GLuint texture, GLint level); - void (*FrontFace)(PP_Resource context, GLenum mode); - void (*GenBuffers)(PP_Resource context, GLsizei n, GLuint* buffers); - void (*GenerateMipmap)(PP_Resource context, GLenum target); - void (*GenFramebuffers)( - PP_Resource context, GLsizei n, GLuint* framebuffers); - void (*GenRenderbuffers)( - PP_Resource context, GLsizei n, GLuint* renderbuffers); - void (*GenTextures)(PP_Resource context, GLsizei n, GLuint* textures); - void (*GetActiveAttrib)( - PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, - GLsizei* length, GLint* size, GLenum* type, char* name); - void (*GetActiveUniform)( - PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, - GLsizei* length, GLint* size, GLenum* type, char* name); - void (*GetAttachedShaders)( - PP_Resource context, GLuint program, GLsizei maxcount, GLsizei* count, - GLuint* shaders); - GLint (*GetAttribLocation)( - PP_Resource context, GLuint program, const char* name); - void (*GetBooleanv)(PP_Resource context, GLenum pname, GLboolean* params); - void (*GetBufferParameteriv)( - PP_Resource context, GLenum target, GLenum pname, GLint* params); - GLenum (*GetError)(PP_Resource context); - void (*GetFloatv)(PP_Resource context, GLenum pname, GLfloat* params); - void (*GetFramebufferAttachmentParameteriv)( - PP_Resource context, GLenum target, GLenum attachment, GLenum pname, - GLint* params); - void (*GetIntegerv)(PP_Resource context, GLenum pname, GLint* params); - void (*GetProgramiv)( - PP_Resource context, GLuint program, GLenum pname, GLint* params); - void (*GetProgramInfoLog)( - PP_Resource context, GLuint program, GLsizei bufsize, GLsizei* length, - char* infolog); - void (*GetRenderbufferParameteriv)( - PP_Resource context, GLenum target, GLenum pname, GLint* params); - void (*GetShaderiv)( - PP_Resource context, GLuint shader, GLenum pname, GLint* params); - void (*GetShaderInfoLog)( - PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, - char* infolog); - void (*GetShaderPrecisionFormat)( - PP_Resource context, GLenum shadertype, GLenum precisiontype, - GLint* range, GLint* precision); - void (*GetShaderSource)( - PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, - char* source); - const GLubyte* (*GetString)(PP_Resource context, GLenum name); - void (*GetTexParameterfv)( - PP_Resource context, GLenum target, GLenum pname, GLfloat* params); - void (*GetTexParameteriv)( - PP_Resource context, GLenum target, GLenum pname, GLint* params); - void (*GetUniformfv)( - PP_Resource context, GLuint program, GLint location, GLfloat* params); - void (*GetUniformiv)( - PP_Resource context, GLuint program, GLint location, GLint* params); - GLint (*GetUniformLocation)( - PP_Resource context, GLuint program, const char* name); - void (*GetVertexAttribfv)( - PP_Resource context, GLuint index, GLenum pname, GLfloat* params); - void (*GetVertexAttribiv)( - PP_Resource context, GLuint index, GLenum pname, GLint* params); - void (*GetVertexAttribPointerv)( - PP_Resource context, GLuint index, GLenum pname, void** pointer); - void (*Hint)(PP_Resource context, GLenum target, GLenum mode); - GLboolean (*IsBuffer)(PP_Resource context, GLuint buffer); - GLboolean (*IsEnabled)(PP_Resource context, GLenum cap); - GLboolean (*IsFramebuffer)(PP_Resource context, GLuint framebuffer); - GLboolean (*IsProgram)(PP_Resource context, GLuint program); - GLboolean (*IsRenderbuffer)(PP_Resource context, GLuint renderbuffer); - GLboolean (*IsShader)(PP_Resource context, GLuint shader); - GLboolean (*IsTexture)(PP_Resource context, GLuint texture); - void (*LineWidth)(PP_Resource context, GLfloat width); - void (*LinkProgram)(PP_Resource context, GLuint program); - void (*PixelStorei)(PP_Resource context, GLenum pname, GLint param); - void (*PolygonOffset)(PP_Resource context, GLfloat factor, GLfloat units); - void (*ReadPixels)( - PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, void* pixels); - void (*ReleaseShaderCompiler)(PP_Resource context); - void (*RenderbufferStorage)( - PP_Resource context, GLenum target, GLenum internalformat, GLsizei width, - GLsizei height); - void (*SampleCoverage)( - PP_Resource context, GLclampf value, GLboolean invert); - void (*Scissor)( - PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); - void (*ShaderBinary)( - PP_Resource context, GLsizei n, const GLuint* shaders, - GLenum binaryformat, const void* binary, GLsizei length); - void (*ShaderSource)( - PP_Resource context, GLuint shader, GLsizei count, const char** str, - const GLint* length); - void (*StencilFunc)( - PP_Resource context, GLenum func, GLint ref, GLuint mask); - void (*StencilFuncSeparate)( - PP_Resource context, GLenum face, GLenum func, GLint ref, GLuint mask); - void (*StencilMask)(PP_Resource context, GLuint mask); - void (*StencilMaskSeparate)(PP_Resource context, GLenum face, GLuint mask); - void (*StencilOp)( - PP_Resource context, GLenum fail, GLenum zfail, GLenum zpass); - void (*StencilOpSeparate)( - PP_Resource context, GLenum face, GLenum fail, GLenum zfail, - GLenum zpass); - void (*TexImage2D)( - PP_Resource context, GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, - const void* pixels); - void (*TexParameterf)( - PP_Resource context, GLenum target, GLenum pname, GLfloat param); - void (*TexParameterfv)( - PP_Resource context, GLenum target, GLenum pname, const GLfloat* params); - void (*TexParameteri)( - PP_Resource context, GLenum target, GLenum pname, GLint param); - void (*TexParameteriv)( - PP_Resource context, GLenum target, GLenum pname, const GLint* params); - void (*TexSubImage2D)( - PP_Resource context, GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, - const void* pixels); - void (*Uniform1f)(PP_Resource context, GLint location, GLfloat x); - void (*Uniform1fv)( - PP_Resource context, GLint location, GLsizei count, const GLfloat* v); - void (*Uniform1i)(PP_Resource context, GLint location, GLint x); - void (*Uniform1iv)( - PP_Resource context, GLint location, GLsizei count, const GLint* v); - void (*Uniform2f)(PP_Resource context, GLint location, GLfloat x, GLfloat y); - void (*Uniform2fv)( - PP_Resource context, GLint location, GLsizei count, const GLfloat* v); - void (*Uniform2i)(PP_Resource context, GLint location, GLint x, GLint y); - void (*Uniform2iv)( - PP_Resource context, GLint location, GLsizei count, const GLint* v); - void (*Uniform3f)( - PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z); - void (*Uniform3fv)( - PP_Resource context, GLint location, GLsizei count, const GLfloat* v); - void (*Uniform3i)( - PP_Resource context, GLint location, GLint x, GLint y, GLint z); - void (*Uniform3iv)( - PP_Resource context, GLint location, GLsizei count, const GLint* v); - void (*Uniform4f)( - PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z, - GLfloat w); - void (*Uniform4fv)( - PP_Resource context, GLint location, GLsizei count, const GLfloat* v); - void (*Uniform4i)( - PP_Resource context, GLint location, GLint x, GLint y, GLint z, GLint w); - void (*Uniform4iv)( - PP_Resource context, GLint location, GLsizei count, const GLint* v); - void (*UniformMatrix2fv)( - PP_Resource context, GLint location, GLsizei count, GLboolean transpose, - const GLfloat* value); - void (*UniformMatrix3fv)( - PP_Resource context, GLint location, GLsizei count, GLboolean transpose, - const GLfloat* value); - void (*UniformMatrix4fv)( - PP_Resource context, GLint location, GLsizei count, GLboolean transpose, - const GLfloat* value); - void (*UseProgram)(PP_Resource context, GLuint program); - void (*ValidateProgram)(PP_Resource context, GLuint program); - void (*VertexAttrib1f)(PP_Resource context, GLuint indx, GLfloat x); - void (*VertexAttrib1fv)( - PP_Resource context, GLuint indx, const GLfloat* values); - void (*VertexAttrib2f)( - PP_Resource context, GLuint indx, GLfloat x, GLfloat y); - void (*VertexAttrib2fv)( - PP_Resource context, GLuint indx, const GLfloat* values); - void (*VertexAttrib3f)( - PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z); - void (*VertexAttrib3fv)( - PP_Resource context, GLuint indx, const GLfloat* values); - void (*VertexAttrib4f)( - PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z, - GLfloat w); - void (*VertexAttrib4fv)( - PP_Resource context, GLuint indx, const GLfloat* values); - void (*VertexAttribPointer)( - PP_Resource context, GLuint indx, GLint size, GLenum type, - GLboolean normalized, GLsizei stride, const void* ptr); - void (*Viewport)( - PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); -}; - -#endif // PPAPI_C_DEV_PPB_OPENGLES_DEV_H_ - diff --git a/ppapi/c/dev/ppb_surface_3d_dev.h b/ppapi/c/dev/ppb_surface_3d_dev.h index 47b47ef..c89d721 100644 --- a/ppapi/c/dev/ppb_surface_3d_dev.h +++ b/ppapi/c/dev/ppb_surface_3d_dev.h @@ -6,8 +6,8 @@ #ifndef PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ #define PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_ -#include "ppapi/c/dev/pp_graphics_3d_dev.h" #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_graphics_3d.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" diff --git a/ppapi/c/dev/ppp_graphics_3d_dev.h b/ppapi/c/dev/ppp_graphics_3d_dev.h deleted file mode 100644 index ae9b2e1..0000000 --- a/ppapi/c/dev/ppp_graphics_3d_dev.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef PPAPI_C_DEV_PPP_GRAPHICS_3D_DEV_H_ -#define PPAPI_C_DEV_PPP_GRAPHICS_3D_DEV_H_ - -#include "ppapi/c/pp_instance.h" - -#define PPP_GRAPHICS_3D_DEV_INTERFACE "PPP_Graphics_3D(Dev);0.2" - -struct PPP_Graphics3D_Dev { - // Called when the OpenGL ES window is invalidated and needs to be repainted. - void (*Graphics3DContextLost)(PP_Instance instance); -}; - -#endif /* PPAPI_C_DEV_PPP_GRAPHICS_3D_DEV_H_ */ - diff --git a/ppapi/c/pp_graphics_3d.h b/ppapi/c/pp_graphics_3d.h new file mode 100644 index 0000000..06886f8 --- /dev/null +++ b/ppapi/c/pp_graphics_3d.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef PPAPI_C_PP_GRAPHICS_3D_H_ +#define PPAPI_C_PP_GRAPHICS_3D_H_ + +#include "ppapi/c/pp_stdint.h" + +enum PP_Graphics3DAttrib { + // Bits of Alpha in the color buffer. + PP_GRAPHICS3DATTRIB_ALPHA_SIZE = 0x3021, + // Bits of Blue in the color buffer. + PP_GRAPHICS3DATTRIB_BLUE_SIZE = 0x3022, + // Bits of Green in the color buffer. + PP_GRAPHICS3DATTRIB_GREEN_SIZE = 0x3023, + // Bits of Red in the color buffer. + PP_GRAPHICS3DATTRIB_RED_SIZE = 0x3024, + // Bits of Z in the depth buffer. + PP_GRAPHICS3DATTRIB_DEPTH_SIZE = 0x3025, + // Bits of Stencil in the stencil buffer. + PP_GRAPHICS3DATTRIB_STENCIL_SIZE = 0x3026, + // Number of samples per pixel. + PP_GRAPHICS3DATTRIB_SAMPLES = 0x3031, + // Number of multisample buffers. + PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS = 0x3032, + // Attrib list terminator. + PP_GRAPHICS3DATTRIB_NONE = 0x3038, + // Height of surface in pixels. + PP_GRAPHICS3DATTRIB_HEIGHT = 0x3056, + // Width of surface in pixels. + PP_GRAPHICS3DATTRIB_WIDTH = 0x3057, + + // Specifies the effect on the color buffer of posting a surface + // with SwapBuffers. The initial value is chosen by the implementation. + PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR = 0x3093, + // Indicates that color buffer contents are unaffected. + PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED = 0x3094, + // Indicates that color buffer contents may be destroyed or changed. + PP_GRAPHICS3DATTRIB_BUFFER_DESTROYED = 0x3095 +}; + +// TODO(alokp): Remove this when PPB_Context3D_Dev and PPB_Surface3D_Dev +// are deprecated. +typedef int32_t PP_Config3D_Dev; + +#endif // PPAPI_C_PP_GRAPHICS_3D_H_ diff --git a/ppapi/c/ppb_graphics_3d.h b/ppapi/c/ppb_graphics_3d.h new file mode 100644 index 0000000..ef93402 --- /dev/null +++ b/ppapi/c/ppb_graphics_3d.h @@ -0,0 +1,204 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef PPAPI_C_PPB_GRAPHICS_3D_H_ +#define PPAPI_C_PPB_GRAPHICS_3D_H_ + +#include "ppapi/c/pp_graphics_3d.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_resource.h" + +// Example usage from plugin code: +// +// // Setup. +// PP_Resource context; +// int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, +// PP_GRAPHICS3DATTRIB_HEIGHT, 800, +// PP_GRAPHICS3DATTRIB_NONE}; +// context = g3d->Create(instance, attribs, &context); +// inst->BindGraphics(instance, context); +// +// // Present one frame. +// gles2->Clear(context, GL_COLOR_BUFFER); +// g3d->SwapBuffers(context); +// +// // Shutdown. +// core->ReleaseResource(context); + +#define PPB_GRAPHICS_3D_INTERFACE_1_0 "PPB_Graphics3D;1.0" +#define PPB_GRAPHICS_3D_INTERFACE PPB_GRAPHICS_3D_INTERFACE_1_0 + +struct PPB_Graphics3D { + // Retrieves the maximum supported value for the given attribute. + // + // This function may be used to check if a particular attribute value is + // supported before attempting to create a context. + // Attributes that can be queried for include: + // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE + // - PP_GRAPHICS3DATTRIB_BLUE_SIZE + // - PP_GRAPHICS3DATTRIB_GREEN_SIZE + // - PP_GRAPHICS3DATTRIB_RED_SIZE + // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE + // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE + // - PP_GRAPHICS3DATTRIB_SAMPLES + // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS + // - PP_GRAPHICS3DATTRIB_WIDTH + // - PP_GRAPHICS3DATTRIB_HEIGHT + // + // On failure the following error codes may be returned: + // - PP_ERROR_BADRESOURCE if instance is invalid. + // - PP_ERROR_BADARGUMENT if attribute is invalid or value is NULL + int32_t (*GetAttribMaxValue)(PP_Resource instance, + int32_t attribute, int32_t* value); + + // Creates and initializes a rendering context and returns a handle to it. + // The returned context is off-screen to start with. It must be attached to + // a plugin instance using PPB_Instance::BindGraphics to draw on the web page. + // + // If share_context is not NULL, then all shareable data, as defined + // by the client API (note that for OpenGL and OpenGL ES, shareable data + // excludes texture objects named 0) will be shared by share_context, all + // other contexts share_context already shares with, and the newly created + // context. An arbitrary number of PPB_Graphics3D_Dev can share data in + // this fashion. + // + // attrib_list specifies a list of attributes for the context. It is a list + // of attribute name-value pairs in which each attribute is immediately + // followed by the corresponding desired value. The list is terminated with + // PP_GRAPHICS3DATTRIB_NONE. The attrib_list may be NULL or empty + // (first attribute is PP_GRAPHICS3DATTRIB_NONE). If an attribute is not + // specified in attrib_list, then the default value is used (it is said to + // be specified implicitly). + // + // Attributes for the context are chosen according to an attribute-specific + // criteria. Attributes can be classified into two categories: + // - AtLeast: The attribute value in the returned context meets or exceeds + // the value specified in attrib_list. + // - Exact: The attribute value in the returned context is equal to + // the value specified in attrib_list. + // + // Attributes that can be specified in attrib_list include: + // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0. + // - PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0. + // - PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0. + // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: + // Category: Exact Default: Implementation defined. + // + // On failure NULL resource is returned. + PP_Resource (*Create)(PP_Instance instance, + PP_Resource share_context, + const int32_t* attrib_list); + + // Returns PP_TRUE if the given resource is a valid PPB_Graphics3D_Dev, + // PP_FALSE if it is an invalid resource or is a resource of another type. + PP_Bool (*IsGraphics3D)(PP_Resource resource); + + // Retrieves the value for each attribute in attrib_list. The list + // has the same structure as described for PPB_Graphics3D_Dev::Create. + // It is both input and output structure for this function. + // + // All attributes specified in PPB_Graphics3D_Dev::Create can be queried for. + // On failure the following error codes may be returned: + // - PP_ERROR_BADRESOURCE if context is invalid. + // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the + // attrib_list is not a valid attribute. + // + // Example usage: To get the values for rgb bits in the color buffer, + // this function must be called as following: + // int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, + // PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, + // PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, + // PP_GRAPHICS3DATTRIB_NONE}; + // GetAttribs(context, attrib_list); + // int red_bits = attrib_list[1]; + // int green_bits = attrib_list[3]; + // int blue_bits = attrib_list[5]; + int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list); + + // Sets the values for each attribute in attrib_list. The list + // has the same structure as described for PPB_Graphics3D_Dev::Create. + // + // Attributes that can be specified are: + // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR + // + // On failure the following error codes may be returned: + // - PP_ERROR_BADRESOURCE if context is invalid. + // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the + // attrib_list is not a valid attribute. + int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list); + + // The recoverable error conditions that have no side effect are + // detected and returned immediately by all functions in this interface. + // In addition the implementation may get into a fatal state while + // processing a command. In this case the application must detroy the + // context and reinitialize client API state and objects to continue + // rendering. + // + // Note that the same error code is also returned in the SwapBuffers callback. + // It is recommended to handle error in the SwapBuffers callback because + // GetError is synchronous. This function may be useful in rare cases where + // drawing a frame is expensive and you want to verify the result of + // ResizeBuffers before attemptimg to draw a frame. + // + // The following error codes may be returned: + // - PP_ERROR_NOMEMORY + // - PP_ERROR_CONTEXT_LOST + int32_t (*GetError)(PP_Resource context); + + // Resizes the backing surface for context. + // + // On failure the following error codes may be returned: + // - PP_ERROR_BADRESOURCE if context is invalid. + // - PP_ERROR_BADARGUMENT if the value specified for width or height + // is less than zero. + // + // If the surface could not be resized due to insufficient resources, + // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. + int32_t (*ResizeBuffers)(PP_Resource context, + int32_t width, int32_t height); + + // Makes the contents of the color buffer available for compositing. + // This function has no effect on off-screen surfaces - ones not bound + // to any plugin instance. The contents of ancillary buffers are always + // undefined after calling SwapBuffers. The contents of the color buffer are + // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute + // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. + // + // SwapBuffers runs in asynchronous mode. Specify a callback function and the + // argument for that callback function. The callback function will be executed + // on the calling thread after the color buffer has been composited with + // rest of the html page. While you are waiting for a SwapBuffers callback, + // additional calls to SwapBuffers will fail. + // + // Because the callback is executed (or thread unblocked) only when the + // plugin's current state is actually on the screen, this function provides a + // way to rate limit animations. By waiting until the image is on the screen + // before painting the next frame, you can ensure you're not generating + // updates faster than the screen can be updated. + // + // SwapBuffers performs an implicit flush operation on context. + // If the context gets into an unrecoverable error condition while + // processing a command, the error code will be returned as the argument + // for the callback. The callback may return the following error codes: + // - PP_ERROR_NOMEMORY + // - PP_ERROR_CONTEXT_LOST + // Note that the same error code may also be obtained by calling GetError. + // + // On failure SwapBuffers may return the following error codes: + // - PP_ERROR_BADRESOURCE if context is invalid. + // - PP_ERROR_BADARGUMENT if callback is invalid. + int32_t (*SwapBuffers)(PP_Resource context, + struct PP_CompletionCallback callback); +}; + +#endif /* PPAPI_C_PPB_GRAPHICS_3D_H_ */ diff --git a/ppapi/c/ppb_opengles.h b/ppapi/c/ppb_opengles.h new file mode 100644 index 0000000..2d6923e --- /dev/null +++ b/ppapi/c/ppb_opengles.h @@ -0,0 +1,305 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto-generated. DO NOT EDIT! + +// OpenGL ES interface. +#ifndef PPAPI_C_PPB_OPENGLES_H_ +#define PPAPI_C_PPB_OPENGLES_H_ + +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" + +#ifndef __gl2_h_ +typedef unsigned int GLenum; +typedef void GLvoid; +typedef long int GLintptr; +typedef int GLsizei; +typedef long int GLsizeiptr; +typedef int GLint; +typedef unsigned char GLboolean; +typedef unsigned int GLuint; +typedef unsigned int GLbitfield; +typedef short GLshort; +typedef float GLfloat; +typedef float GLclampf; +typedef int8_t GLbyte; +typedef uint8_t GLubyte; +typedef int32_t GLfixed; +typedef unsigned short GLushort; +typedef int GLclampx; +#endif // __gl2_h_ + +#define PPB_OPENGLES2_INTERFACE_1_0 "PPB_OpenGLES2;1.0" +#define PPB_OPENGLES2_INTERFACE PPB_OPENGLES2_INTERFACE_1_0 + +struct PPB_OpenGLES2 { + void (*ActiveTexture)(PP_Resource context, GLenum texture); + void (*AttachShader)(PP_Resource context, GLuint program, GLuint shader); + void (*BindAttribLocation)( + PP_Resource context, GLuint program, GLuint index, const char* name); + void (*BindBuffer)(PP_Resource context, GLenum target, GLuint buffer); + void (*BindFramebuffer)( + PP_Resource context, GLenum target, GLuint framebuffer); + void (*BindRenderbuffer)( + PP_Resource context, GLenum target, GLuint renderbuffer); + void (*BindTexture)(PP_Resource context, GLenum target, GLuint texture); + void (*BlendColor)( + PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, + GLclampf alpha); + void (*BlendEquation)(PP_Resource context, GLenum mode); + void (*BlendEquationSeparate)( + PP_Resource context, GLenum modeRGB, GLenum modeAlpha); + void (*BlendFunc)(PP_Resource context, GLenum sfactor, GLenum dfactor); + void (*BlendFuncSeparate)( + PP_Resource context, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, + GLenum dstAlpha); + void (*BufferData)( + PP_Resource context, GLenum target, GLsizeiptr size, const void* data, + GLenum usage); + void (*BufferSubData)( + PP_Resource context, GLenum target, GLintptr offset, GLsizeiptr size, + const void* data); + GLenum (*CheckFramebufferStatus)(PP_Resource context, GLenum target); + void (*Clear)(PP_Resource context, GLbitfield mask); + void (*ClearColor)( + PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, + GLclampf alpha); + void (*ClearDepthf)(PP_Resource context, GLclampf depth); + void (*ClearStencil)(PP_Resource context, GLint s); + void (*ColorMask)( + PP_Resource context, GLboolean red, GLboolean green, GLboolean blue, + GLboolean alpha); + void (*CompileShader)(PP_Resource context, GLuint shader); + void (*CompressedTexImage2D)( + PP_Resource context, GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, + const void* data); + void (*CompressedTexSubImage2D)( + PP_Resource context, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, GLenum format, + GLsizei imageSize, const void* data); + void (*CopyTexImage2D)( + PP_Resource context, GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + void (*CopyTexSubImage2D)( + PP_Resource context, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLuint (*CreateProgram)(PP_Resource context); + GLuint (*CreateShader)(PP_Resource context, GLenum type); + void (*CullFace)(PP_Resource context, GLenum mode); + void (*DeleteBuffers)(PP_Resource context, GLsizei n, const GLuint* buffers); + void (*DeleteFramebuffers)( + PP_Resource context, GLsizei n, const GLuint* framebuffers); + void (*DeleteProgram)(PP_Resource context, GLuint program); + void (*DeleteRenderbuffers)( + PP_Resource context, GLsizei n, const GLuint* renderbuffers); + void (*DeleteShader)(PP_Resource context, GLuint shader); + void (*DeleteTextures)( + PP_Resource context, GLsizei n, const GLuint* textures); + void (*DepthFunc)(PP_Resource context, GLenum func); + void (*DepthMask)(PP_Resource context, GLboolean flag); + void (*DepthRangef)(PP_Resource context, GLclampf zNear, GLclampf zFar); + void (*DetachShader)(PP_Resource context, GLuint program, GLuint shader); + void (*Disable)(PP_Resource context, GLenum cap); + void (*DisableVertexAttribArray)(PP_Resource context, GLuint index); + void (*DrawArrays)( + PP_Resource context, GLenum mode, GLint first, GLsizei count); + void (*DrawElements)( + PP_Resource context, GLenum mode, GLsizei count, GLenum type, + const void* indices); + void (*Enable)(PP_Resource context, GLenum cap); + void (*EnableVertexAttribArray)(PP_Resource context, GLuint index); + void (*Finish)(PP_Resource context); + void (*Flush)(PP_Resource context); + void (*FramebufferRenderbuffer)( + PP_Resource context, GLenum target, GLenum attachment, + GLenum renderbuffertarget, GLuint renderbuffer); + void (*FramebufferTexture2D)( + PP_Resource context, GLenum target, GLenum attachment, GLenum textarget, + GLuint texture, GLint level); + void (*FrontFace)(PP_Resource context, GLenum mode); + void (*GenBuffers)(PP_Resource context, GLsizei n, GLuint* buffers); + void (*GenerateMipmap)(PP_Resource context, GLenum target); + void (*GenFramebuffers)( + PP_Resource context, GLsizei n, GLuint* framebuffers); + void (*GenRenderbuffers)( + PP_Resource context, GLsizei n, GLuint* renderbuffers); + void (*GenTextures)(PP_Resource context, GLsizei n, GLuint* textures); + void (*GetActiveAttrib)( + PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, + GLsizei* length, GLint* size, GLenum* type, char* name); + void (*GetActiveUniform)( + PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, + GLsizei* length, GLint* size, GLenum* type, char* name); + void (*GetAttachedShaders)( + PP_Resource context, GLuint program, GLsizei maxcount, GLsizei* count, + GLuint* shaders); + GLint (*GetAttribLocation)( + PP_Resource context, GLuint program, const char* name); + void (*GetBooleanv)(PP_Resource context, GLenum pname, GLboolean* params); + void (*GetBufferParameteriv)( + PP_Resource context, GLenum target, GLenum pname, GLint* params); + GLenum (*GetError)(PP_Resource context); + void (*GetFloatv)(PP_Resource context, GLenum pname, GLfloat* params); + void (*GetFramebufferAttachmentParameteriv)( + PP_Resource context, GLenum target, GLenum attachment, GLenum pname, + GLint* params); + void (*GetIntegerv)(PP_Resource context, GLenum pname, GLint* params); + void (*GetProgramiv)( + PP_Resource context, GLuint program, GLenum pname, GLint* params); + void (*GetProgramInfoLog)( + PP_Resource context, GLuint program, GLsizei bufsize, GLsizei* length, + char* infolog); + void (*GetRenderbufferParameteriv)( + PP_Resource context, GLenum target, GLenum pname, GLint* params); + void (*GetShaderiv)( + PP_Resource context, GLuint shader, GLenum pname, GLint* params); + void (*GetShaderInfoLog)( + PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, + char* infolog); + void (*GetShaderPrecisionFormat)( + PP_Resource context, GLenum shadertype, GLenum precisiontype, + GLint* range, GLint* precision); + void (*GetShaderSource)( + PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, + char* source); + const GLubyte* (*GetString)(PP_Resource context, GLenum name); + void (*GetTexParameterfv)( + PP_Resource context, GLenum target, GLenum pname, GLfloat* params); + void (*GetTexParameteriv)( + PP_Resource context, GLenum target, GLenum pname, GLint* params); + void (*GetUniformfv)( + PP_Resource context, GLuint program, GLint location, GLfloat* params); + void (*GetUniformiv)( + PP_Resource context, GLuint program, GLint location, GLint* params); + GLint (*GetUniformLocation)( + PP_Resource context, GLuint program, const char* name); + void (*GetVertexAttribfv)( + PP_Resource context, GLuint index, GLenum pname, GLfloat* params); + void (*GetVertexAttribiv)( + PP_Resource context, GLuint index, GLenum pname, GLint* params); + void (*GetVertexAttribPointerv)( + PP_Resource context, GLuint index, GLenum pname, void** pointer); + void (*Hint)(PP_Resource context, GLenum target, GLenum mode); + GLboolean (*IsBuffer)(PP_Resource context, GLuint buffer); + GLboolean (*IsEnabled)(PP_Resource context, GLenum cap); + GLboolean (*IsFramebuffer)(PP_Resource context, GLuint framebuffer); + GLboolean (*IsProgram)(PP_Resource context, GLuint program); + GLboolean (*IsRenderbuffer)(PP_Resource context, GLuint renderbuffer); + GLboolean (*IsShader)(PP_Resource context, GLuint shader); + GLboolean (*IsTexture)(PP_Resource context, GLuint texture); + void (*LineWidth)(PP_Resource context, GLfloat width); + void (*LinkProgram)(PP_Resource context, GLuint program); + void (*PixelStorei)(PP_Resource context, GLenum pname, GLint param); + void (*PolygonOffset)(PP_Resource context, GLfloat factor, GLfloat units); + void (*ReadPixels)( + PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, void* pixels); + void (*ReleaseShaderCompiler)(PP_Resource context); + void (*RenderbufferStorage)( + PP_Resource context, GLenum target, GLenum internalformat, GLsizei width, + GLsizei height); + void (*SampleCoverage)( + PP_Resource context, GLclampf value, GLboolean invert); + void (*Scissor)( + PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); + void (*ShaderBinary)( + PP_Resource context, GLsizei n, const GLuint* shaders, + GLenum binaryformat, const void* binary, GLsizei length); + void (*ShaderSource)( + PP_Resource context, GLuint shader, GLsizei count, const char** str, + const GLint* length); + void (*StencilFunc)( + PP_Resource context, GLenum func, GLint ref, GLuint mask); + void (*StencilFuncSeparate)( + PP_Resource context, GLenum face, GLenum func, GLint ref, GLuint mask); + void (*StencilMask)(PP_Resource context, GLuint mask); + void (*StencilMaskSeparate)(PP_Resource context, GLenum face, GLuint mask); + void (*StencilOp)( + PP_Resource context, GLenum fail, GLenum zfail, GLenum zpass); + void (*StencilOpSeparate)( + PP_Resource context, GLenum face, GLenum fail, GLenum zfail, + GLenum zpass); + void (*TexImage2D)( + PP_Resource context, GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, + const void* pixels); + void (*TexParameterf)( + PP_Resource context, GLenum target, GLenum pname, GLfloat param); + void (*TexParameterfv)( + PP_Resource context, GLenum target, GLenum pname, const GLfloat* params); + void (*TexParameteri)( + PP_Resource context, GLenum target, GLenum pname, GLint param); + void (*TexParameteriv)( + PP_Resource context, GLenum target, GLenum pname, const GLint* params); + void (*TexSubImage2D)( + PP_Resource context, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, + const void* pixels); + void (*Uniform1f)(PP_Resource context, GLint location, GLfloat x); + void (*Uniform1fv)( + PP_Resource context, GLint location, GLsizei count, const GLfloat* v); + void (*Uniform1i)(PP_Resource context, GLint location, GLint x); + void (*Uniform1iv)( + PP_Resource context, GLint location, GLsizei count, const GLint* v); + void (*Uniform2f)(PP_Resource context, GLint location, GLfloat x, GLfloat y); + void (*Uniform2fv)( + PP_Resource context, GLint location, GLsizei count, const GLfloat* v); + void (*Uniform2i)(PP_Resource context, GLint location, GLint x, GLint y); + void (*Uniform2iv)( + PP_Resource context, GLint location, GLsizei count, const GLint* v); + void (*Uniform3f)( + PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z); + void (*Uniform3fv)( + PP_Resource context, GLint location, GLsizei count, const GLfloat* v); + void (*Uniform3i)( + PP_Resource context, GLint location, GLint x, GLint y, GLint z); + void (*Uniform3iv)( + PP_Resource context, GLint location, GLsizei count, const GLint* v); + void (*Uniform4f)( + PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z, + GLfloat w); + void (*Uniform4fv)( + PP_Resource context, GLint location, GLsizei count, const GLfloat* v); + void (*Uniform4i)( + PP_Resource context, GLint location, GLint x, GLint y, GLint z, GLint w); + void (*Uniform4iv)( + PP_Resource context, GLint location, GLsizei count, const GLint* v); + void (*UniformMatrix2fv)( + PP_Resource context, GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value); + void (*UniformMatrix3fv)( + PP_Resource context, GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value); + void (*UniformMatrix4fv)( + PP_Resource context, GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value); + void (*UseProgram)(PP_Resource context, GLuint program); + void (*ValidateProgram)(PP_Resource context, GLuint program); + void (*VertexAttrib1f)(PP_Resource context, GLuint indx, GLfloat x); + void (*VertexAttrib1fv)( + PP_Resource context, GLuint indx, const GLfloat* values); + void (*VertexAttrib2f)( + PP_Resource context, GLuint indx, GLfloat x, GLfloat y); + void (*VertexAttrib2fv)( + PP_Resource context, GLuint indx, const GLfloat* values); + void (*VertexAttrib3f)( + PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z); + void (*VertexAttrib3fv)( + PP_Resource context, GLuint indx, const GLfloat* values); + void (*VertexAttrib4f)( + PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z, + GLfloat w); + void (*VertexAttrib4fv)( + PP_Resource context, GLuint indx, const GLfloat* values); + void (*VertexAttribPointer)( + PP_Resource context, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, const void* ptr); + void (*Viewport)( + PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); +}; + +#endif // PPAPI_C_PPB_OPENGLES_H_ + diff --git a/ppapi/c/ppp_graphics_3d.h b/ppapi/c/ppp_graphics_3d.h new file mode 100644 index 0000000..9916770 --- /dev/null +++ b/ppapi/c/ppp_graphics_3d.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef PPAPI_C_PPP_GRAPHICS_3D_H_ +#define PPAPI_C_PPP_GRAPHICS_3D_H_ + +#include "ppapi/c/pp_instance.h" + +#define PPP_GRAPHICS_3D_INTERFACE "PPP_Graphics_3D;1.0" + +struct PPP_Graphics3D { + // Called when the OpenGL ES window is invalidated and needs to be repainted. + void (*Graphics3DContextLost)(PP_Instance instance); +}; + +#endif /* PPAPI_C_PPP_GRAPHICS_3D_H_ */ + diff --git a/ppapi/c/trusted/ppb_graphics_3d_trusted.h b/ppapi/c/trusted/ppb_graphics_3d_trusted.h new file mode 100644 index 0000000..1be88c4 --- /dev/null +++ b/ppapi/c/trusted/ppb_graphics_3d_trusted.h @@ -0,0 +1,103 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_C_TRUSTED_PPB_GRAPHICS_3D_TRUSTED_H_ +#define PPAPI_C_TRUSTED_PPB_GRAPHICS_3D_TRUSTED_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" + +#define PPB_GRAPHICS_3D_TRUSTED_INTERFACE_0_1 \ + "PPB_Graphics3DTrusted;0.1" +#define PPB_GRAPHICS_3D_TRUSTED_INTERFACE \ + PPB_GRAPHICS_3D_TRUSTED_INTERFACE_0_1 + +typedef enum { + PPB_GRAPHICS3D_TRUSTED_ERROR_OK, + PPB_GRAPHICS3D_TRUSTED_ERROR_GENERICERROR, + PPB_GRAPHICS3D_TRUSTED_ERROR_INVALIDARGUMENTS, + PPB_GRAPHICS3D_TRUSTED_ERROR_INVALIDSIZE, + PPB_GRAPHICS3D_TRUSTED_ERROR_LOSTCONTEXT, + PPB_GRAPHICS3D_TRUSTED_ERROR_OUTOFBOUNDS, + PPB_GRAPHICS3D_TRUSTED_ERROR_UNKNOWNCOMMAND +} PPB_Graphics3DTrustedError; + +struct PP_Graphics3DTrustedState { + // Size of the command buffer in command buffer entries. + int32_t num_entries; + + // The offset (in entries) from which the reader is reading. + int32_t get_offset; + + // The offset (in entries) at which the writer is writing. + int32_t put_offset; + + // The current token value. This is used by the writer to defer + // changes to shared memory objects until the reader has reached a certain + // point in the command buffer. The reader is responsible for updating the + // token value, for example in response to an asynchronous set token command + // embedded in the command buffer. The default token value is zero. + int32_t token; + + // Error status. + PPB_Graphics3DTrustedError error; + + // Generation index of this state. The generation index is incremented every + // time a new state is retrieved from the command processor, so that + // consistency can be kept even if IPC messages are processed out-of-order. + uint32_t generation; +}; + +struct PPB_Graphics3DTrusted { + // Creates a raw Graphics3D resource. A raw Graphics3D is intended to be used + // with the trusted interface, through the command buffer (for proxying). + PP_Resource (*CreateRaw)(PP_Instance instance_id, + PP_Resource share_context, + const int32_t* attrib_list); + + // Initializes the command buffer with the given size. + PP_Bool (*InitCommandBuffer)(PP_Resource context_id, int32_t size); + + // Gets the ring buffer for the command buffer. + PP_Bool (*GetRingBuffer)(PP_Resource context_id, + int* shm_handle, + uint32_t* shm_size); + + // Returns the current state. + struct PP_Graphics3DTrustedState (*GetState)(PP_Resource context); + + // Create a transfer buffer and return a handle that uniquely + // identifies it or -1 on error. + int32_t (*CreateTransferBuffer)(PP_Resource context, uint32_t size); + + // Destroy a transfer buffer and recycle the handle. + PP_Bool (*DestroyTransferBuffer)(PP_Resource context, int32_t id); + + // Get the transfer buffer associated with a handle. + PP_Bool (*GetTransferBuffer)(PP_Resource context, + int32_t id, + int* shm_handle, + uint32_t* shm_size); + + // The writer calls this to update its put offset. + PP_Bool (*Flush)(PP_Resource context, int32_t put_offset); + + // The writer calls this to update its put offset. This function returns the + // reader's most recent get offset. Does not return until after the put offset + // change callback has been invoked. + struct PP_Graphics3DTrustedState (*FlushSync)(PP_Resource context, + int32_t put_offset); + + // Like FlushSync, but returns before processing commands if the get offset is + // different than last_known_get. Allows synchronization with the command + // processor without forcing immediate command execution. + struct PP_Graphics3DTrustedState (*FlushSyncFast)(PP_Resource context, + int32_t put_offset, + int32_t last_known_get); +}; + +#endif // PPAPI_C_TRUSTED_PPB_GRAPHICS_3D_TRUSTED_H_ + diff --git a/ppapi/cpp/dev/graphics_3d_client_dev.cc b/ppapi/cpp/dev/graphics_3d_client_dev.cc deleted file mode 100644 index bdd2e7e..0000000 --- a/ppapi/cpp/dev/graphics_3d_client_dev.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/cpp/dev/graphics_3d_client_dev.h" - -#include "ppapi/c/dev/ppp_graphics_3d_dev.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -const char kPPPGraphics3DInterface[] = PPP_GRAPHICS_3D_DEV_INTERFACE; - -void Graphics3D_ContextLost(PP_Instance instance) { - void* object = - pp::Instance::GetPerInstanceObject(instance, kPPPGraphics3DInterface); - if (!object) - return; - return static_cast(object)->Graphics3DContextLost(); -} - -static PPP_Graphics3D_Dev graphics3d_interface = { - &Graphics3D_ContextLost, -}; - -} // namespace - -Graphics3DClient_Dev::Graphics3DClient_Dev(Instance* instance) - : associated_instance_(instance) { - pp::Module::Get()->AddPluginInterface(kPPPGraphics3DInterface, - &graphics3d_interface); - associated_instance_->AddPerInstanceObject(kPPPGraphics3DInterface, this); -} - -Graphics3DClient_Dev::~Graphics3DClient_Dev() { - associated_instance_->RemovePerInstanceObject(kPPPGraphics3DInterface, this); -} - -} // namespace pp diff --git a/ppapi/cpp/dev/graphics_3d_client_dev.h b/ppapi/cpp/dev/graphics_3d_client_dev.h deleted file mode 100644 index 5f68fb2..0000000 --- a/ppapi/cpp/dev/graphics_3d_client_dev.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_CPP_DEV_GRAPHICS_3D_CLIENT_DEV_H_ -#define PPAPI_CPP_DEV_GRAPHICS_3D_CLIENT_DEV_H_ - -#include "ppapi/c/pp_stdint.h" - -namespace pp { - -class Instance; -class Rect; -class Scrollbar_Dev; -class Widget_Dev; - -// This class provides a C++ interface for callbacks related to 3D. You -// would normally use multiple inheritance to derive from this class in your -// instance. -class Graphics3DClient_Dev { - public: - Graphics3DClient_Dev(Instance* instance); - virtual ~Graphics3DClient_Dev(); - - /** - * Notification that the context was lost for the 3D devices. - */ - virtual void Graphics3DContextLost() = 0; - - private: - Instance* associated_instance_; -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_GRAPHICS_3D_CLIENT_DEV_H_ diff --git a/ppapi/cpp/dev/graphics_3d_dev.cc b/ppapi/cpp/dev/graphics_3d_dev.cc deleted file mode 100644 index 953b859..0000000 --- a/ppapi/cpp/dev/graphics_3d_dev.cc +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/cpp/dev/graphics_3d_dev.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/var.h" - -namespace pp { - -namespace { - -template <> const char* interface_name() { - return PPB_GRAPHICS_3D_DEV_INTERFACE; -} - -} // namespace - -Graphics3D_Dev::Graphics3D_Dev() { -} - -Graphics3D_Dev::Graphics3D_Dev(const Instance& instance, - const Graphics3D_Dev& share_context, - const int32_t* attrib_list) { - if (has_interface()) { - PassRefFromConstructor(get_interface()->Create( - instance.pp_instance(), - share_context.pp_resource(), - attrib_list)); - } -} - -Graphics3D_Dev::~Graphics3D_Dev() { -} - -int32_t Graphics3D_Dev::GetAttribs(int32_t* attrib_list) const { - if (!has_interface()) - return PP_ERROR_NOINTERFACE; - - return get_interface()->GetAttribs( - pp_resource(), - attrib_list); -} - -int32_t Graphics3D_Dev::SetAttribs(int32_t* attrib_list) { - if (!has_interface()) - return PP_ERROR_NOINTERFACE; - - return get_interface()->SetAttribs( - pp_resource(), - attrib_list); -} - -int32_t Graphics3D_Dev::ResizeBuffers(int32_t width, int32_t height) { - if (!has_interface()) - return PP_ERROR_NOINTERFACE; - - return get_interface()->ResizeBuffers( - pp_resource(), width, height); -} - -int32_t Graphics3D_Dev::SwapBuffers(const CompletionCallback& cc) { - if (!has_interface()) - return PP_ERROR_NOINTERFACE; - - return get_interface()->SwapBuffers( - pp_resource(), - cc.pp_completion_callback()); -} - -} // namespace pp - diff --git a/ppapi/cpp/dev/graphics_3d_dev.h b/ppapi/cpp/dev/graphics_3d_dev.h deleted file mode 100644 index 30a46e7..0000000 --- a/ppapi/cpp/dev/graphics_3d_dev.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_ -#define PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_ - -#include "ppapi/c/dev/ppb_graphics_3d_dev.h" -#include "ppapi/cpp/resource.h" - -namespace pp { - -class CompletionCallback; -class Instance; -class Var; - -class Graphics3D_Dev : public Resource { - public: - // Creates an is_null() Graphics3D_Dev object. - Graphics3D_Dev(); - - Graphics3D_Dev(const Instance& instance, - const Graphics3D_Dev& share_context, - const int32_t* attrib_list); - - ~Graphics3D_Dev(); - - int32_t GetAttribs(int32_t* attrib_list) const; - int32_t SetAttribs(int32_t* attrib_list); - - int32_t ResizeBuffers(int32_t width, int32_t height); - - int32_t SwapBuffers(const CompletionCallback& cc); -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_ - diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc index f7ab651..991ad55 100644 --- a/ppapi/cpp/dev/video_decoder_dev.cc +++ b/ppapi/cpp/dev/video_decoder_dev.cc @@ -8,7 +8,7 @@ #include "ppapi/c/dev/ppp_video_decoder_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/cpp/dev/context_3d_dev.h" -#include "ppapi/cpp/dev/graphics_3d_dev.h" +#include "ppapi/cpp/graphics_3d.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -33,7 +33,7 @@ VideoDecoder_Dev::VideoDecoder_Dev(const Instance* instance, } VideoDecoder_Dev::VideoDecoder_Dev(const Instance* instance, - const Graphics3D_Dev& context, + const Graphics3D& context, PP_VideoDecoder_Profile profile) { if (!has_interface()) return; diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h index e260050..b761ef1 100644 --- a/ppapi/cpp/dev/video_decoder_dev.h +++ b/ppapi/cpp/dev/video_decoder_dev.h @@ -15,7 +15,7 @@ namespace pp { class Context3D_Dev; -class Graphics3D_Dev; +class Graphics3D; class Instance; // C++ wrapper for the Pepper Video Decoder interface. For more detailed @@ -29,7 +29,7 @@ class VideoDecoder_Dev : public Resource { const Context3D_Dev& context, PP_VideoDecoder_Profile profile); VideoDecoder_Dev(const Instance* instance, - const Graphics3D_Dev& context, + const Graphics3D& context, PP_VideoDecoder_Profile profile); explicit VideoDecoder_Dev(PP_Resource resource); diff --git a/ppapi/cpp/graphics_3d.cc b/ppapi/cpp/graphics_3d.cc new file mode 100644 index 0000000..0cd8ba2 --- /dev/null +++ b/ppapi/cpp/graphics_3d.cc @@ -0,0 +1,76 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/graphics_3d.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name() { + return PPB_GRAPHICS_3D_INTERFACE; +} + +} // namespace + +Graphics3D::Graphics3D() { +} + +Graphics3D::Graphics3D(const Instance& instance, + const Graphics3D& share_context, + const int32_t* attrib_list) { + if (has_interface()) { + PassRefFromConstructor(get_interface()->Create( + instance.pp_instance(), + share_context.pp_resource(), + attrib_list)); + } +} + +Graphics3D::~Graphics3D() { +} + +int32_t Graphics3D::GetAttribs(int32_t* attrib_list) const { + if (!has_interface()) + return PP_ERROR_NOINTERFACE; + + return get_interface()->GetAttribs( + pp_resource(), + attrib_list); +} + +int32_t Graphics3D::SetAttribs(int32_t* attrib_list) { + if (!has_interface()) + return PP_ERROR_NOINTERFACE; + + return get_interface()->SetAttribs( + pp_resource(), + attrib_list); +} + +int32_t Graphics3D::ResizeBuffers(int32_t width, int32_t height) { + if (!has_interface()) + return PP_ERROR_NOINTERFACE; + + return get_interface()->ResizeBuffers( + pp_resource(), width, height); +} + +int32_t Graphics3D::SwapBuffers(const CompletionCallback& cc) { + if (!has_interface()) + return PP_ERROR_NOINTERFACE; + + return get_interface()->SwapBuffers( + pp_resource(), + cc.pp_completion_callback()); +} + +} // namespace pp + diff --git a/ppapi/cpp/graphics_3d.h b/ppapi/cpp/graphics_3d.h new file mode 100644 index 0000000..aaa6d08 --- /dev/null +++ b/ppapi/cpp/graphics_3d.h @@ -0,0 +1,39 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_GRAPHICS_3D_H_ +#define PPAPI_CPP_GRAPHICS_3D_H_ + +#include "ppapi/c/ppb_graphics_3d.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class CompletionCallback; +class Instance; +class Var; + +class Graphics3D : public Resource { + public: + // Creates an is_null() Graphics3D_Dev object. + Graphics3D(); + + Graphics3D(const Instance& instance, + const Graphics3D& share_context, + const int32_t* attrib_list); + + ~Graphics3D(); + + int32_t GetAttribs(int32_t* attrib_list) const; + int32_t SetAttribs(int32_t* attrib_list); + + int32_t ResizeBuffers(int32_t width, int32_t height); + + int32_t SwapBuffers(const CompletionCallback& cc); +}; + +} // namespace pp + +#endif // PPAPI_CPP_GRAPHICS_3D_H_ + diff --git a/ppapi/cpp/graphics_3d_client.cc b/ppapi/cpp/graphics_3d_client.cc new file mode 100644 index 0000000..d827f9d --- /dev/null +++ b/ppapi/cpp/graphics_3d_client.cc @@ -0,0 +1,43 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/graphics_3d_client.h" + +#include "ppapi/c/ppp_graphics_3d.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +const char kPPPGraphics3DInterface[] = PPP_GRAPHICS_3D_INTERFACE; + +void Graphics3D_ContextLost(PP_Instance instance) { + void* object = + pp::Instance::GetPerInstanceObject(instance, kPPPGraphics3DInterface); + if (!object) + return; + return static_cast(object)->Graphics3DContextLost(); +} + +static PPP_Graphics3D graphics3d_interface = { + &Graphics3D_ContextLost, +}; + +} // namespace + +Graphics3DClient::Graphics3DClient(Instance* instance) + : associated_instance_(instance) { + pp::Module::Get()->AddPluginInterface(kPPPGraphics3DInterface, + &graphics3d_interface); + associated_instance_->AddPerInstanceObject(kPPPGraphics3DInterface, this); +} + +Graphics3DClient::~Graphics3DClient() { + associated_instance_->RemovePerInstanceObject(kPPPGraphics3DInterface, this); +} + +} // namespace pp diff --git a/ppapi/cpp/graphics_3d_client.h b/ppapi/cpp/graphics_3d_client.h new file mode 100644 index 0000000..511ca2d --- /dev/null +++ b/ppapi/cpp/graphics_3d_client.h @@ -0,0 +1,36 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_GRAPHICS_3D_CLIENT_H_ +#define PPAPI_CPP_GRAPHICS_3D_CLIENT_H_ + +#include "ppapi/c/pp_stdint.h" + +namespace pp { + +class Instance; +class Rect; +class Scrollbar_Dev; +class Widget_Dev; + +// This class provides a C++ interface for callbacks related to 3D. You +// would normally use multiple inheritance to derive from this class in your +// instance. +class Graphics3DClient { + public: + Graphics3DClient(Instance* instance); + virtual ~Graphics3DClient(); + + /** + * Notification that the context was lost for the 3D devices. + */ + virtual void Graphics3DContextLost() = 0; + + private: + Instance* associated_instance_; +}; + +} // namespace pp + +#endif // PPAPI_CPP_DEV_GRAPHICS_3D_CLIENT_H_ diff --git a/ppapi/cpp/instance.cc b/ppapi/cpp/instance.cc index 9bb77dc..a6f5997 100644 --- a/ppapi/cpp/instance.cc +++ b/ppapi/cpp/instance.cc @@ -8,9 +8,9 @@ #include "ppapi/c/ppb_input_event.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppb_messaging.h" -#include "ppapi/cpp/dev/graphics_3d_dev.h" #include "ppapi/cpp/dev/surface_3d_dev.h" #include "ppapi/cpp/graphics_2d.h" +#include "ppapi/cpp/graphics_3d.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/logging.h" #include "ppapi/cpp/module.h" @@ -82,7 +82,7 @@ bool Instance::BindGraphics(const Graphics2D& graphics) { pp_instance(), graphics.pp_resource())); } -bool Instance::BindGraphics(const Graphics3D_Dev& graphics) { +bool Instance::BindGraphics(const Graphics3D& graphics) { if (!has_interface()) return false; return PP_ToBool(get_interface()->BindGraphics( diff --git a/ppapi/cpp/instance.h b/ppapi/cpp/instance.h index ea145f9..528c08a 100644 --- a/ppapi/cpp/instance.h +++ b/ppapi/cpp/instance.h @@ -21,7 +21,7 @@ struct PP_InputEvent; namespace pp { class Graphics2D; -class Graphics3D_Dev; +class Graphics3D; class InputEvent; class ImageData; class Point; @@ -275,12 +275,12 @@ class Instance { /// Refer to BindGraphics(const Graphics2D& graphics) for /// further information. /// - /// @param[in] graphics A Graphics3D_Dev to bind. + /// @param[in] graphics A Graphics3D to bind. /// /// @return true if bind was successful or false if the device was not the /// correct type. On success, a reference to the device will be held by the /// instance, so the caller can release its reference if it chooses. - bool BindGraphics(const Graphics3D_Dev& graphics); + bool BindGraphics(const Graphics3D& graphics); /// Binds the given Surface3D as the current display surface. /// Refer to BindGraphics(const Graphics2D& graphics) for diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc index 26d94a4..04f31f7 100644 --- a/ppapi/examples/gles2/gles2.cc +++ b/ppapi/examples/gles2/gles2.cc @@ -12,14 +12,14 @@ #include #include "ppapi/c/dev/ppb_console_dev.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_opengles.h" #include "ppapi/cpp/dev/context_3d_dev.h" -#include "ppapi/cpp/dev/graphics_3d_client_dev.h" -#include "ppapi/cpp/dev/graphics_3d_dev.h" #include "ppapi/cpp/dev/surface_3d_dev.h" #include "ppapi/cpp/dev/video_decoder_client_dev.h" #include "ppapi/cpp/dev/video_decoder_dev.h" +#include "ppapi/cpp/graphics_3d.h" +#include "ppapi/cpp/graphics_3d_client.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/rect.h" @@ -41,7 +41,7 @@ namespace { class GLES2DemoInstance : public pp::Instance, - public pp::Graphics3DClient_Dev, + public pp::Graphics3DClient, public pp::VideoDecoderClient_Dev { public: GLES2DemoInstance(PP_Instance instance, pp::Module* module); @@ -51,7 +51,7 @@ class GLES2DemoInstance : public pp::Instance, virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip_ignored); - // pp::Graphics3DClient_Dev implementation. + // pp::Graphics3DClient implementation. virtual void Graphics3DContextLost() { // TODO(vrk/fischman): Properly reset after a lost graphics context. In // particular need to delete context_ & surface_ and re-create textures. @@ -159,7 +159,7 @@ class GLES2DemoInstance : public pp::Instance, // Unowned pointers. const struct PPB_Console_Dev* console_if_; const struct PPB_Core* core_if_; - const struct PPB_OpenGLES2_Dev* gles2_if_; + const struct PPB_OpenGLES2* gles2_if_; // Owned data. pp::Context3D_Dev* context_; @@ -193,7 +193,7 @@ GLES2DemoInstance::DecoderClient::~DecoderClient() { } GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) - : pp::Instance(instance), pp::Graphics3DClient_Dev(this), + : pp::Instance(instance), pp::Graphics3DClient(this), pp::VideoDecoderClient_Dev(this), num_frames_rendered_(0), first_frame_delivered_ticks_(-1), @@ -205,8 +205,8 @@ GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)))); assert((core_if_ = static_cast( module->GetBrowserInterface(PPB_CORE_INTERFACE)))); - assert((gles2_if_ = static_cast( - module->GetBrowserInterface(PPB_OPENGLES2_DEV_INTERFACE)))); + assert((gles2_if_ = static_cast( + module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE)))); } GLES2DemoInstance::~GLES2DemoInstance() { diff --git a/ppapi/lib/gl/gles2/gl2ext_ppapi.c b/ppapi/lib/gl/gles2/gl2ext_ppapi.c index 02e3005..62d842d 100644 --- a/ppapi/lib/gl/gles2/gl2ext_ppapi.c +++ b/ppapi/lib/gl/gles2/gl2ext_ppapi.c @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,7 +25,7 @@ // TODO(alokp): This will need to be thread-safe if we build gles2 as a // shared library. -static const struct PPB_OpenGLES2_Dev* g_gles2_interface = NULL; +static const struct PPB_OpenGLES2* g_gles2_interface = NULL; // TODO(alokp): Make sure PP_TLS works on all supported platforms. static PP_TLS PP_Resource g_current_context = 0; @@ -33,7 +33,7 @@ static PP_TLS PP_Resource g_current_context = 0; GLboolean GL_APIENTRY glInitializePPAPI( PPB_GetInterface get_browser_interface) { if (!g_gles2_interface) { - g_gles2_interface = get_browser_interface(PPB_OPENGLES2_DEV_INTERFACE); + g_gles2_interface = get_browser_interface(PPB_OPENGLES2_INTERFACE); } return g_gles2_interface ? GL_TRUE : GL_FALSE; } @@ -51,7 +51,7 @@ PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { return g_current_context; } -const struct PPB_OpenGLES2_Dev* GL_APIENTRY glGetInterfacePPAPI() { +const struct PPB_OpenGLES2* GL_APIENTRY glGetInterfacePPAPI() { return g_gles2_interface; } diff --git a/ppapi/lib/gl/gles2/gl2ext_ppapi.h b/ppapi/lib/gl/gles2/gl2ext_ppapi.h index 97953ce..7c84397 100644 --- a/ppapi/lib/gl/gles2/gl2ext_ppapi.h +++ b/ppapi/lib/gl/gles2/gl2ext_ppapi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,7 +11,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" +#include "ppapi/c/ppb_opengles.h" #ifdef __cplusplus extern "C" { @@ -35,7 +35,7 @@ GL_APICALL void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context); GL_APICALL PP_Resource GL_APIENTRY glGetCurrentContextPPAPI(); // Returns OpenGL ES 2.0 interface. -GL_APICALL const struct PPB_OpenGLES2_Dev* GL_APIENTRY glGetInterfacePPAPI(); +GL_APICALL const struct PPB_OpenGLES2* GL_APIENTRY glGetInterfacePPAPI(); #ifdef __cplusplus } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc index 566dcf6..1ac2a5f 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc @@ -213,16 +213,16 @@ const PPB_Graphics2D* PPBGraphics2DInterface() { return ppb; } -const PPB_Graphics3D_Dev* PPBGraphics3DInterface() { - static const PPB_Graphics3D_Dev* ppb = static_cast( - GetBrowserInterfaceSafe(PPB_GRAPHICS_3D_DEV_INTERFACE)); +const PPB_Graphics3D* PPBGraphics3DInterface() { + static const PPB_Graphics3D* ppb = static_cast( + GetBrowserInterfaceSafe(PPB_GRAPHICS_3D_INTERFACE)); return ppb; } -const PPB_Graphics3DTrusted_Dev* PPBGraphics3DTrustedInterface() { - static const PPB_Graphics3DTrusted_Dev* ppb = - static_cast( - GetBrowserInterfaceSafe(PPB_GRAPHICS_3D_TRUSTED_DEV_INTERFACE)); +const PPB_Graphics3DTrusted* PPBGraphics3DTrustedInterface() { + static const PPB_Graphics3DTrusted* ppb = + static_cast( + GetBrowserInterfaceSafe(PPB_GRAPHICS_3D_TRUSTED_INTERFACE)); return ppb; } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h index e0d17a1..e118e6a 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h @@ -9,8 +9,6 @@ #include "ppapi/c/dev/ppb_find_dev.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/dev/ppb_fullscreen_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_trusted_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" @@ -25,6 +23,7 @@ #include "ppapi/c/ppb_file_ref.h" #include "ppapi/c/ppb_file_system.h" #include "ppapi/c/ppb_graphics_2d.h" +#include "ppapi/c/ppb_graphics_3d.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/ppb_input_event.h" #include "ppapi/c/ppb_instance.h" @@ -34,6 +33,7 @@ #include "ppapi/c/ppb_url_response_info.h" #include "ppapi/c/ppb_var.h" #include "ppapi/c/private/ppb_pdf.h" +#include "ppapi/c/trusted/ppb_graphics_3d_trusted.h" #include "ppapi/c/trusted/ppb_image_data_trusted.h" struct NaClSrpcRpc; @@ -105,8 +105,8 @@ const PPB_Find_Dev* PPBFindInterface(); const PPB_Font_Dev* PPBFontInterface(); const PPB_Fullscreen_Dev* PPBFullscreenInterface(); const PPB_Graphics2D* PPBGraphics2DInterface(); -const PPB_Graphics3D_Dev* PPBGraphics3DInterface(); -const PPB_Graphics3DTrusted_Dev* PPBGraphics3DTrustedInterface(); +const PPB_Graphics3D* PPBGraphics3DInterface(); +const PPB_Graphics3DTrusted* PPBGraphics3DTrustedInterface(); const PPB_ImageData* PPBImageDataInterface(); const PPB_ImageDataTrusted* PPBImageDataTrustedInterface(); const PPB_InputEvent* PPBInputEventInterface(); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc index 59fd02c..f86c735 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc @@ -14,11 +14,11 @@ #include "native_client/src/shared/ppapi_proxy/plugin_resource.h" #include "native_client/src/shared/ppapi_proxy/utility.h" #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" -#include "ppapi/c/dev/pp_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_trusted_dev.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/c/pp_graphics_3d.h" +#include "ppapi/c/ppb_graphics_3d.h" #include "ppapi/c/private/ppb_gpu_blacklist_private.h" +#include "ppapi/c/trusted/ppb_graphics_3d_trusted.h" #include "srpcgen/ppb_rpc.h" using ppapi_proxy::DebugPrintf; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h b/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h index 0b0dd6a..a699241 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Native Client Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,9 +6,9 @@ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_COMMAND_BUFFER_NACL_H #include "gpu/command_buffer/common/command_buffer.h" -#include "ppapi/c/dev/pp_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_trusted_dev.h" +#include "ppapi/c/pp_graphics_3d.h" #include "ppapi/c/pp_resource.h" +#include "ppapi/c/trusted/ppb_graphics_3d_trusted.h" struct PPB_Core; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_opengles.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_opengles.cc index 266981c..af2f009 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_opengles.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_opengles.cc @@ -9,7 +9,7 @@ #include "native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h" #include "gpu/command_buffer/client/gles2_implementation.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" +#include "ppapi/c/ppb_opengles.h" using ppapi_proxy::PluginGraphics3D; using ppapi_proxy::PluginResource; @@ -632,8 +632,8 @@ void Viewport( } // namespace -const PPB_OpenGLES2_Dev* PluginGraphics3D::GetOpenGLESInterface() { - const static struct PPB_OpenGLES2_Dev ppb_opengles = { +const PPB_OpenGLES2* PluginGraphics3D::GetOpenGLESInterface() { + const static struct PPB_OpenGLES2 ppb_opengles = { &ActiveTexture, &AttachShader, &BindAttribLocation, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc index 8032f84..8db868e 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc @@ -61,7 +61,7 @@ InterfaceMapElement interface_map[] = { { PPB_FONT_DEV_INTERFACE, PluginFont::GetInterface(), true }, { PPB_FULLSCREEN_DEV_INTERFACE, PluginFullscreen::GetInterface(), true }, { PPB_GRAPHICS_2D_INTERFACE, PluginGraphics2D::GetInterface(), true }, - { PPB_GRAPHICS_3D_DEV_INTERFACE, PluginGraphics3D::GetInterface(), true }, + { PPB_GRAPHICS_3D_INTERFACE, PluginGraphics3D::GetInterface(), true }, { PPB_IMAGEDATA_INTERFACE, PluginImageData::GetInterface(), true }, { PPB_INPUT_EVENT_INTERFACE, PluginInputEvent::GetInterface(), true }, { PPB_INSTANCE_INTERFACE, PluginInstance::GetInterface(), true }, @@ -73,7 +73,7 @@ InterfaceMapElement interface_map[] = { PluginInputEvent::GetMouseInterface1_0(), true }, { PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1, PluginInputEvent::GetMouseInterface1_1(), true }, - { PPB_OPENGLES2_DEV_INTERFACE, PluginGraphics3D::GetOpenGLESInterface(), + { PPB_OPENGLES2_INTERFACE, PluginGraphics3D::GetOpenGLESInterface(), true }, { PPB_PDF_INTERFACE, PluginPDF::GetInterface(), true }, { PPB_SCROLLBAR_DEV_INTERFACE, PluginScrollbar::GetInterface(), true }, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc index 3befbf5..974563a 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc @@ -259,8 +259,8 @@ int32_t PluginGraphics3D::SwapBuffers(PP_Resource graphics3d_id, // static -const PPB_Graphics3D_Dev* PluginGraphics3D::GetInterface() { - static const PPB_Graphics3D_Dev intf = { +const PPB_Graphics3D* PluginGraphics3D::GetInterface() { + static const PPB_Graphics3D intf = { &GetAttribMaxValue, &Create, &IsGraphics3D, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h index 63c3bca..f3358de 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h @@ -1,8 +1,6 @@ -/* - * Copyright 2011 The Native Client Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can - * be found in the LICENSE file. - */ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_GRAPHICS_3D_H_ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_GRAPHICS_3D_H_ @@ -10,9 +8,9 @@ #include "base/scoped_ptr.h" #include "native_client/src/include/nacl_macros.h" #include "native_client/src/shared/ppapi_proxy/plugin_resource.h" -#include "ppapi/c/dev/pp_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" +#include "ppapi/c/pp_graphics_3d.h" +#include "ppapi/c/ppb_graphics_3d.h" +#include "ppapi/c/ppb_opengles.h" #include "ppapi/c/pp_instance.h" namespace gpu { @@ -31,8 +29,8 @@ class PluginGraphics3D : public PluginResource { PluginGraphics3D(); virtual ~PluginGraphics3D(); - static const PPB_Graphics3D_Dev* GetInterface(); - static const PPB_OpenGLES2_Dev* GetOpenGLESInterface(); + static const PPB_Graphics3D* GetInterface(); + static const PPB_OpenGLES2* GetOpenGLESInterface(); virtual bool InitFromBrowserResource(PP_Resource graphics3d_id); diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc b/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc index 1362a97..d1e6d6a 100644 --- a/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc +++ b/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Native Client Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -29,10 +29,8 @@ #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/dev/ppb_fullscreen_dev.h" #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_dev.h" #include "ppapi/c/dev/ppb_layer_compositor_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" #include "ppapi/c/dev/ppb_surface_3d_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" @@ -67,10 +65,8 @@ void TestGetDevInterfaces() { CHECK(GetBrowserInterface(PPB_FULLSCREEN_DEV_INTERFACE) == NULL); CHECK(GetBrowserInterface( PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE) == NULL); - CHECK(GetBrowserInterface(PPB_GRAPHICS_3D_DEV_INTERFACE) == NULL); CHECK(GetBrowserInterface(PPB_LAYER_COMPOSITOR_DEV_INTERFACE) == NULL); CHECK(GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE) == NULL); - CHECK(GetBrowserInterface(PPB_OPENGLES2_DEV_INTERFACE) == NULL); CHECK(GetBrowserInterface(PPB_SCROLLBAR_DEV_INTERFACE) == NULL); CHECK(GetBrowserInterface(PPB_SURFACE_3D_DEV_INTERFACE) == NULL); CHECK(GetBrowserInterface(PPB_TESTING_DEV_INTERFACE) == NULL); diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc index 63f1143..9621c5e 100644 --- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc +++ b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc @@ -14,19 +14,19 @@ #include "native_client/tests/ppapi_test_lib/get_browser_interface.h" #include "native_client/tests/ppapi_test_lib/internal_utils.h" #include "native_client/tests/ppapi_test_lib/test_interface.h" -#include "ppapi/c/dev/pp_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/c/pp_graphics_3d.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/ppb_core.h" +#include "ppapi/c/ppb_graphics_3d.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/ppb_instance.h" +#include "ppapi/c/ppb_opengles.h" #include "ppapi/c/ppb_url_loader.h" #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" @@ -40,13 +40,13 @@ const int kHeight = 200; // Tests the Graphics3D interface is available. void TestGraphics3DInterface() { - EXPECT(PPBGraphics3DDev() != NULL); + EXPECT(PPBGraphics3D() != NULL); TEST_PASSED; } // Tests the OpenGLES interface is available. void TestOpenGLES2Interface() { - EXPECT(PPBOpenGLES2Dev() != NULL); + EXPECT(PPBOpenGLES2() != NULL); TEST_PASSED; } @@ -56,20 +56,20 @@ void TestCreate() { PP_GRAPHICS3DATTRIB_WIDTH, kWidth, PP_GRAPHICS3DATTRIB_HEIGHT, kHeight, PP_GRAPHICS3DATTRIB_NONE}; - PP_Resource graphics3d_id = PPBGraphics3DDev()-> + PP_Resource graphics3d_id = PPBGraphics3D()-> Create(pp_instance(), kInvalidResource, attribs); EXPECT(graphics3d_id != kInvalidResource); PPBCore()->ReleaseResource(graphics3d_id); - PP_Resource invalid_graphics3d_id = PPBGraphics3DDev()-> + PP_Resource invalid_graphics3d_id = PPBGraphics3D()-> Create(0, kInvalidResource, attribs); EXPECT(invalid_graphics3d_id == kInvalidResource); int32_t empty_attribs[] = { PP_GRAPHICS3DATTRIB_NONE}; - PP_Resource graphics3d_empty_attrib_id = PPBGraphics3DDev()-> + PP_Resource graphics3d_empty_attrib_id = PPBGraphics3D()-> Create(pp_instance(), kInvalidResource, empty_attribs); EXPECT(graphics3d_empty_attrib_id != kInvalidResource); PPBCore()->ReleaseResource(graphics3d_empty_attrib_id); - PP_Resource graphics3d_null_attrib_id = PPBGraphics3DDev()-> + PP_Resource graphics3d_null_attrib_id = PPBGraphics3D()-> Create(pp_instance(), kInvalidResource, NULL); EXPECT(graphics3d_null_attrib_id != kInvalidResource); PPBCore()->ReleaseResource(graphics3d_null_attrib_id); @@ -82,10 +82,10 @@ void TestIsGraphics3D() { PP_GRAPHICS3DATTRIB_WIDTH, kWidth, PP_GRAPHICS3DATTRIB_HEIGHT, kHeight, PP_GRAPHICS3DATTRIB_NONE}; - PP_Resource graphics3d_id = PPBGraphics3DDev()-> + PP_Resource graphics3d_id = PPBGraphics3D()-> Create(pp_instance(), kInvalidResource, attribs); EXPECT(graphics3d_id != kInvalidResource); - EXPECT(PPBGraphics3DDev()->IsGraphics3D(graphics3d_id) == PP_TRUE); + EXPECT(PPBGraphics3D()->IsGraphics3D(graphics3d_id) == PP_TRUE); PPBCore()->ReleaseResource(graphics3d_id); TEST_PASSED; } @@ -118,7 +118,7 @@ void TestSwapCallback(void* user_data, int32_t result) { if (info->frame_counter < info->frame_end) { PP_CompletionCallback cc = PP_MakeCompletionCallback(TestSwapCallback, info); - int32_t result = PPBGraphics3DDev()->SwapBuffers(info->graphics3d_id, cc); + int32_t result = PPBGraphics3D()->SwapBuffers(info->graphics3d_id, cc); CHECK(PP_OK_COMPLETIONPENDING == result); } else { PPBCore()->ReleaseResource(info->graphics3d_id); @@ -135,7 +135,7 @@ void TestSwapBuffers() { PP_GRAPHICS3DATTRIB_WIDTH, kWidth, PP_GRAPHICS3DATTRIB_HEIGHT, kHeight, PP_GRAPHICS3DATTRIB_NONE}; - PP_Resource graphics3d_id = PPBGraphics3DDev()-> + PP_Resource graphics3d_id = PPBGraphics3D()-> Create(pp_instance(), kInvalidResource, attribs); EXPECT(graphics3d_id != kInvalidResource); int32_t success = PPBInstance()->BindGraphics(pp_instance(), graphics3d_id); @@ -150,6 +150,86 @@ void TestSwapBuffers() { PPBCore()->CallOnMainThread(0, cc, PP_OK); } +void TestResizeAndSwapCallback(void* user_data, int32_t result) { + EXPECT(result == PP_OK); + RenderInfo* info = static_cast(user_data); + int32_t new_width = kWidth - info->frame_counter * 2; + int32_t new_height = kHeight - info->frame_counter * 2; + if (new_width < 0) new_width = 0; + if (new_height < 0) new_height = 0; + int32_t resize_result = PPBGraphics3D()->ResizeBuffers(info->graphics3d_id, + new_width, new_height); + EXPECT(resize_result == PP_OK); + // Set graphics3d_id to the main context, so we can use normal gl style calls + // instead of going through the PPAPI PPBOpenGLES2 interface. + glSetCurrentContextPPAPI(info->graphics3d_id); + // Note: still use original width & height in glViewport; visual inspection + // should show a clipped window that shrinks to new_width, new_height size. + glViewport(0, 0, new_width, new_height); + float green = float(info->frame_counter) / float(info->frame_end); + glClearColor(0.0f, green, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + info->frame_counter += info->frame_increment; + if (info->frame_counter < info->frame_end) { + PP_CompletionCallback cc = + PP_MakeCompletionCallback(TestResizeAndSwapCallback, info); + int32_t result = PPBGraphics3D()->SwapBuffers(info->graphics3d_id, cc); + CHECK(PP_OK_COMPLETIONPENDING == result); + } else { + PPBCore()->ReleaseResource(info->graphics3d_id); + delete info; + TEST_PASSED; + } + glSetCurrentContextPPAPI(0); +} + +// Tests PPB_Graphics3D::ResizeBuffers(). +void TestResizeBuffers(int32_t* attribs) { + PP_Resource graphics3d_id = PPBGraphics3D()-> + Create(pp_instance(), kInvalidResource, attribs); + EXPECT(graphics3d_id != kInvalidResource); + int32_t success = PPBInstance()->BindGraphics(pp_instance(), graphics3d_id); + EXPECT(success == PP_TRUE); + int32_t result; + // Attempt negative width & heights + result = PPBGraphics3D()->ResizeBuffers(graphics3d_id, -1000, 0); + EXPECT(result == PP_ERROR_BADARGUMENT); + result = PPBGraphics3D()->ResizeBuffers(graphics3d_id, 100, -1); + EXPECT(result == PP_ERROR_BADARGUMENT); + result = PPBGraphics3D()->ResizeBuffers(graphics3d_id, -1, -1); + EXPECT(result == PP_ERROR_BADARGUMENT); + RenderInfo* render_info = new RenderInfo; + render_info->graphics3d_id = graphics3d_id; + render_info->frame_counter = 0; + render_info->frame_end = 256; + render_info->frame_increment = 8; + PP_CompletionCallback cc = PP_MakeCompletionCallback( + TestResizeAndSwapCallback, render_info); + PPBCore()->CallOnMainThread(0, cc, PP_OK); +} + + +// Tests PPB_Graphics3D::ResizeBuffers() w/o depth buffer attached. +void TestResizeBuffersWithoutDepthBuffer() { + int32_t attribs[] = { + PP_GRAPHICS3DATTRIB_WIDTH, kWidth, + PP_GRAPHICS3DATTRIB_HEIGHT, kHeight, + PP_GRAPHICS3DATTRIB_NONE}; + TestResizeBuffers(attribs); +} + + +// Tests PPB_Graphics3D::ResizeBuffers() w/ depth buffer attached. +void TestResizeBuffersWithDepthBuffer() { + int32_t attribs[] = { + PP_GRAPHICS3DATTRIB_WIDTH, kWidth, + PP_GRAPHICS3DATTRIB_HEIGHT, kHeight, + PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 32, + PP_GRAPHICS3DATTRIB_NONE}; + TestResizeBuffers(attribs); +} + + // Tests glTerminatePPAPI. void Test_glTerminatePPAPI() { GLboolean terminate = glTerminatePPAPI(); @@ -166,6 +246,10 @@ void SetupTests() { RegisterTest("TestIsGraphics3D", TestIsGraphics3D); RegisterTest("Test_glInitializePPAPI", Test_glInitializePPAPI); RegisterTest("TestSwapBuffers", TestSwapBuffers); + RegisterTest("TestResizeBuffersWithoutDepthBuffer", + TestResizeBuffersWithoutDepthBuffer); + RegisterTest("TestResizeBuffersWithDepthBuffer", + TestResizeBuffersWithDepthBuffer); RegisterTest("Test_glTerminatePPAPI", Test_glTerminatePPAPI); } diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html index 196747c..8fe0a01 100644 --- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html +++ b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html @@ -38,6 +38,14 @@ function setupTests(tester, plugin) { tester.addAsyncTest('PPB_Graphics3D::SwapBuffers', function(test) { testAndAssertStatus(test, 'TestSwapBuffers', 'TestSwapCallback:PASSED'); }); + tester.addAsyncTest('PPB_Graphics3D::ResizeBuffers', function(test) { + testAndAssertStatus(test, 'TestResizeBuffersWithoutDepthBuffer', + 'TestResizeAndSwapCallback:PASSED'); + }); + tester.addAsyncTest('PPB_Graphics3D::ResizeBuffers w/ Depth', function(test) { + testAndAssertStatus(test, 'TestResizeBuffersWithDepthBuffer', + 'TestResizeAndSwapCallback:PASSED'); + }); tester.addAsyncTest('glTerminatePPAPI', function(test) { testAndAssertStatus(test, 'Test_glTerminatePPAPI'); }); @@ -46,7 +54,7 @@ function setupTests(tester, plugin) { PPAPI PPB_Graphics3D Test - +

PPAPI PPB_Graphics3D Test

NOTE: requires --enable-pepper-testing --enable-accelerated-plugins
@@ -58,7 +66,7 @@ function setupTests(tester, plugin) { name="nacl_module" src="ppapi_ppb_graphics3d.nmf" style="background-color:#FFFFFF" - width="320" height="200" /> + width="80%" height="40%" />