summaryrefslogtreecommitdiffstats
path: root/mojo/examples/pepper_container_app
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-22 04:11:12 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-22 04:11:12 +0000
commit6bcc45b3c23fdc5df364b122d88609eec2d52e7e (patch)
tree999fc49bc92b5bb0a82825cb42e9525179880fc7 /mojo/examples/pepper_container_app
parentc0ff5f4f54073f3952838e3a360dfaabecf1f570 (diff)
downloadchromium_src-6bcc45b3c23fdc5df364b122d88609eec2d52e7e.zip
chromium_src-6bcc45b3c23fdc5df364b122d88609eec2d52e7e.tar.gz
chromium_src-6bcc45b3c23fdc5df364b122d88609eec2d52e7e.tar.bz2
Currently it automatically loads pepper_spinning_cube_demo and only supports those APIs that needed by it.
BUG=None TEST=None Review URL: https://codereview.chromium.org/178953003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258773 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/examples/pepper_container_app')
-rw-r--r--mojo/examples/pepper_container_app/DEPS6
-rw-r--r--mojo/examples/pepper_container_app/graphics_3d_resource.cc170
-rw-r--r--mojo/examples/pepper_container_app/graphics_3d_resource.h74
-rw-r--r--mojo/examples/pepper_container_app/interface_list.cc50
-rw-r--r--mojo/examples/pepper_container_app/interface_list.h37
-rw-r--r--mojo/examples/pepper_container_app/mojo_ppapi_globals.cc183
-rw-r--r--mojo/examples/pepper_container_app/mojo_ppapi_globals.h90
-rw-r--r--mojo/examples/pepper_container_app/pepper_container_app.cc134
-rw-r--r--mojo/examples/pepper_container_app/plugin_instance.cc378
-rw-r--r--mojo/examples/pepper_container_app/plugin_instance.h167
-rw-r--r--mojo/examples/pepper_container_app/plugin_module.cc111
-rw-r--r--mojo/examples/pepper_container_app/plugin_module.h61
-rw-r--r--mojo/examples/pepper_container_app/ppb_core_thunk.cc64
-rw-r--r--mojo/examples/pepper_container_app/ppb_opengles2_thunk.cc1454
-rw-r--r--mojo/examples/pepper_container_app/resource_creation_impl.cc393
-rw-r--r--mojo/examples/pepper_container_app/resource_creation_impl.h174
-rw-r--r--mojo/examples/pepper_container_app/thunk.h20
-rw-r--r--mojo/examples/pepper_container_app/type_converters.h67
18 files changed, 3633 insertions, 0 deletions
diff --git a/mojo/examples/pepper_container_app/DEPS b/mojo/examples/pepper_container_app/DEPS
new file mode 100644
index 0000000..b1e8ef3
--- /dev/null
+++ b/mojo/examples/pepper_container_app/DEPS
@@ -0,0 +1,6 @@
+include_rules = [
+ "+base",
+ "+ppapi/c",
+ "+ppapi/shared_impl",
+ "+ppapi/thunk",
+]
diff --git a/mojo/examples/pepper_container_app/graphics_3d_resource.cc b/mojo/examples/pepper_container_app/graphics_3d_resource.cc
new file mode 100644
index 0000000..334c5ef
--- /dev/null
+++ b/mojo/examples/pepper_container_app/graphics_3d_resource.cc
@@ -0,0 +1,170 @@
+// Copyright 2014 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 "mojo/examples/pepper_container_app/graphics_3d_resource.h"
+
+#include "base/logging.h"
+#include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h"
+#include "mojo/examples/pepper_container_app/plugin_instance.h"
+#include "mojo/public/gles2/gles2.h"
+#include "ppapi/c/pp_errors.h"
+
+namespace mojo {
+namespace examples {
+
+namespace {
+
+gpu::CommandBuffer::State GetErrorState() {
+ gpu::CommandBuffer::State error_state;
+ error_state.error = gpu::error::kGenericError;
+ return error_state;
+}
+
+} // namespace
+
+Graphics3DResource::Graphics3DResource(PP_Instance instance)
+ : Resource(ppapi::OBJECT_IS_IMPL, instance) {
+ ScopedMessagePipeHandle pipe = MojoPpapiGlobals::Get()->CreateGLES2Context();
+ context_ = MojoGLES2CreateContext(pipe.release().value(),
+ &ContextLostThunk,
+ &DrawAnimationFrameThunk,
+ this);
+}
+
+Graphics3DResource::~Graphics3DResource() {
+ MojoGLES2DestroyContext(context_);
+}
+
+bool Graphics3DResource::IsBoundGraphics() const {
+ PluginInstance* plugin_instance =
+ MojoPpapiGlobals::Get()->GetInstance(pp_instance());
+ return plugin_instance && plugin_instance->IsBoundGraphics(pp_resource());
+}
+
+void Graphics3DResource::BindGraphics() {
+ MojoGLES2MakeCurrent(context_);
+}
+
+ppapi::thunk::PPB_Graphics3D_API* Graphics3DResource::AsPPB_Graphics3D_API() {
+ return this;
+}
+
+int32_t Graphics3DResource::GetAttribs(int32_t attrib_list[]) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+int32_t Graphics3DResource::SetAttribs(const int32_t attrib_list[]) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+int32_t Graphics3DResource::GetError() {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+int32_t Graphics3DResource::ResizeBuffers(int32_t width, int32_t height) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+int32_t Graphics3DResource::SwapBuffers(
+ scoped_refptr<ppapi::TrackedCallback> callback) {
+ if (!IsBoundGraphics())
+ return PP_ERROR_FAILED;
+
+ MojoGLES2SwapBuffers();
+ return PP_OK;
+}
+
+int32_t Graphics3DResource::GetAttribMaxValue(int32_t attribute,
+ int32_t* value) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+PP_Bool Graphics3DResource::SetGetBuffer(int32_t shm_id) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+gpu::CommandBuffer::State Graphics3DResource::GetState() {
+ NOTIMPLEMENTED();
+ return GetErrorState();
+}
+
+int32_t Graphics3DResource::CreateTransferBuffer(uint32_t size) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Bool Graphics3DResource::DestroyTransferBuffer(int32_t id) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Bool Graphics3DResource::GetTransferBuffer(int32_t id,
+ int* shm_handle,
+ uint32_t* shm_size) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Bool Graphics3DResource::Flush(int32_t put_offset) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+gpu::CommandBuffer::State Graphics3DResource::WaitForTokenInRange(int32_t start,
+ int32_t end) {
+ NOTIMPLEMENTED();
+ return GetErrorState();
+}
+
+gpu::CommandBuffer::State Graphics3DResource::WaitForGetOffsetInRange(
+ int32_t start, int32_t end) {
+ NOTIMPLEMENTED();
+ return GetErrorState();
+}
+
+void* Graphics3DResource::MapTexSubImage2DCHROMIUM(GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ GLenum access) {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+void Graphics3DResource::UnmapTexSubImage2DCHROMIUM(const void* mem) {
+ NOTIMPLEMENTED();
+}
+
+uint32_t Graphics3DResource::InsertSyncPoint() {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+void Graphics3DResource::ContextLostThunk(void* closure) {
+ static_cast<Graphics3DResource*>(closure)->ContextLost();
+}
+
+void Graphics3DResource::DrawAnimationFrameThunk(void* closure) {
+ // TODO(yzshen): Use this notification to drive the SwapBuffers() callback.
+}
+
+void Graphics3DResource::ContextLost() {
+ PluginInstance* plugin_instance =
+ MojoPpapiGlobals::Get()->GetInstance(pp_instance());
+ if (plugin_instance)
+ plugin_instance->Graphics3DContextLost();
+}
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/graphics_3d_resource.h b/mojo/examples/pepper_container_app/graphics_3d_resource.h
new file mode 100644
index 0000000..6359a45
--- /dev/null
+++ b/mojo/examples/pepper_container_app/graphics_3d_resource.h
@@ -0,0 +1,74 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_GRAPHICS_3D_RESOURCE_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_GRAPHICS_3D_RESOURCE_H_
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "mojo/public/gles2/gles2_types.h"
+#include "ppapi/shared_impl/resource.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/ppb_graphics_3d_api.h"
+
+namespace mojo {
+namespace examples {
+
+class Graphics3DResource : public ppapi::Resource,
+ public ppapi::thunk::PPB_Graphics3D_API {
+ public:
+ explicit Graphics3DResource(PP_Instance instance);
+ virtual ~Graphics3DResource();
+
+ bool IsBoundGraphics() const;
+ void BindGraphics();
+
+ // ppapi::Resource overrides.
+ virtual ppapi::thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE;
+
+ // ppapi::thunk::PPB_Graphics3D_API implementation.
+ virtual int32_t GetAttribs(int32_t attrib_list[]) OVERRIDE;
+ virtual int32_t SetAttribs(const int32_t attrib_list[]) OVERRIDE;
+ virtual int32_t GetError() OVERRIDE;
+ virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE;
+ virtual int32_t SwapBuffers(
+ scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) OVERRIDE;
+ virtual PP_Bool SetGetBuffer(int32_t shm_id) OVERRIDE;
+ virtual gpu::CommandBuffer::State GetState() OVERRIDE;
+ virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE;
+ virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
+ virtual PP_Bool GetTransferBuffer(int32_t id,
+ int* shm_handle,
+ uint32_t* shm_size) OVERRIDE;
+ virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
+ virtual gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
+ int32_t end) OVERRIDE;
+ virtual gpu::CommandBuffer::State WaitForGetOffsetInRange(
+ int32_t start, int32_t end) OVERRIDE;
+ virtual void* MapTexSubImage2DCHROMIUM(GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ GLenum access) OVERRIDE;
+ virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE;
+ virtual uint32_t InsertSyncPoint() OVERRIDE;
+
+ private:
+ static void ContextLostThunk(void* closure);
+ static void DrawAnimationFrameThunk(void* closure);
+ void ContextLost();
+
+ MojoGLES2Context context_;
+ DISALLOW_COPY_AND_ASSIGN(Graphics3DResource);
+};
+
+} // namespace examples
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_GRAPHICS_3D_RESOURCE_H_
diff --git a/mojo/examples/pepper_container_app/interface_list.cc b/mojo/examples/pepper_container_app/interface_list.cc
new file mode 100644
index 0000000..7f4d2ea
--- /dev/null
+++ b/mojo/examples/pepper_container_app/interface_list.cc
@@ -0,0 +1,50 @@
+// Copyright 2014 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 "mojo/examples/pepper_container_app/interface_list.h"
+
+#include "base/memory/singleton.h"
+#include "mojo/examples/pepper_container_app/thunk.h"
+#include "ppapi/c/ppb_core.h"
+#include "ppapi/c/ppb_graphics_3d.h"
+#include "ppapi/c/ppb_instance.h"
+#include "ppapi/c/ppb_opengles2.h"
+#include "ppapi/c/ppb_view.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace mojo {
+namespace examples {
+
+InterfaceList::InterfaceList() {
+ browser_interfaces_[PPB_CORE_INTERFACE_1_0] = GetPPB_Core_1_0_Thunk();
+ browser_interfaces_[PPB_GRAPHICS_3D_INTERFACE_1_0] =
+ ppapi::thunk::GetPPB_Graphics3D_1_0_Thunk();
+ browser_interfaces_[PPB_OPENGLES2_INTERFACE_1_0] =
+ GetPPB_OpenGLES2_Thunk();
+ browser_interfaces_[PPB_INSTANCE_INTERFACE_1_0] =
+ ppapi::thunk::GetPPB_Instance_1_0_Thunk();
+ browser_interfaces_[PPB_VIEW_INTERFACE_1_0] =
+ ppapi::thunk::GetPPB_View_1_0_Thunk();
+ browser_interfaces_[PPB_VIEW_INTERFACE_1_1] =
+ ppapi::thunk::GetPPB_View_1_1_Thunk();
+}
+
+InterfaceList::~InterfaceList() {}
+
+// static
+InterfaceList* InterfaceList::GetInstance() {
+ return Singleton<InterfaceList>::get();
+}
+
+const void* InterfaceList::GetBrowserInterface(const std::string& name) const {
+ NameToInterfaceMap::const_iterator iter = browser_interfaces_.find(name);
+
+ if (iter == browser_interfaces_.end())
+ return NULL;
+
+ return iter->second;
+}
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/interface_list.h b/mojo/examples/pepper_container_app/interface_list.h
new file mode 100644
index 0000000..5cff06c
--- /dev/null
+++ b/mojo/examples/pepper_container_app/interface_list.h
@@ -0,0 +1,37 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_INTERFACE_LIST_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_INTERFACE_LIST_H_
+
+#include <map>
+#include <string>
+
+#include "base/macros.h"
+
+namespace mojo {
+namespace examples {
+
+// InterfaceList maintains the mapping from Pepper interface names to
+// interface pointers.
+class InterfaceList {
+ public:
+ InterfaceList();
+ ~InterfaceList();
+
+ static InterfaceList* GetInstance();
+
+ const void* GetBrowserInterface(const std::string& name) const;
+
+ private:
+ typedef std::map<std::string, const void*> NameToInterfaceMap;
+ NameToInterfaceMap browser_interfaces_;
+
+ DISALLOW_COPY_AND_ASSIGN(InterfaceList);
+};
+
+} // namespace examples
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_INTERFACE_LIST_H_
diff --git a/mojo/examples/pepper_container_app/mojo_ppapi_globals.cc b/mojo/examples/pepper_container_app/mojo_ppapi_globals.cc
new file mode 100644
index 0000000..e5b13f2
--- /dev/null
+++ b/mojo/examples/pepper_container_app/mojo_ppapi_globals.cc
@@ -0,0 +1,183 @@
+// Copyright 2014 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 "mojo/examples/pepper_container_app/mojo_ppapi_globals.h"
+
+#include "base/logging.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "base/time/time.h"
+#include "mojo/examples/pepper_container_app/plugin_instance.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/ppb_message_loop_shared.h"
+
+namespace mojo {
+namespace examples {
+
+namespace {
+
+const PP_Instance kInstanceId = 1;
+
+} // namespace
+
+// A non-abstract subclass of ppapi::MessageLoopShared that represents the
+// message loop of the main thread.
+// TODO(yzshen): Build a more general ppapi::MessageLoopShared subclass to fully
+// support PPB_MessageLoop.
+class MojoPpapiGlobals::MainThreadMessageLoopResource
+ : public ppapi::MessageLoopShared {
+ public:
+ explicit MainThreadMessageLoopResource(
+ base::MessageLoopProxy* main_thread_message_loop)
+ : MessageLoopShared(ForMainThread()),
+ main_thread_message_loop_(main_thread_message_loop) {}
+ virtual ~MainThreadMessageLoopResource() {}
+
+ // ppapi::MessageLoopShared implementation.
+ virtual void PostClosure(const tracked_objects::Location& from_here,
+ const base::Closure& closure,
+ int64 delay_ms) OVERRIDE {
+ main_thread_message_loop_->PostDelayedTask(
+ from_here, closure, base::TimeDelta::FromMilliseconds(delay_ms));
+ }
+
+ virtual base::MessageLoopProxy* GetMessageLoopProxy() OVERRIDE {
+ return main_thread_message_loop_.get();
+ }
+
+ // ppapi::thunk::PPB_MessageLoop_API implementation.
+ virtual int32_t AttachToCurrentThread() OVERRIDE {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+ }
+
+ virtual int32_t Run() OVERRIDE {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+ }
+
+ virtual int32_t PostWork(PP_CompletionCallback callback,
+ int64_t delay_ms) OVERRIDE {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+ }
+
+ virtual int32_t PostQuit(PP_Bool should_destroy) OVERRIDE {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+ }
+
+ private:
+ scoped_refptr<base::MessageLoopProxy> main_thread_message_loop_;
+ DISALLOW_COPY_AND_ASSIGN(MainThreadMessageLoopResource);
+};
+
+MojoPpapiGlobals::MojoPpapiGlobals(Delegate* delegate)
+ : delegate_(delegate),
+ plugin_instance_(NULL),
+ resource_tracker_(ppapi::ResourceTracker::THREAD_SAFE) {}
+
+MojoPpapiGlobals::~MojoPpapiGlobals() {}
+
+PP_Instance MojoPpapiGlobals::AddInstance(PluginInstance* instance) {
+ DCHECK(!plugin_instance_);
+ plugin_instance_ = instance;
+ resource_tracker_.DidCreateInstance(kInstanceId);
+ return kInstanceId;
+}
+
+void MojoPpapiGlobals::InstanceDeleted(PP_Instance instance) {
+ DCHECK_EQ(instance, kInstanceId);
+ DCHECK(plugin_instance_);
+ resource_tracker_.DidDeleteInstance(instance);
+ plugin_instance_ = NULL;
+}
+
+PluginInstance* MojoPpapiGlobals::GetInstance(PP_Instance instance) {
+ if (instance == kInstanceId)
+ return plugin_instance_;
+ return NULL;
+}
+
+ScopedMessagePipeHandle MojoPpapiGlobals::CreateGLES2Context() {
+ return delegate_->CreateGLES2Context();
+}
+
+ppapi::ResourceTracker* MojoPpapiGlobals::GetResourceTracker() {
+ return &resource_tracker_;
+}
+
+ppapi::VarTracker* MojoPpapiGlobals::GetVarTracker() {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+ppapi::CallbackTracker* MojoPpapiGlobals::GetCallbackTrackerForInstance(
+ PP_Instance instance) {
+ if (instance == kInstanceId && plugin_instance_)
+ return plugin_instance_->plugin_module()->callback_tracker();
+ return NULL;
+}
+
+void MojoPpapiGlobals::LogWithSource(PP_Instance instance,
+ PP_LogLevel level,
+ const std::string& source,
+ const std::string& value) {
+ NOTIMPLEMENTED();
+}
+
+void MojoPpapiGlobals::BroadcastLogWithSource(PP_Module module,
+ PP_LogLevel level,
+ const std::string& source,
+ const std::string& value) {
+ NOTIMPLEMENTED();
+}
+
+ppapi::thunk::PPB_Instance_API* MojoPpapiGlobals::GetInstanceAPI(
+ PP_Instance instance) {
+ if (instance == kInstanceId && plugin_instance_)
+ return plugin_instance_;
+ return NULL;
+}
+
+ppapi::thunk::ResourceCreationAPI* MojoPpapiGlobals::GetResourceCreationAPI(
+ PP_Instance instance) {
+ if (instance == kInstanceId && plugin_instance_)
+ return plugin_instance_->resource_creation();
+ return NULL;
+}
+
+PP_Module MojoPpapiGlobals::GetModuleForInstance(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+ppapi::MessageLoopShared* MojoPpapiGlobals::GetCurrentMessageLoop() {
+ if (base::MessageLoopProxy::current().get() == GetMainThreadMessageLoop()) {
+ if (!main_thread_message_loop_resource_) {
+ main_thread_message_loop_resource_ = new MainThreadMessageLoopResource(
+ GetMainThreadMessageLoop());
+ }
+ return main_thread_message_loop_resource_.get();
+ }
+
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+base::TaskRunner* MojoPpapiGlobals::GetFileTaskRunner() {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+std::string MojoPpapiGlobals::GetCmdLine() {
+ NOTIMPLEMENTED();
+ return std::string();
+}
+
+void MojoPpapiGlobals::PreCacheFontForFlash(const void* logfontw) {
+ NOTIMPLEMENTED();
+}
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/mojo_ppapi_globals.h b/mojo/examples/pepper_container_app/mojo_ppapi_globals.h
new file mode 100644
index 0000000..784e6f4
--- /dev/null
+++ b/mojo/examples/pepper_container_app/mojo_ppapi_globals.h
@@ -0,0 +1,90 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_MOJO_PPAPI_GLOBALS_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_MOJO_PPAPI_GLOBALS_H_
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "mojo/public/system/core_cpp.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/resource_tracker.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace mojo {
+namespace examples {
+
+class PluginInstance;
+
+class MojoPpapiGlobals : public ppapi::PpapiGlobals {
+ public:
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ virtual ScopedMessagePipeHandle CreateGLES2Context() = 0;
+ };
+
+ // |delegate| must live longer than this object.
+ explicit MojoPpapiGlobals(Delegate* delegate);
+ virtual ~MojoPpapiGlobals();
+
+ inline static MojoPpapiGlobals* Get() {
+ return static_cast<MojoPpapiGlobals*>(PpapiGlobals::Get());
+ }
+
+ PP_Instance AddInstance(PluginInstance* instance);
+ void InstanceDeleted(PP_Instance instance);
+ PluginInstance* GetInstance(PP_Instance instance);
+
+ ScopedMessagePipeHandle CreateGLES2Context();
+
+ // ppapi::PpapiGlobals implementation.
+ virtual ppapi::ResourceTracker* GetResourceTracker() OVERRIDE;
+ virtual ppapi::VarTracker* GetVarTracker() OVERRIDE;
+ virtual ppapi::CallbackTracker* GetCallbackTrackerForInstance(
+ PP_Instance instance) OVERRIDE;
+ virtual void LogWithSource(PP_Instance instance,
+ PP_LogLevel level,
+ const std::string& source,
+ const std::string& value) OVERRIDE;
+ virtual void BroadcastLogWithSource(PP_Module module,
+ PP_LogLevel level,
+ const std::string& source,
+ const std::string& value) OVERRIDE;
+ virtual ppapi::thunk::PPB_Instance_API* GetInstanceAPI(
+ PP_Instance instance) OVERRIDE;
+ virtual ppapi::thunk::ResourceCreationAPI* GetResourceCreationAPI(
+ PP_Instance instance) OVERRIDE;
+ virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
+ virtual ppapi::MessageLoopShared* GetCurrentMessageLoop() OVERRIDE;
+ virtual base::TaskRunner* GetFileTaskRunner() OVERRIDE;
+ virtual std::string GetCmdLine() OVERRIDE;
+ virtual void PreCacheFontForFlash(const void* logfontw) OVERRIDE;
+
+ private:
+ class MainThreadMessageLoopResource;
+
+ // Non-owning pointer.
+ Delegate* const delegate_;
+
+ // Non-owning pointer.
+ PluginInstance* plugin_instance_;
+
+ ppapi::ResourceTracker resource_tracker_;
+
+ scoped_refptr<MainThreadMessageLoopResource>
+ main_thread_message_loop_resource_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoPpapiGlobals);
+};
+
+} // namespace examples
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_MOJO_PPAPI_GLOBALS_H_
diff --git a/mojo/examples/pepper_container_app/pepper_container_app.cc b/mojo/examples/pepper_container_app/pepper_container_app.cc
new file mode 100644
index 0000000..d1c018d
--- /dev/null
+++ b/mojo/examples/pepper_container_app/pepper_container_app.cc
@@ -0,0 +1,134 @@
+// Copyright 2014 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 "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "build/build_config.h"
+#include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h"
+#include "mojo/examples/pepper_container_app/plugin_instance.h"
+#include "mojo/examples/pepper_container_app/plugin_module.h"
+#include "mojo/examples/pepper_container_app/type_converters.h"
+#include "mojo/public/bindings/allocation_scope.h"
+#include "mojo/public/bindings/remote_ptr.h"
+#include "mojo/public/environment/environment.h"
+#include "mojo/public/gles2/gles2_cpp.h"
+#include "mojo/public/shell/application.h"
+#include "mojo/public/shell/shell.mojom.h"
+#include "mojo/public/system/core.h"
+#include "mojo/services/native_viewport/native_viewport.mojom.h"
+#include "ppapi/c/pp_rect.h"
+#include "ppapi/shared_impl/proxy_lock.h"
+
+#if defined(OS_WIN)
+#if !defined(CDECL)
+#define CDECL __cdecl
+#endif
+#define PEPPER_CONTAINER_APP_EXPORT __declspec(dllexport)
+#else
+#define CDECL
+#define PEPPER_CONTAINER_APP_EXPORT __attribute__((visibility("default")))
+#endif
+
+namespace mojo {
+namespace examples {
+
+class PepperContainerApp: public Application,
+ public NativeViewportClient,
+ public MojoPpapiGlobals::Delegate {
+ public:
+ explicit PepperContainerApp(MojoHandle shell_handle)
+ : Application(shell_handle),
+ ppapi_globals_(this),
+ plugin_module_(new PluginModule) {
+ InterfacePipe<NativeViewport, AnyInterface> viewport_pipe;
+ mojo::AllocationScope scope;
+ shell()->Connect("mojo:mojo_native_viewport_service",
+ viewport_pipe.handle_to_peer.Pass());
+ viewport_.reset(viewport_pipe.handle_to_self.Pass(), this);
+ Rect::Builder rect;
+ Point::Builder point;
+ point.set_x(10);
+ point.set_y(10);
+ rect.set_position(point.Finish());
+ Size::Builder size;
+ size.set_width(800);
+ size.set_height(600);
+ rect.set_size(size.Finish());
+ viewport_->Create(rect.Finish());
+ viewport_->Show();
+ }
+
+ virtual ~PepperContainerApp() {}
+
+ // NativeViewportClient implementation.
+ virtual void OnCreated() OVERRIDE {
+ ppapi::ProxyAutoLock lock;
+
+ plugin_instance_ = plugin_module_->CreateInstance().Pass();
+ if (!plugin_instance_->DidCreate())
+ plugin_instance_.reset();
+ }
+
+ virtual void OnDestroyed() OVERRIDE {
+ ppapi::ProxyAutoLock lock;
+
+ if (plugin_instance_) {
+ plugin_instance_->DidDestroy();
+ plugin_instance_.reset();
+ }
+
+ base::MessageLoop::current()->Quit();
+ }
+
+ virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE {
+ ppapi::ProxyAutoLock lock;
+
+ if (plugin_instance_)
+ plugin_instance_->DidChangeView(bounds);
+ }
+
+ virtual void OnEvent(const Event& event) OVERRIDE {
+ if (event.location().is_null())
+ return;
+
+ {
+ ppapi::ProxyAutoLock lock;
+
+ // TODO(yzshen): Handle events.
+ }
+ viewport_->AckEvent(event);
+ }
+
+ // MojoPpapiGlobals::Delegate implementation.
+ virtual ScopedMessagePipeHandle CreateGLES2Context() OVERRIDE {
+ MessagePipe gles2_pipe;
+ viewport_->CreateGLES2Context(gles2_pipe.handle1.Pass());
+ return gles2_pipe.handle0.Pass();
+ }
+
+ private:
+ MojoPpapiGlobals ppapi_globals_;
+
+ RemotePtr<NativeViewport> viewport_;
+ scoped_refptr<PluginModule> plugin_module_;
+ scoped_ptr<PluginInstance> plugin_instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperContainerApp);
+};
+
+} // namespace examples
+} // namespace mojo
+
+extern "C" PEPPER_CONTAINER_APP_EXPORT MojoResult CDECL MojoMain(
+ MojoHandle shell_handle) {
+ mojo::Environment env;
+ mojo::GLES2Initializer gles2;
+ base::MessageLoop run_loop;
+ mojo::examples::PepperContainerApp app(shell_handle);
+
+ run_loop.Run();
+ return MOJO_RESULT_OK;
+}
diff --git a/mojo/examples/pepper_container_app/plugin_instance.cc b/mojo/examples/pepper_container_app/plugin_instance.cc
new file mode 100644
index 0000000..2403927
--- /dev/null
+++ b/mojo/examples/pepper_container_app/plugin_instance.cc
@@ -0,0 +1,378 @@
+// Copyright 2014 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 "mojo/examples/pepper_container_app/plugin_instance.h"
+
+#include "base/logging.h"
+#include "mojo/examples/pepper_container_app/graphics_3d_resource.h"
+#include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppp_graphics_3d.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/shared_impl/ppb_view_shared.h"
+#include "ppapi/shared_impl/proxy_lock.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_graphics_3d_api.h"
+
+namespace mojo {
+namespace examples {
+
+PluginInstance::PluginInstance(scoped_refptr<PluginModule> plugin_module)
+ : pp_instance_(0),
+ plugin_module_(plugin_module) {
+ pp_instance_ = MojoPpapiGlobals::Get()->AddInstance(this);
+}
+
+PluginInstance::~PluginInstance() {
+ MojoPpapiGlobals::Get()->InstanceDeleted(pp_instance_);
+}
+
+bool PluginInstance::DidCreate() {
+ ppapi::ProxyAutoUnlock unlock;
+ const PPP_Instance_1_1* instance_interface =
+ static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface(
+ PPP_INSTANCE_INTERFACE_1_1));
+ return !!instance_interface->DidCreate(pp_instance(), 0, NULL, NULL);
+}
+
+void PluginInstance::DidDestroy() {
+ ppapi::ProxyAutoUnlock unlock;
+ const PPP_Instance_1_1* instance_interface =
+ static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface(
+ PPP_INSTANCE_INTERFACE_1_1));
+ instance_interface->DidDestroy(pp_instance());
+}
+
+void PluginInstance::DidChangeView(const PP_Rect& bounds) {
+ ppapi::ViewData view_data;
+ view_data.rect = bounds;
+ view_data.is_fullscreen = false;
+ view_data.is_page_visible = true;
+ view_data.clip_rect = bounds;
+ view_data.device_scale = 1.0f;
+ view_data.css_scale = 1.0f;
+
+ ppapi::ScopedPPResource resource(ppapi::ScopedPPResource::PassRef(),
+ (new ppapi::PPB_View_Shared(
+ ppapi::OBJECT_IS_IMPL, pp_instance(), view_data))->GetReference());
+ {
+ ppapi::ProxyAutoUnlock unlock;
+ const PPP_Instance_1_1* instance_interface =
+ static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface(
+ PPP_INSTANCE_INTERFACE_1_1));
+ instance_interface->DidChangeView(pp_instance(), resource);
+ }
+}
+
+void PluginInstance::Graphics3DContextLost() {
+ ppapi::ProxyAutoUnlock unlock;
+ const PPP_Graphics3D_1_0* graphic_3d_interface =
+ static_cast<const PPP_Graphics3D_1_0*>(plugin_module_->GetPluginInterface(
+ PPP_GRAPHICS_3D_INTERFACE_1_0));
+ // TODO(yzshen): Maybe we only need to notify for the bound graphics context?
+ graphic_3d_interface->Graphics3DContextLost(pp_instance());
+}
+
+bool PluginInstance::IsBoundGraphics(PP_Resource device) const {
+ return device != 0 && device == bound_graphics_.get();
+}
+
+PP_Bool PluginInstance::BindGraphics(PP_Instance instance, PP_Resource device) {
+ if (bound_graphics_.get() == device)
+ return PP_TRUE;
+
+ ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_Graphics3D_API>
+ enter(device, false);
+ if (enter.failed())
+ return PP_FALSE;
+
+ bound_graphics_ = device;
+ static_cast<Graphics3DResource*>(enter.object())->BindGraphics();
+
+ return PP_TRUE;
+}
+
+PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+const ppapi::ViewData* PluginInstance::GetViewData(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Var PluginInstance::GetWindowObject(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+PP_Var PluginInstance::GetOwnerElementObject(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+PP_Var PluginInstance::ExecuteScript(PP_Instance instance,
+ PP_Var script,
+ PP_Var* exception) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+uint32_t PluginInstance::GetAudioHardwareOutputSampleRate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+uint32_t PluginInstance::GetAudioHardwareOutputBufferSize(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+void PluginInstance::Log(PP_Instance instance,
+ PP_LogLevel log_level,
+ PP_Var value) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::LogWithSource(PP_Instance instance,
+ PP_LogLevel log_level,
+ PP_Var source,
+ PP_Var value) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SetPluginToHandleFindRequests(PP_Instance instance) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance,
+ int32_t total,
+ PP_Bool final_result) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SelectedFindResultChanged(PP_Instance instance,
+ int32_t index) {
+ NOTIMPLEMENTED();
+}
+
+PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Bool PluginInstance::SetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+ppapi::Resource* PluginInstance::GetSingletonResource(
+ PP_Instance instance,
+ ppapi::SingletonResourceID id) {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+int32_t PluginInstance::RequestInputEvents(PP_Instance instance,
+ uint32_t event_classes) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance,
+ uint32_t event_classes) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+void PluginInstance::ClearInputEventRequest(PP_Instance instance,
+ uint32_t event_classes) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) {
+ NOTIMPLEMENTED();
+}
+
+PP_Bool PluginInstance::SetCursor(PP_Instance instance,
+ PP_MouseCursor_Type type,
+ PP_Resource image,
+ const PP_Point* hot_spot) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+int32_t PluginInstance::LockMouse(
+ PP_Instance instance,
+ scoped_refptr<ppapi::TrackedCallback> callback) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+}
+
+void PluginInstance::UnlockMouse(PP_Instance instance) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SetTextInputType(PP_Instance instance,
+ PP_TextInput_Type type) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::UpdateCaretPosition(PP_Instance instance,
+ const PP_Rect& caret,
+ const PP_Rect& bounding_box) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::CancelCompositionText(PP_Instance instance) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SelectionChanged(PP_Instance instance) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::UpdateSurroundingText(PP_Instance instance,
+ const char* text,
+ uint32_t caret,
+ uint32_t anchor) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::ZoomChanged(PP_Instance instance, double factor) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::ZoomLimitsChanged(PP_Instance instance,
+ double minimum_factor,
+ double maximum_factor) {
+ NOTIMPLEMENTED();
+}
+
+PP_Var PluginInstance::GetDocumentURL(PP_Instance instance,
+ PP_URLComponents_Dev* components) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+void PluginInstance::SessionCreated(PP_Instance instance,
+ uint32_t session_id,
+ PP_Var web_session_id) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SessionMessage(PP_Instance instance,
+ uint32_t session_id,
+ PP_Var message,
+ PP_Var destination_url) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SessionReady(PP_Instance instance, uint32_t session_id) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SessionClosed(PP_Instance instance, uint32_t session_id) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::SessionError(PP_Instance instance,
+ uint32_t session_id,
+ int32_t media_error,
+ uint32_t system_code) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::DeliverBlock(PP_Instance instance,
+ PP_Resource decrypted_block,
+ const PP_DecryptedBlockInfo* block_info) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::DecoderInitializeDone(PP_Instance instance,
+ PP_DecryptorStreamType decoder_type,
+ uint32_t request_id,
+ PP_Bool success) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::DecoderDeinitializeDone(
+ PP_Instance instance,
+ PP_DecryptorStreamType decoder_type,
+ uint32_t request_id) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::DecoderResetDone(PP_Instance instance,
+ PP_DecryptorStreamType decoder_type,
+ uint32_t request_id) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::DeliverFrame(PP_Instance instance,
+ PP_Resource decrypted_frame,
+ const PP_DecryptedFrameInfo* frame_info) {
+ NOTIMPLEMENTED();
+}
+
+void PluginInstance::DeliverSamples(PP_Instance instance,
+ PP_Resource audio_frames,
+ const PP_DecryptedSampleInfo* sample_info) {
+ NOTIMPLEMENTED();
+}
+
+PP_Var PluginInstance::ResolveRelativeToDocument(
+ PP_Instance instance,
+ PP_Var relative,
+ PP_URLComponents_Dev* components) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Bool PluginInstance::DocumentCanAccessDocument(PP_Instance instance,
+ PP_Instance target) {
+ NOTIMPLEMENTED();
+ return PP_FALSE;
+}
+
+PP_Var PluginInstance::GetPluginInstanceURL(PP_Instance instance,
+ PP_URLComponents_Dev* components) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+PP_Var PluginInstance::GetPluginReferrerURL(PP_Instance instance,
+ PP_URLComponents_Dev* components) {
+ NOTIMPLEMENTED();
+ return PP_MakeUndefined();
+}
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/plugin_instance.h b/mojo/examples/pepper_container_app/plugin_instance.h
new file mode 100644
index 0000000..61f25fb
--- /dev/null
+++ b/mojo/examples/pepper_container_app/plugin_instance.h
@@ -0,0 +1,167 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_PLUGIN_INSTANCE_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_PLUGIN_INSTANCE_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "mojo/examples/pepper_container_app/plugin_module.h"
+#include "mojo/examples/pepper_container_app/resource_creation_impl.h"
+#include "ppapi/c/pp_rect.h"
+#include "ppapi/shared_impl/scoped_pp_resource.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+
+namespace mojo {
+namespace examples {
+
+class PluginInstance : public ppapi::thunk::PPB_Instance_API {
+ public:
+ explicit PluginInstance(scoped_refptr<PluginModule> plugin_module);
+ virtual ~PluginInstance();
+
+ // Notifies the plugin that a new instance has been created.
+ bool DidCreate();
+ // Notifies the plugin that the instance has been destroyed.
+ void DidDestroy();
+ // Notifies the plugin that the position or size of the instance has changed.
+ void DidChangeView(const PP_Rect& bounds);
+ // Notifies the plugin that the Graphics 3D context has been invalidated.
+ void Graphics3DContextLost();
+
+ // Returns true if |device| has been bound as the current display surface.
+ bool IsBoundGraphics(PP_Resource device) const;
+
+ PP_Instance pp_instance() const { return pp_instance_; }
+ ResourceCreationImpl* resource_creation() { return &resource_creation_; }
+ PluginModule* plugin_module() { return plugin_module_.get(); }
+
+ // ppapi::thunk::PPB_Instance_API implementation.
+ virtual PP_Bool BindGraphics(PP_Instance instance,
+ PP_Resource device) OVERRIDE;
+ virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE;
+ virtual const ppapi::ViewData* GetViewData(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE;
+ virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE;
+ virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE;
+ virtual PP_Var ExecuteScript(PP_Instance instance,
+ PP_Var script,
+ PP_Var* exception) OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputSampleRate(
+ PP_Instance instance) OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputBufferSize(
+ PP_Instance instance) OVERRIDE;
+ virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
+ virtual void Log(PP_Instance instance,
+ PP_LogLevel log_level,
+ PP_Var value) OVERRIDE;
+ virtual void LogWithSource(PP_Instance instance,
+ PP_LogLevel log_level,
+ PP_Var source,
+ PP_Var value) OVERRIDE;
+ virtual void SetPluginToHandleFindRequests(PP_Instance instance) OVERRIDE;
+ virtual void NumberOfFindResultsChanged(PP_Instance instance,
+ int32_t total,
+ PP_Bool final_result) OVERRIDE;
+ virtual void SelectedFindResultChanged(PP_Instance instance,
+ int32_t index) OVERRIDE;
+ virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool SetFullscreen(PP_Instance instance,
+ PP_Bool fullscreen) OVERRIDE;
+ virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE;
+ virtual ppapi::Resource* GetSingletonResource(
+ PP_Instance instance, ppapi::SingletonResourceID id) OVERRIDE;
+ virtual int32_t RequestInputEvents(PP_Instance instance,
+ uint32_t event_classes) OVERRIDE;
+ virtual int32_t RequestFilteringInputEvents(PP_Instance instance,
+ uint32_t event_classes) OVERRIDE;
+ virtual void ClearInputEventRequest(PP_Instance instance,
+ uint32_t event_classes) OVERRIDE;
+ virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE;
+ virtual PP_Bool SetCursor(PP_Instance instance,
+ PP_MouseCursor_Type type,
+ PP_Resource image,
+ const PP_Point* hot_spot) OVERRIDE;
+ virtual int32_t LockMouse(
+ PP_Instance instance,
+ scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual void UnlockMouse(PP_Instance instance) OVERRIDE;
+ virtual void SetTextInputType(PP_Instance instance,
+ PP_TextInput_Type type) OVERRIDE;
+ virtual void UpdateCaretPosition(PP_Instance instance,
+ const PP_Rect& caret,
+ const PP_Rect& bounding_box) OVERRIDE;
+ virtual void CancelCompositionText(PP_Instance instance) OVERRIDE;
+ virtual void SelectionChanged(PP_Instance instance) OVERRIDE;
+ virtual void UpdateSurroundingText(PP_Instance instance,
+ const char* text,
+ uint32_t caret,
+ uint32_t anchor) OVERRIDE;
+ virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE;
+ virtual void ZoomLimitsChanged(PP_Instance instance,
+ double minimum_factor,
+ double maximum_factor) OVERRIDE;
+ virtual PP_Var GetDocumentURL(PP_Instance instance,
+ PP_URLComponents_Dev* components) OVERRIDE;
+ virtual void SessionCreated(PP_Instance instance,
+ uint32_t session_id,
+ PP_Var web_session_id) OVERRIDE;
+ virtual void SessionMessage(PP_Instance instance,
+ uint32_t session_id,
+ PP_Var message,
+ PP_Var destination_url) OVERRIDE;
+ virtual void SessionReady(PP_Instance instance, uint32_t session_id) OVERRIDE;
+ virtual void SessionClosed(PP_Instance instance,
+ uint32_t session_id) OVERRIDE;
+ virtual void SessionError(PP_Instance instance,
+ uint32_t session_id,
+ int32_t media_error,
+ uint32_t system_code) OVERRIDE;
+ virtual void DeliverBlock(PP_Instance instance,
+ PP_Resource decrypted_block,
+ const PP_DecryptedBlockInfo* block_info) OVERRIDE;
+ virtual void DecoderInitializeDone(PP_Instance instance,
+ PP_DecryptorStreamType decoder_type,
+ uint32_t request_id,
+ PP_Bool success) OVERRIDE;
+ virtual void DecoderDeinitializeDone(PP_Instance instance,
+ PP_DecryptorStreamType decoder_type,
+ uint32_t request_id) OVERRIDE;
+ virtual void DecoderResetDone(PP_Instance instance,
+ PP_DecryptorStreamType decoder_type,
+ uint32_t request_id) OVERRIDE;
+ virtual void DeliverFrame(PP_Instance instance,
+ PP_Resource decrypted_frame,
+ const PP_DecryptedFrameInfo* frame_info) OVERRIDE;
+ virtual void DeliverSamples(
+ PP_Instance instance,
+ PP_Resource audio_frames,
+ const PP_DecryptedSampleInfo* sample_info) OVERRIDE;
+ virtual PP_Var ResolveRelativeToDocument(
+ PP_Instance instance,
+ PP_Var relative,
+ PP_URLComponents_Dev* components) OVERRIDE;
+ virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE;
+ virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance,
+ PP_Instance target) OVERRIDE;
+ virtual PP_Var GetPluginInstanceURL(
+ PP_Instance instance,
+ PP_URLComponents_Dev* components) OVERRIDE;
+ virtual PP_Var GetPluginReferrerURL(
+ PP_Instance instance,
+ PP_URLComponents_Dev* components) OVERRIDE;
+
+ private:
+ PP_Instance pp_instance_;
+ ResourceCreationImpl resource_creation_;
+ scoped_refptr<PluginModule> plugin_module_;
+ ppapi::ScopedPPResource bound_graphics_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginInstance);
+};
+
+} // namespace examples
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_PLUGIN_INSTANCE_H_
diff --git a/mojo/examples/pepper_container_app/plugin_module.cc b/mojo/examples/pepper_container_app/plugin_module.cc
new file mode 100644
index 0000000..9ec26aa
--- /dev/null
+++ b/mojo/examples/pepper_container_app/plugin_module.cc
@@ -0,0 +1,111 @@
+// Copyright 2014 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 "mojo/examples/pepper_container_app/plugin_module.h"
+
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "build/build_config.h"
+#include "mojo/examples/pepper_container_app/interface_list.h"
+#include "mojo/examples/pepper_container_app/plugin_instance.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/callback_tracker.h"
+
+namespace mojo {
+namespace examples {
+
+namespace {
+
+const void* GetInterface(const char* name) {
+ const void* interface =
+ InterfaceList::GetInstance()->GetBrowserInterface(name);
+
+ if (!interface)
+ LOG(WARNING) << "Interface requested " << name;
+
+ return interface;
+}
+
+} // namespace
+
+PluginModule::EntryPoints::EntryPoints() : get_interface(NULL),
+ initialize_module(NULL),
+ shutdown_module(NULL) {}
+
+PluginModule::PluginModule() : callback_tracker_(new ppapi::CallbackTracker) {
+ Initialize();
+}
+
+PluginModule::~PluginModule() {
+ callback_tracker_->AbortAll();
+
+ if (entry_points_.shutdown_module)
+ entry_points_.shutdown_module();
+}
+
+scoped_ptr<PluginInstance> PluginModule::CreateInstance() {
+ return make_scoped_ptr(new PluginInstance(this));
+}
+
+const void* PluginModule::GetPluginInterface(const char* name) const {
+ if (entry_points_.get_interface)
+ return entry_points_.get_interface(name);
+ return NULL;
+}
+
+void PluginModule::Initialize() {
+ // Platform-specific filename.
+ // TODO(yzshen): Don't hard-code it.
+#if defined(OS_WIN)
+ static const wchar_t plugin_name[] = L"ppapi_example_gles2_spinning_cube.dll";
+#elif defined(OS_MACOSX)
+ static const char plugin_name[] = "ppapi_example_gles2_spinning_cube.plugin";
+#elif defined(OS_POSIX)
+ static const char plugin_name[] = "libppapi_example_gles2_spinning_cube.so";
+#endif
+
+ base::FilePath plugin_path(plugin_name);
+
+ std::string error;
+ plugin_module_.Reset(
+ base::LoadNativeLibrary(plugin_path, &error));
+
+ if (!plugin_module_.is_valid()) {
+ LOG(WARNING) << "Cannot load " << plugin_path.AsUTF8Unsafe()
+ << ". Error: " << error;
+ return;
+ }
+
+ entry_points_.get_interface =
+ reinterpret_cast<PP_GetInterface_Func>(
+ plugin_module_.GetFunctionPointer("PPP_GetInterface"));
+ if (!entry_points_.get_interface) {
+ LOG(WARNING) << "No PPP_GetInterface in plugin library";
+ return;
+ }
+
+ entry_points_.initialize_module =
+ reinterpret_cast<PP_InitializeModule_Func>(
+ plugin_module_.GetFunctionPointer("PPP_InitializeModule"));
+ if (!entry_points_.initialize_module) {
+ LOG(WARNING) << "No PPP_InitializeModule in plugin library";
+ return;
+ }
+
+ // It's okay for PPP_ShutdownModule to not be defined and |shutdown_module| to
+ // be NULL.
+ entry_points_.shutdown_module =
+ reinterpret_cast<PP_ShutdownModule_Func>(
+ plugin_module_.GetFunctionPointer("PPP_ShutdownModule"));
+
+ int32_t result = entry_points_.initialize_module(pp_module(),
+ &GetInterface);
+ if (result != PP_OK)
+ LOG(WARNING) << "Initializing module failed with error " << result;
+}
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/plugin_module.h b/mojo/examples/pepper_container_app/plugin_module.h
new file mode 100644
index 0000000..05aad3b
--- /dev/null
+++ b/mojo/examples/pepper_container_app/plugin_module.h
@@ -0,0 +1,61 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_PLUGIN_MODULE_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_PLUGIN_MODULE_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/native_library.h"
+#include "base/scoped_native_library.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/ppp.h"
+
+namespace ppapi {
+class CallbackTracker;
+}
+
+namespace mojo {
+namespace examples {
+
+class PluginInstance;
+
+class PluginModule : public base::RefCounted<PluginModule> {
+ public:
+ PluginModule();
+
+ scoped_ptr<PluginInstance> CreateInstance();
+
+ const void* GetPluginInterface(const char* name) const;
+
+ PP_Module pp_module() const { return 1; }
+ ppapi::CallbackTracker* callback_tracker() { return callback_tracker_.get(); }
+
+ private:
+ friend class base::RefCounted<PluginModule>;
+
+ struct EntryPoints {
+ EntryPoints();
+
+ PP_GetInterface_Func get_interface;
+ PP_InitializeModule_Func initialize_module;
+ PP_ShutdownModule_Func shutdown_module; // Optional, may be NULL.
+ };
+
+ ~PluginModule();
+
+ void Initialize();
+
+ base::ScopedNativeLibrary plugin_module_;
+ EntryPoints entry_points_;
+ scoped_refptr<ppapi::CallbackTracker> callback_tracker_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginModule);
+};
+
+} // namespace examples
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_PLUGIN_MODULE_H_
diff --git a/mojo/examples/pepper_container_app/ppb_core_thunk.cc b/mojo/examples/pepper_container_app/ppb_core_thunk.cc
new file mode 100644
index 0000000..a76a976
--- /dev/null
+++ b/mojo/examples/pepper_container_app/ppb_core_thunk.cc
@@ -0,0 +1,64 @@
+// Copyright 2014 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 "base/logging.h"
+#include "mojo/examples/pepper_container_app/thunk.h"
+#include "ppapi/c/ppb_core.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/proxy_lock.h"
+#include "ppapi/shared_impl/resource_tracker.h"
+
+namespace mojo {
+namespace examples {
+
+namespace {
+
+void AddRefResource(PP_Resource resource) {
+ ppapi::ProxyAutoLock lock;
+ ppapi::PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(resource);
+}
+
+void ReleaseResource(PP_Resource resource) {
+ ppapi::ProxyAutoLock lock;
+ ppapi::PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resource);
+}
+
+PP_Time GetTime() {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_TimeTicks GetTimeTicks() {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+void CallOnMainThread(int32_t delay_in_milliseconds,
+ PP_CompletionCallback callback,
+ int32_t result) {
+ NOTIMPLEMENTED();
+}
+
+PP_Bool IsMainThread() {
+ NOTIMPLEMENTED();
+ return PP_TRUE;
+}
+
+} // namespace
+
+const PPB_Core_1_0 g_ppb_core_thunk_1_0 = {
+ &AddRefResource,
+ &ReleaseResource,
+ &GetTime,
+ &GetTimeTicks,
+ &CallOnMainThread,
+ &IsMainThread
+};
+
+const PPB_Core_1_0* GetPPB_Core_1_0_Thunk() {
+ return &g_ppb_core_thunk_1_0;
+}
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/ppb_opengles2_thunk.cc b/mojo/examples/pepper_container_app/ppb_opengles2_thunk.cc
new file mode 100644
index 0000000..56fc891
--- /dev/null
+++ b/mojo/examples/pepper_container_app/ppb_opengles2_thunk.cc
@@ -0,0 +1,1454 @@
+// Copyright 2014 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 "base/logging.h"
+#include "mojo/examples/pepper_container_app/graphics_3d_resource.h"
+#include "mojo/examples/pepper_container_app/thunk.h"
+#include "mojo/public/gles2/gles2.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_graphics_3d_api.h"
+
+namespace mojo {
+namespace examples {
+
+namespace {
+
+typedef ppapi::thunk::EnterResource<ppapi::thunk::PPB_Graphics3D_API> Enter3D;
+
+bool IsBoundGraphics(Enter3D* enter) {
+ return enter->succeeded() &&
+ static_cast<Graphics3DResource*>(enter->object())->IsBoundGraphics();
+}
+
+void ActiveTexture(PP_Resource context_id, GLenum texture) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glActiveTexture(texture);
+ }
+}
+
+void AttachShader(PP_Resource context_id, GLuint program, GLuint shader) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glAttachShader(program, shader);
+ }
+}
+
+void BindAttribLocation(PP_Resource context_id,
+ GLuint program,
+ GLuint index,
+ const char* name) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBindAttribLocation(program, index, name);
+ }
+}
+
+void BindBuffer(PP_Resource context_id, GLenum target, GLuint buffer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBindBuffer(target, buffer);
+ }
+}
+
+void BindFramebuffer(PP_Resource context_id,
+ GLenum target,
+ GLuint framebuffer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBindFramebuffer(target, framebuffer);
+ }
+}
+
+void BindRenderbuffer(PP_Resource context_id,
+ GLenum target,
+ GLuint renderbuffer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBindRenderbuffer(target, renderbuffer);
+ }
+}
+
+void BindTexture(PP_Resource context_id, GLenum target, GLuint texture) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBindTexture(target, texture);
+ }
+}
+
+void BlendColor(PP_Resource context_id,
+ GLclampf red,
+ GLclampf green,
+ GLclampf blue,
+ GLclampf alpha) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBlendColor(red, green, blue, alpha);
+ }
+}
+
+void BlendEquation(PP_Resource context_id, GLenum mode) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBlendEquation(mode);
+ }
+}
+
+void BlendEquationSeparate(PP_Resource context_id,
+ GLenum modeRGB,
+ GLenum modeAlpha) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBlendEquationSeparate(modeRGB, modeAlpha);
+ }
+}
+
+void BlendFunc(PP_Resource context_id, GLenum sfactor, GLenum dfactor) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBlendFunc(sfactor, dfactor);
+ }
+}
+
+void BlendFuncSeparate(PP_Resource context_id,
+ GLenum srcRGB,
+ GLenum dstRGB,
+ GLenum srcAlpha,
+ GLenum dstAlpha) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ }
+}
+
+void BufferData(PP_Resource context_id,
+ GLenum target,
+ GLsizeiptr size,
+ const void* data,
+ GLenum usage) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBufferData(target, size, data, usage);
+ }
+}
+
+void BufferSubData(PP_Resource context_id,
+ GLenum target,
+ GLintptr offset,
+ GLsizeiptr size,
+ const void* data) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glBufferSubData(target, offset, size, data);
+ }
+}
+
+GLenum CheckFramebufferStatus(PP_Resource context_id, GLenum target) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glCheckFramebufferStatus(target);
+ } else {
+ return 0;
+ }
+}
+
+void Clear(PP_Resource context_id, GLbitfield mask) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glClear(mask);
+ }
+}
+
+void ClearColor(PP_Resource context_id,
+ GLclampf red,
+ GLclampf green,
+ GLclampf blue,
+ GLclampf alpha) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glClearColor(red, green, blue, alpha);
+ }
+}
+
+void ClearDepthf(PP_Resource context_id, GLclampf depth) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glClearDepthf(depth);
+ }
+}
+
+void ClearStencil(PP_Resource context_id, GLint s) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glClearStencil(s);
+ }
+}
+
+void ColorMask(PP_Resource context_id,
+ GLboolean red,
+ GLboolean green,
+ GLboolean blue,
+ GLboolean alpha) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glColorMask(red, green, blue, alpha);
+ }
+}
+
+void CompileShader(PP_Resource context_id, GLuint shader) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glCompileShader(shader);
+ }
+}
+
+void CompressedTexImage2D(PP_Resource context_id,
+ GLenum target,
+ GLint level,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLint border,
+ GLsizei imageSize,
+ const void* data) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glCompressedTexImage2D(
+ target, level, internalformat, width, height, border, imageSize, data);
+ }
+}
+
+void CompressedTexSubImage2D(PP_Resource context_id,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLsizei imageSize,
+ const void* data) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glCompressedTexSubImage2D(target,
+ level,
+ xoffset,
+ yoffset,
+ width,
+ height,
+ format,
+ imageSize,
+ data);
+ }
+}
+
+void CopyTexImage2D(PP_Resource context_id,
+ GLenum target,
+ GLint level,
+ GLenum internalformat,
+ GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height,
+ GLint border) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glCopyTexImage2D(
+ target, level, internalformat, x, y, width, height, border);
+ }
+}
+
+void CopyTexSubImage2D(PP_Resource context_id,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+ }
+}
+
+GLuint CreateProgram(PP_Resource context_id) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glCreateProgram();
+ } else {
+ return 0;
+ }
+}
+
+GLuint CreateShader(PP_Resource context_id, GLenum type) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glCreateShader(type);
+ } else {
+ return 0;
+ }
+}
+
+void CullFace(PP_Resource context_id, GLenum mode) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glCullFace(mode);
+ }
+}
+
+void DeleteBuffers(PP_Resource context_id, GLsizei n, const GLuint* buffers) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDeleteBuffers(n, buffers);
+ }
+}
+
+void DeleteFramebuffers(PP_Resource context_id,
+ GLsizei n,
+ const GLuint* framebuffers) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDeleteFramebuffers(n, framebuffers);
+ }
+}
+
+void DeleteProgram(PP_Resource context_id, GLuint program) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDeleteProgram(program);
+ }
+}
+
+void DeleteRenderbuffers(PP_Resource context_id,
+ GLsizei n,
+ const GLuint* renderbuffers) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDeleteRenderbuffers(n, renderbuffers);
+ }
+}
+
+void DeleteShader(PP_Resource context_id, GLuint shader) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDeleteShader(shader);
+ }
+}
+
+void DeleteTextures(PP_Resource context_id, GLsizei n, const GLuint* textures) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDeleteTextures(n, textures);
+ }
+}
+
+void DepthFunc(PP_Resource context_id, GLenum func) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDepthFunc(func);
+ }
+}
+
+void DepthMask(PP_Resource context_id, GLboolean flag) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDepthMask(flag);
+ }
+}
+
+void DepthRangef(PP_Resource context_id, GLclampf zNear, GLclampf zFar) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDepthRangef(zNear, zFar);
+ }
+}
+
+void DetachShader(PP_Resource context_id, GLuint program, GLuint shader) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDetachShader(program, shader);
+ }
+}
+
+void Disable(PP_Resource context_id, GLenum cap) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDisable(cap);
+ }
+}
+
+void DisableVertexAttribArray(PP_Resource context_id, GLuint index) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDisableVertexAttribArray(index);
+ }
+}
+
+void DrawArrays(PP_Resource context_id,
+ GLenum mode,
+ GLint first,
+ GLsizei count) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDrawArrays(mode, first, count);
+ }
+}
+
+void DrawElements(PP_Resource context_id,
+ GLenum mode,
+ GLsizei count,
+ GLenum type,
+ const void* indices) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glDrawElements(mode, count, type, indices);
+ }
+}
+
+void Enable(PP_Resource context_id, GLenum cap) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glEnable(cap);
+ }
+}
+
+void EnableVertexAttribArray(PP_Resource context_id, GLuint index) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glEnableVertexAttribArray(index);
+ }
+}
+
+void Finish(PP_Resource context_id) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glFinish();
+ }
+}
+
+void Flush(PP_Resource context_id) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glFlush();
+ }
+}
+
+void FramebufferRenderbuffer(PP_Resource context_id,
+ GLenum target,
+ GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glFramebufferRenderbuffer(
+ target, attachment, renderbuffertarget, renderbuffer);
+ }
+}
+
+void FramebufferTexture2D(PP_Resource context_id,
+ GLenum target,
+ GLenum attachment,
+ GLenum textarget,
+ GLuint texture,
+ GLint level) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glFramebufferTexture2D(target, attachment, textarget, texture, level);
+ }
+}
+
+void FrontFace(PP_Resource context_id, GLenum mode) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glFrontFace(mode);
+ }
+}
+
+void GenBuffers(PP_Resource context_id, GLsizei n, GLuint* buffers) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGenBuffers(n, buffers);
+ }
+}
+
+void GenerateMipmap(PP_Resource context_id, GLenum target) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGenerateMipmap(target);
+ }
+}
+
+void GenFramebuffers(PP_Resource context_id, GLsizei n, GLuint* framebuffers) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGenFramebuffers(n, framebuffers);
+ }
+}
+
+void GenRenderbuffers(PP_Resource context_id,
+ GLsizei n,
+ GLuint* renderbuffers) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGenRenderbuffers(n, renderbuffers);
+ }
+}
+
+void GenTextures(PP_Resource context_id, GLsizei n, GLuint* textures) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGenTextures(n, textures);
+ }
+}
+
+void GetActiveAttrib(PP_Resource context_id,
+ GLuint program,
+ GLuint index,
+ GLsizei bufsize,
+ GLsizei* length,
+ GLint* size,
+ GLenum* type,
+ char* name) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetActiveAttrib(program, index, bufsize, length, size, type, name);
+ }
+}
+
+void GetActiveUniform(PP_Resource context_id,
+ GLuint program,
+ GLuint index,
+ GLsizei bufsize,
+ GLsizei* length,
+ GLint* size,
+ GLenum* type,
+ char* name) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetActiveUniform(program, index, bufsize, length, size, type, name);
+ }
+}
+
+void GetAttachedShaders(PP_Resource context_id,
+ GLuint program,
+ GLsizei maxcount,
+ GLsizei* count,
+ GLuint* shaders) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetAttachedShaders(program, maxcount, count, shaders);
+ }
+}
+
+GLint GetAttribLocation(PP_Resource context_id,
+ GLuint program,
+ const char* name) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glGetAttribLocation(program, name);
+ } else {
+ return -1;
+ }
+}
+
+void GetBooleanv(PP_Resource context_id, GLenum pname, GLboolean* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetBooleanv(pname, params);
+ }
+}
+
+void GetBufferParameteriv(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetBufferParameteriv(target, pname, params);
+ }
+}
+
+GLenum GetError(PP_Resource context_id) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glGetError();
+ } else {
+ return 0;
+ }
+}
+
+void GetFloatv(PP_Resource context_id, GLenum pname, GLfloat* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetFloatv(pname, params);
+ }
+}
+
+void GetFramebufferAttachmentParameteriv(PP_Resource context_id,
+ GLenum target,
+ GLenum attachment,
+ GLenum pname,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
+ }
+}
+
+void GetIntegerv(PP_Resource context_id, GLenum pname, GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetIntegerv(pname, params);
+ }
+}
+
+void GetProgramiv(PP_Resource context_id,
+ GLuint program,
+ GLenum pname,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetProgramiv(program, pname, params);
+ }
+}
+
+void GetProgramInfoLog(PP_Resource context_id,
+ GLuint program,
+ GLsizei bufsize,
+ GLsizei* length,
+ char* infolog) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetProgramInfoLog(program, bufsize, length, infolog);
+ }
+}
+
+void GetRenderbufferParameteriv(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetRenderbufferParameteriv(target, pname, params);
+ }
+}
+
+void GetShaderiv(PP_Resource context_id,
+ GLuint shader,
+ GLenum pname,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetShaderiv(shader, pname, params);
+ }
+}
+
+void GetShaderInfoLog(PP_Resource context_id,
+ GLuint shader,
+ GLsizei bufsize,
+ GLsizei* length,
+ char* infolog) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetShaderInfoLog(shader, bufsize, length, infolog);
+ }
+}
+
+void GetShaderPrecisionFormat(PP_Resource context_id,
+ GLenum shadertype,
+ GLenum precisiontype,
+ GLint* range,
+ GLint* precision) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
+ }
+}
+
+void GetShaderSource(PP_Resource context_id,
+ GLuint shader,
+ GLsizei bufsize,
+ GLsizei* length,
+ char* source) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetShaderSource(shader, bufsize, length, source);
+ }
+}
+
+const GLubyte* GetString(PP_Resource context_id, GLenum name) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glGetString(name);
+ } else {
+ return NULL;
+ }
+}
+
+void GetTexParameterfv(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ GLfloat* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetTexParameterfv(target, pname, params);
+ }
+}
+
+void GetTexParameteriv(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetTexParameteriv(target, pname, params);
+ }
+}
+
+void GetUniformfv(PP_Resource context_id,
+ GLuint program,
+ GLint location,
+ GLfloat* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetUniformfv(program, location, params);
+ }
+}
+
+void GetUniformiv(PP_Resource context_id,
+ GLuint program,
+ GLint location,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetUniformiv(program, location, params);
+ }
+}
+
+GLint GetUniformLocation(PP_Resource context_id,
+ GLuint program,
+ const char* name) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glGetUniformLocation(program, name);
+ } else {
+ return -1;
+ }
+}
+
+void GetVertexAttribfv(PP_Resource context_id,
+ GLuint index,
+ GLenum pname,
+ GLfloat* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetVertexAttribfv(index, pname, params);
+ }
+}
+
+void GetVertexAttribiv(PP_Resource context_id,
+ GLuint index,
+ GLenum pname,
+ GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetVertexAttribiv(index, pname, params);
+ }
+}
+
+void GetVertexAttribPointerv(PP_Resource context_id,
+ GLuint index,
+ GLenum pname,
+ void** pointer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glGetVertexAttribPointerv(index, pname, pointer);
+ }
+}
+
+void Hint(PP_Resource context_id, GLenum target, GLenum mode) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glHint(target, mode);
+ }
+}
+
+GLboolean IsBuffer(PP_Resource context_id, GLuint buffer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glIsBuffer(buffer);
+ } else {
+ return GL_FALSE;
+ }
+}
+
+GLboolean IsEnabled(PP_Resource context_id, GLenum cap) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glIsEnabled(cap);
+ } else {
+ return GL_FALSE;
+ }
+}
+
+GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glIsFramebuffer(framebuffer);
+ } else {
+ return GL_FALSE;
+ }
+}
+
+GLboolean IsProgram(PP_Resource context_id, GLuint program) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glIsProgram(program);
+ } else {
+ return GL_FALSE;
+ }
+}
+
+GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glIsRenderbuffer(renderbuffer);
+ } else {
+ return GL_FALSE;
+ }
+}
+
+GLboolean IsShader(PP_Resource context_id, GLuint shader) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glIsShader(shader);
+ } else {
+ return GL_FALSE;
+ }
+}
+
+GLboolean IsTexture(PP_Resource context_id, GLuint texture) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ return glIsTexture(texture);
+ } else {
+ return GL_FALSE;
+ }
+}
+
+void LineWidth(PP_Resource context_id, GLfloat width) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glLineWidth(width);
+ }
+}
+
+void LinkProgram(PP_Resource context_id, GLuint program) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glLinkProgram(program);
+ }
+}
+
+void PixelStorei(PP_Resource context_id, GLenum pname, GLint param) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glPixelStorei(pname, param);
+ }
+}
+
+void PolygonOffset(PP_Resource context_id, GLfloat factor, GLfloat units) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glPolygonOffset(factor, units);
+ }
+}
+
+void ReadPixels(PP_Resource context_id,
+ GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ void* pixels) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glReadPixels(x, y, width, height, format, type, pixels);
+ }
+}
+
+void ReleaseShaderCompiler(PP_Resource context_id) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glReleaseShaderCompiler();
+ }
+}
+
+void RenderbufferStorage(PP_Resource context_id,
+ GLenum target,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glRenderbufferStorage(target, internalformat, width, height);
+ }
+}
+
+void SampleCoverage(PP_Resource context_id, GLclampf value, GLboolean invert) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glSampleCoverage(value, invert);
+ }
+}
+
+void Scissor(PP_Resource context_id,
+ GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glScissor(x, y, width, height);
+ }
+}
+
+void ShaderBinary(PP_Resource context_id,
+ GLsizei n,
+ const GLuint* shaders,
+ GLenum binaryformat,
+ const void* binary,
+ GLsizei length) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glShaderBinary(n, shaders, binaryformat, binary, length);
+ }
+}
+
+void ShaderSource(PP_Resource context_id,
+ GLuint shader,
+ GLsizei count,
+ const char** str,
+ const GLint* length) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glShaderSource(shader, count, str, length);
+ }
+}
+
+void StencilFunc(PP_Resource context_id, GLenum func, GLint ref, GLuint mask) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glStencilFunc(func, ref, mask);
+ }
+}
+
+void StencilFuncSeparate(PP_Resource context_id,
+ GLenum face,
+ GLenum func,
+ GLint ref,
+ GLuint mask) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glStencilFuncSeparate(face, func, ref, mask);
+ }
+}
+
+void StencilMask(PP_Resource context_id, GLuint mask) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glStencilMask(mask);
+ }
+}
+
+void StencilMaskSeparate(PP_Resource context_id, GLenum face, GLuint mask) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glStencilMaskSeparate(face, mask);
+ }
+}
+
+void StencilOp(PP_Resource context_id,
+ GLenum fail,
+ GLenum zfail,
+ GLenum zpass) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glStencilOp(fail, zfail, zpass);
+ }
+}
+
+void StencilOpSeparate(PP_Resource context_id,
+ GLenum face,
+ GLenum fail,
+ GLenum zfail,
+ GLenum zpass) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glStencilOpSeparate(face, fail, zfail, zpass);
+ }
+}
+
+void TexImage2D(PP_Resource context_id,
+ GLenum target,
+ GLint level,
+ GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLint border,
+ GLenum format,
+ GLenum type,
+ const void* pixels) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glTexImage2D(target,
+ level,
+ internalformat,
+ width,
+ height,
+ border,
+ format,
+ type,
+ pixels);
+ }
+}
+
+void TexParameterf(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ GLfloat param) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glTexParameterf(target, pname, param);
+ }
+}
+
+void TexParameterfv(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ const GLfloat* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glTexParameterfv(target, pname, params);
+ }
+}
+
+void TexParameteri(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ GLint param) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glTexParameteri(target, pname, param);
+ }
+}
+
+void TexParameteriv(PP_Resource context_id,
+ GLenum target,
+ GLenum pname,
+ const GLint* params) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glTexParameteriv(target, pname, params);
+ }
+}
+
+void TexSubImage2D(PP_Resource context_id,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ const void* pixels) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glTexSubImage2D(
+ target, level, xoffset, yoffset, width, height, format, type, pixels);
+ }
+}
+
+void Uniform1f(PP_Resource context_id, GLint location, GLfloat x) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform1f(location, x);
+ }
+}
+
+void Uniform1fv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLfloat* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform1fv(location, count, v);
+ }
+}
+
+void Uniform1i(PP_Resource context_id, GLint location, GLint x) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform1i(location, x);
+ }
+}
+
+void Uniform1iv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLint* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform1iv(location, count, v);
+ }
+}
+
+void Uniform2f(PP_Resource context_id, GLint location, GLfloat x, GLfloat y) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform2f(location, x, y);
+ }
+}
+
+void Uniform2fv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLfloat* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform2fv(location, count, v);
+ }
+}
+
+void Uniform2i(PP_Resource context_id, GLint location, GLint x, GLint y) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform2i(location, x, y);
+ }
+}
+
+void Uniform2iv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLint* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform2iv(location, count, v);
+ }
+}
+
+void Uniform3f(PP_Resource context_id,
+ GLint location,
+ GLfloat x,
+ GLfloat y,
+ GLfloat z) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform3f(location, x, y, z);
+ }
+}
+
+void Uniform3fv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLfloat* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform3fv(location, count, v);
+ }
+}
+
+void Uniform3i(PP_Resource context_id,
+ GLint location,
+ GLint x,
+ GLint y,
+ GLint z) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform3i(location, x, y, z);
+ }
+}
+
+void Uniform3iv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLint* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform3iv(location, count, v);
+ }
+}
+
+void Uniform4f(PP_Resource context_id,
+ GLint location,
+ GLfloat x,
+ GLfloat y,
+ GLfloat z,
+ GLfloat w) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform4f(location, x, y, z, w);
+ }
+}
+
+void Uniform4fv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLfloat* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform4fv(location, count, v);
+ }
+}
+
+void Uniform4i(PP_Resource context_id,
+ GLint location,
+ GLint x,
+ GLint y,
+ GLint z,
+ GLint w) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform4i(location, x, y, z, w);
+ }
+}
+
+void Uniform4iv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ const GLint* v) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniform4iv(location, count, v);
+ }
+}
+
+void UniformMatrix2fv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ GLboolean transpose,
+ const GLfloat* value) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniformMatrix2fv(location, count, transpose, value);
+ }
+}
+
+void UniformMatrix3fv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ GLboolean transpose,
+ const GLfloat* value) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniformMatrix3fv(location, count, transpose, value);
+ }
+}
+
+void UniformMatrix4fv(PP_Resource context_id,
+ GLint location,
+ GLsizei count,
+ GLboolean transpose,
+ const GLfloat* value) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUniformMatrix4fv(location, count, transpose, value);
+ }
+}
+
+void UseProgram(PP_Resource context_id, GLuint program) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glUseProgram(program);
+ }
+}
+
+void ValidateProgram(PP_Resource context_id, GLuint program) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glValidateProgram(program);
+ }
+}
+
+void VertexAttrib1f(PP_Resource context_id, GLuint indx, GLfloat x) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib1f(indx, x);
+ }
+}
+
+void VertexAttrib1fv(PP_Resource context_id,
+ GLuint indx,
+ const GLfloat* values) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib1fv(indx, values);
+ }
+}
+
+void VertexAttrib2f(PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib2f(indx, x, y);
+ }
+}
+
+void VertexAttrib2fv(PP_Resource context_id,
+ GLuint indx,
+ const GLfloat* values) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib2fv(indx, values);
+ }
+}
+
+void VertexAttrib3f(PP_Resource context_id,
+ GLuint indx,
+ GLfloat x,
+ GLfloat y,
+ GLfloat z) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib3f(indx, x, y, z);
+ }
+}
+
+void VertexAttrib3fv(PP_Resource context_id,
+ GLuint indx,
+ const GLfloat* values) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib3fv(indx, values);
+ }
+}
+
+void VertexAttrib4f(PP_Resource context_id,
+ GLuint indx,
+ GLfloat x,
+ GLfloat y,
+ GLfloat z,
+ GLfloat w) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib4f(indx, x, y, z, w);
+ }
+}
+
+void VertexAttrib4fv(PP_Resource context_id,
+ GLuint indx,
+ const GLfloat* values) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttrib4fv(indx, values);
+ }
+}
+
+void VertexAttribPointer(PP_Resource context_id,
+ GLuint indx,
+ GLint size,
+ GLenum type,
+ GLboolean normalized,
+ GLsizei stride,
+ const void* ptr) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
+ }
+}
+
+void Viewport(PP_Resource context_id,
+ GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height) {
+ Enter3D enter(context_id, true);
+ if (IsBoundGraphics(&enter)) {
+ glViewport(x, y, width, height);
+ }
+}
+
+} // namespace
+
+const PPB_OpenGLES2* GetPPB_OpenGLES2_Thunk() {
+ static const struct PPB_OpenGLES2 ppb_opengles2 = {
+ &ActiveTexture, &AttachShader,
+ &BindAttribLocation, &BindBuffer,
+ &BindFramebuffer, &BindRenderbuffer,
+ &BindTexture, &BlendColor,
+ &BlendEquation, &BlendEquationSeparate,
+ &BlendFunc, &BlendFuncSeparate,
+ &BufferData, &BufferSubData,
+ &CheckFramebufferStatus, &Clear,
+ &ClearColor, &ClearDepthf,
+ &ClearStencil, &ColorMask,
+ &CompileShader, &CompressedTexImage2D,
+ &CompressedTexSubImage2D, &CopyTexImage2D,
+ &CopyTexSubImage2D, &CreateProgram,
+ &CreateShader, &CullFace,
+ &DeleteBuffers, &DeleteFramebuffers,
+ &DeleteProgram, &DeleteRenderbuffers,
+ &DeleteShader, &DeleteTextures,
+ &DepthFunc, &DepthMask,
+ &DepthRangef, &DetachShader,
+ &Disable, &DisableVertexAttribArray,
+ &DrawArrays, &DrawElements,
+ &Enable, &EnableVertexAttribArray,
+ &Finish, &Flush,
+ &FramebufferRenderbuffer, &FramebufferTexture2D,
+ &FrontFace, &GenBuffers,
+ &GenerateMipmap, &GenFramebuffers,
+ &GenRenderbuffers, &GenTextures,
+ &GetActiveAttrib, &GetActiveUniform,
+ &GetAttachedShaders, &GetAttribLocation,
+ &GetBooleanv, &GetBufferParameteriv,
+ &GetError, &GetFloatv,
+ &GetFramebufferAttachmentParameteriv, &GetIntegerv,
+ &GetProgramiv, &GetProgramInfoLog,
+ &GetRenderbufferParameteriv, &GetShaderiv,
+ &GetShaderInfoLog, &GetShaderPrecisionFormat,
+ &GetShaderSource, &GetString,
+ &GetTexParameterfv, &GetTexParameteriv,
+ &GetUniformfv, &GetUniformiv,
+ &GetUniformLocation, &GetVertexAttribfv,
+ &GetVertexAttribiv, &GetVertexAttribPointerv,
+ &Hint, &IsBuffer,
+ &IsEnabled, &IsFramebuffer,
+ &IsProgram, &IsRenderbuffer,
+ &IsShader, &IsTexture,
+ &LineWidth, &LinkProgram,
+ &PixelStorei, &PolygonOffset,
+ &ReadPixels, &ReleaseShaderCompiler,
+ &RenderbufferStorage, &SampleCoverage,
+ &Scissor, &ShaderBinary,
+ &ShaderSource, &StencilFunc,
+ &StencilFuncSeparate, &StencilMask,
+ &StencilMaskSeparate, &StencilOp,
+ &StencilOpSeparate, &TexImage2D,
+ &TexParameterf, &TexParameterfv,
+ &TexParameteri, &TexParameteriv,
+ &TexSubImage2D, &Uniform1f,
+ &Uniform1fv, &Uniform1i,
+ &Uniform1iv, &Uniform2f,
+ &Uniform2fv, &Uniform2i,
+ &Uniform2iv, &Uniform3f,
+ &Uniform3fv, &Uniform3i,
+ &Uniform3iv, &Uniform4f,
+ &Uniform4fv, &Uniform4i,
+ &Uniform4iv, &UniformMatrix2fv,
+ &UniformMatrix3fv, &UniformMatrix4fv,
+ &UseProgram, &ValidateProgram,
+ &VertexAttrib1f, &VertexAttrib1fv,
+ &VertexAttrib2f, &VertexAttrib2fv,
+ &VertexAttrib3f, &VertexAttrib3fv,
+ &VertexAttrib4f, &VertexAttrib4fv,
+ &VertexAttribPointer, &Viewport};
+ return &ppb_opengles2;
+}
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/resource_creation_impl.cc b/mojo/examples/pepper_container_app/resource_creation_impl.cc
new file mode 100644
index 0000000..cfb0679
--- /dev/null
+++ b/mojo/examples/pepper_container_app/resource_creation_impl.cc
@@ -0,0 +1,393 @@
+// Copyright 2014 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 "mojo/examples/pepper_container_app/resource_creation_impl.h"
+
+#include "base/logging.h"
+#include "mojo/examples/pepper_container_app/graphics_3d_resource.h"
+
+namespace mojo {
+namespace examples {
+
+ResourceCreationImpl::ResourceCreationImpl() {}
+
+ResourceCreationImpl::~ResourceCreationImpl() {}
+
+PP_Resource ResourceCreationImpl::CreateFileIO(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateFileRef(
+ PP_Instance instance,
+ const ppapi::FileRefCreateInfo& create_info) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateFileSystem(
+ PP_Instance instance,
+ PP_FileSystemType type) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateIMEInputEvent(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ struct PP_Var text,
+ uint32_t segment_number,
+ const uint32_t* segment_offsets,
+ int32_t target_segment,
+ uint32_t selection_start,
+ uint32_t selection_end) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_0(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ uint32_t key_code,
+ struct PP_Var character_text) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_2(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ uint32_t key_code,
+ struct PP_Var character_text,
+ struct PP_Var code) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateMouseInputEvent(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ PP_InputEvent_MouseButton mouse_button,
+ const PP_Point* mouse_position,
+ int32_t click_count,
+ const PP_Point* mouse_movement) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateTouchInputEvent(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateTrueTypeFont(
+ PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev* desc) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateURLLoader(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateURLRequestInfo(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateWheelInputEvent(
+ PP_Instance instance,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ const PP_FloatPoint* wheel_delta,
+ const PP_FloatPoint* wheel_ticks,
+ PP_Bool scroll_by_page) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateAudio1_0(
+ PP_Instance instance,
+ PP_Resource config_id,
+ PPB_Audio_Callback_1_0 audio_callback,
+ void* user_data) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateAudio(
+ PP_Instance instance,
+ PP_Resource config_id,
+ PPB_Audio_Callback audio_callback,
+ void* user_data) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateAudioTrusted(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateAudioConfig(
+ PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateFileChooser(
+ PP_Instance instance,
+ PP_FileChooserMode_Dev mode,
+ const PP_Var& accept_types) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateGraphics2D(PP_Instance instance,
+ const PP_Size* size,
+ PP_Bool is_always_opaque) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateGraphics3D(
+ PP_Instance instance,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
+ return (new Graphics3DResource(instance))->GetReference();
+}
+
+PP_Resource ResourceCreationImpl::CreateGraphics3DRaw(
+ PP_Instance instance,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateHostResolver(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateHostResolverPrivate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateImageData(
+ PP_Instance instance,
+ PP_ImageDataFormat format,
+ const PP_Size* size,
+ PP_Bool init_to_zero) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateImageDataSimple(
+ PP_Instance instance,
+ PP_ImageDataFormat format,
+ const PP_Size* size,
+ PP_Bool init_to_zero) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv4Address(
+ PP_Instance instance,
+ const PP_NetAddress_IPv4* ipv4_addr) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv6Address(
+ PP_Instance instance,
+ const PP_NetAddress_IPv6* ipv6_addr) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate(
+ PP_Instance instance,
+ const PP_NetAddress_Private& private_addr) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateNetworkMonitor(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateOutputProtectionPrivate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreatePrinting(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateTCPServerSocketPrivate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateTCPSocket1_0(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateTCPSocket(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateTCPSocketPrivate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateUDPSocket(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateVideoDestination(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateVideoSource(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateWebSocket(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+#if !defined(OS_NACL)
+PP_Resource ResourceCreationImpl::CreateAudioInput(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateBrowserFont(
+ PP_Instance instance,
+ const PP_BrowserFont_Trusted_Description* description) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance,
+ uint32_t size) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateFlashDRM(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateFlashFontFile(
+ PP_Instance instance,
+ const PP_BrowserFont_Trusted_Description* description,
+ PP_PrivateFontCharset charset) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateFlashMenu(
+ PP_Instance instance,
+ const PP_Flash_Menu* menu_data) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateFlashMessageLoop(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreatePlatformVerificationPrivate(
+ PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance,
+ PP_Bool vertical) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateTalk(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+PP_Resource ResourceCreationImpl::CreateVideoDecoder(
+ PP_Instance instance,
+ PP_Resource context3d_id,
+ PP_VideoDecoder_Profile profile) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+#endif // !defined(OS_NACL)
+
+} // namespace examples
+} // namespace mojo
diff --git a/mojo/examples/pepper_container_app/resource_creation_impl.h b/mojo/examples/pepper_container_app/resource_creation_impl.h
new file mode 100644
index 0000000..de1760e
--- /dev/null
+++ b/mojo/examples/pepper_container_app/resource_creation_impl.h
@@ -0,0 +1,174 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_RESOURCE_CREATION_IMPL_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_RESOURCE_CREATION_IMPL_H_
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "build/build_config.h"
+#include "ppapi/thunk/resource_creation_api.h"
+
+namespace mojo {
+namespace examples {
+
+class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI {
+ public:
+ ResourceCreationImpl();
+ virtual ~ResourceCreationImpl();
+
+ // ppapi::thunk::ResourceCreationAPI implementation.
+ virtual PP_Resource CreateFileIO(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateFileRef(
+ PP_Instance instance,
+ const ppapi::FileRefCreateInfo& create_info) OVERRIDE;
+ virtual PP_Resource CreateFileSystem(PP_Instance instance,
+ PP_FileSystemType type) OVERRIDE;
+ virtual PP_Resource CreateIMEInputEvent(PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ struct PP_Var text,
+ uint32_t segment_number,
+ const uint32_t* segment_offsets,
+ int32_t target_segment,
+ uint32_t selection_start,
+ uint32_t selection_end) OVERRIDE;
+ virtual PP_Resource CreateKeyboardInputEvent_1_0(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ uint32_t key_code,
+ PP_Var character_text) OVERRIDE;
+ virtual PP_Resource CreateKeyboardInputEvent_1_2(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ uint32_t key_code,
+ PP_Var character_text,
+ PP_Var code) OVERRIDE;
+ virtual PP_Resource CreateMouseInputEvent(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ PP_InputEvent_MouseButton mouse_button,
+ const PP_Point* mouse_position,
+ int32_t click_count,
+ const PP_Point* mouse_movement) OVERRIDE;
+ virtual PP_Resource CreateTouchInputEvent(
+ PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers) OVERRIDE;
+ virtual PP_Resource CreateTrueTypeFont(
+ PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev* desc) OVERRIDE;
+ virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateURLRequestInfo(
+ PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateWheelInputEvent(
+ PP_Instance instance,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ const PP_FloatPoint* wheel_delta,
+ const PP_FloatPoint* wheel_ticks,
+ PP_Bool scroll_by_page) OVERRIDE;
+ virtual PP_Resource CreateAudio1_0(PP_Instance instance,
+ PP_Resource config_id,
+ PPB_Audio_Callback_1_0 audio_callback,
+ void* user_data) OVERRIDE;
+ virtual PP_Resource CreateAudio(PP_Instance instance,
+ PP_Resource config_id,
+ PPB_Audio_Callback audio_callback,
+ void* user_data) OVERRIDE;
+ virtual PP_Resource CreateAudioTrusted(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateAudioConfig(PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count) OVERRIDE;
+ virtual PP_Resource CreateFileChooser(PP_Instance instance,
+ PP_FileChooserMode_Dev mode,
+ const PP_Var& accept_types) OVERRIDE;
+ virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance,
+ const PP_Size* size,
+ PP_Bool is_always_opaque) OVERRIDE;
+ virtual PP_Resource CreateGraphics3D(PP_Instance instance,
+ PP_Resource share_context,
+ const int32_t* attrib_list) OVERRIDE;
+ virtual PP_Resource CreateGraphics3DRaw(
+ PP_Instance instance,
+ PP_Resource share_context,
+ const int32_t* attrib_list) OVERRIDE;
+ virtual PP_Resource CreateHostResolver(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateImageData(PP_Instance instance,
+ PP_ImageDataFormat format,
+ const PP_Size* size,
+ PP_Bool init_to_zero) OVERRIDE;
+ virtual PP_Resource CreateImageDataSimple(PP_Instance instance,
+ PP_ImageDataFormat format,
+ const PP_Size* size,
+ PP_Bool init_to_zero) OVERRIDE;
+ virtual PP_Resource CreateNetAddressFromIPv4Address(
+ PP_Instance instance,
+ const PP_NetAddress_IPv4* ipv4_addr) OVERRIDE;
+ virtual PP_Resource CreateNetAddressFromIPv6Address(
+ PP_Instance instance,
+ const PP_NetAddress_IPv6* ipv6_addr) OVERRIDE;
+ virtual PP_Resource CreateNetAddressFromNetAddressPrivate(
+ PP_Instance instance,
+ const PP_NetAddress_Private& private_addr) OVERRIDE;
+ virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateOutputProtectionPrivate(
+ PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreatePrinting(PP_Instance) OVERRIDE;
+ virtual PP_Resource CreateTCPServerSocketPrivate(
+ PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateTCPSocket1_0(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateTCPSocket(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateUDPSocket(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateVideoDestination(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateVideoSource(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateWebSocket(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateX509CertificatePrivate(
+ PP_Instance instance) OVERRIDE;
+#if !defined(OS_NACL)
+ virtual PP_Resource CreateAudioInput(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateBrowserFont(
+ PP_Instance instance,
+ const PP_BrowserFont_Trusted_Description* description) OVERRIDE;
+ virtual PP_Resource CreateBuffer(PP_Instance instance,
+ uint32_t size) OVERRIDE;
+ virtual PP_Resource CreateFlashDRM(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateFlashFontFile(
+ PP_Instance instance,
+ const PP_BrowserFont_Trusted_Description* description,
+ PP_PrivateFontCharset charset) OVERRIDE;
+ virtual PP_Resource CreateFlashMenu(PP_Instance instance,
+ const PP_Flash_Menu* menu_data) OVERRIDE;
+ virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreatePlatformVerificationPrivate(
+ PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateScrollbar(PP_Instance instance,
+ PP_Bool vertical) OVERRIDE;
+ virtual PP_Resource CreateTalk(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateVideoCapture(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateVideoDecoder(
+ PP_Instance instance,
+ PP_Resource context3d_id,
+ PP_VideoDecoder_Profile profile) OVERRIDE;
+#endif // !defined(OS_NACL)
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ResourceCreationImpl);
+};
+
+} // namespace examples
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_RESOURCE_CREATION_IMPL_H_
diff --git a/mojo/examples/pepper_container_app/thunk.h b/mojo/examples/pepper_container_app/thunk.h
new file mode 100644
index 0000000..f3b3d54
--- /dev/null
+++ b/mojo/examples/pepper_container_app/thunk.h
@@ -0,0 +1,20 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_THUNK_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_THUNK_H_
+
+#include "ppapi/c/ppb_core.h"
+#include "ppapi/c/ppb_opengles2.h"
+
+namespace mojo {
+namespace examples {
+
+const PPB_Core_1_0* GetPPB_Core_1_0_Thunk();
+const PPB_OpenGLES2* GetPPB_OpenGLES2_Thunk();
+
+} // namespace examples
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_THUNK_H_
diff --git a/mojo/examples/pepper_container_app/type_converters.h b/mojo/examples/pepper_container_app/type_converters.h
new file mode 100644
index 0000000..7362c3a
--- /dev/null
+++ b/mojo/examples/pepper_container_app/type_converters.h
@@ -0,0 +1,67 @@
+// Copyright 2014 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 MOJO_EXAMPLES_PEPPER_CONTAINER_APP_TYPE_CONVERTERS_H_
+#define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_TYPE_CONVERTERS_H_
+
+#include "mojo/public/bindings/type_converter.h"
+#include "mojo/services/native_viewport/native_viewport.mojom.h"
+#include "ppapi/c/pp_point.h"
+#include "ppapi/c/pp_rect.h"
+#include "ppapi/c/pp_size.h"
+
+namespace mojo {
+
+template <>
+class TypeConverter<Point, PP_Point> {
+ public:
+ static Point ConvertFrom(const PP_Point& input, Buffer* buf) {
+ Point::Builder point(buf);
+ point.set_x(input.x);
+ point.set_y(input.y);
+ return point.Finish();
+ }
+
+ static PP_Point ConvertTo(const Point& input) {
+ return PP_MakePoint(static_cast<int32_t>(input.x()),
+ static_cast<int32_t>(input.y()));
+ }
+};
+
+template <>
+class TypeConverter<Size, PP_Size> {
+ public:
+ static Size ConvertFrom(const PP_Size& input, Buffer* buf) {
+ Size::Builder size(buf);
+ size.set_width(input.width);
+ size.set_height(input.height);
+ return size.Finish();
+ }
+
+ static PP_Size ConvertTo(const Size& input) {
+ return PP_MakeSize(static_cast<int32_t>(input.width()),
+ static_cast<int32_t>(input.height()));
+ }
+};
+
+template <>
+class TypeConverter<Rect, PP_Rect> {
+ public:
+ static Rect ConvertFrom(const PP_Rect& input, Buffer* buf) {
+ Rect::Builder rect(buf);
+ rect.set_position(input.point);
+ rect.set_size(input.size);
+ return rect.Finish();
+ }
+
+ static PP_Rect ConvertTo(const Rect& input) {
+ PP_Rect rect = { input.position().To<PP_Point>(),
+ input.size().To<PP_Size>() };
+ return rect;
+ }
+};
+
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_TYPE_CONVERTERS_H_