diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 04:51:52 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 04:51:52 +0000 |
commit | be8fd116e295fd7ef6c75e4dd717017d68c7fd57 (patch) | |
tree | c6ef9e02c1e60d189ead67e9a7ce90f01c8da2e8 /ppapi/cpp | |
parent | 79cc8d9d943c79c2e5237265591d36b884470fbf (diff) | |
download | chromium_src-be8fd116e295fd7ef6c75e4dd717017d68c7fd57.zip chromium_src-be8fd116e295fd7ef6c75e4dd717017d68c7fd57.tar.gz chromium_src-be8fd116e295fd7ef6c75e4dd717017d68c7fd57.tar.bz2 |
Added ppapi::Context3D interface. The API has already been reviewed. I am adding the new API incrementally so as not to break the demos.
Review URL: http://codereview.chromium.org/6062003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/dev/context_3d_dev.cc | 58 | ||||
-rw-r--r-- | ppapi/cpp/dev/context_3d_dev.h | 38 | ||||
-rw-r--r-- | ppapi/cpp/dev/graphics_3d_dev.cc | 94 | ||||
-rw-r--r-- | ppapi/cpp/dev/graphics_3d_dev.h | 40 | ||||
-rw-r--r-- | ppapi/cpp/instance.cc | 4 | ||||
-rw-r--r-- | ppapi/cpp/instance.h | 5 |
6 files changed, 131 insertions, 108 deletions
diff --git a/ppapi/cpp/dev/context_3d_dev.cc b/ppapi/cpp/dev/context_3d_dev.cc new file mode 100644 index 0000000..47f51ac --- /dev/null +++ b/ppapi/cpp/dev/context_3d_dev.cc @@ -0,0 +1,58 @@ +// 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/context_3d_dev.h" + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/dev/ppb_opengles_dev.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_Context3D_Dev>() { + return PPB_CONTEXT_3D_DEV_INTERFACE; +} + +template <> const char* interface_name<PPB_OpenGLES2_Dev>() { + return PPB_OPENGLES2_DEV_INTERFACE; +} + +} // namespace + +Context3D_Dev Context3D_Dev::FromResource(PP_Resource resource_id) { + if (has_interface<PPB_Context3D_Dev>() && + get_interface<PPB_Context3D_Dev>()->IsContext3D(resource_id)) + return Context3D_Dev(resource_id); + + return Context3D_Dev(); +} + +Context3D_Dev::Context3D_Dev(const Instance& instance, + PP_Config3D_Dev config, + const Context3D_Dev& share_context, + const int32_t* attrib_list) { + if (has_interface<PPB_Context3D_Dev>() && + has_interface<PPB_OpenGLES2_Dev>()) { + PassRefFromConstructor(get_interface<PPB_Context3D_Dev>()->Create( + instance.pp_instance(), + config, + share_context.pp_resource(), + attrib_list)); + } +} + +int32_t Context3D_Dev::SwapBuffers() const { + if (!has_interface<PPB_Context3D_Dev>()) + return PP_ERROR_NOINTERFACE; + + return get_interface<PPB_Context3D_Dev>()->SwapBuffers( + pp_resource(), + PP_BlockUntilComplete()); +} + +} // namespace pp diff --git a/ppapi/cpp/dev/context_3d_dev.h b/ppapi/cpp/dev/context_3d_dev.h new file mode 100644 index 0000000..51881f3 --- /dev/null +++ b/ppapi/cpp/dev/context_3d_dev.h @@ -0,0 +1,38 @@ +// 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_DEV_H_ +#define PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_ + +#include "ppapi/c/dev/ppb_context_3d_dev.h" + +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class CompletionCallback; + +class Context3D_Dev : public Resource { + public: + // Creates an is_null() Context3D object. + Context3D_Dev() {} + + Context3D_Dev(const Instance& instance, + PP_Config3D_Dev config, + const Context3D_Dev& share_context, + const int32_t* attrib_list); + + // TODO(alokp): Move to Surface3D. + int32_t SwapBuffers() const; + + protected: + explicit Context3D_Dev(PP_Resource resource_id) : Resource(resource_id) {} + static Context3D_Dev FromResource(PP_Resource resource_id); +}; + +} // namespace pp + +#endif // PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_ + diff --git a/ppapi/cpp/dev/graphics_3d_dev.cc b/ppapi/cpp/dev/graphics_3d_dev.cc index 579b610..f0a587e 100644 --- a/ppapi/cpp/dev/graphics_3d_dev.cc +++ b/ppapi/cpp/dev/graphics_3d_dev.cc @@ -4,11 +4,9 @@ #include "ppapi/cpp/dev/graphics_3d_dev.h" -#include "ppapi/cpp/common.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/resource.h" -#include "ppapi/cpp/module.h" +#include "ppapi/c/pp_errors.h" #include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/var.h" namespace pp { @@ -18,87 +16,37 @@ template <> const char* interface_name<PPB_Graphics3D_Dev>() { return PPB_GRAPHICS_3D_DEV_INTERFACE; } -template <> const char* interface_name<PPB_OpenGLES2_Dev>() { - return PPB_OPENGLES2_DEV_INTERFACE; -} - } // namespace // static -bool Graphics3D_Dev::GetConfigs(int32_t *configs, int32_t config_size, - int32_t *num_config) { - if (has_interface<PPB_Graphics3D_Dev>()) { - return PPBoolToBool(get_interface<PPB_Graphics3D_Dev>()->GetConfigs( - configs, config_size, num_config)); - } - return false; -} +int32_t Graphics3D_Dev::GetConfigs(int32_t *configs, + int32_t config_size, + int32_t *num_config) { + if (!has_interface<PPB_Graphics3D_Dev>()) + return PP_ERROR_NOINTERFACE; -// static -bool Graphics3D_Dev::ChooseConfig(const int32_t *attrib_list, int32_t *configs, - int32_t config_size, int32_t *num_config) { - if (has_interface<PPB_Graphics3D_Dev>()) { - return PPBoolToBool(get_interface<PPB_Graphics3D_Dev>()->ChooseConfig( - attrib_list, configs, config_size, num_config)); - } - return false; + return get_interface<PPB_Graphics3D_Dev>()->GetConfigs( + configs, config_size, num_config); } // static -bool Graphics3D_Dev::GetConfigAttrib(int32_t config, int32_t attribute, - int32_t *value) { - if (has_interface<PPB_Graphics3D_Dev>()) { - return PPBoolToBool(get_interface<PPB_Graphics3D_Dev>()->GetConfigAttrib( - config, attribute, value)); - } - return false; -} +int32_t Graphics3D_Dev::GetConfigAttribs(PP_Config3D_Dev config, + int32_t* attrib_list) { + if (!has_interface<PPB_Graphics3D_Dev>()) + return PP_ERROR_NOINTERFACE; -// static -const char* Graphics3D_Dev::QueryString(int32_t name) { - if (has_interface<PPB_Graphics3D_Dev>()) - return get_interface<PPB_Graphics3D_Dev>()->QueryString(name); - return NULL; + return get_interface<PPB_Graphics3D_Dev>()->GetConfigAttribs( + config, attrib_list); } // static -void* Graphics3D_Dev::GetProcAddress(const char* name) { - if (has_interface<PPB_Graphics3D_Dev>()) - return get_interface<PPB_Graphics3D_Dev>()->GetProcAddress(name); - return NULL; -} - -Graphics3D_Dev Graphics3D_Dev::FromResource(PP_Resource resource_id) { - if (has_interface<PPB_Graphics3D_Dev>() && - get_interface<PPB_Graphics3D_Dev>()->IsGraphics3D(resource_id)) - return Graphics3D_Dev(resource_id); - return Graphics3D_Dev(); -} - -uint32_t Graphics3D_Dev::GetError() { - if (has_interface<PPB_Graphics3D_Dev>()) - return get_interface<PPB_Graphics3D_Dev>()->GetError(); - return PP_GRAPHICS_3D_ERROR_NOT_INITIALIZED; -} - -const PPB_OpenGLES2_Dev* Graphics3D_Dev::GetImplementation() { - return get_interface<PPB_OpenGLES2_Dev>(); -} - -Graphics3D_Dev::Graphics3D_Dev(const Instance& instance, - int32_t config, - int32_t share_context, - const int32_t* attrib_list) { - if (has_interface<PPB_Graphics3D_Dev>() && - has_interface<PPB_OpenGLES2_Dev>()) { - PassRefFromConstructor(get_interface<PPB_Graphics3D_Dev>()->CreateContext( - instance.pp_instance(), config, share_context, attrib_list)); - } -} +Var Graphics3D_Dev::GetString(int32_t name) { + if (!has_interface<PPB_Graphics3D_Dev>()) + return Var(); -bool Graphics3D_Dev::SwapBuffers() const { - return has_interface<PPB_Graphics3D_Dev>() && - get_interface<PPB_Graphics3D_Dev>()->SwapBuffers(pp_resource()); + return Var(Var::PassRef(), + get_interface<PPB_Graphics3D_Dev>()->GetString(name)); } } // namespace pp + diff --git a/ppapi/cpp/dev/graphics_3d_dev.h b/ppapi/cpp/dev/graphics_3d_dev.h index 43bd0b0..dece4c0 100644 --- a/ppapi/cpp/dev/graphics_3d_dev.h +++ b/ppapi/cpp/dev/graphics_3d_dev.h @@ -6,43 +6,21 @@ #define PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_ #include "ppapi/c/dev/ppb_graphics_3d_dev.h" -#include "ppapi/c/dev/ppb_opengles_dev.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/resource.h" namespace pp { -class Graphics3D_Dev : public Resource { - public: - static bool GetConfigs(int32_t* configs, int32_t config_size, - int32_t* num_config); - - static bool ChooseConfig(const int32_t* attrib_list, int32_t* configs, - int32_t config_size, int32_t* num_config); - - static bool GetConfigAttrib(int32_t config, int32_t attribute, - int32_t* value); - - static const char* QueryString(int32_t name); +class Var; - static void* GetProcAddress(const char* name); - - static uint32_t GetError(); - static const PPB_OpenGLES2_Dev* GetImplementation(); - - // Creates an is_null() Graphics3D object. - Graphics3D_Dev() {} - - Graphics3D_Dev(const Instance& instance, - int32_t config, - int32_t share_context, - const int32_t* attrib_list); +class Graphics3D_Dev { + public: + static int32_t GetConfigs(PP_Config3D_Dev* configs, + int32_t config_size, + int32_t* num_config); - bool SwapBuffers() const; + static int32_t GetConfigAttribs(PP_Config3D_Dev config, + int32_t* attrib_list); - protected: - explicit Graphics3D_Dev(PP_Resource resource_id) : Resource(resource_id) {} - static Graphics3D_Dev FromResource(PP_Resource resource_id); + static Var GetString(int32_t name); }; } // namespace pp diff --git a/ppapi/cpp/instance.cc b/ppapi/cpp/instance.cc index 379518d..369b277 100644 --- a/ppapi/cpp/instance.cc +++ b/ppapi/cpp/instance.cc @@ -7,7 +7,7 @@ #include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/cpp/common.h" -#include "ppapi/cpp/dev/graphics_3d_dev.h" +#include "ppapi/cpp/dev/context_3d_dev.h" #include "ppapi/cpp/graphics_2d.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/logging.h" @@ -91,7 +91,7 @@ bool Instance::BindGraphics(const Graphics2D& graphics) { pp_instance(), graphics.pp_resource())); } -bool Instance::BindGraphics(const Graphics3D_Dev& graphics) { +bool Instance::BindGraphics(const Context3D_Dev& graphics) { if (!has_interface<PPB_Instance>()) return false; return PPBoolToBool(get_interface<PPB_Instance>()->BindGraphics( diff --git a/ppapi/cpp/instance.h b/ppapi/cpp/instance.h index d74995e..161d6b0 100644 --- a/ppapi/cpp/instance.h +++ b/ppapi/cpp/instance.h @@ -26,7 +26,7 @@ struct PP_InputEvent; namespace pp { class Graphics2D; -class Graphics3D_Dev; +class Context3D_Dev; class ImageData; class Point; class Rect; @@ -89,7 +89,8 @@ class Instance { bool BindGraphics(const Graphics2D& graphics); /** See PPB_Instance.BindGraphics. */ - bool BindGraphics(const Graphics3D_Dev& graphics); + // TODO(alokp): Change it to Surface3D. + bool BindGraphics(const Context3D_Dev& graphics); /** See PPB_Instance.IsFullFrame. */ bool IsFullFrame(); |