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

Side by Side Diff: src/gpu/gl/SkNullGLContext.cpp

Issue 1490473003: Add transfer buffer support. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix roll issue Created 5 years 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
« no previous file with comments | « src/gpu/gl/GrGLVertexBuffer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "gl/SkNullGLContext.h" 9 #include "gl/SkNullGLContext.h"
10 #include "gl/GrGLInterface.h" 10 #include "gl/GrGLInterface.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 /** 115 /**
116 * The state object for the null interface. 116 * The state object for the null interface.
117 */ 117 */
118 class SkNullGLContext::ContextState : public SkRefCnt { 118 class SkNullGLContext::ContextState : public SkRefCnt {
119 public: 119 public:
120 120
121 121
122 BufferManager fBufferManager; 122 BufferManager fBufferManager;
123 GrGLuint fCurrArrayBuffer; 123 GrGLuint fCurrArrayBuffer;
124 GrGLuint fCurrElementArrayBuffer; 124 GrGLuint fCurrElementArrayBuffer;
125 GrGLuint fCurrPixelPackBuffer;
126 GrGLuint fCurrPixelUnpackBuffer;
125 GrGLuint fCurrProgramID; 127 GrGLuint fCurrProgramID;
126 GrGLuint fCurrShaderID; 128 GrGLuint fCurrShaderID;
127 129
128 130
129 ContextState() 131 ContextState()
130 : fCurrArrayBuffer(0) 132 : fCurrArrayBuffer(0)
131 , fCurrElementArrayBuffer(0) 133 , fCurrElementArrayBuffer(0)
134 , fCurrPixelPackBuffer(0)
135 , fCurrPixelUnpackBuffer(0)
132 , fCurrProgramID(0) 136 , fCurrProgramID(0)
133 , fCurrShaderID(0) {} 137 , fCurrShaderID(0) {}
134 138
135 static ContextState* Get() { return current_context(); } 139 static ContextState* Get() { return current_context(); }
136 }; 140 };
137 141
138 typedef SkNullGLContext::ContextState State; 142 typedef SkNullGLContext::ContextState State;
139 143
140 // Functions not declared in GrGLBogusInterface.h (not common with the Debug GL interface). 144 // Functions not declared in GrGLBogusInterface.h (not common with the Debug GL interface).
141 145
(...skipping 23 matching lines...) Expand all
165 State* state = State::Get(); 169 State* state = State::Get();
166 GrGLuint id = 0; 170 GrGLuint id = 0;
167 171
168 switch (target) { 172 switch (target) {
169 case GR_GL_ARRAY_BUFFER: 173 case GR_GL_ARRAY_BUFFER:
170 id = state->fCurrArrayBuffer; 174 id = state->fCurrArrayBuffer;
171 break; 175 break;
172 case GR_GL_ELEMENT_ARRAY_BUFFER: 176 case GR_GL_ELEMENT_ARRAY_BUFFER:
173 id = state->fCurrElementArrayBuffer; 177 id = state->fCurrElementArrayBuffer;
174 break; 178 break;
179 case GR_GL_PIXEL_PACK_BUFFER:
180 id = state->fCurrPixelPackBuffer;
181 break;
182 case GR_GL_PIXEL_UNPACK_BUFFER:
183 id = state->fCurrPixelUnpackBuffer;
184 break;
175 default: 185 default:
176 SkFAIL("Unexpected target to nullGLBufferData"); 186 SkFAIL("Unexpected target to nullGLBufferData");
177 break; 187 break;
178 } 188 }
179 189
180 if (id > 0) { 190 if (id > 0) {
181 BufferObj* buffer = state->fBufferManager.lookUp(id); 191 BufferObj* buffer = state->fBufferManager.lookUp(id);
182 buffer->allocate(size, (const GrGLchar*) data); 192 buffer->allocate(size, (const GrGLchar*) data);
183 } 193 }
184 } 194 }
(...skipping 23 matching lines...) Expand all
208 218
209 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindBuffer(GrGLenum target, GrGLuint buffer) { 219 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindBuffer(GrGLenum target, GrGLuint buffer) {
210 State* state = State::Get(); 220 State* state = State::Get();
211 switch (target) { 221 switch (target) {
212 case GR_GL_ARRAY_BUFFER: 222 case GR_GL_ARRAY_BUFFER:
213 state->fCurrArrayBuffer = buffer; 223 state->fCurrArrayBuffer = buffer;
214 break; 224 break;
215 case GR_GL_ELEMENT_ARRAY_BUFFER: 225 case GR_GL_ELEMENT_ARRAY_BUFFER:
216 state->fCurrElementArrayBuffer = buffer; 226 state->fCurrElementArrayBuffer = buffer;
217 break; 227 break;
228 case GR_GL_PIXEL_PACK_BUFFER:
229 state->fCurrPixelPackBuffer = buffer;
230 break;
231 case GR_GL_PIXEL_UNPACK_BUFFER:
232 state->fCurrPixelUnpackBuffer = buffer;
233 break;
218 } 234 }
219 } 235 }
220 236
221 // deleting a bound buffer has the side effect of binding 0 237 // deleting a bound buffer has the side effect of binding 0
222 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteBuffers(GrGLsizei n, const GrGLuint* id s) { 238 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteBuffers(GrGLsizei n, const GrGLuint* id s) {
223 State* state = State::Get(); 239 State* state = State::Get();
224 for (int i = 0; i < n; ++i) { 240 for (int i = 0; i < n; ++i) {
225 if (ids[i] == state->fCurrArrayBuffer) { 241 if (ids[i] == state->fCurrArrayBuffer) {
226 state->fCurrArrayBuffer = 0; 242 state->fCurrArrayBuffer = 0;
227 } 243 }
228 if (ids[i] == state->fCurrElementArrayBuffer) { 244 if (ids[i] == state->fCurrElementArrayBuffer) {
229 state->fCurrElementArrayBuffer = 0; 245 state->fCurrElementArrayBuffer = 0;
230 } 246 }
247 if (ids[i] == state->fCurrPixelPackBuffer) {
248 state->fCurrPixelPackBuffer = 0;
249 }
250 if (ids[i] == state->fCurrPixelUnpackBuffer) {
251 state->fCurrPixelUnpackBuffer = 0;
252 }
231 253
232 BufferObj* buffer = state->fBufferManager.lookUp(ids[i]); 254 BufferObj* buffer = state->fBufferManager.lookUp(ids[i]);
233 state->fBufferManager.free(buffer); 255 state->fBufferManager.free(buffer);
234 } 256 }
235 } 257 }
236 258
237 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBufferRange(GrGLenum target, GrGLintptr o ffset, 259 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBufferRange(GrGLenum target, GrGLintptr o ffset,
238 GrGLsizeiptr length, GrGLbitf ield access) { 260 GrGLsizeiptr length, GrGLbitf ield access) {
239 State* state = State::Get(); 261 State* state = State::Get();
240 GrGLuint id = 0; 262 GrGLuint id = 0;
241 switch (target) { 263 switch (target) {
242 case GR_GL_ARRAY_BUFFER: 264 case GR_GL_ARRAY_BUFFER:
243 id = state->fCurrArrayBuffer; 265 id = state->fCurrArrayBuffer;
244 break; 266 break;
245 case GR_GL_ELEMENT_ARRAY_BUFFER: 267 case GR_GL_ELEMENT_ARRAY_BUFFER:
246 id = state->fCurrElementArrayBuffer; 268 id = state->fCurrElementArrayBuffer;
247 break; 269 break;
270 case GR_GL_PIXEL_PACK_BUFFER:
271 id = state->fCurrPixelPackBuffer;
272 break;
273 case GR_GL_PIXEL_UNPACK_BUFFER:
274 id = state->fCurrPixelUnpackBuffer;
275 break;
248 } 276 }
249 277
250 if (id > 0) { 278 if (id > 0) {
251 // We just ignore the offset and length here. 279 // We just ignore the offset and length here.
252 BufferObj* buffer = state->fBufferManager.lookUp(id); 280 BufferObj* buffer = state->fBufferManager.lookUp(id);
253 SkASSERT(!buffer->mapped()); 281 SkASSERT(!buffer->mapped());
254 buffer->setMapped(true); 282 buffer->setMapped(true);
255 return buffer->dataPtr(); 283 return buffer->dataPtr();
256 } 284 }
257 return nullptr; 285 return nullptr;
258 } 286 }
259 287
260 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access) { 288 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access) {
261 State* state = State::Get(); 289 State* state = State::Get();
262 GrGLuint id = 0; 290 GrGLuint id = 0;
263 switch (target) { 291 switch (target) {
264 case GR_GL_ARRAY_BUFFER: 292 case GR_GL_ARRAY_BUFFER:
265 id = state->fCurrArrayBuffer; 293 id = state->fCurrArrayBuffer;
266 break; 294 break;
267 case GR_GL_ELEMENT_ARRAY_BUFFER: 295 case GR_GL_ELEMENT_ARRAY_BUFFER:
268 id = state->fCurrElementArrayBuffer; 296 id = state->fCurrElementArrayBuffer;
269 break; 297 break;
298 case GR_GL_PIXEL_PACK_BUFFER:
299 id = state->fCurrPixelPackBuffer;
300 break;
301 case GR_GL_PIXEL_UNPACK_BUFFER:
302 id = state->fCurrPixelUnpackBuffer;
303 break;
270 } 304 }
271 305
272 if (id > 0) { 306 if (id > 0) {
273 BufferObj* buffer = state->fBufferManager.lookUp(id); 307 BufferObj* buffer = state->fBufferManager.lookUp(id);
274 SkASSERT(!buffer->mapped()); 308 SkASSERT(!buffer->mapped());
275 buffer->setMapped(true); 309 buffer->setMapped(true);
276 return buffer->dataPtr(); 310 return buffer->dataPtr();
277 } 311 }
278 312
279 SkASSERT(false); 313 SkASSERT(false);
280 return nullptr; // no buffer bound to target 314 return nullptr; // no buffer bound to target
281 } 315 }
282 316
283 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFlushMappedBufferRange(GrGLenum target, 317 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFlushMappedBufferRange(GrGLenum target,
284 GrGLintptr offset, 318 GrGLintptr offset,
285 GrGLsizeiptr length) { } 319 GrGLsizeiptr length) { }
286 320
287 321
288 GrGLboolean GR_GL_FUNCTION_TYPE nullGLUnmapBuffer(GrGLenum target) { 322 GrGLboolean GR_GL_FUNCTION_TYPE nullGLUnmapBuffer(GrGLenum target) {
289 State* state = State::Get(); 323 State* state = State::Get();
290 GrGLuint id = 0; 324 GrGLuint id = 0;
291 switch (target) { 325 switch (target) {
292 case GR_GL_ARRAY_BUFFER: 326 case GR_GL_ARRAY_BUFFER:
293 id = state->fCurrArrayBuffer; 327 id = state->fCurrArrayBuffer;
294 break; 328 break;
295 case GR_GL_ELEMENT_ARRAY_BUFFER: 329 case GR_GL_ELEMENT_ARRAY_BUFFER:
296 id = state->fCurrElementArrayBuffer; 330 id = state->fCurrElementArrayBuffer;
297 break; 331 break;
332 case GR_GL_PIXEL_PACK_BUFFER:
333 id = state->fCurrPixelPackBuffer;
334 break;
335 case GR_GL_PIXEL_UNPACK_BUFFER:
336 id = state->fCurrPixelUnpackBuffer;
337 break;
298 } 338 }
299 if (id > 0) { 339 if (id > 0) {
300 BufferObj* buffer = state->fBufferManager.lookUp(id); 340 BufferObj* buffer = state->fBufferManager.lookUp(id);
301 SkASSERT(buffer->mapped()); 341 SkASSERT(buffer->mapped());
302 buffer->setMapped(false); 342 buffer->setMapped(false);
303 return GR_GL_TRUE; 343 return GR_GL_TRUE;
304 } 344 }
305 345
306 GrAlwaysAssert(false); 346 GrAlwaysAssert(false);
307 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION; 347 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
308 } 348 }
309 349
310 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetBufferParameteriv(GrGLenum target, GrGLenu m pname, GrGLint* params) { 350 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetBufferParameteriv(GrGLenum target, GrGLenu m pname, GrGLint* params) {
311 State* state = State::Get(); 351 State* state = State::Get();
312 switch (pname) { 352 switch (pname) {
313 case GR_GL_BUFFER_MAPPED: { 353 case GR_GL_BUFFER_MAPPED: {
314 *params = GR_GL_FALSE; 354 *params = GR_GL_FALSE;
315 GrGLuint id = 0; 355 GrGLuint id = 0;
316 switch (target) { 356 switch (target) {
317 case GR_GL_ARRAY_BUFFER: 357 case GR_GL_ARRAY_BUFFER:
318 id = state->fCurrArrayBuffer; 358 id = state->fCurrArrayBuffer;
319 break; 359 break;
320 case GR_GL_ELEMENT_ARRAY_BUFFER: 360 case GR_GL_ELEMENT_ARRAY_BUFFER:
321 id = state->fCurrElementArrayBuffer; 361 id = state->fCurrElementArrayBuffer;
322 break; 362 break;
363 case GR_GL_PIXEL_PACK_BUFFER:
364 id = state->fCurrPixelPackBuffer;
365 break;
366 case GR_GL_PIXEL_UNPACK_BUFFER:
367 id = state->fCurrPixelUnpackBuffer;
368 break;
323 } 369 }
324 if (id > 0) { 370 if (id > 0) {
325 BufferObj* buffer = state->fBufferManager.lookUp(id); 371 BufferObj* buffer = state->fBufferManager.lookUp(id);
326 if (buffer->mapped()) { 372 if (buffer->mapped()) {
327 *params = GR_GL_TRUE; 373 *params = GR_GL_TRUE;
328 } 374 }
329 } 375 }
330 break; } 376 break; }
331 default: 377 default:
332 SkFAIL("Unexpected pname to GetBufferParamateriv"); 378 SkFAIL("Unexpected pname to GetBufferParamateriv");
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(fStat e); 599 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(fStat e);
554 #endif 600 #endif
555 } 601 }
556 602
557 SkNullGLContext::~SkNullGLContext() { 603 SkNullGLContext::~SkNullGLContext() {
558 this->teardown(); 604 this->teardown();
559 fState->unref(); 605 fState->unref();
560 } 606 }
561 607
562 void SkNullGLContext::onPlatformMakeCurrent() const { set_current_context(fState ); } 608 void SkNullGLContext::onPlatformMakeCurrent() const { set_current_context(fState ); }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLVertexBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698