1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/pgl/command_buffer_pepper.h"
#ifdef __native_client__
#include <assert.h>
#define NOTREACHED() assert(0)
#else
#include "base/logging.h"
#endif // __native_client__
using base::SharedMemory;
using gpu::Buffer;
CommandBufferPepper::CommandBufferPepper(NPP npp,
NPDevice* device,
NPDeviceContext3D* context)
: npp_(npp),
device_(device),
context_(context) {
}
CommandBufferPepper::~CommandBufferPepper() {
}
// Not implemented in CommandBufferPepper.
bool CommandBufferPepper::Initialize(int32 size) {
NOTREACHED();
return false;
}
Buffer CommandBufferPepper::GetRingBuffer() {
Buffer buffer;
buffer.ptr = context_->commandBuffer;
buffer.size = context_->commandBufferEntries * sizeof(int32);
return buffer;
}
int32 CommandBufferPepper::GetSize() {
return context_->commandBufferEntries;
}
int32 CommandBufferPepper::SyncOffsets(int32 put_offset) {
context_->putOffset = put_offset;
if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL))
return -1;
return context_->getOffset;
}
int32 CommandBufferPepper::GetGetOffset() {
int32 value;
if (NPERR_NO_ERROR != device_->getStateContext(
npp_,
context_,
NPDeviceContext3DState_GetOffset,
&value)) {
return -1;
}
return value;
}
void CommandBufferPepper::SetGetOffset(int32 get_offset) {
// Not implemented by proxy.
NOTREACHED();
}
int32 CommandBufferPepper::GetPutOffset() {
int32 value;
if (NPERR_NO_ERROR != device_->getStateContext(
npp_,
context_,
NPDeviceContext3DState_PutOffset,
&value)) {
return -1;
}
return value;
}
int32 CommandBufferPepper::CreateTransferBuffer(size_t size) {
int32 id;
if (NPERR_NO_ERROR != device_->createBuffer(npp_, context_, size, &id))
return -1;
return id;
}
void CommandBufferPepper::DestroyTransferBuffer(int32 id) {
device_->destroyBuffer(npp_, context_, id);
}
Buffer CommandBufferPepper::GetTransferBuffer(int32 id) {
NPDeviceBuffer np_buffer;
if (NPERR_NO_ERROR != device_->mapBuffer(npp_, context_, id, &np_buffer))
return Buffer();
Buffer buffer;
buffer.ptr = np_buffer.ptr;
buffer.size = np_buffer.size;
return buffer;
}
int32 CommandBufferPepper::GetToken() {
int32 value;
if (NPERR_NO_ERROR != device_->getStateContext(
npp_,
context_,
NPDeviceContext3DState_Token,
&value)) {
return -1;
}
return value;
}
void CommandBufferPepper::SetToken(int32 token) {
// Not implemented by proxy.
NOTREACHED();
}
int32 CommandBufferPepper::ResetParseError() {
int32 value;
if (NPERR_NO_ERROR != device_->getStateContext(
npp_,
context_,
NPDeviceContext3DState_ParseError,
&value)) {
return -1;
}
return value;
}
void CommandBufferPepper::SetParseError(int32 parse_error) {
// Not implemented by proxy.
NOTREACHED();
}
bool CommandBufferPepper::GetErrorStatus() {
int32 value;
if (NPERR_NO_ERROR != device_->getStateContext(
npp_,
context_,
NPDeviceContext3DState_ErrorStatus,
&value)) {
return value != 0;
}
return true;
}
void CommandBufferPepper::RaiseErrorStatus() {
// Not implemented by proxy.
NOTREACHED();
}
|