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/shared_memory_limits.h" | 10 #include "gpu/command_buffer/client/shared_memory_limits.h" |
11 #include "gpu/command_buffer/client/transfer_buffer.h" | 11 #include "gpu/command_buffer/client/transfer_buffer.h" |
12 #include "gpu/command_buffer/common/sync_token.h" | 12 #include "gpu/command_buffer/common/sync_token.h" |
13 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
14 | 14 |
15 namespace ppapi { | 15 namespace ppapi { |
16 | 16 |
17 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance) | 17 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance) |
18 : Resource(OBJECT_IS_IMPL, instance) {} | 18 : Resource(OBJECT_IS_IMPL, instance) {} |
19 | 19 |
20 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource, | 20 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource) |
21 const gfx::Size& size) | 21 : Resource(OBJECT_IS_PROXY, host_resource) {} |
22 : Resource(OBJECT_IS_PROXY, host_resource), size_(size) {} | |
23 | 22 |
24 PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { | 23 PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { |
25 // Make sure that GLES2 implementation has already been destroyed. | 24 // Make sure that GLES2 implementation has already been destroyed. |
26 DCHECK(!gles2_helper_.get()); | 25 DCHECK(!gles2_helper_.get()); |
27 DCHECK(!transfer_buffer_.get()); | 26 DCHECK(!transfer_buffer_.get()); |
28 DCHECK(!gles2_impl_.get()); | 27 DCHECK(!gles2_impl_.get()); |
29 } | 28 } |
30 | 29 |
31 thunk::PPB_Graphics3D_API* PPB_Graphics3D_Shared::AsPPB_Graphics3D_API() { | 30 thunk::PPB_Graphics3D_API* PPB_Graphics3D_Shared::AsPPB_Graphics3D_API() { |
32 return this; | 31 return this; |
(...skipping 12 matching lines...) Expand all Loading... |
45 int32_t PPB_Graphics3D_Shared::GetError() { | 44 int32_t PPB_Graphics3D_Shared::GetError() { |
46 // TODO(alokp): Implement me. | 45 // TODO(alokp): Implement me. |
47 return PP_ERROR_FAILED; | 46 return PP_ERROR_FAILED; |
48 } | 47 } |
49 | 48 |
50 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) { |
51 if ((width < 0) || (height < 0)) | 50 if ((width < 0) || (height < 0)) |
52 return PP_ERROR_BADARGUMENT; | 51 return PP_ERROR_BADARGUMENT; |
53 | 52 |
54 gles2_impl()->ResizeCHROMIUM(width, height, 1.f, true); | 53 gles2_impl()->ResizeCHROMIUM(width, height, 1.f, true); |
55 size_ = gfx::Size(width, height); | 54 width_ = width; |
| 55 height_ = height; |
56 // TODO(alokp): Check if resize succeeded and return appropriate error code. | 56 // TODO(alokp): Check if resize succeeded and return appropriate error code. |
57 return PP_OK; | 57 return PP_OK; |
58 } | 58 } |
59 | 59 |
60 int32_t PPB_Graphics3D_Shared::SwapBuffers( | 60 int32_t PPB_Graphics3D_Shared::SwapBuffers( |
61 scoped_refptr<TrackedCallback> callback) { | 61 scoped_refptr<TrackedCallback> callback) { |
62 return SwapBuffersWithSyncToken(callback, gpu::SyncToken(), size_); | 62 return SwapBuffersWithSyncToken(callback, gpu::SyncToken(), width_, height_); |
63 } | 63 } |
64 | 64 |
65 int32_t PPB_Graphics3D_Shared::SwapBuffersWithSyncToken( | 65 int32_t PPB_Graphics3D_Shared::SwapBuffersWithSyncToken( |
66 scoped_refptr<TrackedCallback> callback, | 66 scoped_refptr<TrackedCallback> callback, |
67 const gpu::SyncToken& sync_token, | 67 const gpu::SyncToken& sync_token, |
68 const gfx::Size& size) { | 68 int32_t width, |
| 69 int32_t height) { |
69 if (HasPendingSwap()) { | 70 if (HasPendingSwap()) { |
70 Log(PP_LOGLEVEL_ERROR, | 71 Log(PP_LOGLEVEL_ERROR, |
71 "PPB_Graphics3D.SwapBuffers: Plugin attempted swap " | 72 "PPB_Graphics3D.SwapBuffers: Plugin attempted swap " |
72 "with previous swap still pending."); | 73 "with previous swap still pending."); |
73 // Already a pending SwapBuffers that hasn't returned yet. | 74 // Already a pending SwapBuffers that hasn't returned yet. |
74 return PP_ERROR_INPROGRESS; | 75 return PP_ERROR_INPROGRESS; |
75 } | 76 } |
76 | 77 |
77 swap_callback_ = callback; | 78 swap_callback_ = callback; |
78 return DoSwapBuffers(sync_token, size); | 79 return DoSwapBuffers(sync_token, width, height); |
79 } | 80 } |
80 | 81 |
81 int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute, | 82 int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute, |
82 int32_t* value) { | 83 int32_t* value) { |
83 // TODO(alokp): Implement me. | 84 // TODO(alokp): Implement me. |
84 return PP_ERROR_FAILED; | 85 return PP_ERROR_FAILED; |
85 } | 86 } |
86 | 87 |
87 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target, | 88 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target, |
88 GLint level, | 89 GLint level, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return true; | 159 return true; |
159 } | 160 } |
160 | 161 |
161 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { | 162 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { |
162 gles2_impl_.reset(); | 163 gles2_impl_.reset(); |
163 transfer_buffer_.reset(); | 164 transfer_buffer_.reset(); |
164 gles2_helper_.reset(); | 165 gles2_helper_.reset(); |
165 } | 166 } |
166 | 167 |
167 } // namespace ppapi | 168 } // namespace ppapi |
OLD | NEW |