Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: ppapi/shared_impl/ppb_graphics_3d_shared.h

Issue 24466004: PPAPI: Make GLES2 calls resilient to bad/dead resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.cc ('k') | ppapi/shared_impl/ppb_graphics_3d_shared.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; 52 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE;
53 53
54 gpu::gles2::GLES2Implementation* gles2_impl() { 54 gpu::gles2::GLES2Implementation* gles2_impl() {
55 return gles2_impl_.get(); 55 return gles2_impl_.get();
56 } 56 }
57 57
58 // Sends swap-buffers notification to the plugin. 58 // Sends swap-buffers notification to the plugin.
59 void SwapBuffersACK(int32_t pp_error); 59 void SwapBuffersACK(int32_t pp_error);
60 60
61 protected: 61 protected:
62 // ScopedNoLocking makes sure we don't try to lock again when we already have
63 // the proxy lock. This is used when we need to use the CommandBuffer
64 // (possibly via gles2_impl) but we already have the proxy lock. The
65 // CommandBuffer in the plugin side of the proxy will otherwise try to acquire
66 // the ProxyLock, causing a crash because we already own the lock. (Locks in
67 // Chromium are never recursive).
68 class ScopedNoLocking {
69 public:
70 explicit ScopedNoLocking(PPB_Graphics3D_Shared* graphics3d_shared)
71 : graphics3d_shared_(graphics3d_shared) {
72 graphics3d_shared_->PushAlreadyLocked();
73 }
74 ~ScopedNoLocking() {
75 graphics3d_shared_->PopAlreadyLocked();
76 }
77 private:
78 PPB_Graphics3D_Shared* graphics3d_shared_; // Weak
79
80 DISALLOW_COPY_AND_ASSIGN(ScopedNoLocking);
81 };
82
83
84 PPB_Graphics3D_Shared(PP_Instance instance); 62 PPB_Graphics3D_Shared(PP_Instance instance);
85 PPB_Graphics3D_Shared(const HostResource& host_resource); 63 PPB_Graphics3D_Shared(const HostResource& host_resource);
86 virtual ~PPB_Graphics3D_Shared(); 64 virtual ~PPB_Graphics3D_Shared();
87 65
88 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; 66 virtual gpu::CommandBuffer* GetCommandBuffer() = 0;
89 virtual gpu::GpuControl* GetGpuControl() = 0; 67 virtual gpu::GpuControl* GetGpuControl() = 0;
90 virtual int32 DoSwapBuffers() = 0; 68 virtual int32 DoSwapBuffers() = 0;
91 69
92 bool HasPendingSwap() const; 70 bool HasPendingSwap() const;
93 bool CreateGLES2Impl(int32 command_buffer_size, 71 bool CreateGLES2Impl(int32 command_buffer_size,
94 int32 transfer_buffer_size, 72 int32 transfer_buffer_size,
95 gpu::gles2::GLES2Implementation* share_gles2); 73 gpu::gles2::GLES2Implementation* share_gles2);
96 void DestroyGLES2Impl(); 74 void DestroyGLES2Impl();
97 75
98 private: 76 private:
99 // On the plugin side, we need to know that we already have the lock, so that
100 // we don't try to acquire it again. The default implementation does nothing;
101 // the Plugin side of the proxy must implement these.
102 friend class ScopedNoLocking;
103 virtual void PushAlreadyLocked();
104 virtual void PopAlreadyLocked();
105
106 // The VideoDecoder needs to be able to call Graphics3D Flush() after taking
107 // the proxy lock. Hence it needs access to ScopedNoLocking.
108 friend class PPB_VideoDecoder_Shared;
109
110 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; 77 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_;
111 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; 78 scoped_ptr<gpu::TransferBuffer> transfer_buffer_;
112 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; 79 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_;
113 80
114 // Callback that needs to be executed when swap-buffers is completed. 81 // Callback that needs to be executed when swap-buffers is completed.
115 scoped_refptr<TrackedCallback> swap_callback_; 82 scoped_refptr<TrackedCallback> swap_callback_;
116 83
117 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); 84 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared);
118 }; 85 };
119 86
120 } // namespace ppapi 87 } // namespace ppapi
121 88
122 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ 89 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_
123 90
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.cc ('k') | ppapi/shared_impl/ppb_graphics_3d_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698