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

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

Issue 7398033: Revert 92885 - Completed the implementation for PPB_Graphics3D interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 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/shared_impl/graphics_3d_impl.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/shared_impl/graphics_3d_impl.h"
6
7 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "ppapi/c/pp_errors.h"
10
11 namespace ppapi {
12
13 Graphics3DImpl::Graphics3DImpl()
14 : transfer_buffer_id_(-1),
15 swap_callback_(PP_BlockUntilComplete()) {
16 }
17
18 Graphics3DImpl::~Graphics3DImpl() {
19 // Make sure that GLES2 implementation has already been destroyed.
20 DCHECK_EQ(transfer_buffer_id_, -1);
21 DCHECK(!gles2_helper_.get());
22 DCHECK(!gles2_impl_.get());
23 }
24
25 int32_t Graphics3DImpl::GetAttribs(int32_t* attrib_list) {
26 // TODO(alokp): Implement me.
27 return PP_ERROR_FAILED;
28 }
29
30 int32_t Graphics3DImpl::SetAttribs(int32_t* attrib_list) {
31 // TODO(alokp): Implement me.
32 return PP_ERROR_FAILED;
33 }
34
35 int32_t Graphics3DImpl::SwapBuffers(PP_CompletionCallback callback) {
36 if (!callback.func) {
37 // Blocking SwapBuffers isn't supported (since we have to be on the main
38 // thread).
39 return PP_ERROR_BADARGUMENT;
40 }
41
42 if (HasPendingSwap()) {
43 // Already a pending SwapBuffers that hasn't returned yet.
44 return PP_ERROR_INPROGRESS;
45 }
46
47 swap_callback_ = callback;
48 return DoSwapBuffers();
49 }
50
51 void Graphics3DImpl::SwapBuffersACK(int32_t pp_error) {
52 DCHECK(HasPendingSwap());
53 PP_RunAndClearCompletionCallback(&swap_callback_, pp_error);
54 }
55
56 bool Graphics3DImpl::CreateGLES2Impl(int32 command_buffer_size,
57 int32 transfer_buffer_size) {
58 gpu::CommandBuffer* command_buffer = GetCommandBuffer();
59 DCHECK(command_buffer);
60
61 // Create the GLES2 helper, which writes the command buffer protocol.
62 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer));
63 if (!gles2_helper_->Initialize(command_buffer_size))
64 return false;
65
66 // Create a transfer buffer used to copy resources between the renderer
67 // process and the GPU process.
68 transfer_buffer_id_ =
69 command_buffer->CreateTransferBuffer(transfer_buffer_size, -1);
70 if (transfer_buffer_id_ < 0)
71 return false;
72
73 // Map the buffer into the renderer process's address space.
74 gpu::Buffer transfer_buffer =
75 command_buffer->GetTransferBuffer(transfer_buffer_id_);
76 if (!transfer_buffer.ptr)
77 return false;
78
79 // Create the object exposing the OpenGL API.
80 gles2_impl_.reset(new gpu::gles2::GLES2Implementation(
81 gles2_helper_.get(),
82 transfer_buffer.size,
83 transfer_buffer.ptr,
84 transfer_buffer_id_,
85 false));
86
87 return true;
88 }
89
90 void Graphics3DImpl::DestroyGLES2Impl() {
91 gles2_impl_.reset();
92
93 if (transfer_buffer_id_ != -1) {
94 gpu::CommandBuffer* command_buffer = GetCommandBuffer();
95 DCHECK(command_buffer);
96 command_buffer->DestroyTransferBuffer(transfer_buffer_id_);
97 transfer_buffer_id_ = -1;
98 }
99
100 gles2_helper_.reset();
101 }
102
103 } // namespace ppapi
104
OLDNEW
« no previous file with comments | « ppapi/shared_impl/graphics_3d_impl.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698