Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: webkit/plugins/ppapi/ppb_graphics_3d_impl.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppb_graphics_3d_impl.h ('k') | webkit/plugins/ppapi/ppb_image_data_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_graphics_3d_impl.cc (revision 0)
+++ webkit/plugins/ppapi/ppb_graphics_3d_impl.cc (working copy)
@@ -2,29 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/glue/plugins/pepper_graphics_3d.h"
+#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "gpu/command_buffer/common/command_buffer.h"
-#include "base/singleton.h"
+#include "base/lazy_instance.h"
#include "base/thread_local.h"
#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/plugin_instance.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
-struct CurrentContextTag {};
-typedef Singleton<base::ThreadLocalPointer<Graphics3D>,
- DefaultSingletonTraits<base::ThreadLocalPointer<Graphics3D> >,
- CurrentContextTag> CurrentContextKey;
+static base::LazyInstance<base::ThreadLocalPointer<PPB_Graphics3D_Impl> >
+ g_current_context_key(base::LINKER_INITIALIZED);
// Size of the transfer buffer.
enum { kTransferBufferSize = 512 * 1024 };
PP_Bool IsGraphics3D(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<Graphics3D>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_Graphics3D_Impl>(resource));
}
PP_Bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) {
@@ -68,7 +67,8 @@
return 0;
}
- scoped_refptr<Graphics3D> context(new Graphics3D(instance->module()));
+ scoped_refptr<PPB_Graphics3D_Impl> context(
+ new PPB_Graphics3D_Impl(instance->module()));
if (!context->Init(instance_id, config, attrib_list)) {
return 0;
}
@@ -83,21 +83,23 @@
PP_Bool MakeCurrent(PP_Resource graphics3d) {
if (!graphics3d) {
- Graphics3D::ResetCurrent();
+ PPB_Graphics3D_Impl::ResetCurrent();
return PP_TRUE;
} else {
- scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d));
+ scoped_refptr<PPB_Graphics3D_Impl> context(
+ Resource::GetAs<PPB_Graphics3D_Impl>(graphics3d));
return BoolToPPBool(context.get() && context->MakeCurrent());
}
}
PP_Resource GetCurrentContext() {
- Graphics3D* current_context = Graphics3D::GetCurrent();
+ PPB_Graphics3D_Impl* current_context = PPB_Graphics3D_Impl::GetCurrent();
return current_context ? current_context->GetReference() : 0;
}
PP_Bool SwapBuffers(PP_Resource graphics3d) {
- scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d));
+ scoped_refptr<PPB_Graphics3D_Impl> context(
+ Resource::GetAs<PPB_Graphics3D_Impl>(graphics3d));
return BoolToPPBool(context && context->SwapBuffers());
}
@@ -105,7 +107,7 @@
// Technically, this should return the last error that occurred on the current
// thread, rather than an error associated with a particular context.
// TODO(apatrick): Fix this.
- Graphics3D* current_context = Graphics3D::GetCurrent();
+ PPB_Graphics3D_Impl* current_context = PPB_Graphics3D_Impl::GetCurrent();
if (!current_context)
return 0;
@@ -128,29 +130,33 @@
} // namespace
-Graphics3D::Graphics3D(PluginModule* module)
+PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginModule* module)
: Resource(module),
bound_instance_(NULL) {
}
-const PPB_Graphics3D_Dev* Graphics3D::GetInterface() {
+const PPB_Graphics3D_Dev* PPB_Graphics3D_Impl::GetInterface() {
return &ppb_graphics3d;
}
-Graphics3D* Graphics3D::GetCurrent() {
- return CurrentContextKey::get()->Get();
+PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::GetCurrent() {
+ return g_current_context_key.Get().Get();
}
-void Graphics3D::ResetCurrent() {
- CurrentContextKey::get()->Set(NULL);
+void PPB_Graphics3D_Impl::ResetCurrent() {
+ g_current_context_key.Get().Set(NULL);
}
-Graphics3D::~Graphics3D() {
+PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
Destroy();
}
-bool Graphics3D::Init(PP_Instance instance_id, int32_t config,
- const int32_t* attrib_list) {
+PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::AsPPB_Graphics3D_Impl() {
+ return this;
+}
+
+bool PPB_Graphics3D_Impl::Init(PP_Instance instance_id, int32_t config,
+ const int32_t* attrib_list) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance) {
return false;
@@ -174,7 +180,7 @@
return true;
}
-bool Graphics3D::BindToInstance(PluginInstance* new_instance) {
+bool PPB_Graphics3D_Impl::BindToInstance(PluginInstance* new_instance) {
if (bound_instance_ == new_instance)
return true; // Rebinding the same device, nothing to do.
if (bound_instance_ && new_instance)
@@ -197,52 +203,52 @@
return true;
}
-bool Graphics3D::MakeCurrent() {
+bool PPB_Graphics3D_Impl::MakeCurrent() {
if (!platform_context_.get())
return false;
- CurrentContextKey::get()->Set(this);
+ g_current_context_key.Get().Set(this);
// TODO(apatrick): Return false on context lost.
return true;
}
-bool Graphics3D::SwapBuffers() {
+bool PPB_Graphics3D_Impl::SwapBuffers() {
if (!platform_context_.get())
return false;
return platform_context_->SwapBuffers();
}
-unsigned Graphics3D::GetError() {
+unsigned PPB_Graphics3D_Impl::GetError() {
if (!platform_context_.get())
return 0;
return platform_context_->GetError();
}
-void Graphics3D::ResizeBackingTexture(const gfx::Size& size) {
+void PPB_Graphics3D_Impl::ResizeBackingTexture(const gfx::Size& size) {
if (!platform_context_.get())
return;
platform_context_->ResizeBackingTexture(size);
}
-void Graphics3D::SetSwapBuffersCallback(Callback0::Type* callback) {
+void PPB_Graphics3D_Impl::SetSwapBuffersCallback(Callback0::Type* callback) {
if (!platform_context_.get())
return;
platform_context_->SetSwapBuffersCallback(callback);
}
-unsigned Graphics3D::GetBackingTextureId() {
+unsigned PPB_Graphics3D_Impl::GetBackingTextureId() {
if (!platform_context_.get())
return 0;
return platform_context_->GetBackingTextureId();
}
-void Graphics3D::Destroy() {
+void PPB_Graphics3D_Impl::Destroy() {
if (GetCurrent() == this) {
ResetCurrent();
}
@@ -252,5 +258,6 @@
platform_context_.reset();
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
« no previous file with comments | « webkit/plugins/ppapi/ppb_graphics_3d_impl.h ('k') | webkit/plugins/ppapi/ppb_image_data_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698