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

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

Issue 24466004: PPAPI: Make GLES2 calls resilient to bad/dead resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add AssertAcquiredDebugOnly 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
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 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" 5 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
9 #include "gpu/command_buffer/client/gles2_implementation.h" 9 #include "gpu/command_buffer/client/gles2_implementation.h"
10 #include "gpu/command_buffer/client/transfer_buffer.h" 10 #include "gpu/command_buffer/client/transfer_buffer.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 int32_t PPB_Graphics3D_Shared::GetError() { 44 int32_t PPB_Graphics3D_Shared::GetError() {
45 // TODO(alokp): Implement me. 45 // TODO(alokp): Implement me.
46 return PP_ERROR_FAILED; 46 return PP_ERROR_FAILED;
47 } 47 }
48 48
49 int32_t PPB_Graphics3D_Shared::ResizeBuffers(int32_t width, int32_t height) { 49 int32_t PPB_Graphics3D_Shared::ResizeBuffers(int32_t width, int32_t height) {
50 if ((width < 0) || (height < 0)) 50 if ((width < 0) || (height < 0))
51 return PP_ERROR_BADARGUMENT; 51 return PP_ERROR_BADARGUMENT;
52 52
53 ScopedNoLocking already_locked(this);
54 gles2_impl()->ResizeCHROMIUM(width, height, 1.f); 53 gles2_impl()->ResizeCHROMIUM(width, height, 1.f);
55 // TODO(alokp): Check if resize succeeded and return appropriate error code. 54 // TODO(alokp): Check if resize succeeded and return appropriate error code.
56 return PP_OK; 55 return PP_OK;
57 } 56 }
58 57
59 int32_t PPB_Graphics3D_Shared::SwapBuffers( 58 int32_t PPB_Graphics3D_Shared::SwapBuffers(
60 scoped_refptr<TrackedCallback> callback) { 59 scoped_refptr<TrackedCallback> callback) {
61 ScopedNoLocking already_locked(this);
62 if (HasPendingSwap()) { 60 if (HasPendingSwap()) {
63 Log(PP_LOGLEVEL_ERROR, "PPB_Graphics3D.SwapBuffers: Plugin attempted swap " 61 Log(PP_LOGLEVEL_ERROR, "PPB_Graphics3D.SwapBuffers: Plugin attempted swap "
64 "with previous swap still pending."); 62 "with previous swap still pending.");
65 // Already a pending SwapBuffers that hasn't returned yet. 63 // Already a pending SwapBuffers that hasn't returned yet.
66 return PP_ERROR_INPROGRESS; 64 return PP_ERROR_INPROGRESS;
67 } 65 }
68 66
69 swap_callback_ = callback; 67 swap_callback_ = callback;
70 return DoSwapBuffers(); 68 return DoSwapBuffers();
71 } 69 }
72 70
73 int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute, 71 int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute,
74 int32_t* value) { 72 int32_t* value) {
75 // TODO(alokp): Implement me. 73 // TODO(alokp): Implement me.
76 return PP_ERROR_FAILED; 74 return PP_ERROR_FAILED;
77 } 75 }
78 76
79 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target, 77 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target,
80 GLint level, 78 GLint level,
81 GLint xoffset, 79 GLint xoffset,
82 GLint yoffset, 80 GLint yoffset,
83 GLsizei width, 81 GLsizei width,
84 GLsizei height, 82 GLsizei height,
85 GLenum format, 83 GLenum format,
86 GLenum type, 84 GLenum type,
87 GLenum access) { 85 GLenum access) {
88 ScopedNoLocking already_locked(this);
89 return gles2_impl_->MapTexSubImage2DCHROMIUM( 86 return gles2_impl_->MapTexSubImage2DCHROMIUM(
90 target, level, xoffset, yoffset, width, height, format, type, access); 87 target, level, xoffset, yoffset, width, height, format, type, access);
91 } 88 }
92 89
93 void PPB_Graphics3D_Shared::UnmapTexSubImage2DCHROMIUM(const void* mem) { 90 void PPB_Graphics3D_Shared::UnmapTexSubImage2DCHROMIUM(const void* mem) {
94 ScopedNoLocking already_locked(this);
95 gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); 91 gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem);
96 } 92 }
97 93
98 void PPB_Graphics3D_Shared::SwapBuffersACK(int32_t pp_error) { 94 void PPB_Graphics3D_Shared::SwapBuffersACK(int32_t pp_error) {
99 DCHECK(HasPendingSwap()); 95 DCHECK(HasPendingSwap());
100 swap_callback_->Run(pp_error); 96 swap_callback_->Run(pp_error);
101 } 97 }
102 98
103 bool PPB_Graphics3D_Shared::HasPendingSwap() const { 99 bool PPB_Graphics3D_Shared::HasPendingSwap() const {
104 return TrackedCallback::IsPending(swap_callback_); 100 return TrackedCallback::IsPending(swap_callback_);
105 } 101 }
106 102
107 bool PPB_Graphics3D_Shared::CreateGLES2Impl( 103 bool PPB_Graphics3D_Shared::CreateGLES2Impl(
108 int32 command_buffer_size, 104 int32 command_buffer_size,
109 int32 transfer_buffer_size, 105 int32 transfer_buffer_size,
110 gpu::gles2::GLES2Implementation* share_gles2) { 106 gpu::gles2::GLES2Implementation* share_gles2) {
111 ScopedNoLocking already_locked(this);
112 gpu::CommandBuffer* command_buffer = GetCommandBuffer(); 107 gpu::CommandBuffer* command_buffer = GetCommandBuffer();
113 DCHECK(command_buffer); 108 DCHECK(command_buffer);
114 109
115 // Create the GLES2 helper, which writes the command buffer protocol. 110 // Create the GLES2 helper, which writes the command buffer protocol.
116 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); 111 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer));
117 if (!gles2_helper_->Initialize(command_buffer_size)) 112 if (!gles2_helper_->Initialize(command_buffer_size))
118 return false; 113 return false;
119 114
120 // Create a transfer buffer used to copy resources between the renderer 115 // Create a transfer buffer used to copy resources between the renderer
121 // process and the GPU process. 116 // process and the GPU process.
(...skipping 17 matching lines...) Expand all
139 gpu::gles2::GLES2Implementation::kNoLimit)) { 134 gpu::gles2::GLES2Implementation::kNoLimit)) {
140 return false; 135 return false;
141 } 136 }
142 137
143 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext"); 138 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext");
144 139
145 return true; 140 return true;
146 } 141 }
147 142
148 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { 143 void PPB_Graphics3D_Shared::DestroyGLES2Impl() {
149 ScopedNoLocking already_locked(this);
150 gles2_impl_.reset(); 144 gles2_impl_.reset();
151 transfer_buffer_.reset(); 145 transfer_buffer_.reset();
152 gles2_helper_.reset(); 146 gles2_helper_.reset();
153 } 147 }
154 148
155 void PPB_Graphics3D_Shared::PushAlreadyLocked() {
156 // Do nothing. This should be overridden in the plugin side.
157 }
158
159 void PPB_Graphics3D_Shared::PopAlreadyLocked() {
160 // Do nothing. This should be overridden in the plugin side.
161 }
162
163 } // namespace ppapi 149 } // namespace ppapi
164 150
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698