| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef PPAPI_PPB_SURFACE_3D_PROXY_H_ | 5 #ifndef PPAPI_PPB_SURFACE_3D_PROXY_H_ |
| 6 #define PPAPI_PPB_SURFACE_3D_PROXY_H_ | 6 #define PPAPI_PPB_SURFACE_3D_PROXY_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/c/dev/pp_graphics_3d_dev.h" | 10 #include "ppapi/c/dev/pp_graphics_3d_dev.h" |
| 11 #include "ppapi/c/pp_completion_callback.h" | 11 #include "ppapi/c/pp_completion_callback.h" |
| 12 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
| 13 #include "ppapi/cpp/completion_callback.h" | 13 #include "ppapi/cpp/completion_callback.h" |
| 14 #include "ppapi/proxy/interface_proxy.h" | 14 #include "ppapi/proxy/interface_proxy.h" |
| 15 #include "ppapi/proxy/plugin_resource.h" | 15 #include "ppapi/proxy/plugin_resource.h" |
| 16 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" | 16 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" |
| 17 #include "ppapi/thunk/ppb_surface_3d_api.h" |
| 17 | 18 |
| 18 struct PPB_Surface3D_Dev; | 19 struct PPB_Surface3D_Dev; |
| 19 | 20 |
| 20 namespace pp { | 21 namespace pp { |
| 21 namespace proxy { | 22 namespace proxy { |
| 22 | 23 |
| 23 class Context3D; | 24 class Context3D; |
| 24 | 25 |
| 25 class Surface3D : public PluginResource { | 26 class Surface3D : public PluginResource, |
| 27 public ppapi::thunk::PPB_Surface3D_API { |
| 26 public: | 28 public: |
| 27 explicit Surface3D(const HostResource& host_resource) | 29 explicit Surface3D(const HostResource& host_resource); |
| 28 : PluginResource(host_resource), | |
| 29 resource_(0), | |
| 30 context_(NULL), | |
| 31 current_flush_callback_(PP_BlockUntilComplete()) { | |
| 32 } | |
| 33 virtual ~Surface3D(); | 30 virtual ~Surface3D(); |
| 34 | 31 |
| 35 // Resource overrides. | 32 // ResourceObjectBase overrides. |
| 36 virtual Surface3D* AsSurface3D() { return this; } | 33 virtual PPB_Surface3D_API* AsPPB_Surface3D_API() OVERRIDE; |
| 34 |
| 35 // PPB_Surface3D_API implementation. |
| 36 virtual int32_t SetAttrib(int32_t attribute, int32_t value) OVERRIDE; |
| 37 virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; |
| 38 virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; |
| 39 |
| 40 void SwapBuffersACK(int32_t pp_error); |
| 37 | 41 |
| 38 bool is_flush_pending() const { return !!current_flush_callback_.func; } | 42 bool is_flush_pending() const { return !!current_flush_callback_.func; } |
| 39 | 43 |
| 40 PP_CompletionCallback current_flush_callback() const { | 44 PP_CompletionCallback current_flush_callback() const { |
| 41 return current_flush_callback_; | 45 return current_flush_callback_; |
| 42 } | 46 } |
| 43 | 47 |
| 44 void set_current_flush_callback(PP_CompletionCallback cb) { | |
| 45 current_flush_callback_ = cb; | |
| 46 } | |
| 47 | |
| 48 void set_context(Context3D* context) { | 48 void set_context(Context3D* context) { |
| 49 context_ = context; | 49 context_ = context; |
| 50 } | 50 } |
| 51 | 51 |
| 52 Context3D* context() const { return context_; } | 52 Context3D* context() const { return context_; } |
| 53 | 53 |
| 54 void set_resource(PP_Resource resource) { resource_ = resource; } | 54 void set_resource(PP_Resource resource) { resource_ = resource; } |
| 55 PP_Resource resource() const { return resource_; } | 55 PP_Resource resource() const { return resource_; } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 PP_Resource resource_; | 58 PP_Resource resource_; |
| 59 Context3D* context_; | 59 Context3D* context_; |
| 60 |
| 60 // In the plugin, this is the current callback set for Flushes. When the | 61 // In the plugin, this is the current callback set for Flushes. When the |
| 61 // callback function pointer is non-NULL, we're waiting for a flush ACK. | 62 // callback function pointer is non-NULL, we're waiting for a flush ACK. |
| 62 PP_CompletionCallback current_flush_callback_; | 63 PP_CompletionCallback current_flush_callback_; |
| 63 | 64 |
| 64 DISALLOW_COPY_AND_ASSIGN(Surface3D); | 65 DISALLOW_COPY_AND_ASSIGN(Surface3D); |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 class PPB_Surface3D_Proxy : public InterfaceProxy { | 68 class PPB_Surface3D_Proxy : public InterfaceProxy { |
| 68 public: | 69 public: |
| 69 PPB_Surface3D_Proxy(Dispatcher* dispatcher, const void* target_interface); | 70 PPB_Surface3D_Proxy(Dispatcher* dispatcher, const void* target_interface); |
| 70 virtual ~PPB_Surface3D_Proxy(); | 71 virtual ~PPB_Surface3D_Proxy(); |
| 71 | 72 |
| 72 static const Info* GetInfo(); | 73 static const Info* GetInfo(); |
| 73 | 74 |
| 74 const PPB_Surface3D_Dev* ppb_surface_3d_target() const { | 75 static PP_Resource CreateProxyResource(PP_Instance instance, |
| 75 return reinterpret_cast<const PPB_Surface3D_Dev*>(target_interface()); | 76 PP_Config3D_Dev config, |
| 76 } | 77 const int32_t* attrib_list); |
| 77 | 78 |
| 78 // InterfaceProxy implementation. | 79 // InterfaceProxy implementation. |
| 79 virtual bool OnMessageReceived(const IPC::Message& msg); | 80 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 80 | 81 |
| 81 private: | 82 private: |
| 82 // Message handlers. | 83 // Message handlers. |
| 83 void OnMsgCreate(PP_Instance instance, | 84 void OnMsgCreate(PP_Instance instance, |
| 84 PP_Config3D_Dev config, | 85 PP_Config3D_Dev config, |
| 85 std::vector<int32_t> attribs, | 86 std::vector<int32_t> attribs, |
| 86 HostResource* result); | 87 HostResource* result); |
| 87 void OnMsgSwapBuffers(const HostResource& surface); | 88 void OnMsgSwapBuffers(const HostResource& surface); |
| 88 // Renderer->plugin message handlers. | 89 // Renderer->plugin message handlers. |
| 89 void OnMsgSwapBuffersACK(const HostResource& surface, int32_t pp_error); | 90 void OnMsgSwapBuffersACK(const HostResource& surface, int32_t pp_error); |
| 90 | 91 |
| 91 void SendSwapBuffersACKToPlugin(int32_t result, | 92 void SendSwapBuffersACKToPlugin(int32_t result, |
| 92 const HostResource& surface_3d); | 93 const HostResource& surface_3d); |
| 93 | 94 |
| 94 CompletionCallbackFactory<PPB_Surface3D_Proxy, | 95 CompletionCallbackFactory<PPB_Surface3D_Proxy, |
| 95 ProxyNonThreadSafeRefCount> callback_factory_; | 96 ProxyNonThreadSafeRefCount> callback_factory_; |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 } // namespace proxy | 99 } // namespace proxy |
| 99 } // namespace pp | 100 } // namespace pp |
| 100 | 101 |
| 101 #endif // PPAPI_PPB_SURFACE_3D_PROXY_H_ | 102 #endif // PPAPI_PPB_SURFACE_3D_PROXY_H_ |
| OLD | NEW |