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