summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-06 22:55:47 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-06 22:55:47 +0000
commit6239d34076222cbfe1d42770c604822b0ba894f4 (patch)
treed873cdf138b002bb2d2d4a554ba4fcd210251760 /ppapi/shared_impl
parentc50a948dd9c07a71524949a28a5347e11d80da47 (diff)
downloadchromium_src-6239d34076222cbfe1d42770c604822b0ba894f4.zip
chromium_src-6239d34076222cbfe1d42770c604822b0ba894f4.tar.gz
chromium_src-6239d34076222cbfe1d42770c604822b0ba894f4.tar.bz2
This implements the new system for Graphics2D only.
This works by adding a new thunk layer that will forward to an "API" that's either per-instance (function APIs) or per-resource (resource APIs). The proxying and such is then implemented in terms of this C++ API. Ideally the trackers of the PP_Resource/PP_Instance -> object mapping would be shared between the plugin and renderer processes. To keep this patch under control, I did this as a virtual base class which is implemented by ppapi::proxy::PluginResourceTracker and webkit::ppapi::ResourceTracker. Later, the functionality of these objects should be shared in a common tracker class. Still to do it a lot of cleanup and merging of things. Also, the namespaces are a bit out of control. Review URL: http://codereview.chromium.org/6905088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r--ppapi/shared_impl/function_group_base.h33
-rw-r--r--ppapi/shared_impl/resource_object_base.h38
-rw-r--r--ppapi/shared_impl/tracker_base.cc25
-rw-r--r--ppapi/shared_impl/tracker_base.h49
4 files changed, 145 insertions, 0 deletions
diff --git a/ppapi/shared_impl/function_group_base.h b/ppapi/shared_impl/function_group_base.h
new file mode 100644
index 0000000..9b3f728
--- /dev/null
+++ b/ppapi/shared_impl/function_group_base.h
@@ -0,0 +1,33 @@
+// 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_SHARED_IMPL_FUNCTION_GROUP_BASE_H_
+#define PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_
+
+namespace ppapi {
+
+namespace thunk {
+class ResourceCreationAPI;
+}
+
+namespace shared_impl {
+
+class FunctionGroupBase {
+ public:
+ // Dynamic casting for this object. Returns the pointer to the given type if
+ // it's supported.
+ virtual thunk::ResourceCreationAPI* AsResourceCreation() { return NULL; }
+
+ template <typename T> T* GetAs() { return NULL; }
+};
+
+template<>
+inline thunk::ResourceCreationAPI* FunctionGroupBase::GetAs() {
+ return AsResourceCreation();
+}
+
+} // namespace shared_impl
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_
diff --git a/ppapi/shared_impl/resource_object_base.h b/ppapi/shared_impl/resource_object_base.h
new file mode 100644
index 0000000..50ba30d
--- /dev/null
+++ b/ppapi/shared_impl/resource_object_base.h
@@ -0,0 +1,38 @@
+// 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_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_
+#define PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_
+
+namespace ppapi {
+
+namespace thunk {
+class PPB_Graphics2D_API;
+class PPB_ImageData_API;
+}
+
+namespace shared_impl {
+
+class ResourceObjectBase {
+ public:
+
+ virtual thunk::PPB_Graphics2D_API* AsGraphics2D_API() { return NULL; }
+ virtual thunk::PPB_ImageData_API* AsImageData_API() { return NULL; }
+
+ template <typename T> T* GetAs() { return NULL; }
+};
+
+template<>
+inline thunk::PPB_Graphics2D_API* ResourceObjectBase::GetAs() {
+ return AsGraphics2D_API();
+}
+template<>
+inline thunk::PPB_ImageData_API* ResourceObjectBase::GetAs() {
+ return AsImageData_API();
+}
+
+} // namespace shared_impl
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_
diff --git a/ppapi/shared_impl/tracker_base.cc b/ppapi/shared_impl/tracker_base.cc
new file mode 100644
index 0000000..79c4b4e
--- /dev/null
+++ b/ppapi/shared_impl/tracker_base.cc
@@ -0,0 +1,25 @@
+// 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/shared_impl/tracker_base.h"
+
+#include "base/logging.h"
+
+namespace ppapi {
+namespace shared_impl {
+
+static TrackerBase* (*g_global_getter)() = NULL;
+
+// static
+void TrackerBase::Init(TrackerBase* (*getter)()) {
+ g_global_getter = getter;
+}
+
+// static
+TrackerBase* TrackerBase::Get() {
+ return g_global_getter();
+}
+
+} // namespace shared_impl
+} // namespace ppapi
diff --git a/ppapi/shared_impl/tracker_base.h b/ppapi/shared_impl/tracker_base.h
new file mode 100644
index 0000000..c44ee2b
--- /dev/null
+++ b/ppapi/shared_impl/tracker_base.h
@@ -0,0 +1,49 @@
+// 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_SHARED_IMPL_TRACKER_BASE_H_
+#define PPAPI_SHARED_IMPL_TRACKER_BASE_H_
+
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/proxy/interface_id.h"
+
+namespace ppapi {
+namespace shared_impl {
+
+class FunctionGroupBase;
+class ResourceObjectBase;
+
+// Tracks resource and function APIs, providing a mapping between ID and
+// object.
+// TODO(brettw) Eventually this should be one object with global tracking and
+// called "Tracker", and this would be used in both the plugin side of the
+// proxy as well as the implementation in the renderer. Currently, all this
+// does is forward to the process-type-specific tracker to get the information.
+class TrackerBase {
+ public:
+ // Must be called before any other function that uses the TrackerBase.
+ // This sets the getter that returns the global implmenetation of
+ // TrackerBase. It will be different for in the renderer and in the plugin
+ // process.
+ static void Init(TrackerBase*(*getter)());
+
+ // Retrieves the global tracker. This will be NULL if you haven't called
+ // Init() first (it should be unnecessary to NULL-check this).
+ static TrackerBase* Get();
+
+ // Returns the resource object corresponding to the given ID, or NULL if
+ // there isn't one.
+ virtual ResourceObjectBase* GetResourceAPI(PP_Resource res) = 0;
+
+ // Returns the function object corresponding to the given ID, or NULL if
+ // there isn't one.
+ virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
+ pp::proxy::InterfaceID id) = 0;
+};
+
+} // namespace shared_impl
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_TRACKER_BASE_H_