OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/glue/plugins/pepper_graphics_3d.h" | 5 #include "webkit/glue/plugins/pepper_graphics_3d.h" |
6 | 6 |
7 #include "gpu/command_buffer/common/command_buffer.h" | 7 #include "gpu/command_buffer/common/command_buffer.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "base/thread_local.h" | 9 #include "base/thread_local.h" |
| 10 #include "third_party/ppapi/c/dev/ppb_graphics_3d_dev.h" |
10 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 11 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
11 | 12 |
12 namespace pepper { | 13 namespace pepper { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 struct CurrentContextTag {}; | 17 struct CurrentContextTag {}; |
17 typedef Singleton<base::ThreadLocalPointer<Graphics3D>, | 18 typedef Singleton<base::ThreadLocalPointer<Graphics3D>, |
18 DefaultSingletonTraits<base::ThreadLocalPointer<Graphics3D> >, | 19 DefaultSingletonTraits<base::ThreadLocalPointer<Graphics3D> >, |
19 CurrentContextTag> CurrentContextKey; | 20 CurrentContextTag> CurrentContextKey; |
(...skipping 77 matching lines...) Loading... |
97 bool SwapBuffers(PP_Resource graphics3d) { | 98 bool SwapBuffers(PP_Resource graphics3d) { |
98 scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); | 99 scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); |
99 return context && context->SwapBuffers(); | 100 return context && context->SwapBuffers(); |
100 } | 101 } |
101 | 102 |
102 uint32_t GetError() { | 103 uint32_t GetError() { |
103 // TODO(neb): Figure out error checking. | 104 // TODO(neb): Figure out error checking. |
104 return PP_GRAPHICS_3D_ERROR_SUCCESS; | 105 return PP_GRAPHICS_3D_ERROR_SUCCESS; |
105 } | 106 } |
106 | 107 |
107 const PPB_Graphics3D ppb_graphics3d = { | 108 const PPB_Graphics3D_Dev ppb_graphics3d = { |
108 &IsGraphics3D, | 109 &IsGraphics3D, |
109 &GetConfigs, | 110 &GetConfigs, |
110 &ChooseConfig, | 111 &ChooseConfig, |
111 &GetConfigAttrib, | 112 &GetConfigAttrib, |
112 &QueryString, | 113 &QueryString, |
113 &CreateContext, | 114 &CreateContext, |
114 &GetProcAddress, | 115 &GetProcAddress, |
115 &MakeCurrent, | 116 &MakeCurrent, |
116 &GetCurrentContext, | 117 &GetCurrentContext, |
117 &SwapBuffers, | 118 &SwapBuffers, |
118 &GetError | 119 &GetError |
119 }; | 120 }; |
120 | 121 |
121 | |
122 } // namespace | 122 } // namespace |
123 | 123 |
124 Graphics3D::Graphics3D(PluginModule* module) | 124 Graphics3D::Graphics3D(PluginModule* module) |
125 : Resource(module), | 125 : Resource(module), |
126 command_buffer_(NULL), | 126 command_buffer_(NULL), |
127 transfer_buffer_id_(0), | 127 transfer_buffer_id_(0), |
128 method_factory3d_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 128 method_factory3d_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
129 } | 129 } |
130 | 130 |
131 const PPB_Graphics3D* Graphics3D::GetInterface() { | 131 const PPB_Graphics3D_Dev* Graphics3D::GetInterface() { |
132 return &ppb_graphics3d; | 132 return &ppb_graphics3d; |
133 } | 133 } |
134 | 134 |
135 Graphics3D* Graphics3D::GetCurrent() { | 135 Graphics3D* Graphics3D::GetCurrent() { |
136 return CurrentContextKey::get()->Get(); | 136 return CurrentContextKey::get()->Get(); |
137 } | 137 } |
138 | 138 |
139 void Graphics3D::ResetCurrent() { | 139 void Graphics3D::ResetCurrent() { |
140 CurrentContextKey::get()->Set(NULL); | 140 CurrentContextKey::get()->Set(NULL); |
141 } | 141 } |
(...skipping 105 matching lines...) Loading... |
247 if (platform_context_.get()) { | 247 if (platform_context_.get()) { |
248 platform_context_->SetNotifyRepaintTask( | 248 platform_context_->SetNotifyRepaintTask( |
249 method_factory3d_.NewRunnableMethod(&Graphics3D::HandleRepaint, | 249 method_factory3d_.NewRunnableMethod(&Graphics3D::HandleRepaint, |
250 instance_id)); | 250 instance_id)); |
251 } | 251 } |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 } // namespace pepper | 255 } // namespace pepper |
256 | 256 |
OLD | NEW |