summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-28 18:02:10 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-28 18:02:10 +0000
commit900b20d4a4d98d511989879f90ef78f26d77e60e (patch)
treeeeab6121361ae55f2344ec8bf823aaef9b2fc0a3 /ppapi
parent37f858dbc0411f0b69f9a524ae6f4d89d3bc886b (diff)
downloadchromium_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')
-rw-r--r--ppapi/c/dev/ppb_context_3d_dev.h6
-rw-r--r--ppapi/c/dev/ppb_surface_3d_dev.h111
-rw-r--r--ppapi/cpp/dev/context_3d_dev.cc18
-rw-r--r--ppapi/cpp/dev/context_3d_dev.h6
-rw-r--r--ppapi/cpp/dev/surface_3d_dev.cc50
-rw-r--r--ppapi/cpp/dev/surface_3d_dev.h37
-rw-r--r--ppapi/cpp/instance.cc4
-rw-r--r--ppapi/cpp/instance.h5
-rw-r--r--ppapi/ppapi.gyp3
-rw-r--r--ppapi/tests/all_c_includes.h1
-rw-r--r--ppapi/tests/all_cpp_includes.h2
11 files changed, 218 insertions, 25 deletions
diff --git a/ppapi/c/dev/ppb_context_3d_dev.h b/ppapi/c/dev/ppb_context_3d_dev.h
index 79969a3..11a3b66 100644
--- a/ppapi/c/dev/ppb_context_3d_dev.h
+++ b/ppapi/c/dev/ppb_context_3d_dev.h
@@ -92,7 +92,7 @@ struct PPB_Context3D_Dev {
// - PP_GRAPHICS3DERROR_BAD_CONTEXT: if context is not a valid context.
// - PP_GRAPHICS3DERROR_BAD_SURFACE: if either draw or read are not valid
// surfaces.
- // - PP_GRAPHICS3DERROR_BAD_MATCH:fIf draw and read cannot fit into
+ // - PP_GRAPHICS3DERROR_BAD_MATCH: if draw and read cannot fit into
// graphics memory simultaneously.
// - PP_ERROR_NOMEMORY: if the ancillary buffers for draw and read cannot
// be allocated.
@@ -119,10 +119,6 @@ struct PPB_Context3D_Dev {
int32_t (*GetBoundSurfaces)(PP_Resource context,
PP_Resource* draw,
PP_Resource* read);
-
- // TODO(alokp): Move to PPB_Surface3D_Dev
- int32_t (*SwapBuffers)(PP_Resource context,
- struct PP_CompletionCallback callback);
};
#endif // PPAPI_C_DEV_PPB_CONTEXT_3D_DEV_H_
diff --git a/ppapi/c/dev/ppb_surface_3d_dev.h b/ppapi/c/dev/ppb_surface_3d_dev.h
new file mode 100644
index 0000000..9618bdd
--- /dev/null
+++ b/ppapi/c/dev/ppb_surface_3d_dev.h
@@ -0,0 +1,111 @@
+/* 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_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_instance.h"
+#include "ppapi/c/pp_resource.h"
+
+#define PPB_SURFACE_3D_DEV_INTERFACE "PPB_Surface3D(Dev);0.1"
+
+struct PPB_Surface3D_Dev {
+ // Creates a render surface and returns a handle to it.
+ // Any PPB_Context3D_Dev created with a compatible PP_Config3D_Dev
+ // can be used to render into this surface. The returned surface is
+ // off-screen to start with. It must be attached to a plugin instance
+ // using PPB_Instance::BindGraphics to draw on the web page.
+ //
+ // attrib_list specifies a list of attributes for the surface. The list has
+ // the same structure as described for PPB_Graphics3D_Dev::GetConfigAttribs.
+ // Attributes that can be specified in attrib_list include:
+ // - PP_GRAPHICS3DATTRIB_WIDTH
+ // - PP_GRAPHICS3DATTRIB_HEIGHT
+ // - PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: If true, creates the largest
+ // possible surface when the allocation of the surface would otherwise fail.
+ // The width and height of the allocated surface will never exceed the
+ // values of PP_GRAPHICS3DATTRIB_WIDTH and PP_GRAPHICS3DATTRIB_HEIGHT,
+ // respectively. If this option is used, PPB_Surface3D_Dev::GetAttrib
+ // can be used to retrieve surface dimensions.
+ // - PP_GRAPHICS3DATTRIB_RENDER_BUFFER
+ PP_Resource (*Create)(PP_Instance instance,
+ PP_Config3D_Dev config,
+ const int32_t* attrib_list);
+
+ // Returns PP_TRUE if the given resource is a valid Surface3D, PP_FALSE if it
+ // is an invalid resource or is a resource of another type.
+ PP_Bool (*IsSurface3D)(PP_Resource resource);
+
+ // Sets an attribute for PPB_Surface3D_Dev. The specified attribute of
+ // surface is set to value. Attributes that can be specified are:
+ // - PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE: If value
+ // is PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX, and the
+ // PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface does
+ // not contain PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX_BIT, a
+ // PP_GRAPHICS3DERROR_BAD_MATCH error is returned.
+ // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: If value is
+ // PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED, and the
+ // PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface
+ // does not contain PP_GRAPHICS3DATTRIBVALUE_SWAP_BEHAVIOR_PRESERVED_BIT,
+ // a PP_GRAPHICS3DERROR_BAD_MATCH error is returned.
+ int32_t (*SetAttrib)(PP_Resource surface,
+ int32_t attribute,
+ int32_t value);
+
+ // Retrieves the value of attribute for surface. Attributes that can be
+ // queried for are:
+ // - PP_GRAPHICS3DATTRIB_CONFIG_ID: returns the ID of the
+ // PP_Config3D_Dev with respect to which the surface was created.
+ // - PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: returns the same attribute value
+ // specified when the surface was created with PPB_Surface3D_Dev::Create.
+ // - PP_GRAPHICS3DATTRIB_WIDTH and PP_GRAPHICS3DATTRIB_HEIGHT: The returned
+ // size may be less than the requested size if
+ // PP_GRAPHICS3DATTRIB_LARGEST_SURFACE is true.
+ // - PP_GRAPHICS3DATTRIB_RENDER_BUFFER
+ // - PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE
+ // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR
+ //
+ // If attribute is not a valid PPB_Surface3D_Dev surface attribute,
+ // then an PP_GRAPHICS3DERROR_BAD_ATTRIBUTE error is returned. If surface
+ // is not a valid PPB_Surface3D_Dev then an PP_GRAPHICS3DERROR_BAD_SURFACE
+ // error is returned.
+ int32_t (*GetAttrib)(PP_Resource surface,
+ int32_t attribute,
+ int32_t* value);
+
+ // 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 surface is not PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED.
+ //
+ // If surface is bound as the draw surface of a context then SwapBuffers
+ // performs an implicit flush operation on the context.
+ //
+ // This functions can run in two modes:
+ // - In synchronous mode, you specify NULL for the callback and the callback
+ // data. This function will block the calling thread until the image has
+ // been painted to the screen. It is not legal to block the main thread of
+ // the plugin, you can use synchronous mode only from background threads.
+ // - In asynchronous mode, you specify a callback function and the argument
+ // for that callback function. The callback function will be executed on
+ // the calling thread when the image has been painted to the screen. While
+ // you are waiting for a Flush callback, additional calls to Flush 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.
+ //
+ int32_t (*SwapBuffers)(PP_Resource surface,
+ struct PP_CompletionCallback callback);
+};
+
+#endif // PPAPI_C_DEV_PPB_SURFACE_3D_DEV_H_
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();
diff --git a/ppapi/ppapi.gyp b/ppapi/ppapi.gyp
index 0bc5ea0..c8ce7d1 100644
--- a/ppapi/ppapi.gyp
+++ b/ppapi/ppapi.gyp
@@ -87,6 +87,7 @@
'c/dev/ppb_graphics_3d_dev.h',
'c/dev/ppb_opengles_dev.h',
'c/dev/ppb_scrollbar_dev.h',
+ 'c/dev/ppb_surface_3d_dev.h',
'c/dev/ppb_testing_dev.h',
'c/dev/ppb_transport_dev.h',
'c/dev/ppb_url_util_dev.h',
@@ -196,6 +197,8 @@
'cpp/dev/scrollbar_dev.h',
'cpp/dev/selection_dev.cc',
'cpp/dev/selection_dev.h',
+ 'cpp/dev/surface_3d_dev.cc',
+ 'cpp/dev/surface_3d_dev.h',
'cpp/dev/transport_dev.cc',
'cpp/dev/transport_dev.h',
'cpp/dev/url_util_dev.cc',
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index 3661bfc..fde2c02 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -32,6 +32,7 @@
#include "ppapi/c/dev/ppb_graphics_3d_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"
#include "ppapi/c/dev/ppb_transport_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index b9e634a..c835195 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -14,6 +14,7 @@
#include "ppapi/cpp/dev/audio_config_dev.h"
#include "ppapi/cpp/dev/audio_dev.h"
#include "ppapi/cpp/dev/buffer_dev.h"
+#include "ppapi/cpp/dev/context_3d_dev.h"
#include "ppapi/cpp/dev/directory_entry_dev.h"
#include "ppapi/cpp/dev/directory_reader_dev.h"
#include "ppapi/cpp/dev/file_chooser_dev.h"
@@ -29,6 +30,7 @@
#include "ppapi/cpp/dev/scriptable_object_deprecated.h"
#include "ppapi/cpp/dev/scrollbar_dev.h"
#include "ppapi/cpp/dev/selection_dev.h"
+#include "ppapi/cpp/dev/surface_3d_dev.h"
#include "ppapi/cpp/dev/transport_dev.h"
#include "ppapi/cpp/dev/url_util_dev.h"
#include "ppapi/cpp/dev/video_decoder_dev.h"