diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-28 18:02:10 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-28 18:02:10 +0000 |
commit | 900b20d4a4d98d511989879f90ef78f26d77e60e (patch) | |
tree | eeab6121361ae55f2344ec8bf823aaef9b2fc0a3 /ppapi/cpp | |
parent | 37f858dbc0411f0b69f9a524ae6f4d89d3bc886b (diff) | |
download | chromium_src-900b20d4a4d98d511989879f90ef78f26d77e60e.zip chromium_src-900b20d4a4d98d511989879f90ef78f26d77e60e.tar.gz chromium_src-900b20d4a4d98d511989879f90ef78f26d77e60e.tar.bz2 |
Added ppapi::Surface3D. This CL completes the new Pepper3D interface. The implementation is still incomplete but all gpu demos still work!
Review URL: http://codereview.chromium.org/6047008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/dev/context_3d_dev.cc | 18 | ||||
-rw-r--r-- | ppapi/cpp/dev/context_3d_dev.h | 6 | ||||
-rw-r--r-- | ppapi/cpp/dev/surface_3d_dev.cc | 50 | ||||
-rw-r--r-- | ppapi/cpp/dev/surface_3d_dev.h | 37 | ||||
-rw-r--r-- | ppapi/cpp/instance.cc | 4 | ||||
-rw-r--r-- | ppapi/cpp/instance.h | 5 |
6 files changed, 100 insertions, 20 deletions
diff --git a/ppapi/cpp/dev/context_3d_dev.cc b/ppapi/cpp/dev/context_3d_dev.cc index 47f51ac..4847642 100644 --- a/ppapi/cpp/dev/context_3d_dev.cc +++ b/ppapi/cpp/dev/context_3d_dev.cc @@ -4,9 +4,8 @@ #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/dev/surface_3d_dev.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module_impl.h" @@ -18,10 +17,6 @@ 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) { @@ -36,8 +31,7 @@ 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>()) { + if (has_interface<PPB_Context3D_Dev>()) { PassRefFromConstructor(get_interface<PPB_Context3D_Dev>()->Create( instance.pp_instance(), config, @@ -46,13 +40,13 @@ Context3D_Dev::Context3D_Dev(const Instance& instance, } } -int32_t Context3D_Dev::SwapBuffers() const { +int32_t Context3D_Dev::BindSurfaces(const Surface3D_Dev& draw, + const Surface3D_Dev& read) { if (!has_interface<PPB_Context3D_Dev>()) return PP_ERROR_NOINTERFACE; - return get_interface<PPB_Context3D_Dev>()->SwapBuffers( - pp_resource(), - PP_BlockUntilComplete()); + return get_interface<PPB_Context3D_Dev>()->BindSurfaces( + pp_resource(), draw.pp_resource(), read.pp_resource()); } } // namespace pp diff --git a/ppapi/cpp/dev/context_3d_dev.h b/ppapi/cpp/dev/context_3d_dev.h index 51881f3..60521d0 100644 --- a/ppapi/cpp/dev/context_3d_dev.h +++ b/ppapi/cpp/dev/context_3d_dev.h @@ -12,7 +12,7 @@ namespace pp { -class CompletionCallback; +class Surface3D_Dev; class Context3D_Dev : public Resource { public: @@ -24,8 +24,8 @@ class Context3D_Dev : public Resource { const Context3D_Dev& share_context, const int32_t* attrib_list); - // TODO(alokp): Move to Surface3D. - int32_t SwapBuffers() const; + int32_t BindSurfaces(const Surface3D_Dev& draw, + const Surface3D_Dev& read); protected: explicit Context3D_Dev(PP_Resource resource_id) : Resource(resource_id) {} diff --git a/ppapi/cpp/dev/surface_3d_dev.cc b/ppapi/cpp/dev/surface_3d_dev.cc new file mode 100644 index 0000000..a222683 --- /dev/null +++ b/ppapi/cpp/dev/surface_3d_dev.cc @@ -0,0 +1,50 @@ +// 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/surface_3d_dev.h" + +#include "ppapi/c/pp_completion_callback.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_Surface3D_Dev>() { + return PPB_SURFACE_3D_DEV_INTERFACE; +} + +} // namespace + +Surface3D_Dev Surface3D_Dev::FromResource(PP_Resource resource_id) { + if (has_interface<PPB_Surface3D_Dev>() && + get_interface<PPB_Surface3D_Dev>()->IsSurface3D(resource_id)) + return Surface3D_Dev(resource_id); + + return Surface3D_Dev(); +} + +Surface3D_Dev::Surface3D_Dev(const Instance& instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) { + if (has_interface<PPB_Surface3D_Dev>()) { + PassRefFromConstructor(get_interface<PPB_Surface3D_Dev>()->Create( + instance.pp_instance(), + config, + attrib_list)); + } +} + +int32_t Surface3D_Dev::SwapBuffers() const { + if (!has_interface<PPB_Surface3D_Dev>()) + return PP_ERROR_NOINTERFACE; + + return get_interface<PPB_Surface3D_Dev>()->SwapBuffers( + pp_resource(), + PP_BlockUntilComplete()); +} + +} // namespace pp diff --git a/ppapi/cpp/dev/surface_3d_dev.h b/ppapi/cpp/dev/surface_3d_dev.h new file mode 100644 index 0000000..ff7c809 --- /dev/null +++ b/ppapi/cpp/dev/surface_3d_dev.h @@ -0,0 +1,37 @@ +// 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_SURFACE_3D_DEV_H_ +#define PPAPI_CPP_DEV_SURFACE_3D_DEV_H_ + +#include "ppapi/c/dev/ppb_surface_3d_dev.h" + +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class CompletionCallback; + +class Surface3D_Dev : public Resource { + public: + // Creates an is_null() Surface3D object. + Surface3D_Dev() {} + + Surface3D_Dev(const Instance& instance, + PP_Config3D_Dev config, + const int32_t* attrib_list); + + // TODO(alokp): Add completion callback. + int32_t SwapBuffers() const; + + protected: + explicit Surface3D_Dev(PP_Resource resource_id) : Resource(resource_id) {} + static Surface3D_Dev FromResource(PP_Resource resource_id); +}; + +} // namespace pp + +#endif // PPAPI_CPP_DEV_SURFACE_3D_DEV_H_ + diff --git a/ppapi/cpp/instance.cc b/ppapi/cpp/instance.cc index 369b277..72676d1 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/context_3d_dev.h" +#include "ppapi/cpp/dev/surface_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 Context3D_Dev& graphics) { +bool Instance::BindGraphics(const Surface3D_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 161d6b0..497189f 100644 --- a/ppapi/cpp/instance.h +++ b/ppapi/cpp/instance.h @@ -26,12 +26,12 @@ struct PP_InputEvent; namespace pp { class Graphics2D; -class Context3D_Dev; class ImageData; class Point; class Rect; class Rect; class Resource; +class Surface3D_Dev; class URLLoader; class Var; class Widget_Dev; @@ -89,8 +89,7 @@ class Instance { bool BindGraphics(const Graphics2D& graphics); /** See PPB_Instance.BindGraphics. */ - // TODO(alokp): Change it to Surface3D. - bool BindGraphics(const Context3D_Dev& graphics); + bool BindGraphics(const Surface3D_Dev& graphics); /** See PPB_Instance.IsFullFrame. */ bool IsFullFrame(); |