OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "gl/GrGLInterface.h" | 9 #include "gl/GrGLInterface.h" |
10 #include "GrGLTestInterface.h" | 10 #include "GrGLTestInterface.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 static const intptr_t kFreeListEnd = -1; | 105 static const intptr_t kFreeListEnd = -1; |
106 // Index of the first entry of fBuffers in the free list. Free slots in fBuf
fers are indices to | 106 // Index of the first entry of fBuffers in the free list. Free slots in fBuf
fers are indices to |
107 // the next free slot. The last free slot has a value of kFreeListEnd. | 107 // the next free slot. The last free slot has a value of kFreeListEnd. |
108 intptr_t fFreeListHead; | 108 intptr_t fFreeListHead; |
109 SkTDArray<BufferObj*> fBuffers; | 109 SkTDArray<BufferObj*> fBuffers; |
110 }; | 110 }; |
111 | 111 |
112 /** Null interface implementation */ | 112 /** Null interface implementation */ |
113 class NullInterface : public GrGLTestInterface { | 113 class NullInterface : public GrGLTestInterface { |
114 public: | 114 public: |
115 NullInterface() | 115 NullInterface(bool enableNVPR) |
116 : fCurrArrayBuffer(0) | 116 : fCurrArrayBuffer(0) |
117 , fCurrElementArrayBuffer(0) | 117 , fCurrElementArrayBuffer(0) |
118 , fCurrPixelPackBuffer(0) | 118 , fCurrPixelPackBuffer(0) |
119 , fCurrPixelUnpackBuffer(0) | 119 , fCurrPixelUnpackBuffer(0) |
120 , fCurrProgramID(0) | 120 , fCurrProgramID(0) |
121 , fCurrShaderID(0) | 121 , fCurrShaderID(0) |
122 , fCurrGenericID(0) | 122 , fCurrGenericID(0) |
123 , fCurrUniformLocation(0) { | 123 , fCurrUniformLocation(0) |
| 124 , fCurrPathID(0) { |
| 125 fExtensions.push_back("GL_ARB_framebuffer_object"); |
| 126 fExtensions.push_back("GL_ARB_blend_func_extended"); |
| 127 fExtensions.push_back("GL_ARB_timer_query"); |
| 128 fExtensions.push_back("GL_ARB_draw_buffers"); |
| 129 fExtensions.push_back("GL_ARB_occlusion_query"); |
| 130 fExtensions.push_back("GL_EXT_stencil_wrap"); |
| 131 if (enableNVPR) { |
| 132 fExtensions.push_back("GL_NV_path_rendering"); |
| 133 fExtensions.push_back("GL_ARB_program_interface_query"); |
| 134 } |
| 135 fExtensions.push_back(nullptr); |
| 136 |
124 this->init(kGL_GrGLStandard); | 137 this->init(kGL_GrGLStandard); |
125 } | 138 } |
126 | 139 |
127 GrGLenum checkFramebufferStatus(GrGLenum target) override { | 140 GrGLenum checkFramebufferStatus(GrGLenum target) override { |
128 return GR_GL_FRAMEBUFFER_COMPLETE; | 141 return GR_GL_FRAMEBUFFER_COMPLETE; |
129 } | 142 } |
130 | 143 |
131 GrGLvoid genBuffers(GrGLsizei n, GrGLuint* ids) override { | 144 GrGLvoid genBuffers(GrGLsizei n, GrGLuint* ids) override { |
132 for (int i = 0; i < n; ++i) { | 145 for (int i = 0; i < n; ++i) { |
133 BufferObj* buffer = fBufferManager.create(); | 146 BufferObj* buffer = fBufferManager.create(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 *params = 32; | 299 *params = 32; |
287 break; | 300 break; |
288 case GR_GL_MAX_VERTEX_ATTRIBS: | 301 case GR_GL_MAX_VERTEX_ATTRIBS: |
289 *params = kDefaultMaxVertexAttribs; | 302 *params = kDefaultMaxVertexAttribs; |
290 break; | 303 break; |
291 case GR_GL_MAX_VARYING_VECTORS: | 304 case GR_GL_MAX_VARYING_VECTORS: |
292 *params = kDefaultMaxVaryingVectors; | 305 *params = kDefaultMaxVaryingVectors; |
293 break; | 306 break; |
294 case GR_GL_NUM_EXTENSIONS: { | 307 case GR_GL_NUM_EXTENSIONS: { |
295 GrGLint i = 0; | 308 GrGLint i = 0; |
296 while (kExtensions[i++]); | 309 while (fExtensions[i++]); |
297 *params = i; | 310 *params = i; |
298 break; | 311 break; |
299 } | 312 } |
300 default: | 313 default: |
301 SkFAIL("Unexpected pname to GetIntegerv"); | 314 SkFAIL("Unexpected pname to GetIntegerv"); |
302 } | 315 } |
303 } | 316 } |
304 | 317 |
305 GrGLvoid getProgramiv(GrGLuint program, GrGLenum pname, GrGLint* params) ove
rride { | 318 GrGLvoid getProgramiv(GrGLuint program, GrGLenum pname, GrGLint* params) ove
rride { |
306 this->getShaderOrProgramiv(program, pname, params); | 319 this->getShaderOrProgramiv(program, pname, params); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return nullptr; | 383 return nullptr; |
371 } | 384 } |
372 } | 385 } |
373 | 386 |
374 const GrGLubyte* getStringi(GrGLenum name, GrGLuint i) override { | 387 const GrGLubyte* getStringi(GrGLenum name, GrGLuint i) override { |
375 switch (name) { | 388 switch (name) { |
376 case GR_GL_EXTENSIONS: { | 389 case GR_GL_EXTENSIONS: { |
377 GrGLint count; | 390 GrGLint count; |
378 this->getIntegerv(GR_GL_NUM_EXTENSIONS, &count); | 391 this->getIntegerv(GR_GL_NUM_EXTENSIONS, &count); |
379 if ((GrGLint)i <= count) { | 392 if ((GrGLint)i <= count) { |
380 return (const GrGLubyte*) kExtensions[i]; | 393 return (const GrGLubyte*) fExtensions[i]; |
381 } else { | 394 } else { |
382 return nullptr; | 395 return nullptr; |
383 } | 396 } |
384 } | 397 } |
385 default: | 398 default: |
386 SkFAIL("Unexpected name passed to GetStringi"); | 399 SkFAIL("Unexpected name passed to GetStringi"); |
387 return nullptr; | 400 return nullptr; |
388 } | 401 } |
389 } | 402 } |
390 | 403 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 *params = GR_GL_TRUE; | 513 *params = GR_GL_TRUE; |
501 } | 514 } |
502 } | 515 } |
503 break; } | 516 break; } |
504 default: | 517 default: |
505 SkFAIL("Unexpected pname to GetBufferParamateriv"); | 518 SkFAIL("Unexpected pname to GetBufferParamateriv"); |
506 break; | 519 break; |
507 } | 520 } |
508 }; | 521 }; |
509 | 522 |
| 523 // NV_path_rendering |
| 524 GrGLuint genPaths(GrGLsizei range) override { |
| 525 return ++fCurrPathID; |
| 526 } |
| 527 |
| 528 |
510 private: | 529 private: |
511 BufferManager fBufferManager; | 530 BufferManager fBufferManager; |
512 GrGLuint fCurrArrayBuffer; | 531 GrGLuint fCurrArrayBuffer; |
513 GrGLuint fCurrElementArrayBuffer; | 532 GrGLuint fCurrElementArrayBuffer; |
514 GrGLuint fCurrPixelPackBuffer; | 533 GrGLuint fCurrPixelPackBuffer; |
515 GrGLuint fCurrPixelUnpackBuffer; | 534 GrGLuint fCurrPixelUnpackBuffer; |
516 GrGLuint fCurrProgramID; | 535 GrGLuint fCurrProgramID; |
517 GrGLuint fCurrShaderID; | 536 GrGLuint fCurrShaderID; |
518 GrGLuint fCurrGenericID; | 537 GrGLuint fCurrGenericID; |
519 GrGLuint fCurrUniformLocation; | 538 GrGLuint fCurrUniformLocation; |
| 539 GrGLuint fCurrPathID; |
| 540 SkTArray<const char*> fExtensions; |
520 | 541 |
521 // the OpenGLES 2.0 spec says this must be >= 128 | 542 // the OpenGLES 2.0 spec says this must be >= 128 |
522 static const GrGLint kDefaultMaxVertexUniformVectors = 128; | 543 static const GrGLint kDefaultMaxVertexUniformVectors = 128; |
523 | 544 |
524 // the OpenGLES 2.0 spec says this must be >=16 | 545 // the OpenGLES 2.0 spec says this must be >=16 |
525 static const GrGLint kDefaultMaxFragmentUniformVectors = 16; | 546 static const GrGLint kDefaultMaxFragmentUniformVectors = 16; |
526 | 547 |
527 // the OpenGLES 2.0 spec says this must be >= 8 | 548 // the OpenGLES 2.0 spec says this must be >= 8 |
528 static const GrGLint kDefaultMaxVertexAttribs = 8; | 549 static const GrGLint kDefaultMaxVertexAttribs = 8; |
529 | 550 |
530 // the OpenGLES 2.0 spec says this must be >= 8 | 551 // the OpenGLES 2.0 spec says this must be >= 8 |
531 static const GrGLint kDefaultMaxVaryingVectors = 8; | 552 static const GrGLint kDefaultMaxVaryingVectors = 8; |
532 | 553 |
533 static const char* kExtensions[]; | 554 const GrGLubyte* CombinedExtensionString() { |
534 | |
535 static const GrGLubyte* CombinedExtensionString() { | |
536 static SkString gExtString; | 555 static SkString gExtString; |
537 static SkMutex gMutex; | 556 static SkMutex gMutex; |
538 gMutex.acquire(); | 557 gMutex.acquire(); |
539 if (0 == gExtString.size()) { | 558 if (0 == gExtString.size()) { |
540 int i = 0; | 559 int i = 0; |
541 while (kExtensions[i]) { | 560 while (fExtensions[i]) { |
542 if (i > 0) { | 561 if (i > 0) { |
543 gExtString.append(" "); | 562 gExtString.append(" "); |
544 } | 563 } |
545 gExtString.append(kExtensions[i]); | 564 gExtString.append(fExtensions[i]); |
546 ++i; | 565 ++i; |
547 } | 566 } |
548 } | 567 } |
549 gMutex.release(); | 568 gMutex.release(); |
550 return (const GrGLubyte*) gExtString.c_str(); | 569 return (const GrGLubyte*) gExtString.c_str(); |
551 } | 570 } |
552 | 571 |
553 GrGLvoid genGenericIds(GrGLsizei n, GrGLuint* ids) { | 572 GrGLvoid genGenericIds(GrGLsizei n, GrGLuint* ids) { |
554 for (int i = 0; i < n; ++i) { | 573 for (int i = 0; i < n; ++i) { |
555 ids[i] = ++fCurrGenericID; | 574 ids[i] = ++fCurrGenericID; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 break; | 612 break; |
594 default: | 613 default: |
595 SkFAIL("Unexpected pname passed to GetQueryObject."); | 614 SkFAIL("Unexpected pname passed to GetQueryObject."); |
596 break; | 615 break; |
597 } | 616 } |
598 } | 617 } |
599 | 618 |
600 typedef GrGLTestInterface INHERITED; | 619 typedef GrGLTestInterface INHERITED; |
601 }; | 620 }; |
602 | 621 |
603 const char* NullInterface::kExtensions[] = { | |
604 "GL_ARB_framebuffer_object", | |
605 "GL_ARB_blend_func_extended", | |
606 "GL_ARB_timer_query", | |
607 "GL_ARB_draw_buffers", | |
608 "GL_ARB_occlusion_query", | |
609 "GL_EXT_stencil_wrap", | |
610 nullptr, // signifies the end of the array. | |
611 }; | |
612 | |
613 } // anonymous namespace | 622 } // anonymous namespace |
614 | 623 |
615 const GrGLInterface* GrGLCreateNullInterface() { return new NullInterface; } | 624 const GrGLInterface* GrGLCreateNullInterface(bool enableNVPR) { return new NullI
nterface(enableNVPR); } |
OLD | NEW |