| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_ | |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/task.h" | |
| 10 #include "ppapi/shared_impl/resource.h" | |
| 11 #include "ppapi/thunk/ppb_surface_3d_api.h" | |
| 12 #include "webkit/plugins/ppapi/callbacks.h" | |
| 13 #include "webkit/plugins/ppapi/plugin_delegate.h" | |
| 14 | |
| 15 namespace webkit { | |
| 16 namespace ppapi { | |
| 17 | |
| 18 class PPB_Context3D_Impl; | |
| 19 | |
| 20 class PPB_Surface3D_Impl : public ::ppapi::Resource, | |
| 21 public ::ppapi::thunk::PPB_Surface3D_API { | |
| 22 public: | |
| 23 virtual ~PPB_Surface3D_Impl(); | |
| 24 | |
| 25 static PP_Resource Create(PP_Instance instance, | |
| 26 PP_Config3D_Dev config, | |
| 27 const int32_t* attrib_list); | |
| 28 | |
| 29 // Resource override. | |
| 30 virtual ::ppapi::thunk::PPB_Surface3D_API* AsPPB_Surface3D_API() OVERRIDE; | |
| 31 | |
| 32 // PPB_Surface3D_API implementation. | |
| 33 virtual int32_t SetAttrib(int32_t attribute, int32_t value) OVERRIDE; | |
| 34 virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; | |
| 35 virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; | |
| 36 | |
| 37 PPB_Context3D_Impl* context() const { | |
| 38 return context_; | |
| 39 } | |
| 40 | |
| 41 // Binds/unbinds the graphics of this surface with the associated instance. | |
| 42 // If the surface is bound, anything drawn on the surface appears on instance | |
| 43 // window. Returns true if binding/unbinding is successful. | |
| 44 bool BindToInstance(bool bind); | |
| 45 | |
| 46 // Binds the context such that all draw calls to context | |
| 47 // affect this surface. To unbind call this function will NULL context. | |
| 48 // Returns true if successful. | |
| 49 bool BindToContext(PPB_Context3D_Impl* context); | |
| 50 | |
| 51 unsigned int GetBackingTextureId(); | |
| 52 | |
| 53 void ViewInitiatedPaint(); | |
| 54 void ViewFlushedPaint(); | |
| 55 void OnContextLost(); | |
| 56 | |
| 57 private: | |
| 58 explicit PPB_Surface3D_Impl(PP_Instance instance); | |
| 59 | |
| 60 bool Init(PP_Config3D_Dev config, const int32_t* attrib_list); | |
| 61 | |
| 62 // Called when SwapBuffers is complete. | |
| 63 void OnSwapBuffers(); | |
| 64 void SendContextLost(); | |
| 65 | |
| 66 bool bound_to_instance_; | |
| 67 | |
| 68 // True when the page's SwapBuffers has been issued but not returned yet. | |
| 69 bool swap_initiated_; | |
| 70 scoped_refptr<TrackedCompletionCallback> swap_callback_; | |
| 71 | |
| 72 // The context this surface is currently bound to. | |
| 73 PPB_Context3D_Impl* context_; | |
| 74 | |
| 75 base::WeakPtrFactory<PPB_Surface3D_Impl> weak_ptr_factory_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(PPB_Surface3D_Impl); | |
| 78 }; | |
| 79 | |
| 80 } // namespace ppapi | |
| 81 } // namespace webkit | |
| 82 | |
| 83 #endif // WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_ | |
| OLD | NEW |