OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
6 #define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ppapi/c/pp_completion_callback.h" | 10 #include "ppapi/c/pp_completion_callback.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; | 51 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; |
52 | 52 |
53 gpu::gles2::GLES2Implementation* gles2_impl() { | 53 gpu::gles2::GLES2Implementation* gles2_impl() { |
54 return gles2_impl_.get(); | 54 return gles2_impl_.get(); |
55 } | 55 } |
56 | 56 |
57 // Sends swap-buffers notification to the plugin. | 57 // Sends swap-buffers notification to the plugin. |
58 void SwapBuffersACK(int32_t pp_error); | 58 void SwapBuffersACK(int32_t pp_error); |
59 | 59 |
60 protected: | 60 protected: |
61 // ScopedNoLocking makes sure we don't try to lock again when we already have | |
62 // the proxy lock. This is used when we need to use the CommandBuffer | |
63 // (possibly via gles2_impl) but we already have the proxy lock. The | |
64 // CommandBuffer in the plugin side of the proxy will otherwise try to acquire | |
65 // the ProxyLock, causing a crash because we already own the lock. (Locks in | |
66 // Chromium are never recursive). | |
67 class ScopedNoLocking { | |
68 public: | |
69 explicit ScopedNoLocking(PPB_Graphics3D_Shared* graphics3d_shared) | |
70 : graphics3d_shared_(graphics3d_shared) { | |
71 graphics3d_shared_->PushAlreadyLocked(); | |
72 } | |
73 ~ScopedNoLocking() { | |
74 graphics3d_shared_->PopAlreadyLocked(); | |
75 } | |
76 private: | |
77 PPB_Graphics3D_Shared* graphics3d_shared_; // Weak | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(ScopedNoLocking); | |
80 }; | |
81 | |
82 | |
83 PPB_Graphics3D_Shared(PP_Instance instance); | 61 PPB_Graphics3D_Shared(PP_Instance instance); |
84 PPB_Graphics3D_Shared(const HostResource& host_resource); | 62 PPB_Graphics3D_Shared(const HostResource& host_resource); |
85 virtual ~PPB_Graphics3D_Shared(); | 63 virtual ~PPB_Graphics3D_Shared(); |
86 | 64 |
87 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; | 65 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; |
88 virtual int32 DoSwapBuffers() = 0; | 66 virtual int32 DoSwapBuffers() = 0; |
89 | 67 |
90 bool HasPendingSwap() const; | 68 bool HasPendingSwap() const; |
91 bool CreateGLES2Impl(int32 command_buffer_size, | 69 bool CreateGLES2Impl(int32 command_buffer_size, |
92 int32 transfer_buffer_size, | 70 int32 transfer_buffer_size, |
93 gpu::gles2::GLES2Implementation* share_gles2); | 71 gpu::gles2::GLES2Implementation* share_gles2); |
94 void DestroyGLES2Impl(); | 72 void DestroyGLES2Impl(); |
95 | 73 |
96 private: | 74 private: |
97 // On the plugin side, we need to know that we already have the lock, so that | |
98 // we don't try to acquire it again. The default implementation does nothing; | |
99 // the Plugin side of the proxy must implement these. | |
100 friend class ScopedNoLocking; | |
101 virtual void PushAlreadyLocked(); | |
102 virtual void PopAlreadyLocked(); | |
103 | |
104 // The VideoDecoder needs to be able to call Graphics3D Flush() after taking | |
105 // the proxy lock. Hence it needs access to ScopedNoLocking. | |
106 friend class PPB_VideoDecoder_Shared; | |
107 | |
108 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | 75 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
109 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; | 76 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
110 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; | 77 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; |
111 | 78 |
112 // Callback that needs to be executed when swap-buffers is completed. | 79 // Callback that needs to be executed when swap-buffers is completed. |
113 scoped_refptr<TrackedCallback> swap_callback_; | 80 scoped_refptr<TrackedCallback> swap_callback_; |
114 | 81 |
115 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); | 82 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); |
116 }; | 83 }; |
117 | 84 |
118 } // namespace ppapi | 85 } // namespace ppapi |
119 | 86 |
120 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 87 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
121 | 88 |
OLD | NEW |