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 #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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 gles2_impl()->ResizeCHROMIUM(width, height); | 53 gles2_impl()->ResizeCHROMIUM(width, height); |
54 // TODO(alokp): Check if resize succeeded and return appropriate error code. | 54 // TODO(alokp): Check if resize succeeded and return appropriate error code. |
55 return PP_OK; | 55 return PP_OK; |
56 } | 56 } |
57 | 57 |
58 int32_t PPB_Graphics3D_Shared::SwapBuffers(PP_CompletionCallback callback) { | 58 int32_t PPB_Graphics3D_Shared::SwapBuffers( |
59 if (!callback.func) { | 59 scoped_refptr<TrackedCallback> callback) { |
60 // Blocking SwapBuffers isn't supported (since we have to be on the main | |
61 // thread). | |
62 return PP_ERROR_BADARGUMENT; | |
63 } | |
64 | |
65 if (HasPendingSwap()) { | 60 if (HasPendingSwap()) { |
66 // Already a pending SwapBuffers that hasn't returned yet. | 61 // Already a pending SwapBuffers that hasn't returned yet. |
67 return PP_ERROR_INPROGRESS; | 62 return PP_ERROR_INPROGRESS; |
68 } | 63 } |
69 | 64 |
70 swap_callback_ = new TrackedCallback(this, callback); | 65 swap_callback_ = callback; |
71 return DoSwapBuffers(); | 66 return DoSwapBuffers(); |
72 } | 67 } |
73 | 68 |
74 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target, | 69 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target, |
75 GLint level, | 70 GLint level, |
76 GLint xoffset, | 71 GLint xoffset, |
77 GLint yoffset, | 72 GLint yoffset, |
78 GLsizei width, | 73 GLsizei width, |
79 GLsizei height, | 74 GLsizei height, |
80 GLenum format, | 75 GLenum format, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 129 } |
135 | 130 |
136 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { | 131 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { |
137 gles2_impl_.reset(); | 132 gles2_impl_.reset(); |
138 transfer_buffer_.reset(); | 133 transfer_buffer_.reset(); |
139 gles2_helper_.reset(); | 134 gles2_helper_.reset(); |
140 } | 135 } |
141 | 136 |
142 } // namespace ppapi | 137 } // namespace ppapi |
143 | 138 |
OLD | NEW |